Author: olivier
Date: 2008-10-20 21:26:32 +0000 (Mon, 20 Oct 2008)
New Revision: 28340
Modified:
xfwm4/trunk/ChangeLog
xfwm4/trunk/src/client.c
xfwm4/trunk/src/client.h
xfwm4/trunk/src/events.c
xfwm4/trunk/src/misc.c
xfwm4/trunk/src/netwm.c
Log:
Improve support for NET_MOVERESIZE_WINDOW by reusing most of the code from
configureRequest handler, remove duplicate declaration in the code.
Modified: xfwm4/trunk/ChangeLog
===================================================================
--- xfwm4/trunk/ChangeLog 2008-10-20 21:02:01 UTC (rev 28339)
+++ xfwm4/trunk/ChangeLog 2008-10-20 21:26:32 UTC (rev 28340)
@@ -1,3 +1,10 @@
+2008-10-20 olivier
+
+ * src/events.c, src/client.c, src/client.h, src/netwm.c: Improve
+ support for NET_MOVERESIZE_WINDOW by reusing most of the code
+ from configureRequest handler.
+ src/misc.c: Remove duplicate declaration in the code.
+
2008-10-19 olivier
* src/netwm.h, src/display.c, src/display.h, src/events.c, src/hints.c,
Modified: xfwm4/trunk/src/client.c
===================================================================
--- xfwm4/trunk/src/client.c 2008-10-20 21:02:01 UTC (rev 28339)
+++ xfwm4/trunk/src/client.c 2008-10-20 21:26:32 UTC (rev 28340)
@@ -267,8 +267,8 @@
}
if (mask & UPDATE_GRAVITY)
{
- clientCoordGravitate (c, REMOVE, &c->x, &c->y);
- clientCoordGravitate (c, APPLY, &c->x, &c->y);
+ clientCoordGravitate (c, c->gravity, REMOVE, &c->x, &c->y);
+ clientCoordGravitate (c, c->gravity, APPLY, &c->x, &c->y);
setNetFrameExtents (screen_info->display_info,
c->window,
frameTop (c),
@@ -426,7 +426,7 @@
}
void
-clientCoordGravitate (Client * c, int mode, int *x, int *y)
+clientCoordGravitate (Client * c, int gravity, int mode, int *x, int *y)
{
int dx, dy;
@@ -434,7 +434,7 @@
TRACE ("entering clientCoordGravitate");
c->gravity = c->size->flags & PWinGravity ? c->size->win_gravity :
NorthWestGravity;
- switch (c->gravity)
+ switch (gravity)
{
case CenterGravity:
dx = (c->border_width * 2) - ((frameLeft (c) +
@@ -488,7 +488,7 @@
}
void
-clientAdjustCoordGravity (Client * c, unsigned long *mask, XWindowChanges *wc)
+clientAdjustCoordGravity (Client * c, int gravity, unsigned long *mask,
XWindowChanges *wc)
{
int tx, ty, dw, dh;
@@ -497,9 +497,9 @@
tx = wc->x;
ty = wc->y;
- clientCoordGravitate (c, APPLY, &tx, &ty);
+ clientCoordGravitate (c, gravity, APPLY, &tx, &ty);
- switch (c->gravity)
+ switch (gravity)
{
case CenterGravity:
dw = (c->width - wc->width) / 2;
@@ -784,6 +784,88 @@
}
void
+clientMoveResizeWindow (Client * c, XWindowChanges * wc, unsigned long mask)
+{
+ ScreenInfo *screen_info;
+ DisplayInfo *display_info;
+ gboolean constrained;
+
+ g_return_if_fail (c != NULL);
+ TRACE ("entering clientMoveResizeWindow");
+ TRACE ("client \"%s\" (0x%lx)", c->name, c->window);
+
+ screen_info = c->screen_info;
+ display_info = screen_info->display_info;
+ if (c->type == WINDOW_DESKTOP)
+ {
+ /* Ignore stacking request for DESKTOP windows */
+ mask &= ~(CWSibling | CWStackMode);
+ }
+ if (FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN)
+ || (FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED)
+ && (screen_info->params->borderless_maximize)))
+ {
+ /* Not allowed in fullscreen or maximzed mode */
+ mask &= ~(CWX | CWY | CWWidth | CWHeight);
+ }
+ /* Clean up buggy requests that set all flags */
+ if ((mask & CWX) && (wc->x == c->x))
+ {
+ mask &= ~CWX;
+ }
+ if ((mask & CWY) && (wc->y == c->y))
+ {
+ mask &= ~CWY;
+ }
+ if ((mask & CWWidth) && (wc->width == c->width))
+ {
+ mask &= ~CWWidth;
+ }
+ if ((mask & CWHeight) && (wc->height == c->height))
+ {
+ mask &= ~CWHeight;
+ }
+
+ /* Still a move/resize after cleanup? */
+ constrained = FALSE;
+ if (mask & (CWX | CWY | CWWidth | CWHeight))
+ {
+ if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED))
+ {
+ clientRemoveMaximizeFlag (c);
+ }
+ constrained = TRUE;
+ }
+ /*
+ Let's say that if the client performs a XRaiseWindow, we show the
window if focus
+ stealing prevention is not activated, otherwise we just set the
"demands attention"
+ flag...
+ */
+ if ((mask & CWStackMode) && (wc->stack_mode == Above) && (wc->sibling ==
None) && !(c->type & WINDOW_TYPE_DONT_FOCUS))
+ {
+ Client *last_raised;
+
+ last_raised = clientGetLastRaise (screen_info);
+ if (last_raised && (c != last_raised))
+ {
+ if ((screen_info->params->prevent_focus_stealing) &&
(screen_info->params->activate_action == ACTIVATE_ACTION_NONE))
+ {
+ mask &= ~(CWSibling | CWStackMode);
+ TRACE ("Setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\"
(0x%lx)", c->name, c->window);
+ FLAG_SET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION);
+ clientSetNetState (c);
+ }
+ else
+ {
+ clientActivate (c, getXServerTime (display_info));
+ }
+ }
+ }
+ /* And finally, configure the window */
+ clientConfigure (c, wc, mask, (constrained ? CFG_CONSTRAINED : 0) |
CFG_REQUEST);
+}
+
+void
clientGetMWMHints (Client * c, gboolean update)
{
ScreenInfo *screen_info;
@@ -1779,7 +1861,7 @@
/* Once we know the type of window, we can initialize window position */
if (!FLAG_TEST (c->xfwm_flags, XFWM_FLAG_SESSION_MANAGED))
{
- clientCoordGravitate (c, APPLY, &c->x, &c->y);
+ clientCoordGravitate (c, c->gravity, APPLY, &c->x, &c->y);
if ((attr.map_state == IsUnmapped))
{
clientInitPosition (c);
@@ -1991,7 +2073,7 @@
clientRemoveUserTimeWin (c);
clientUngrabButtons (c);
XUnmapWindow (display_info->dpy, c->frame);
- clientCoordGravitate (c, REMOVE, &c->x, &c->y);
+ clientCoordGravitate (c, c->gravity, REMOVE, &c->x, &c->y);
XSelectInput (display_info->dpy, c->window, NoEventMask);
XChangeSaveSet(display_info->dpy, c->window, SetModeDelete);
Modified: xfwm4/trunk/src/client.h
===================================================================
--- xfwm4/trunk/src/client.h 2008-10-20 21:02:01 UTC (rev 28339)
+++ xfwm4/trunk/src/client.h 2008-10-20 21:26:32 UTC (rev 28340)
@@ -345,15 +345,20 @@
void clientUpdateUrgency (Client *);
void clientCoordGravitate (Client *,
int,
+ int,
int *,
int *);
void clientAdjustCoordGravity (Client *,
+ int,
unsigned long
*,
XWindowChanges *);
void clientConfigure (Client *,
XWindowChanges *,
unsigned long,
unsigned
short);
+void clientMoveResizeWindow (Client *,
+
XWindowChanges *,
+ unsigned
long);
void clientGetMWMHints (Client *,
gboolean);
void clientGetWMNormalHints (Client *,
Modified: xfwm4/trunk/src/events.c
===================================================================
--- xfwm4/trunk/src/events.c 2008-10-20 21:02:01 UTC (rev 28339)
+++ xfwm4/trunk/src/events.c 2008-10-20 21:26:32 UTC (rev 28340)
@@ -1293,105 +1293,13 @@
}
if (c)
{
- gboolean constrained = FALSE;
- ScreenInfo *screen_info = c->screen_info;
-
TRACE ("handleConfigureRequest managed window \"%s\" (0x%lx)",
c->name, c->window);
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MOVING_RESIZING))
{
/* Sorry, but it's not the right time for configure request */
return EVENT_FILTER_REMOVE;
}
- if (c->type == WINDOW_DESKTOP)
- {
- /* Ignore stacking request for DESKTOP windows */
- ev->value_mask &= ~(CWSibling | CWStackMode);
- }
- clientAdjustCoordGravity (c, &ev->value_mask, &wc);
-
- if (FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN))
- {
- GdkRectangle rect;
- gint monitor_nbr;
- int cx, cy;
-
- /* size request from fullscreen windows get fullscreen */
-
- cx = frameX (c) + (frameWidth (c) / 2);
- cy = frameY (c) + (frameHeight (c) / 2);
-
- monitor_nbr = find_monitor_at_point (screen_info->gscr, cx, cy);
- gdk_screen_get_monitor_geometry (screen_info->gscr, monitor_nbr,
&rect);
-
- wc.x = rect.x;
- wc.y = rect.y;
- wc.width = rect.width;
- wc.height = rect.height;
-
- ev->value_mask |= (CWX | CWY | CWWidth | CWHeight);
- }
- else if (FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED)
- && (screen_info->params->borderless_maximize))
- {
- wc.x = c->x;
- wc.y = c->y;
- wc.width = c->width;
- wc.height = c->height;
- }
- /* Clean up buggy requests that set all flags */
- if ((ev->value_mask & CWX) && (wc.x == c->x))
- {
- ev->value_mask &= ~CWX;
- }
- if ((ev->value_mask & CWY) && (wc.y == c->y))
- {
- ev->value_mask &= ~CWY;
- }
- if ((ev->value_mask & CWWidth) && (wc.width == c->width))
- {
- ev->value_mask &= ~CWWidth;
- }
- if ((ev->value_mask & CWHeight) && (wc.height == c->height))
- {
- ev->value_mask &= ~CWHeight;
- }
- /* Still a move/resize after cleanup? */
- if (ev->value_mask & (CWX | CWY | CWWidth | CWHeight))
- {
- if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED))
- {
- clientRemoveMaximizeFlag (c);
- }
- constrained = TRUE;
- }
-
- /*
- Let's say that if the client performs a XRaiseWindow, we show the
window if focus
- stealing prevention is not activated, otherwise we just set the
"demands attention"
- flag...
- */
- if ((ev->value_mask & CWStackMode) && (wc.stack_mode == Above) &&
(wc.sibling == None) && !(c->type & WINDOW_TYPE_DONT_FOCUS))
- {
- Client *last_raised;
-
- last_raised = clientGetLastRaise (screen_info);
- if (last_raised && (c != last_raised))
- {
- if ((screen_info->params->prevent_focus_stealing) &&
(screen_info->params->activate_action == ACTIVATE_ACTION_NONE))
- {
- ev->value_mask &= ~(CWSibling | CWStackMode);
- TRACE ("Setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\"
(0x%lx)", c->name, c->window);
- FLAG_SET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION);
- clientSetNetState (c);
- }
- else
- {
- clientActivate (c, getXServerTime (display_info));
- }
- }
- }
-
- clientConfigure (c, &wc, ev->value_mask, (constrained ?
CFG_CONSTRAINED : 0) | CFG_REQUEST);
+ clientMoveResizeWindow (c, &wc, ev->value_mask);
}
else
{
Modified: xfwm4/trunk/src/misc.c
===================================================================
--- xfwm4/trunk/src/misc.c 2008-10-20 21:02:01 UTC (rev 28339)
+++ xfwm4/trunk/src/misc.c 2008-10-20 21:26:32 UTC (rev 28340)
@@ -304,8 +304,6 @@
if (atom)
{
- char *xname;
-
xname = (gchar *) XGetAtomName (display_info->dpy, atom);
if (xname)
{
Modified: xfwm4/trunk/src/netwm.c
===================================================================
--- xfwm4/trunk/src/netwm.c 2008-10-20 21:02:01 UTC (rev 28339)
+++ xfwm4/trunk/src/netwm.c 2008-10-20 21:26:32 UTC (rev 28340)
@@ -695,13 +695,18 @@
{
XWindowChanges wc;
unsigned long mask;
- int gravity, client_gravity;
+ int gravity;
g_return_if_fail (c != NULL);
TRACE ("entering clientNetMoveResizeWindow");
TRACE ("client \"%s\" (0x%lx)", c->name, c->window);
- client_gravity = c->gravity;
+ if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MOVING_RESIZING))
+ {
+ /* not allowed */
+ return;
+ }
+
gravity = (ev->data.l[0] & 0xff);
if (!gravity)
{
@@ -714,9 +719,8 @@
wc.height = ev->data.l[4];
mask = (ev->data.l[0] & 0xf00) >> 8;
- clientAdjustCoordGravity (c, &mask, &wc);
- clientConfigure (c, &wc, mask, CFG_REQUEST);
- c->gravity = client_gravity;
+ clientAdjustCoordGravity (c, gravity, &mask, &wc);
+ clientMoveResizeWindow (c, &wc, mask);
}
void
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits