- /* compress these */
- while (XCheckTypedWindowEvent(ob_display, client->window,
- ConfigureRequest, &ce)) {
- ++i;
- /* XXX if this causes bad things.. we can compress config req's
- with the same mask. */
- e->xconfigurerequest.value_mask |=
- ce.xconfigurerequest.value_mask;
- if (ce.xconfigurerequest.value_mask & CWX)
- e->xconfigurerequest.x = ce.xconfigurerequest.x;
- if (ce.xconfigurerequest.value_mask & CWY)
- e->xconfigurerequest.y = ce.xconfigurerequest.y;
- if (ce.xconfigurerequest.value_mask & CWWidth)
- e->xconfigurerequest.width = ce.xconfigurerequest.width;
- if (ce.xconfigurerequest.value_mask & CWHeight)
- e->xconfigurerequest.height = ce.xconfigurerequest.height;
- if (ce.xconfigurerequest.value_mask & CWBorderWidth)
- e->xconfigurerequest.border_width =
- ce.xconfigurerequest.border_width;
- if (ce.xconfigurerequest.value_mask & CWStackMode)
- e->xconfigurerequest.detail = ce.xconfigurerequest.detail;
- }
-
- /* if we are iconic (or shaded (fvwm does this)) ignore the event */
- if (client->iconic || client->shaded) return;
-
- if (e->xconfigurerequest.value_mask & CWBorderWidth)
- client->border_width = e->xconfigurerequest.border_width;
-
- /* resize, then move, as specified in the EWMH section 7.7 */
- if (e->xconfigurerequest.value_mask & (CWWidth | CWHeight |
- CWX | CWY)) {
- int x, y, w, h;
- Corner corner;
-
- x = (e->xconfigurerequest.value_mask & CWX) ?
- e->xconfigurerequest.x : client->area.x;
- y = (e->xconfigurerequest.value_mask & CWY) ?
- e->xconfigurerequest.y : client->area.y;
- w = (e->xconfigurerequest.value_mask & CWWidth) ?
- e->xconfigurerequest.width : client->area.width;
- h = (e->xconfigurerequest.value_mask & CWHeight) ?
- e->xconfigurerequest.height : client->area.height;
-
- switch (client->gravity) {
- case NorthEastGravity:
- case EastGravity:
- corner = Corner_TopRight;
- break;
- case SouthWestGravity:
- case SouthGravity:
- corner = Corner_BottomLeft;
- break;
- case SouthEastGravity:
- corner = Corner_BottomRight;
- break;
- default: /* NorthWest, Static, etc */
- corner = Corner_TopLeft;
- }
-
- client_configure(client, corner, x, y, w, h, FALSE, FALSE);
- }
-
- if (e->xconfigurerequest.value_mask & CWStackMode) {
- switch (e->xconfigurerequest.detail) {
- case Below:
- case BottomIf:
- stacking_lower(client);
- break;
-
- case Above:
- case TopIf:
- default:
- stacking_raise(client);
- break;
- }
- }
- break;
+ {
+ /* dont compress these unless you're going to watch for property
+ notifies in between (these can change what the configure would
+ do to the window).
+ also you can't compress stacking events
+ */
+
+ gint x, y, w, h;
+ gboolean move = FALSE;
+ gboolean resize = FALSE;
+
+ /* get the current area */
+ RECT_TO_DIMS(client->area, x, y, w, h);
+
+ ob_debug("ConfigureRequest desktop %d wmstate %d visibile %d\n",
+ screen_desktop, client->wmstate, client->frame->visible);
+
+ if (e->xconfigurerequest.value_mask & CWBorderWidth)
+ if (client->border_width != e->xconfigurerequest.border_width) {
+ client->border_width = e->xconfigurerequest.border_width;
+
+ /* if the border width is changing then that is the same
+ as requesting a resize, but we don't actually change
+ the client's border, so it will change their root
+ coordiantes (since they include the border width) and
+ we need to a notify then */
+ move = TRUE;
+ }
+
+
+ if (e->xconfigurerequest.value_mask & CWStackMode) {
+ ObClient *sibling = NULL;
+
+ /* get the sibling */
+ if (e->xconfigurerequest.value_mask & CWSibling) {
+ ObWindow *win;
+ win = g_hash_table_lookup(window_map,
+ &e->xconfigurerequest.above);
+ if (WINDOW_IS_CLIENT(win) && WINDOW_AS_CLIENT(win) != client)
+ sibling = WINDOW_AS_CLIENT(win);
+ }
+
+ /* activate it rather than just focus it */
+ stacking_restack_request(client, sibling,
+ e->xconfigurerequest.detail, TRUE);
+
+ /* if a stacking change moves the window without resizing */
+ move = TRUE;
+ }
+
+ /* don't allow clients to move shaded windows (fvwm does this) */
+ if (client->shaded && (e->xconfigurerequest.value_mask & CWX ||
+ e->xconfigurerequest.value_mask & CWY))
+ {
+ e->xconfigurerequest.value_mask &= ~CWX;
+ e->xconfigurerequest.value_mask &= ~CWY;
+
+ /* if the client tried to move and we aren't letting it then a
+ synthetic event is needed */
+ move = TRUE;
+ }
+
+ if (e->xconfigurerequest.value_mask & CWX ||
+ e->xconfigurerequest.value_mask & CWY ||
+ e->xconfigurerequest.value_mask & CWWidth ||
+ e->xconfigurerequest.value_mask & CWHeight)
+ {
+ if (e->xconfigurerequest.value_mask & CWX) {
+ x = e->xconfigurerequest.x;
+ move = TRUE;
+ }
+ if (e->xconfigurerequest.value_mask & CWY) {
+ y = e->xconfigurerequest.y;
+ move = TRUE;
+ }
+ if (e->xconfigurerequest.value_mask & CWWidth) {
+ w = e->xconfigurerequest.width;
+ resize = TRUE;
+ }
+ if (e->xconfigurerequest.value_mask & CWHeight) {
+ h = e->xconfigurerequest.height;
+ resize = TRUE;
+ }
+ }
+
+ ob_debug("ConfigureRequest x(%d) %d y(%d) %d w(%d) %d h(%d) %d "
+ "move %d resize %d\n",
+ e->xconfigurerequest.value_mask & CWX, x,
+ e->xconfigurerequest.value_mask & CWY, y,
+ e->xconfigurerequest.value_mask & CWWidth, w,
+ e->xconfigurerequest.value_mask & CWHeight, h,
+ move, resize);
+
+ /* check for broken apps moving to their root position
+
+ XXX remove this some day...that would be nice. right now all
+ kde apps do this when they try activate themselves on another
+ desktop. eg. open amarok window on desktop 1, switch to desktop
+ 2, click amarok tray icon. it will move by its decoration size.
+ */
+ if (move && !resize &&
+ x != client->area.x &&
+ x == (client->frame->area.x + client->frame->size.left -
+ (gint)client->border_width) &&
+ y != client->area.y &&
+ y == (client->frame->area.y + client->frame->size.top -
+ (gint)client->border_width))
+ {
+ ob_debug_type(OB_DEBUG_APP_BUGS,
+ "Application %s is trying to move via "
+ "ConfigureRequest to it's root window position "
+ "but it is not using StaticGravity\n",
+ client->title);
+ /* don't move it */
+ x = client->area.x;
+ y = client->area.y;
+
+ /* they still requested a move, so don't change whether a
+ notify is sent or not */
+ }
+
+ if (move || resize) {
+ gint lw,lh;
+
+ client_find_onscreen(client, &x, &y, w, h, FALSE);
+ client_try_configure(client, &x, &y, &w, &h, &lw, &lh, FALSE);
+ /* if they requested something that moves the window, or if
+ the window is actually being changed then configure it and
+ send a configure notify to them */
+ if (move || !RECT_EQUAL_DIMS(client->area, x, y, w, h)) {
+ ob_debug("Doing configure\n");
+ client_configure(client, x, y, w, h, FALSE, TRUE);
+ }
+
+ /* ignore enter events caused by these like ob actions do */
+ event_ignore_all_queued_enters();
+ }
+ break;
+ }