[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53203] trunk/blender/source/blender/ windowmanager/intern/wm_event_system.c: Mac Retina fix:

Ton Roosendaal ton at blender.org
Thu Dec 20 12:14:53 CET 2012


Revision: 53203
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53203
Author:   ton
Date:     2012-12-20 11:14:52 +0000 (Thu, 20 Dec 2012)
Log Message:
-----------
Mac Retina fix:

Mouse coordinates were not mapped correctly for code that allows to use
multiple windows efficiently (mouse over not-active windows).

Apple's high-density display mode works a bit strange, requiring some hacks :/

- Desktop coordinate system (mouse pos and for windows) is as usual
  (set by display resolution settings)
- However, the available pixels in a window is always on 'retina' level.
  (full screen - 2880 wide, but window can be 1440 or 1920 wide)

In order to get this to work for opengl and Blender, we use internally the
coordinates on pixel level. That means that window positions and sizes have
to mappend in our code.

Once all issues for retinas have been tackled, I'll check on clean API for 
it, so you can also use it in future for other high density screens.

Modified Paths:
--------------
    trunk/blender/source/blender/windowmanager/intern/wm_event_system.c

Modified: trunk/blender/source/blender/windowmanager/intern/wm_event_system.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_event_system.c	2012-12-20 11:03:39 UTC (rev 53202)
+++ trunk/blender/source/blender/windowmanager/intern/wm_event_system.c	2012-12-20 11:14:52 UTC (rev 53203)
@@ -2689,8 +2689,10 @@
 	if (wm->windows.first == wm->windows.last)
 		return NULL;
 	
-	/* top window bar... */
-	if (mx < 0 || my < 0 || mx > win->sizex || my > win->sizey + 30) {
+	/* in order to use window size and mouse position (pixels), we have to use a WM function */
+	
+	/* check if outside, include top window bar... */
+	if (mx < 0 || my < 0 || mx > WM_window_pixels_x(win) || my > WM_window_pixels_y(win) + 30) {
 		wmWindow *owin;
 		wmEventHandler *handler;
 		
@@ -2701,18 +2703,21 @@
 				return NULL;
 		
 		/* to desktop space */
-		mx += (int)win->posx;
-		my += (int)win->posy;
+		mx += (int) (U.pixelsize * win->posx);
+		my += (int) (U.pixelsize * win->posy);
 		
 		/* check other windows to see if it has mouse inside */
 		for (owin = wm->windows.first; owin; owin = owin->next) {
 			
 			if (owin != win) {
-				if (mx - owin->posx >= 0 && my - owin->posy >= 0 &&
-				    mx - owin->posx <= owin->sizex && my - owin->posy <= owin->sizey)
+				int posx = (int) (U.pixelsize * owin->posx);
+				int posy = (int) (U.pixelsize * owin->posy);
+				
+				if (mx - posx >= 0 && owin->posy >= 0 &&
+				    mx - posx <= WM_window_pixels_x(owin) && my - posy <= WM_window_pixels_y(owin))
 				{
-					evt->x = mx - (int)owin->posx;
-					evt->y = my - (int)owin->posy;
+					evt->x = mx - (int)(U.pixelsize * owin->posx);
+					evt->y = my - (int)(U.pixelsize * owin->posy);
 					
 					return owin;
 				}




More information about the Bf-blender-cvs mailing list