[Xfce4-commits] r25780 - xfwm4/trunk/src
Olivier Fourdan
olivier at xfce.org
Sun Jun 3 17:35:47 CEST 2007
Author: olivier
Date: 2007-06-03 15:35:47 +0000 (Sun, 03 Jun 2007)
New Revision: 25780
Modified:
xfwm4/trunk/src/placement.c
xfwm4/trunk/src/placement.h
Log:
Fix dialogs and modals without parents not being automatically centered like before (#Bug #3278)
Modified: xfwm4/trunk/src/placement.c
===================================================================
--- xfwm4/trunk/src/placement.c 2007-06-03 15:33:52 UTC (rev 25779)
+++ xfwm4/trunk/src/placement.c 2007-06-03 15:35:47 UTC (rev 25780)
@@ -467,8 +467,8 @@
translation in Xinerama to center window on physical screen
Not to be confused with clientConstrainPos()
*/
-void
-clientKeepVisible (Client * c)
+static void
+clientKeepVisible (Client * c, gint n_monitors, GdkRectangle *monitor_rect)
{
int cx, cy;
int diff_x, diff_y;
@@ -485,23 +485,15 @@
diff_x = abs (c->size->x - ((c->screen_info->width - c->width) / 2));
diff_y = abs (c->size->y - ((c->screen_info->height - c->height) / 2));
- if (((gdk_screen_get_n_monitors (c->screen_info->gscr) > 1) && (diff_x < 25) && (diff_y < 25)) ||
- ((frameX (c) == 0) && (frameY (c) == 0) && (c->type & (WINDOW_TYPE_DIALOG)) && !clientIsTransient (c)))
+ if (((n_monitors > 1) && (diff_x < 25) && (diff_y < 25)) ||
+ ((frameX (c) == 0) && (frameY (c) == 0) && (c->type & (WINDOW_TYPE_DIALOG))))
{
- GdkRectangle rect;
- gint monitor_nbr;
-
/* We consider that the windows is centered on screen,
* Thus, will move it so its center on the current
* physical screen
*/
- getMouseXY (c->screen_info, c->screen_info->xroot, &cx, &cy);
-
- monitor_nbr = find_monitor_at_point (c->screen_info->gscr, cx, cy);
- gdk_screen_get_monitor_geometry (c->screen_info->gscr, monitor_nbr, &rect);
-
- c->x = rect.x + (rect.width - c->width) / 2;
- c->y = rect.y + (rect.height - c->height) / 2;
+ c->x = monitor_rect->x + (monitor_rect->width - c->width) / 2;
+ c->y = monitor_rect->y + (monitor_rect->height - c->height) / 2;
}
clientConstrainPos (c, TRUE);
}
@@ -642,7 +634,8 @@
int full_x, full_y, full_w, full_h, msx, msy;
gint monitor_nbr;
gint n_monitors;
- gboolean place = TRUE;
+ gboolean place;
+ gboolean position;
g_return_if_fail (c != NULL);
TRACE ("entering clientInitPosition");
@@ -650,48 +643,46 @@
clientGravitate (c, APPLY);
screen_info = c->screen_info;
- n_monitors = gdk_screen_get_n_monitors (screen_info->gscr);
msx = 0;
msy = 0;
+ position = (c->size->flags & (PPosition | USPosition));
- if ((c->size->flags & (PPosition | USPosition)) ||
- (c->type & (WINDOW_TYPE_DONT_PLACE)) ||
- ((c->type & (WINDOW_TYPE_DIALOG)) && !clientIsTransient (c)))
+ n_monitors = gdk_screen_get_n_monitors (c->screen_info->gscr);
+ monitor_nbr = 0;
+ if ((n_monitors > 1) || (screen_info->params->placement_mode == PLACE_MOUSE))
{
- if (CONSTRAINED_WINDOW (c))
- {
- clientKeepVisible (c);
- }
- msx = frameX (c) + (frameWidth (c) / 2);
- msy = frameY (c) + (frameHeight (c) / 2);
- place = FALSE;
+ getMouseXY (screen_info, screen_info->xroot, &msx, &msy);
+ monitor_nbr = find_monitor_at_point (screen_info->gscr, msx, msy);
}
- else if (clientIsTransient (c) && (c2 = clientGetTransient (c)))
+ gdk_screen_get_monitor_geometry (screen_info->gscr, monitor_nbr, &rect);
+
+ if (position || (c->type & (WINDOW_TYPE_DONT_PLACE | WINDOW_TYPE_DIALOG)) || clientIsTransient (c))
{
+ if (!position && clientIsTransient (c) && (c2 = clientGetTransient (c)))
+ {
+ /* Center transient relative to their parent window */
+ c->x = c2->x + (c2->width - c->width) / 2;
+ c->y = c2->y + (c2->height - c->height) / 2;
- /* Center transient relative to their parent window */
- c->x = c2->x + (c2->width - c->width) / 2;
- c->y = c2->y + (c2->height - c->height) / 2;
+ if (n_monitors > 1)
+ {
+ msx = frameX (c) + (frameWidth (c) / 2);
+ msy = frameY (c) + (frameHeight (c) / 2);
+ monitor_nbr = find_monitor_at_point (screen_info->gscr, msx, msy);
+ gdk_screen_get_monitor_geometry (screen_info->gscr, monitor_nbr, &rect);
+ }
+ }
if (CONSTRAINED_WINDOW (c))
{
- clientKeepVisible (c);
+ clientKeepVisible (c, n_monitors, &rect);
}
- msx = frameX (c) + (frameWidth (c) / 2);
- msy = frameY (c) + (frameHeight (c) / 2);
place = FALSE;
}
else
{
- if ((n_monitors > 1) || (screen_info->params->placement_mode == PLACE_MOUSE))
- {
- getMouseXY (screen_info, screen_info->xroot, &msx, &msy);
- }
place = TRUE;
}
- monitor_nbr = find_monitor_at_point (screen_info->gscr, msx, msy);
- gdk_screen_get_monitor_geometry (screen_info->gscr, monitor_nbr, &rect);
-
full_x = MAX (screen_info->params->xfwm_margins[STRUTS_LEFT], rect.x);
full_y = MAX (screen_info->params->xfwm_margins[STRUTS_TOP], rect.y);
full_w = MIN (screen_info->width - screen_info->params->xfwm_margins[STRUTS_RIGHT],
Modified: xfwm4/trunk/src/placement.h
===================================================================
--- xfwm4/trunk/src/placement.h 2007-06-03 15:33:52 UTC (rev 25779)
+++ xfwm4/trunk/src/placement.h 2007-06-03 15:35:47 UTC (rev 25780)
@@ -41,7 +41,6 @@
gboolean clientCkeckTitle (Client *);
unsigned int clientConstrainPos (Client *,
gboolean);
-void clientKeepVisible (Client *);
void clientInitPosition (Client *);
#endif /* INC_PLACEMENT_H */
More information about the Xfce4-commits
mailing list