Skip to content

Commit

Permalink
and fix OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Feb 11, 2019
1 parent 1b8210c commit 0151276
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions src/Window.c
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,6 @@ static XVisualInfo GLContext_SelectVisual(struct GraphicsMode* mode) {
#include <AGL/agl.h>

static WindowRef win_handle;
static int title_height;
static int win_state;
/* Hacks for fullscreen */
static bool ctx_pendingWindowed, ctx_pendingFullscreen;
Expand Down Expand Up @@ -1782,12 +1781,12 @@ static void Window_RefreshBounds(void) {

res = GetWindowBounds(win_handle, kWindowStructureRgn, &r);
if (res) Logger_Abort2(res, "Getting window bounds");
Window_SetRect(&Window_Bounds, r);
Window_SetRect(&Window_Bounds, &r);

/* TODO: kWindowContentRgn ??? */
res = GetWindowBounds(win_handle, kWindowGlobalPortRgn, &r);
if (res) Logger_Abort2(res, "Getting window clientbounds");
Window_SetRect(&Window_ClientBounds, r);
Window_SetRect(&Window_ClientBounds, &r);
}

static void Window_UpdateWindowState(void) {
Expand Down Expand Up @@ -1930,27 +1929,22 @@ static OSStatus Window_ProcessMouseEvent(EventHandlerCallRef inCaller, EventRef
SInt32 delta;
OSStatus res;

if (win_state == WINDOW_STATE_FULLSCREEN) {
res = GetEventParameter(inEvent, kEventParamMouseLocation, typeHIPoint,
NULL, sizeof(HIPoint), NULL, &pt);
} else {
res = GetEventParameter(inEvent, kEventParamWindowMouseLocation, typeHIPoint,
NULL, sizeof(HIPoint), NULL, &pt);
}

res = GetEventParameter(inEvent, kEventParamMouseLocation, typeHIPoint,
NULL, sizeof(HIPoint), NULL, &pt);
/* this error comes up from the application event handler */
if (res && res != eventParameterNotFoundErr) {
Logger_Abort2(res, "Getting mouse position");
}

mousePos.X = (int)pt.x; mousePos.Y = (int)pt.y;
/* Location is relative to structure (i.e. external size) of window */
/* kEventParamMouseLocation is in screen coordinates */
if (win_state != WINDOW_STATE_FULLSCREEN) {
mousePos.Y -= title_height;
mousePos.X -= Window_ClientBounds.X;
mousePos.Y -= Window_ClientBounds.Y;
}

/* mousePos.Y will be < 0 if user clicks or moves on titlebar */
/* don't intercept this, prevents clicking close/minimise/maximise from working */
/* mousePos.Y is < 0 if user clicks or moves when over titlebar */
/* Don't intercept this, prevents clicking close/minimise/maximise from working */
if (mousePos.Y < 0) return eventNotHandledErr;

kind = GetEventKind(inEvent);
Expand Down Expand Up @@ -2068,12 +2062,8 @@ void Window_Create(int x, int y, int width, int height, struct GraphicsMode* mod

if (res) Logger_Abort2(res, "Failed to create window");
Window_RefreshBounds();

res = GetWindowBounds(win_handle, kWindowTitleBarRgn, &r);
if (res) Logger_Abort2(res, "Failed to get titlebar size");
title_height = Rect_Height(r);
AcquireRootMenu();


AcquireRootMenu();
GetCurrentProcess(&psn);
SetFrontProcess(&psn);

Expand All @@ -2094,7 +2084,7 @@ void Window_SetTitle(const String* title) {
}

/* NOTE: All Pasteboard functions are OSX 10.3 or later */
PasteboardRef Window_GetPasteboard(void) {
static PasteboardRef Window_GetPasteboard(void) {
PasteboardRef pbRef;
OSStatus err = PasteboardCreate(kPasteboardClipboard, &pbRef);

Expand Down

0 comments on commit 0151276

Please sign in to comment.