[MPlayer-cvslog] r34086 - in trunk/gui: ui/main.c wm/ws.c wm/ws.h

ib subversion at mplayerhq.hu
Thu Sep 8 17:31:26 CEST 2011


Author: ib
Date: Thu Sep  8 17:31:25 2011
New Revision: 34086

Log:
Preserve x and y position of a double-size window if possible.

Only change position in an evDoubleSize event if necessary.
Do so by "dragging" the window towards the upper left if it
no longer fits into the screen.

Add a new function wsMoveWindowWithin() to accomplish this.

Modified:
   trunk/gui/ui/main.c
   trunk/gui/wm/ws.c
   trunk/gui/wm/ws.h

Modified: trunk/gui/ui/main.c
==============================================================================
--- trunk/gui/ui/main.c	Thu Sep  8 16:00:12 2011	(r34085)
+++ trunk/gui/ui/main.c	Thu Sep  8 17:31:25 2011	(r34086)
@@ -350,9 +350,7 @@ set_volume:
             uiFullScreen();
            }
           wsResizeWindow( &guiApp.subWindow, guiInfo.VideoWidth * 2, guiInfo.VideoHeight * 2 );
-          wsMoveWindow( &guiApp.subWindow, True,
-                        ( wsMaxX - guiInfo.VideoWidth*2  )/2 + wsOrgX,
-                        ( wsMaxY - guiInfo.VideoHeight*2 )/2 + wsOrgY  );
+          wsMoveWindowWithin( &guiApp.subWindow, False, guiApp.sub.x, guiApp.sub.y );
           btnSet( evFullScreen,btnReleased );
          }
         break;

Modified: trunk/gui/wm/ws.c
==============================================================================
--- trunk/gui/wm/ws.c	Thu Sep  8 16:00:12 2011	(r34085)
+++ trunk/gui/wm/ws.c	Thu Sep  8 17:31:25 2011	(r34086)
@@ -1085,6 +1085,41 @@ void wsMoveWindow(wsTWindow *win, Bool a
         win->ReSize(win->X, win->Y, win->Width, win->Height);
 }
 
+/**
+ * @brief Move the window to the x and y position, but if it no longer fits
+ *        into the screen, reposition it towards the upper left.
+ *
+ * @param win pointer to a ws window structure
+ * @param abs flag whether the position is real/absolute (True) or mock (False)
+ * @param x x position of the window (real/absolute or mock)
+ * @param y y position of the window (real/absolute or mock)
+ */
+void wsMoveWindowWithin(wsTWindow *win, Bool abs, int x, int y)
+{
+    Bool fitting = True;
+
+    wsMoveWindow(win, abs, x, y);
+
+    if (win->X + win->Width + 1 > wsMaxX) {
+        fitting = False;
+        win->X  = wsMaxX - win->Width;
+
+        if (win->X < 0)
+            win->X = 0;
+    }
+
+    if (win->Y + win->Height + 1 > wsMaxY) {
+        fitting = False;
+        win->Y  = wsMaxY - win->Height;
+
+        if (win->Y < 0)
+            win->Y = 0;
+    }
+
+    if (!fitting)
+        wsMoveWindow(win, True, win->X, win->Y);
+}
+
 // ----------------------------------------------------------------------------------------------
 //    Resize window to sx, sy.
 // ----------------------------------------------------------------------------------------------

Modified: trunk/gui/wm/ws.h
==============================================================================
--- trunk/gui/wm/ws.h	Thu Sep  8 16:00:12 2011	(r34085)
+++ trunk/gui/wm/ws.h	Thu Sep  8 17:31:25 2011	(r34086)
@@ -230,6 +230,7 @@ void wsHandleEvents(void);
 void wsCreateWindow(wsTWindow *win, int X, int Y, int wX, int hY, int bW, int cV, unsigned char D, char *label);
 void wsDestroyWindow(wsTWindow *win);
 void wsMoveWindow(wsTWindow *win, Bool abs, int x, int y);
+void wsMoveWindowWithin(wsTWindow *win, Bool abs, int x, int y);
 void wsResizeWindow(wsTWindow *win, int sx, int sy);
 void wsIconify(wsTWindow win);
 void wsRaiseWindowTop(Display *dsp, Window win);


More information about the MPlayer-cvslog mailing list