From 699f274b06dc44d5135c8bc6321f0e59997ef821 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 4 Jan 2016 10:51:54 +0200 Subject: [PATCH 1/2] Fixed mouse cursor centering in fullscreen mode Native OS X backed didn't center mouse cursor in fullscreen mode with Retina/HiDPI support enabled Incorrect size of content view led to placement of cursor in upper right corner of the screen upon releasing of mouse capture When some action is assigned to this corner using system Hot Corners feature, the given action was triggered on acquiring mouse capture --- src/posix/cocoa/i_video.mm | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 3fc2b2aed..e99443ee8 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -625,7 +625,7 @@ void CocoaVideo::SetFullscreenMode(const int width, const int height) [m_window setHidesOnDeactivate:YES]; } - [m_window setFrame:displayRect display:YES]; + [m_window setFrame:screenFrame display:YES]; [m_window setFrameOrigin:NSMakePoint(0.0f, 0.0f)]; } @@ -1231,10 +1231,7 @@ NSSize I_GetContentViewSize(const NSWindow* const window) const NSView* const view = [window contentView]; const NSSize frameSize = [view frame].size; - // TODO: figure out why [NSView frame] returns different values in "fullscreen" and in window - // In "fullscreen" the result is multiplied by [NSScreen backingScaleFactor], but not in window - - return (vid_hidpi && !fullscreen) + return (vid_hidpi) ? [view convertSizeToBacking:frameSize] : frameSize; } From 02ff3291bdfc8e7f3e75306204e18fe94aa39fa6 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 4 Jan 2016 12:15:14 +0200 Subject: [PATCH 2/2] Fixed division by zero in RNG Random number generator now returns zero for range [0, 0) --- src/m_random.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/m_random.h b/src/m_random.h index b5e21c63c..452ef41fc 100644 --- a/src/m_random.h +++ b/src/m_random.h @@ -57,7 +57,9 @@ public: // Returns a random number in the range [0,mod) int operator() (int mod) { - return GenRand32() % mod; + return (0 == mod) + ? 0 + : (GenRand32() % mod); } // Returns rand# - rand#