Hello, I changed the way this patch works: instead of saving the screen_ptr in the old_geometry struct, wUnmaximizeWindow compares the current head for the maximized window and the head for the saved coordinates, using wGetHeadForWindow and wGetHeadForRect from xinerama.c. This avoids modifying code outside of wUnmaximizeWindow.
Included in this patch is also a slight change in the definition of
find_Maximus_geometry, for coherence with the rest of the code, and the removal
of a useless and commented part of code in xinerama.c (which makes wmaker
smaller ;-) ).
Regards,
Nicolas
diff --git a/src/actions.c b/src/actions.c
index 4ddfcd2..089152c 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -64,7 +64,8 @@ extern int calcIntersectionLength(int p1, int l1, int p2, int
l2);
static void save_old_geometry(WWindow *wwin);
static void find_Maximus_geometry(WWindow *wwin, WArea usableArea, int *new_x,
- int *new_y, int *new_width, int *new_height);
+ int *new_y, unsigned int *new_width,
+ unsigned int *new_height);
/******* Local Variables *******/
static struct {
@@ -407,7 +408,7 @@ void wMaximizeWindow(WWindow * wwin, int directions)
* while the windows which will stop the maximization of w_0 are denoted by w_j.
*/
static void find_Maximus_geometry(WWindow *wwin, WArea usableArea, int *new_x,
int *new_y,
- int *new_width, int *new_height)
+ unsigned int *new_width, unsigned int
*new_height)
{
WWindow *tmp;
int x_0 = wwin->frame_x;
@@ -503,6 +504,9 @@ static void find_Maximus_geometry(WWindow *wwin, WArea
usableArea, int *new_x, i
void wUnmaximizeWindow(WWindow * wwin)
{
int x, y, w, h;
+ WMRect old_geom_rect;
+ int old_head;
+ Bool same_head;
if (!wwin->flags.maximized)
return;
@@ -512,8 +516,11 @@ void wUnmaximizeWindow(WWindow * wwin)
wUnshadeWindow(wwin);
}
/* Use old coordinates if they are set, current values otherwise */
- x = wwin->old_geometry.x ? wwin->old_geometry.x : wwin->frame_x;
- y = wwin->old_geometry.y ? wwin->old_geometry.y : wwin->frame_y;
+ old_geom_rect = wmkrect(wwin->old_geometry.x, wwin->old_geometry.y,
wwin->old_geometry.width, wwin->old_geometry.height);
+ old_head = wGetHeadForRect(wwin->screen_ptr, old_geom_rect);
+ same_head = (wGetHeadForWindow(wwin) == old_head);
+ x = (wwin->old_geometry.x && same_head) ? wwin->old_geometry.x :
wwin->frame_x;
+ y = (wwin->old_geometry.y && same_head) ? wwin->old_geometry.y :
wwin->frame_y;
w = wwin->old_geometry.width ? wwin->old_geometry.width :
wwin->client.width;
h = wwin->old_geometry.height ? wwin->old_geometry.height :
wwin->client.height;
diff --git a/src/xinerama.c b/src/xinerama.c
index 786c214..dbcda22 100644
--- a/src/xinerama.c
+++ b/src/xinerama.c
@@ -220,45 +220,6 @@ int wGetHeadForWindow(WWindow * wwin)
return wGetHeadForRect(wwin->screen_ptr, rect);
}
-/*
-int
-wGetHeadForPoint(WScreen *scr, WMPoint point, int *flags)
-{
- int i;
-
- // paranoia
- if (flags == NULL) {
- static int tmp;
- flags = &tmp;
- }
- *flags = XFLAG_NONE;
-
- for (i = 0; i < scr->xine_info.count; i++) {
-#if 0
- int yy, xx;
-
- xx = scr->xine_info.screens[i].pos.x +
scr->xine_info.screens[i].size.width;
- yy = scr->xine_info.screens[i].pos.y +
scr->xine_info.screens[i].size.height;
- if (point.x >= scr->xine_info.screens[i].pos.x &&
- point.y >= scr->xine_info.screens[i].pos.y &&
- point.x < xx && point.y < yy) {
- return i;
- }
-#else
- XineramaScreenInfo *xsi = &scr->xine_info.screens[i];
-
- if ((unsigned)(point.x - xsi->x_org) < xsi->width &&
- (unsigned)(point.y - xsi->y_org) < xsi->height)
- return i;
-#endif
- }
-
- *flags |= XFLAG_DEAD;
-
- return scr->xine_primary_head;
-}
-*/
-
int wGetHeadForPoint(WScreen * scr, WMPoint point)
{
int i;
wmaker_xinerama_maximize2.patch.gz
Description: application/gzip
