diff options
author | Olivier Fourdan <fourdan.olivier@wanadoo.fr> | 2004-06-04 22:08:34 +0000 |
---|---|---|
committer | Olivier Fourdan <fourdan.olivier@wanadoo.fr> | 2004-06-04 22:08:34 +0000 |
commit | 3f78aeee4c9e8bcb070f47858a3eb31fc6c9e4b3 (patch) | |
tree | e9375b68762abd3c1afa1ea4f8155eeb91e08bde /src | |
parent | 21879ba93257ee0a8ad769de87c0da419060e1da (diff) | |
download | xfwm4-3f78aeee4c9e8bcb070f47858a3eb31fc6c9e4b3.tar.gz |
Change internals to prepare multi-screen (not quite there yet)
(Old svn revision: 11776)
Diffstat (limited to 'src')
50 files changed, 1191 insertions, 1241 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index a85be1c50..9f7563eb0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,6 @@ xfwm4_SOURCES = \ keyboard.c \ keyboard.h \ main.c \ - main.h \ menu.c \ menu.h \ misc.c \ diff --git a/src/Makefile.in b/src/Makefile.in index e3866221b..f9b9e6445 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -274,7 +274,6 @@ xfwm4_SOURCES = \ keyboard.c \ keyboard.h \ main.c \ - main.h \ menu.c \ menu.h \ misc.c \ diff --git a/src/client.c b/src/client.c index e269d02d1..2e74cc4f7 100644 --- a/src/client.c +++ b/src/client.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -33,7 +33,7 @@ #include <libxfce4util/libxfce4util.h> #include <libxfcegui4/libxfcegui4.h> -#include "main.h" +#include "screen.h" #include "misc.h" #include "client.h" #include "frame.h" @@ -103,7 +103,7 @@ struct _MoveResizeData int oldw, oldh; int corner; Poswin *poswin; - Window tmp_event_window; + myWindow tmp_event_window; Client *c; }; @@ -181,8 +181,8 @@ clientInstallColormaps (Client * c) { for (i = c->ncmap - 1; i >= 0; i--) { - XGetWindowAttributes (md->dpy, c->cmap_windows[i], &attr); - XInstallColormap (md->dpy, attr.colormap); + XGetWindowAttributes (c->md->dpy, c->cmap_windows[i], &attr); + XInstallColormap (c->md->dpy, attr.colormap); if (c->cmap_windows[i] == c->window) { installed = TRUE; @@ -191,7 +191,7 @@ clientInstallColormaps (Client * c) } if ((!installed) && (c->cmap)) { - XInstallColormap (md->dpy, c->cmap); + XInstallColormap (c->md->dpy, c->cmap); } } @@ -207,7 +207,7 @@ clientUpdateColormaps (Client * c) { XFree (c->cmap_windows); } - if (!XGetWMColormapWindows (md->dpy, c->window, &c->cmap_windows, &c->ncmap)) + if (!XGetWMColormapWindows (c->md->dpy, c->window, &c->cmap_windows, &c->ncmap)) { c->ncmap = 0; } @@ -215,12 +215,14 @@ clientUpdateColormaps (Client * c) } void -clientUpdateAllFrames (int mask) +clientUpdateAllFrames (ScreenData *md, int mask) { Client *c; int i; XWindowChanges wc; + g_return_if_fail (md != NULL); + TRACE ("entering clientRedrawAllFrames"); XGrabPointer (md->dpy, md->gnome_win, FALSE, EnterWindowMask, GrabModeAsync, GrabModeAsync, None, None, GDK_CURRENT_TIME); @@ -260,58 +262,58 @@ clientGrabKeys (Client * c) TRACE ("entering clientGrabKeys"); TRACE ("grabbing keys for client \"%s\" (0x%lx)", c->name, c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MOVE_UP], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MOVE_DOWN], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MOVE_LEFT], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MOVE_RIGHT], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_RESIZE_UP], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_RESIZE_DOWN], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_RESIZE_LEFT], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_RESIZE_RIGHT], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_CLOSE_WINDOW], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_HIDE_WINDOW], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MAXIMIZE_WINDOW], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MAXIMIZE_VERT], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MAXIMIZE_HORIZ], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_SHADE_WINDOW], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_STICK_WINDOW], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_RAISE_WINDOW], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_LOWER_WINDOW], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_CYCLE_WINDOWS], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_NEXT_WORKSPACE], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_PREV_WORKSPACE], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_ADD_WORKSPACE], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_DEL_WORKSPACE], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_WORKSPACE_1], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_WORKSPACE_2], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_WORKSPACE_3], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_WORKSPACE_4], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_WORKSPACE_5], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_WORKSPACE_6], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_WORKSPACE_7], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_WORKSPACE_8], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_WORKSPACE_9], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MOVE_NEXT_WORKSPACE], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MOVE_PREV_WORKSPACE], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_1], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_2], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_3], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_4], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_5], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_6], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_7], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_8], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_9], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_SHORTCUT_1], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_SHORTCUT_2], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_SHORTCUT_3], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_SHORTCUT_4], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_SHORTCUT_5], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_SHORTCUT_6], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_SHORTCUT_7], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_SHORTCUT_8], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_SHORTCUT_9], c->window); - grabKey (md->dpy, ¶ms.keys[KEY_SHORTCUT_10], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MOVE_UP], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MOVE_DOWN], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MOVE_LEFT], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MOVE_RIGHT], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_RESIZE_UP], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_RESIZE_DOWN], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_RESIZE_LEFT], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_RESIZE_RIGHT], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_CLOSE_WINDOW], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_HIDE_WINDOW], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MAXIMIZE_WINDOW], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MAXIMIZE_VERT], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MAXIMIZE_HORIZ], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_SHADE_WINDOW], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_STICK_WINDOW], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_RAISE_WINDOW], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_LOWER_WINDOW], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_CYCLE_WINDOWS], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_NEXT_WORKSPACE], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_PREV_WORKSPACE], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_ADD_WORKSPACE], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_DEL_WORKSPACE], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_WORKSPACE_1], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_WORKSPACE_2], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_WORKSPACE_3], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_WORKSPACE_4], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_WORKSPACE_5], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_WORKSPACE_6], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_WORKSPACE_7], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_WORKSPACE_8], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_WORKSPACE_9], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MOVE_NEXT_WORKSPACE], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MOVE_PREV_WORKSPACE], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_1], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_2], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_3], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_4], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_5], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_6], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_7], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_8], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_MOVE_WORKSPACE_9], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_SHORTCUT_1], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_SHORTCUT_2], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_SHORTCUT_3], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_SHORTCUT_4], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_SHORTCUT_5], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_SHORTCUT_6], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_SHORTCUT_7], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_SHORTCUT_8], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_SHORTCUT_9], c->window); + grabKey (c->md->dpy, ¶ms.keys[KEY_SHORTCUT_10], c->window); } void @@ -321,7 +323,7 @@ clientUngrabKeys (Client * c) TRACE ("entering clientUngrabKeys"); TRACE ("ungrabing keys for client \"%s\" (0x%lx)", c->name, c->window); - ungrabKeys (md->dpy, c->window); + ungrabKeys (c->md->dpy, c->window); } void @@ -331,9 +333,9 @@ clientGrabButtons (Client * c) TRACE ("entering clientGrabButtons"); TRACE ("grabbing buttons for client \"%s\" (0x%lx)", c->name, c->window); - grabButton(md->dpy, Button1, AltMask, c->window); - grabButton(md->dpy, Button2, AltMask, c->window); - grabButton(md->dpy, Button3, AltMask, c->window); + grabButton(c->md->dpy, Button1, AltMask, c->window); + grabButton(c->md->dpy, Button2, AltMask, c->window); + grabButton(c->md->dpy, Button3, AltMask, c->window); } void @@ -343,7 +345,7 @@ clientUngrabButtons (Client * c) TRACE ("entering clientUngrabButtons"); TRACE ("grabbing buttons for client \"%s\" (0x%lx)", c->name, c->window); - XUngrabButton (md->dpy, AnyButton, AnyModifier, c->window); + XUngrabButton (c->md->dpy, AnyButton, AnyModifier, c->window); } void @@ -670,9 +672,9 @@ clientConfigure (Client * c, XWindowChanges * wc, int mask, unsigned short flags clientConstrainPos (c, TRUE); } - XMoveResizeWindow (md->dpy, c->frame, frameX (c), frameY (c), + XMoveResizeWindow (c->md->dpy, c->frame, frameX (c), frameY (c), frameWidth (c), frameHeight (c)); - XMoveResizeWindow (md->dpy, c->window, frameLeft (c), frameTop (c), + XMoveResizeWindow (c->md->dpy, c->window, frameLeft (c), frameTop (c), c->width, c->height); if (resized || (flags & CFG_FORCE_REDRAW)) @@ -686,7 +688,7 @@ clientConfigure (Client * c, XWindowChanges * wc, int mask, unsigned short flags { DBG ("Sending ConfigureNotify"); ce.type = ConfigureNotify; - ce.display = md->dpy; + ce.display = c->md->dpy; ce.event = c->window; ce.window = c->window; ce.x = c->x; @@ -696,7 +698,7 @@ clientConfigure (Client * c, XWindowChanges * wc, int mask, unsigned short flags ce.border_width = 0; ce.above = c->frame; ce.override_redirect = FALSE; - XSendEvent (md->dpy, c->window, FALSE, StructureNotifyMask, + XSendEvent (c->md->dpy, c->window, FALSE, StructureNotifyMask, (XEvent *) & ce); } } @@ -713,7 +715,7 @@ clientGetMWMHints (Client * c, gboolean update) TRACE ("entering clientGetMWMHints client \"%s\" (0x%lx)", c->name, c->window); - mwm_hints = getMotifHints (md->dpy, c->window); + mwm_hints = getMotifHints (c->md->dpy, c->window); if (mwm_hints) { if (mwm_hints->flags & MWM_HINTS_DECORATIONS) @@ -822,7 +824,7 @@ clientGetWMNormalHints (Client * c, gboolean update) c->size = XAllocSizeHints (); } g_assert (c->size); - if (!XGetWMNormalHints (md->dpy, c->window, c->size, &dummy)) + if (!XGetWMNormalHints (c->md->dpy, c->window, c->size, &dummy)) { c->size->flags = 0; } @@ -968,7 +970,7 @@ clientGetWMProtocols (Client * c) TRACE ("entering clientGetWMProtocols client \"%s\" (0x%lx)", c->name, c->window); - wm_protocols_flags = getWMProtocols (md->dpy, c->window); + wm_protocols_flags = getWMProtocols (c->md->dpy, c->window); FLAG_SET (c->wm_flags, (wm_protocols_flags & WM_PROTOCOLS_DELETE_WINDOW) ? WM_FLAG_DELETE : 0); @@ -1196,9 +1198,9 @@ clientCheckShape (Client * c) int boundingShaped, clipShaped; g_return_val_if_fail (c != NULL, FALSE); - if (md->shape) + if (c->md->shape) { - XShapeQueryExtents (md->dpy, c->window, &boundingShaped, &xws, &yws, &wws, + XShapeQueryExtents (c->md->dpy, c->window, &boundingShaped, &xws, &yws, &wws, &hws, &clipShaped, &xbs, &ybs, &wbs, &hbs); return (boundingShaped != 0); } @@ -1210,14 +1212,14 @@ clientClearPixmapCache (Client * c) { g_return_if_fail (c != NULL); - myPixmapFree (md->dpy, &c->pm_cache.pm_title[ACTIVE]); - myPixmapFree (md->dpy, &c->pm_cache.pm_title[INACTIVE]); - myPixmapFree (md->dpy, &c->pm_cache.pm_sides[SIDE_LEFT][ACTIVE]); - myPixmapFree (md->dpy, &c->pm_cache.pm_sides[SIDE_LEFT][INACTIVE]); - myPixmapFree (md->dpy, &c->pm_cache.pm_sides[SIDE_RIGHT][ACTIVE]); - myPixmapFree (md->dpy, &c->pm_cache.pm_sides[SIDE_RIGHT][INACTIVE]); - myPixmapFree (md->dpy, &c->pm_cache.pm_sides[SIDE_BOTTOM][ACTIVE]); - myPixmapFree (md->dpy, &c->pm_cache.pm_sides[SIDE_BOTTOM][INACTIVE]); + myPixmapFree (&c->pm_cache.pm_title[ACTIVE]); + myPixmapFree (&c->pm_cache.pm_title[INACTIVE]); + myPixmapFree (&c->pm_cache.pm_sides[SIDE_LEFT][ACTIVE]); + myPixmapFree (&c->pm_cache.pm_sides[SIDE_LEFT][INACTIVE]); + myPixmapFree (&c->pm_cache.pm_sides[SIDE_RIGHT][ACTIVE]); + myPixmapFree (&c->pm_cache.pm_sides[SIDE_RIGHT][INACTIVE]); + myPixmapFree (&c->pm_cache.pm_sides[SIDE_BOTTOM][ACTIVE]); + myPixmapFree (&c->pm_cache.pm_sides[SIDE_BOTTOM][INACTIVE]); } void @@ -1225,14 +1227,14 @@ clientGetUserTime (Client * c) { g_return_if_fail (c != NULL); - if (getNetWMUserTime (md->dpy, c->window, &c->user_time)) + if (getNetWMUserTime (c->md->dpy, c->window, &c->user_time)) { FLAG_SET (c->flags, CLIENT_FLAG_HAS_USER_TIME); } } void -clientFrame (Window w, gboolean recapture) +clientFrame (ScreenData *md, Window w, gboolean recapture) { XWindowAttributes attr; XWindowChanges wc; @@ -1242,6 +1244,8 @@ clientFrame (Window w, gboolean recapture) int i; g_return_if_fail (w != None); + g_return_if_fail (md != NULL); + TRACE ("entering clientFrame"); TRACE ("framing client (0x%lx)", w); @@ -1254,7 +1258,7 @@ clientFrame (Window w, gboolean recapture) gdk_error_trap_push (); if (checkKdeSystrayWindow (md->dpy, w) && (md->systray != None)) { - TRACE ("Not managing KDE md->systray windows"); + TRACE ("Not managing KDE systray windows"); sendSystrayReqDock (md->dpy, w, md->systray); gdk_error_trap_pop (); return; @@ -1283,6 +1287,7 @@ clientFrame (Window w, gboolean recapture) } c->window = w; + c->md = md; c->serial = client_serial++; getWindowName (md->dpy, c->window, &c->name); @@ -1391,7 +1396,7 @@ clientFrame (Window w, gboolean recapture) c->win_layer = WIN_LAYER_NORMAL; } - /* md->reload from session */ + /* Reload from session */ if (sessionMatchWinToSM (c)) { FLAG_SET (c->flags, CLIENT_FLAG_SESSION_MANAGED); @@ -1438,15 +1443,15 @@ clientFrame (Window w, gboolean recapture) if (!recapture) { - myXGrabServer (); + myXGrabServer (c->md); } - if (!myCheckWindow(w)) + if (!myCheckWindow(c->md, w)) { TRACE ("Client has vanished"); clientFree(c); if (!recapture) { - myXUngrabServer (); + myXUngrabServer (c->md); } gdk_error_trap_pop (); return; @@ -1473,7 +1478,7 @@ clientFrame (Window w, gboolean recapture) /* Window is reparented now, so we can safely release the grab * on the server */ - myXUngrabServer (); + myXUngrabServer (md); } clientAddToList (c); @@ -1519,7 +1524,7 @@ clientFrame (Window w, gboolean recapture) wc.width = c->width; wc.height = c->height; clientConfigure (c, &wc, CWX | CWY | CWHeight | CWWidth, CFG_NOTIFY | CFG_FORCE_REDRAW); - clientApplyStackList (); + clientApplyStackList (c->md); clientSetLastRaise (c); /* Clear time counter */ @@ -1582,37 +1587,37 @@ clientUnframe (Client * c, gboolean remap) } clientRemoveFromList (c); - myXGrabServer (); + myXGrabServer (c->md); gdk_error_trap_push (); clientUngrabKeys (c); clientGrabButtons (c); - XUnmapWindow (md->dpy, c->window); - XUnmapWindow (md->dpy, c->frame); + XUnmapWindow (c->md->dpy, c->window); + XUnmapWindow (c->md->dpy, c->frame); clientGravitate (c, REMOVE); - XSelectInput (md->dpy, c->window, NoEventMask); - reparented = XCheckTypedWindowEvent (md->dpy, c->window, ReparentNotify, &ev); + XSelectInput (c->md->dpy, c->window, NoEventMask); + reparented = XCheckTypedWindowEvent (c->md->dpy, c->window, ReparentNotify, &ev); if (remap || !reparented) { - XReparentWindow (md->dpy, c->window, md->xroot, c->x, c->y); - XSetWindowBorderWidth (md->dpy, c->window, c->border_width); + XReparentWindow (c->md->dpy, c->window, c->md->xroot, c->x, c->y); + XSetWindowBorderWidth (c->md->dpy, c->window, c->border_width); if (remap) { - XMapWindow (md->dpy, c->window); + XMapWindow (c->md->dpy, c->window); } else { - setWMState (md->dpy, c->window, WithdrawnState); + setWMState (c->md->dpy, c->window, WithdrawnState); } } if (!remap) { - XDeleteProperty (md->dpy, c->window, net_wm_state); - XDeleteProperty (md->dpy, c->window, win_state); - XDeleteProperty (md->dpy, c->window, net_wm_desktop); - XDeleteProperty (md->dpy, c->window, win_workspace); - XDeleteProperty (md->dpy, c->window, net_wm_allowed_actions); + XDeleteProperty (c->md->dpy, c->window, net_wm_state); + XDeleteProperty (c->md->dpy, c->window, win_state); + XDeleteProperty (c->md->dpy, c->window, net_wm_desktop); + XDeleteProperty (c->md->dpy, c->window, win_workspace); + XDeleteProperty (c->md->dpy, c->window, net_wm_allowed_actions); } myWindowDelete (&c->title); @@ -1628,22 +1633,23 @@ clientUnframe (Client * c, gboolean remap) { myWindowDelete (&c->buttons[i]); } - XDestroyWindow (md->dpy, c->frame); + XDestroyWindow (c->md->dpy, c->frame); if (FLAG_TEST (c->flags, CLIENT_FLAG_HAS_STRUT)) { - workspaceUpdateArea (md->margins, md->gnome_margins); + workspaceUpdateArea (c->md); } - myXUngrabServer (); + myXUngrabServer (c->md); gdk_error_trap_pop (); clientFree (c); } void -clientFrameAll () +clientFrameAll (ScreenData *md) { unsigned int count, i; - Window shield, w1, w2, *wins = NULL; + myWindow shield; + Window w1, w2, *wins = NULL; XWindowAttributes attr; TRACE ("entering clientFrameAll"); @@ -1652,36 +1658,35 @@ clientFrameAll () client_count = 0; clients = NULL; - clientSetFocus (NULL, GDK_CURRENT_TIME, NO_FOCUS_FLAG); - shield = - setTmpEventWin (0, 0, + clientSetFocus (md, NULL, GDK_CURRENT_TIME, NO_FOCUS_FLAG); + myWindowTemp (md->dpy, md->xroot, &shield, 0, 0, gdk_screen_get_width (md->gscr), gdk_screen_get_height (md->gscr), EnterWindowMask); XSync (md->dpy, FALSE); - myXGrabServer (); + myXGrabServer (md); XQueryTree (md->dpy, md->xroot, &w1, &w2, &wins, &count); for (i = 0; i < count; i++) { XGetWindowAttributes (md->dpy, wins[i], &attr); if ((!(attr.override_redirect)) && (attr.map_state == IsViewable)) { - clientFrame (wins[i], TRUE); + clientFrame (md, wins[i], TRUE); } } if (wins) { XFree (wins); } - clientFocusTop (WIN_LAYER_NORMAL); - removeTmpEventWin (shield); - myXUngrabServer (); + clientFocusTop (md, WIN_LAYER_NORMAL); + myWindowDelete (&shield); + myXUngrabServer (md); XSync (md->dpy, FALSE); } void -clientUnframeAll () +clientUnframeAll (ScreenData *md) { Client *c; unsigned int count, i; @@ -1689,9 +1694,9 @@ clientUnframeAll () TRACE ("entering clientUnframeAll"); - clientSetFocus (NULL, GDK_CURRENT_TIME, FOCUS_IGNORE_MODAL); + clientSetFocus (md, NULL, GDK_CURRENT_TIME, FOCUS_IGNORE_MODAL); XSync (md->dpy, FALSE); - myXGrabServer (); + myXGrabServer (md); XQueryTree (md->dpy, md->xroot, &w1, &w2, &wins, &count); for (i = 0; i < count; i++) { @@ -1701,7 +1706,7 @@ clientUnframeAll () clientUnframe (c, TRUE); } } - myXUngrabServer (); + myXUngrabServer (md); XSync(md->dpy, FALSE); if (wins) { @@ -1767,17 +1772,17 @@ clientSetWorkspaceSingle (Client * c, int ws) if (c->win_workspace != ws) { - TRACE ("setting client \"%s\" (0x%lx) to md->current_ws %d", c->name, + TRACE ("setting client \"%s\" (0x%lx) to current_ws %d", c->name, c->window, ws); c->win_workspace = ws; - setHint (md->dpy, c->window, win_workspace, ws); + setHint (c->md->dpy, c->window, win_workspace, ws); if (FLAG_TEST (c->flags, CLIENT_FLAG_STICKY)) { - setHint (md->dpy, c->window, net_wm_desktop, (unsigned long) ALL_WORKSPACES); + setHint (c->md->dpy, c->window, net_wm_desktop, (unsigned long) ALL_WORKSPACES); } else { - setHint (md->dpy, c->window, net_wm_desktop, (unsigned long) ws); + setHint (c->md->dpy, c->window, net_wm_desktop, (unsigned long) ws); } } FLAG_SET (c->flags, CLIENT_FLAG_WORKSPACE_SET); @@ -1800,7 +1805,7 @@ clientSetWorkspace (Client * c, int ws, gboolean manage_mapping) c2 = (Client *) index->data; if (c2->win_workspace != ws) { - TRACE ("setting client \"%s\" (0x%lx) to md->current_ws %d", c->name, + TRACE ("setting client \"%s\" (0x%lx) to current_ws %d", c->name, c->window, ws); clientSetWorkspaceSingle (c2, ws); if (manage_mapping && !clientIsTransientOrModal (c2) @@ -1812,13 +1817,13 @@ clientSetWorkspace (Client * c, int ws, gboolean manage_mapping) } else { - if (ws == md->current_ws) + if (ws == c2->md->current_ws) { clientShow (c2, FALSE); } else { - clientHide (c2, md->current_ws, FALSE); + clientHide (c2, c2->md->current_ws, FALSE); } } } @@ -1831,22 +1836,22 @@ static void clientShowSingle (Client * c, gboolean change_state) { g_return_if_fail (c != NULL); - myXGrabServer (); - if ((c->win_workspace == md->current_ws) + myXGrabServer (c->md); + if ((c->win_workspace == c->md->current_ws) || FLAG_TEST (c->flags, CLIENT_FLAG_STICKY)) { TRACE ("showing client \"%s\" (0x%lx)", c->name, c->window); FLAG_SET (c->flags, CLIENT_FLAG_VISIBLE); - XMapWindow (md->dpy, c->frame); - XMapWindow (md->dpy, c->window); + XMapWindow (c->md->dpy, c->frame); + XMapWindow (c->md->dpy, c->window); } if (change_state) { FLAG_UNSET (c->flags, CLIENT_FLAG_HIDDEN); - setWMState (md->dpy, c->window, NormalState); - workspaceUpdateArea (md->margins, md->gnome_margins); + setWMState (c->md->dpy, c->window, NormalState); + workspaceUpdateArea (c->md); } - myXUngrabServer (); + myXUngrabServer (c->md); clientSetNetState (c); } @@ -1881,11 +1886,11 @@ static void clientHideSingle (Client * c, gboolean change_state) { g_return_if_fail (c != NULL); - myXGrabServer (); + myXGrabServer (c->md); TRACE ("hiding client \"%s\" (0x%lx)", c->name, c->window); - clientPassFocus(c); - XUnmapWindow (md->dpy, c->window); - XUnmapWindow (md->dpy, c->frame); + clientPassFocus(c->md, c); + XUnmapWindow (c->md->dpy, c->window); + XUnmapWindow (c->md->dpy, c->frame); if (FLAG_TEST (c->flags, CLIENT_FLAG_VISIBLE)) { FLAG_UNSET (c->flags, CLIENT_FLAG_VISIBLE); @@ -1894,10 +1899,10 @@ clientHideSingle (Client * c, gboolean change_state) if (change_state) { FLAG_SET (c->flags, CLIENT_FLAG_HIDDEN); - setWMState (md->dpy, c->window, IconicState); - workspaceUpdateArea (md->margins, md->gnome_margins); + setWMState (c->md->dpy, c->window, IconicState); + workspaceUpdateArea (c->md); } - myXUngrabServer (); + myXUngrabServer (c->md); clientSetNetState (c); } @@ -1924,8 +1929,8 @@ clientHide (Client * c, int ws, gboolean change_state) /* ws is used when transitioning between desktops, to avoid hiding a transient for group that will be shown again on the new - md->current_ws (transient for groups can be transients for multiple - ancesors splitted across md->current_wss...) + workspace (transient for groups can be transients for multiple + ancesors splitted across workspaces...) */ if (clientIsTransientOrModalForGroup (c2) && clientTransientOrModalHasAncestor (c2, ws)) @@ -1965,13 +1970,13 @@ clientHideAll (Client * c, int ws) } void -clientToggleShowDesktop (gboolean show_desktop) +clientToggleShowDesktop (ScreenData *md, gboolean show_desktop) { GList *index; TRACE ("entering clientToggleShowDesktop"); - clientSetFocus (NULL, GDK_CURRENT_TIME, FOCUS_IGNORE_MODAL); + clientSetFocus (md, NULL, GDK_CURRENT_TIME, FOCUS_IGNORE_MODAL); if (show_desktop) { for (index = windows_stack; index; index = g_list_next (index)) @@ -1986,7 +1991,7 @@ clientToggleShowDesktop (gboolean show_desktop) } } } - clientFocusTop (WIN_LAYER_DESKTOP); + clientFocusTop (md, WIN_LAYER_DESKTOP); } else { @@ -2001,7 +2006,7 @@ clientToggleShowDesktop (gboolean show_desktop) } FLAG_UNSET (c->flags, CLIENT_FLAG_WAS_SHOWN); } - clientFocusTop (WIN_LAYER_NORMAL); + clientFocusTop (md, WIN_LAYER_NORMAL); } } @@ -2014,7 +2019,7 @@ clientClose (Client * c) if (FLAG_TEST (c->wm_flags, WM_FLAG_DELETE)) { - sendClientMessage (c->window, wm_protocols, wm_delete_window, GDK_CURRENT_TIME); + sendClientMessage (c->md, c->window, wm_protocols, wm_delete_window, GDK_CURRENT_TIME); } else { @@ -2029,7 +2034,7 @@ clientKill (Client * c) TRACE ("entering clientKill"); TRACE ("killing client \"%s\" (0x%lx)", c->name, c->window); - XKillClient (md->dpy, c->window); + XKillClient (c->md->dpy, c->window); } void @@ -2041,7 +2046,7 @@ clientEnterContextMenuState (Client * c) if (FLAG_TEST (c->wm_flags, WM_FLAG_CONTEXT_HELP)) { - sendClientMessage (c->window, wm_protocols, kde_net_wm_context_help, GDK_CURRENT_TIME); + sendClientMessage (c->md, c->window, wm_protocols, kde_net_wm_context_help, GDK_CURRENT_TIME); } } @@ -2064,7 +2069,7 @@ clientSetLayer (Client * c, int l) TRACE ("setting client \"%s\" (0x%lx) layer to %d", c2->name, c2->window, l); c2->win_layer = l; - setHint (md->dpy, c2->window, win_layer, l); + setHint (c2->md->dpy, c2->window, win_layer, l); } } g_list_free (list_of_windows); @@ -2167,11 +2172,11 @@ clientStick (Client * c, gboolean include_transients) TRACE ("sticking client \"%s\" (0x%lx)", c2->name, c2->window); c2->win_state |= WIN_STATE_STICKY; FLAG_SET (c2->flags, CLIENT_FLAG_STICKY); - setHint (md->dpy, c2->window, net_wm_desktop, + setHint (c2->md->dpy, c2->window, net_wm_desktop, (unsigned long) ALL_WORKSPACES); clientSetNetState (c2); } - clientSetWorkspace (c, md->current_ws, TRUE); + clientSetWorkspace (c, c->md->current_ws, TRUE); g_list_free (list_of_windows); } else @@ -2179,10 +2184,10 @@ clientStick (Client * c, gboolean include_transients) TRACE ("sticking client \"%s\" (0x%lx)", c->name, c->window); c->win_state |= WIN_STATE_STICKY; FLAG_SET (c->flags, CLIENT_FLAG_STICKY); - setHint (md->dpy, c->window, net_wm_desktop, + setHint (c->md->dpy, c->window, net_wm_desktop, (unsigned long) ALL_WORKSPACES); clientSetNetState (c); - clientSetWorkspace (c, md->current_ws, TRUE); + clientSetWorkspace (c, c->md->current_ws, TRUE); } } @@ -2205,21 +2210,21 @@ clientUnstick (Client * c, gboolean include_transients) c2 = (Client *) index->data; c2->win_state &= ~WIN_STATE_STICKY; FLAG_UNSET (c2->flags, CLIENT_FLAG_STICKY); - setHint (md->dpy, c2->window, net_wm_desktop, - (unsigned long) md->current_ws); + setHint (c2->md->dpy, c2->window, net_wm_desktop, + (unsigned long) c2->md->current_ws); clientSetNetState (c2); } - clientSetWorkspace (c, md->current_ws, TRUE); + clientSetWorkspace (c, c->md->current_ws, TRUE); g_list_free (list_of_windows); } else { c->win_state &= ~WIN_STATE_STICKY; FLAG_UNSET (c->flags, CLIENT_FLAG_STICKY); - setHint (md->dpy, c->window, net_wm_desktop, - (unsigned long) md->current_ws); + setHint (c->md->dpy, c->window, net_wm_desktop, + (unsigned long) c->md->current_ws); clientSetNetState (c); - clientSetWorkspace (c, md->current_ws, TRUE); + clientSetWorkspace (c, c->md->current_ws, TRUE); } } @@ -2314,14 +2319,14 @@ clientToggleMaximized (Client * c, int mode) cx = frameX (c) + (frameWidth (c) / 2); cy = frameY (c) + (frameHeight (c) / 2); - monitor_nbr = gdk_screen_get_monitor_at_point (md->gscr, cx, cy); - gdk_screen_get_monitor_geometry (md->gscr, monitor_nbr, &rect); + monitor_nbr = gdk_screen_get_monitor_at_point (c->md->gscr, cx, cy); + gdk_screen_get_monitor_geometry (c->md->gscr, monitor_nbr, &rect); full_x = MAX (params.xfwm_margins[LEFT], rect.x); full_y = MAX (params.xfwm_margins[TOP], rect.y); - full_w = MIN (gdk_screen_get_width (md->gscr) - params.xfwm_margins[RIGHT], + full_w = MIN (gdk_screen_get_width (c->md->gscr) - params.xfwm_margins[RIGHT], rect.x + rect.width) - full_x; - full_h = MIN (gdk_screen_get_height (md->gscr) - params.xfwm_margins[BOTTOM], + full_h = MIN (gdk_screen_get_height (c->md->gscr) - params.xfwm_margins[BOTTOM], rect.y + rect.height) - full_y; /* Adjust size to the widest size available, not covering struts */ @@ -2386,10 +2391,10 @@ clientToggleMaximized (Client * c, int mode) grab focus in focus follow mouse mode. Grab the pointer to avoid these effects */ - XGrabPointer (md->dpy, md->gnome_win, FALSE, EnterWindowMask, GrabModeAsync, + XGrabPointer (c->md->dpy, c->md->gnome_win, FALSE, EnterWindowMask, GrabModeAsync, GrabModeAsync, None, None, GDK_CURRENT_TIME); clientConfigure (c, &wc, CWX | CWY | CWWidth | CWHeight, CFG_NOTIFY); - XUngrabPointer (md->dpy, GDK_CURRENT_TIME); + XUngrabPointer (c->md->dpy, GDK_CURRENT_TIME); } else { @@ -2435,12 +2440,12 @@ clientDrawOutline (Client * c) { TRACE ("entering clientDrawOutline"); - XDrawRectangle (md->dpy, md->xroot, params.box_gc, frameX (c), frameY (c), + XDrawRectangle (c->md->dpy, c->md->xroot, params.box_gc, frameX (c), frameY (c), frameWidth (c) - 1, frameHeight (c) - 1); if (FLAG_TEST_AND_NOT (c->flags, CLIENT_FLAG_HAS_BORDER, CLIENT_FLAG_FULLSCREEN | CLIENT_FLAG_SHADED)) { - XDrawRectangle (md->dpy, md->xroot, params.box_gc, c->x, c->y, c->width - 1, + XDrawRectangle (c->md->dpy, c->md->xroot, params.box_gc, c->x, c->y, c->width - 1, c->height - 1); } } @@ -2482,8 +2487,8 @@ clientSnapPosition (Client * c) best_frame_x = frame_x; best_frame_y = frame_y; - monitor_nbr = gdk_screen_get_monitor_at_point (md->gscr, cx, cy); - gdk_screen_get_monitor_geometry (md->gscr, monitor_nbr, &rect); + monitor_nbr = gdk_screen_get_monitor_at_point (c->md->gscr, cx, cy); + gdk_screen_get_monitor_geometry (c->md->gscr, monitor_nbr, &rect); disp_x = rect.x; disp_y = rect.y; @@ -2590,7 +2595,7 @@ clientMove_event_filter (XEvent * xevent, gpointer data) { if (!passdata->grab && params.box_move) { - myXGrabServer (); + myXGrabServer (c->md); passdata->grab = TRUE; clientDrawOutline (c); } @@ -2638,7 +2643,7 @@ clientMove_event_filter (XEvent * xevent, gpointer data) { if (passdata->use_keys) { - if (IsModifierKey (XKeycodeToKeysym (md->dpy, xevent->xkey.keycode, 0))) + if (IsModifierKey (XKeycodeToKeysym (c->md->dpy, xevent->xkey.keycode, 0))) { moving = FALSE; } @@ -2646,7 +2651,7 @@ clientMove_event_filter (XEvent * xevent, gpointer data) } else if (xevent->type == MotionNotify) { - while (XCheckMaskEvent (md->dpy, ButtonMotionMask | PointerMotionMask, xevent)) + while (XCheckMaskEvent (c->md->dpy, ButtonMotionMask | PointerMotionMask, xevent)) ; /* Skip event */ if (xevent->type == ButtonRelease) @@ -2656,7 +2661,7 @@ clientMove_event_filter (XEvent * xevent, gpointer data) if (!passdata->grab && params.box_move) { - myXGrabServer (); + myXGrabServer (c->md); passdata->grab = TRUE; clientDrawOutline (c); } @@ -2674,7 +2679,7 @@ clientMove_event_filter (XEvent * xevent, gpointer data) msx = xevent->xmotion.x_root; msy = xevent->xmotion.y_root; - max = gdk_screen_get_width (md->gscr) - 1; + max = gdk_screen_get_width (c->md->gscr) - 1; if ((msx == 0) || (msx == max)) { @@ -2689,16 +2694,17 @@ clientMove_event_filter (XEvent * xevent, gpointer data) edge_scroll_x = 0; if (msx == 0) { - XWarpPointer (md->dpy, None, md->xroot, 0, 0, 0, 0, max - 10, - msy); + XWarpPointer (c->md->dpy, None, c->md->xroot, 0, 0, 0, 0, + max - 10, msy); msx = xevent->xmotion.x_root = max - 10; - workspaceSwitch (md->current_ws - 1, c); + workspaceSwitch (c->md, c->md->current_ws - 1, c); } else if (msx == max) { - XWarpPointer (md->dpy, None, md->xroot, 0, 0, 0, 0, 10, msy); + XWarpPointer (c->md->dpy, None, c->md->xroot, + 0, 0, 0, 0, 10, msy); msx = xevent->xmotion.x_root = 10; - workspaceSwitch (md->current_ws + 1, c); + workspaceSwitch (c->md, c->md->current_ws + 1, c); } } } @@ -2776,25 +2782,10 @@ clientMove (Client * c, XEvent * e) passdata.oy = c->y; passdata.use_keys = FALSE; passdata.grab = FALSE; - /* - The following trick is experimental, based on a patch for Kwin 3.1alpha1 by aviv bergman - - It is supposed to reduce latency during move/resize by mapping a screen large window that - receives all pointer events. - Original mail message is available here : - - http://www.xfree86.org/pipermail/xpert/2002-July/019434.html - - Note: - - I'm not sure it makes any difference, but who knows... It doesn' t hurt. - */ - - passdata.tmp_event_window = - setTmpEventWin (0, 0, - gdk_screen_get_width (md->gscr), - gdk_screen_get_height (md->gscr), + myWindowTemp (c->md->dpy, c->md->xroot, &passdata.tmp_event_window, 0, 0, + gdk_screen_get_width (c->md->gscr), + gdk_screen_get_height (c->md->gscr), ButtonMotionMask | ButtonReleaseMask); if (e->type == KeyPress) @@ -2812,14 +2803,14 @@ clientMove (Client * c, XEvent * e) } else { - cursor = md->move_cursor; - getMouseXY (md->xroot, &passdata.mx, &passdata.my); + cursor = c->md->move_cursor; + getMouseXY (c->md, c->md->xroot, &passdata.mx, &passdata.my); } - g1 = XGrabKeyboard (md->dpy, passdata.tmp_event_window, FALSE, - GrabModeAsync, GrabModeAsync, GDK_CURRENT_TIME); - g2 = XGrabPointer (md->dpy, passdata.tmp_event_window, FALSE, - ButtonMotionMask | ButtonReleaseMask, GrabModeAsync, - GrabModeAsync, None, cursor, GDK_CURRENT_TIME); + g1 = XGrabKeyboard (c->md->dpy, MYWINDOW_XWINDOW (passdata.tmp_event_window), + FALSE, GrabModeAsync, GrabModeAsync, GDK_CURRENT_TIME); + g2 = XGrabPointer (c->md->dpy, MYWINDOW_XWINDOW (passdata.tmp_event_window), + FALSE, ButtonMotionMask | ButtonReleaseMask, GrabModeAsync, + GrabModeAsync, None, cursor, GDK_CURRENT_TIME); if (((passdata.use_keys) && (g1 != GrabSuccess)) || (g2 != GrabSuccess)) { @@ -2827,13 +2818,13 @@ clientMove (Client * c, XEvent * e) gdk_beep (); if ((passdata.use_keys) && (g1 == GrabSuccess)) { - XUngrabKeyboard (md->dpy, GDK_CURRENT_TIME); + XUngrabKeyboard (c->md->dpy, GDK_CURRENT_TIME); } if (g2 == GrabSuccess) { - XUngrabPointer (md->dpy, GDK_CURRENT_TIME); + XUngrabPointer (c->md->dpy, GDK_CURRENT_TIME); } - removeTmpEventWin (passdata.tmp_event_window); + myWindowDelete (&passdata.tmp_event_window); return; } @@ -2845,13 +2836,13 @@ clientMove (Client * c, XEvent * e) FLAG_SET (c->flags, CLIENT_FLAG_MOVING_RESIZING); TRACE ("entering move loop"); - xfce_push_event_filter (md->gtox_data, clientMove_event_filter, &passdata); + xfce_push_event_filter (c->md->gtox_data, clientMove_event_filter, &passdata); if (passdata.use_keys) { - XPutBackEvent (md->dpy, e); + XPutBackEvent (c->md->dpy, e); } gtk_main (); - xfce_pop_event_filter (md->gtox_data); + xfce_pop_event_filter (c->md->gtox_data); TRACE ("leaving move loop"); FLAG_UNSET (c->flags, CLIENT_FLAG_MOVING_RESIZING); #ifdef SHOW_POSITION @@ -2869,13 +2860,13 @@ clientMove (Client * c, XEvent * e) wc.y = c->y; clientConfigure (c, &wc, CWX | CWY, NO_CFG_FLAG); - XUngrabKeyboard (md->dpy, GDK_CURRENT_TIME); - XUngrabPointer (md->dpy, GDK_CURRENT_TIME); - removeTmpEventWin (passdata.tmp_event_window); + XUngrabKeyboard (c->md->dpy, GDK_CURRENT_TIME); + XUngrabPointer (c->md->dpy, GDK_CURRENT_TIME); + myWindowDelete (&passdata.tmp_event_window); if (passdata.grab && params.box_move) { - myXUngrabServer (); + myXUngrabServer (c->md); } } @@ -2908,8 +2899,8 @@ clientResize_event_filter (XEvent * xevent, gpointer data) cx = frame_x + (frame_width / 2); cy = frame_y + (frame_height / 2); - monitor_nbr = gdk_screen_get_monitor_at_point (md->gscr, cx, cy); - gdk_screen_get_monitor_geometry (md->gscr, monitor_nbr, &rect); + monitor_nbr = gdk_screen_get_monitor_at_point (c->md->gscr, cx, cy); + gdk_screen_get_monitor_geometry (c->md->gscr, monitor_nbr, &rect); disp_x = rect.x; disp_y = rect.y; @@ -2938,7 +2929,7 @@ clientResize_event_filter (XEvent * xevent, gpointer data) if (!passdata->grab && params.box_resize) { - myXGrabServer (); + myXGrabServer (c->md); passdata->grab = TRUE; clientDrawOutline (c); } @@ -2984,12 +2975,12 @@ clientResize_event_filter (XEvent * xevent, gpointer data) else { if ((c->x + c->width < disp_x + CLIENT_MIN_VISIBLE) - || (c->x + c->width < md->margins [LEFT] + CLIENT_MIN_VISIBLE)) + || (c->x + c->width < c->md->margins [LEFT] + CLIENT_MIN_VISIBLE)) { c->width = prev_width; } if ((c->y + c->height < disp_y + CLIENT_MIN_VISIBLE) - || (c->y + c->height < md->margins [TOP] + CLIENT_MIN_VISIBLE)) + || (c->y + c->height < c->md->margins [TOP] + CLIENT_MIN_VISIBLE)) { c->height = prev_height; } @@ -3016,7 +3007,7 @@ clientResize_event_filter (XEvent * xevent, gpointer data) { if (passdata->use_keys) { - if (IsModifierKey (XKeycodeToKeysym (md->dpy, xevent->xkey.keycode, 0))) + if (IsModifierKey (XKeycodeToKeysym (c->md->dpy, xevent->xkey.keycode, 0))) { resizing = FALSE; } @@ -3024,7 +3015,7 @@ clientResize_event_filter (XEvent * xevent, gpointer data) } else if (xevent->type == MotionNotify) { - while (XCheckMaskEvent (md->dpy, ButtonMotionMask | PointerMotionMask, xevent)) + while (XCheckMaskEvent (c->md->dpy, ButtonMotionMask | PointerMotionMask, xevent)) ; /* Skip event */ if (xevent->type == ButtonRelease) @@ -3035,7 +3026,7 @@ clientResize_event_filter (XEvent * xevent, gpointer data) if (!passdata->grab && params.box_resize) { - myXGrabServer (); + myXGrabServer (c->md); passdata->grab = TRUE; clientDrawOutline (c); } @@ -3108,8 +3099,8 @@ clientResize_event_filter (XEvent * xevent, gpointer data) || (passdata->corner == CORNER_TOP_RIGHT)) { if ((c->y > disp_max_y - CLIENT_MIN_VISIBLE) - || (c->y > gdk_screen_get_height (md->gscr) - - md->margins [BOTTOM] - CLIENT_MIN_VISIBLE)) + || (c->y > gdk_screen_get_height (c->md->gscr) + - c->md->margins [BOTTOM] - CLIENT_MIN_VISIBLE)) { c->y = prev_y; c->height = prev_height; @@ -3120,7 +3111,7 @@ clientResize_event_filter (XEvent * xevent, gpointer data) || (passdata->corner == 4 + SIDE_BOTTOM)) { if ((c->y + c->height < disp_y + CLIENT_MIN_VISIBLE) - || (c->y + c->height < md->margins [TOP] + CLIENT_MIN_VISIBLE)) + || (c->y + c->height < c->md->margins [TOP] + CLIENT_MIN_VISIBLE)) { c->height = prev_height; } @@ -3130,8 +3121,8 @@ clientResize_event_filter (XEvent * xevent, gpointer data) || (passdata->corner == 4 + SIDE_LEFT)) { if ((c->x > disp_max_x - CLIENT_MIN_VISIBLE) - || (c->x > gdk_screen_get_width (md->gscr) - - md->margins [RIGHT] - CLIENT_MIN_VISIBLE)) + || (c->x > gdk_screen_get_width (c->md->gscr) + - c->md->margins [RIGHT] - CLIENT_MIN_VISIBLE)) { c->x = prev_x; c->width = prev_width; @@ -3142,7 +3133,7 @@ clientResize_event_filter (XEvent * xevent, gpointer data) || (passdata->corner == 4 + SIDE_RIGHT)) { if ((c->x + c->width < disp_x + CLIENT_MIN_VISIBLE) - || (c->x + c->width < md->margins [LEFT] + CLIENT_MIN_VISIBLE)) + || (c->x + c->width < c->md->margins [LEFT] + CLIENT_MIN_VISIBLE)) { c->width = prev_width; } @@ -3218,10 +3209,10 @@ clientResize (Client * c, int corner, XEvent * e) passdata.use_keys = FALSE; passdata.grab = FALSE; passdata.corner = corner; - passdata.tmp_event_window = - setTmpEventWin (0, 0, - gdk_screen_get_width (md->gscr), - gdk_screen_get_height (md->gscr), + + myWindowTemp (c->md->dpy, c->md->xroot, &passdata.tmp_event_window, 0, 0, + gdk_screen_get_width (c->md->gscr), + gdk_screen_get_height (c->md->gscr), ButtonMotionMask | ButtonReleaseMask); if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED)) @@ -3242,13 +3233,15 @@ clientResize (Client * c, int corner, XEvent * e) } else { - getMouseXY (md->xroot, &passdata.mx, &passdata.my); + getMouseXY (c->md, c->md->xroot, &passdata.mx, &passdata.my); } - g1 = XGrabKeyboard (md->dpy, passdata.tmp_event_window, FALSE, - GrabModeAsync, GrabModeAsync, GDK_CURRENT_TIME); - g2 = XGrabPointer (md->dpy, passdata.tmp_event_window, FALSE, - ButtonMotionMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, - None, md->resize_cursor[passdata.corner], GDK_CURRENT_TIME); + + g1 = XGrabKeyboard (c->md->dpy, MYWINDOW_XWINDOW (passdata.tmp_event_window), + FALSE, GrabModeAsync, GrabModeAsync, GDK_CURRENT_TIME); + g2 = XGrabPointer (c->md->dpy, MYWINDOW_XWINDOW (passdata.tmp_event_window), + FALSE, ButtonMotionMask | ButtonReleaseMask, GrabModeAsync, + GrabModeAsync, None, c->md->resize_cursor[passdata.corner], + GDK_CURRENT_TIME); if (((passdata.use_keys) && (g1 != GrabSuccess)) || (g2 != GrabSuccess)) { @@ -3256,13 +3249,13 @@ clientResize (Client * c, int corner, XEvent * e) gdk_beep (); if ((passdata.use_keys) && (g1 == GrabSuccess)) { - XUngrabKeyboard (md->dpy, GDK_CURRENT_TIME); + XUngrabKeyboard (c->md->dpy, GDK_CURRENT_TIME); } if (g2 == GrabSuccess) { - XUngrabPointer (md->dpy, GDK_CURRENT_TIME); + XUngrabPointer (c->md->dpy, GDK_CURRENT_TIME); } - removeTmpEventWin (passdata.tmp_event_window); + myWindowDelete (&passdata.tmp_event_window); return; } @@ -3283,13 +3276,13 @@ clientResize (Client * c, int corner, XEvent * e) FLAG_SET (c->flags, CLIENT_FLAG_MOVING_RESIZING); TRACE ("entering resize loop"); - xfce_push_event_filter (md->gtox_data, clientResize_event_filter, &passdata); + xfce_push_event_filter (c->md->gtox_data, clientResize_event_filter, &passdata); if (passdata.use_keys) { - XPutBackEvent (md->dpy, e); + XPutBackEvent (c->md->dpy, e); } gtk_main (); - xfce_pop_event_filter (md->gtox_data); + xfce_pop_event_filter (c->md->gtox_data); TRACE ("leaving resize loop"); FLAG_UNSET (c->flags, CLIENT_FLAG_MOVING_RESIZING); @@ -3308,13 +3301,13 @@ clientResize (Client * c, int corner, XEvent * e) wc.height = c->height; clientConfigure (c, &wc, CWX | CWY | CWHeight | CWWidth, CFG_NOTIFY); - XUngrabKeyboard (md->dpy, GDK_CURRENT_TIME); - XUngrabPointer (md->dpy, GDK_CURRENT_TIME); - removeTmpEventWin (passdata.tmp_event_window); + XUngrabKeyboard (c->md->dpy, GDK_CURRENT_TIME); + XUngrabPointer (c->md->dpy, GDK_CURRENT_TIME); + myWindowDelete (&passdata.tmp_event_window); if (passdata.grab && params.box_resize) { - myXUngrabServer (); + myXUngrabServer (c->md); } } @@ -3325,49 +3318,44 @@ clientCycle_event_filter (XEvent * xevent, gpointer data) gboolean cycling = TRUE; gboolean gone = FALSE; ClientCycleData *passdata = (ClientCycleData *) data; - + Client *c = passdata->c; + TRACE ("entering clientCycle_event_filter"); switch (xevent->type) { case DestroyNotify: - gone |= - (passdata->c == - clientGetFromWindow (((XDestroyWindowEvent *) xevent)->window, - WINDOW)); + gone |= (c == clientGetFromWindow (((XDestroyWindowEvent *) xevent)->window, WINDOW)); status = XEV_FILTER_CONTINUE; case UnmapNotify: - gone |= - (passdata->c == - clientGetFromWindow (((XUnmapEvent *) xevent)->window, - WINDOW)); + gone |= (c == clientGetFromWindow (((XUnmapEvent *) xevent)->window, WINDOW)); status = XEV_FILTER_CONTINUE; case KeyPress: - if (gone - || (xevent->xkey.keycode == - params.keys[KEY_CYCLE_WINDOWS].keycode)) + if (gone || (xevent->xkey.keycode == params.keys[KEY_CYCLE_WINDOWS].keycode)) { /* Hide frame draw */ - clientDrawOutline (passdata->c); + clientDrawOutline (c); /* If KEY_CYCLE_WINDOWS has Shift, then do not reverse */ if (!(params.keys[KEY_CYCLE_WINDOWS].modifier & ShiftMask) - && xevent->xkey.state & ShiftMask) { - passdata->c = - clientGetPrevious (passdata->c, passdata->cycle_range); + && xevent->xkey.state & ShiftMask) + { + c = clientGetPrevious (c, passdata->cycle_range); + passdata->c = c; } else { - passdata->c = - clientGetNext (passdata->c, passdata->cycle_range); + c = clientGetNext (c, passdata->cycle_range); + passdata->c = c; } - if (passdata->c) + if (c) { /* Redraw frame draw */ - clientDrawOutline (passdata->c); + clientDrawOutline (c); tabwinSetLabel (passdata->tabwin, - getAppIcon (md->dpy, passdata->c->window, 32, 32), - passdata->c->class.res_class, passdata->c->name); + getAppIcon (c->md->dpy, + c->window, 32, 32), + c->class.res_class, c->name); } else { @@ -3377,7 +3365,7 @@ clientCycle_event_filter (XEvent * xevent, gpointer data) break; case KeyRelease: { - int keysym = XKeycodeToKeysym (md->dpy, xevent->xkey.keycode, 0); + int keysym = XKeycodeToKeysym (c->md->dpy, xevent->xkey.keycode, 0); /* If KEY_CYCE_WINDOWS has Shift, then stop cycling on Shift * release. @@ -3420,9 +3408,9 @@ clientCycle (Client * c, XEvent * e) g_return_if_fail (c != NULL); TRACE ("entering clientCycle"); - g1 = XGrabKeyboard (md->dpy, md->gnome_win, FALSE, GrabModeAsync, GrabModeAsync, + g1 = XGrabKeyboard (c->md->dpy, c->md->gnome_win, FALSE, GrabModeAsync, GrabModeAsync, GDK_CURRENT_TIME); - g2 = XGrabPointer (md->dpy, md->gnome_win, FALSE, NoEventMask, GrabModeAsync, + g2 = XGrabPointer (c->md->dpy, c->md->gnome_win, FALSE, NoEventMask, GrabModeAsync, GrabModeAsync, None, None, GDK_CURRENT_TIME); if ((g1 != GrabSuccess) || (g2 != GrabSuccess)) { @@ -3430,16 +3418,16 @@ clientCycle (Client * c, XEvent * e) gdk_beep (); if (g1 == GrabSuccess) { - XUngrabKeyboard (md->dpy, GDK_CURRENT_TIME); + XUngrabKeyboard (c->md->dpy, GDK_CURRENT_TIME); } if (g2 == GrabSuccess) { - XUngrabPointer (md->dpy, GDK_CURRENT_TIME); + XUngrabPointer (c->md->dpy, GDK_CURRENT_TIME); } return; } - myXGrabServer (); + myXGrabServer (c->md); if (params.cycle_minimum) { passdata.cycle_range = INCLUDE_HIDDEN; @@ -3451,14 +3439,19 @@ clientCycle (Client * c, XEvent * e) passdata.c = clientGetNext (c, passdata.cycle_range); if (passdata.c) { +<<<<<<< client.c + passdata.tabwin = tabwinCreate (getAppIcon (c->md->dpy, passdata.c->window, 32, 32), + passdata.c->class.res_class, passdata.c->name); +======= passdata.tabwin = tabwinCreate (getAppIcon (md->dpy, passdata.c->window, 32, 32), passdata.c->class.res_class, passdata.c->name); +>>>>>>> 1.380 TRACE ("entering cycle loop"); /* Draw frame draw */ clientDrawOutline (passdata.c); - xfce_push_event_filter (md->gtox_data, clientCycle_event_filter, &passdata); + xfce_push_event_filter (c->md->gtox_data, clientCycle_event_filter, &passdata); gtk_main (); - xfce_pop_event_filter (md->gtox_data); + xfce_pop_event_filter (c->md->gtox_data); if (passdata.c) { /* Hide frame draw */ @@ -3468,15 +3461,15 @@ clientCycle (Client * c, XEvent * e) tabwinDestroy (passdata.tabwin); g_free (passdata.tabwin); } - myXUngrabServer (); - XUngrabKeyboard (md->dpy, GDK_CURRENT_TIME); - XUngrabPointer (md->dpy, GDK_CURRENT_TIME); + myXUngrabServer (c->md); + XUngrabKeyboard (c->md->dpy, GDK_CURRENT_TIME); + XUngrabPointer (c->md->dpy, GDK_CURRENT_TIME); if (passdata.c) { clientShow (passdata.c, TRUE); clientRaise (passdata.c); - clientSetFocus (passdata.c, GDK_CURRENT_TIME, NO_FOCUS_FLAG); + clientSetFocus (passdata.c->md, passdata.c, GDK_CURRENT_TIME, NO_FOCUS_FLAG); clientPassGrabButton1 (passdata.c); } } @@ -3543,7 +3536,7 @@ clientButtonPress (Client * c, Window w, XButtonEvent * bev) } } - g1 = XGrabPointer (md->dpy, w, FALSE, + g1 = XGrabPointer (c->md->dpy, w, FALSE, ButtonReleaseMask | EnterWindowMask | LeaveWindowMask, GrabModeAsync, GrabModeAsync, None, None, GDK_CURRENT_TIME); @@ -3553,7 +3546,7 @@ clientButtonPress (Client * c, Window w, XButtonEvent * bev) gdk_beep (); if (g1 == GrabSuccess) { - XUngrabKeyboard (md->dpy, GDK_CURRENT_TIME); + XUngrabKeyboard (c->md->dpy, GDK_CURRENT_TIME); } return; } @@ -3565,12 +3558,12 @@ clientButtonPress (Client * c, Window w, XButtonEvent * bev) frameDraw (c, FALSE, FALSE); TRACE ("entering button press loop"); - xfce_push_event_filter (md->gtox_data, clientButtonPress_event_filter, &passdata); + xfce_push_event_filter (c->md->gtox_data, clientButtonPress_event_filter, &passdata); gtk_main (); - xfce_pop_event_filter (md->gtox_data); + xfce_pop_event_filter (c->md->gtox_data); TRACE ("leaving button press loop"); - XUngrabPointer (md->dpy, GDK_CURRENT_TIME); + XUngrabPointer (c->md->dpy, GDK_CURRENT_TIME); if (c->button_pressed[b]) { diff --git a/src/client.h b/src/client.h index a953e56a8..50ac6991c 100644 --- a/src/client.h +++ b/src/client.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -44,6 +44,7 @@ #include "keyboard.h" #include "mypixmap.h" #include "mywindow.h" +#include "screen.h" #include "settings.h" #define ANY 0 @@ -190,6 +191,9 @@ struct _ClientPixmapCache struct _Client { + /* Reference to our screen structure */ + ScreenData *md; + Window window; Window frame; Window transient_for; @@ -261,13 +265,13 @@ void clientGetMWMHints (Client *, gboolean); void clientGetWMNormalHints (Client *, gboolean); void clientGetWMProtocols (Client *); void clientClearPixmapCache (Client *); -void clientFrame (Window, gboolean); +void clientFrame (ScreenData *, Window, gboolean); void clientUnframe (Client *, gboolean); -void clientFrameAll (); -void clientUnframeAll (); +void clientFrameAll (ScreenData *); +void clientUnframeAll (ScreenData *); void clientInstallColormaps (Client *); void clientUpdateColormaps (Client *); -void clientUpdateAllFrames (gboolean); +void clientUpdateAllFrames (ScreenData *, gboolean); void clientGrabKeys (Client *); void clientUngrabKeys (Client *); void clientGrabButtons (Client *); @@ -277,7 +281,7 @@ Client *clientAtPosition (int, int, Client *); void clientShow (Client *, gboolean); void clientHide (Client *, int, gboolean); void clientHideAll (Client *, int); -void clientToggleShowDesktop (gboolean); +void clientToggleShowDesktop (ScreenData *, gboolean); void clientClose (Client *); void clientKill (Client *); void clientEnterContextMenuState (Client *); diff --git a/src/events.c b/src/events.c index 6bea1bae2..5e9fd1d5e 100644 --- a/src/events.c +++ b/src/events.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -37,7 +37,6 @@ #include <libxfcegui4/libxfcegui4.h> #include <string.h> -#include "main.h" #include "misc.h" #include "workspaces.h" #include "settings.h" @@ -70,17 +69,22 @@ SuperMask | \ HyperMask) +extern gboolean xfwm4_quit; +extern gboolean xfwm4_reload; + + static guint raise_timeout = 0; static gulong button_handler_id = 0; static GdkAtom atom_rcfiles = GDK_NONE; -static Window menu_event_window = None; +static myWindow menu_event_window; static int edge_scroll_x = 0; +static void handleEvent (ScreenData *md, XEvent * ev); static void menu_callback (Menu * menu, MenuOp op, Window client_xwindow, gpointer menu_data, gpointer item_data); static gboolean show_popup_cb (GtkWidget * widget, GdkEventButton * ev, gpointer data); -static gboolean client_event_cb (GtkWidget * widget, GdkEventClient * ev); +static gboolean client_event_cb (GtkWidget * widget, GdkEventClient * ev, gpointer data); typedef enum { @@ -93,7 +97,7 @@ typedef enum XfwmButtonClickType; static XfwmButtonClickType -typeOfClick (Window w, XEvent * ev, gboolean allow_double_click) +typeOfClick (ScreenData *md, Window w, XEvent * ev, gboolean allow_double_click) { unsigned int button; int xcurrent, ycurrent, x, y, total; @@ -101,6 +105,7 @@ typeOfClick (Window w, XEvent * ev, gboolean allow_double_click) int clicks; Time t0; + g_return_val_if_fail (md != NULL, XFWM_BUTTON_UNDEFINED); g_return_val_if_fail (ev != NULL, XFWM_BUTTON_UNDEFINED); g_return_val_if_fail (w != None, XFWM_BUTTON_UNDEFINED); @@ -129,7 +134,7 @@ typeOfClick (Window w, XEvent * ev, gboolean allow_double_click) total += 10; if (XCheckMaskEvent (md->dpy, FocusChangeMask, ev)) { - handleEvent (ev); + handleEvent (md, ev); } if (XCheckMaskEvent (md->dpy, ButtonReleaseMask | ButtonPressMask, ev)) { @@ -205,7 +210,7 @@ moveRequest (Client * c, XEvent * ev) static void resizeRequest (Client * c, int corner, XEvent * ev) { - clientSetFocus (c, GDK_CURRENT_TIME, NO_FOCUS_FLAG); + clientSetFocus (c->md, c, GDK_CURRENT_TIME, NO_FOCUS_FLAG); if (FLAG_TEST_ALL (c->flags, CLIENT_FLAG_HAS_RESIZE | CLIENT_FLAG_IS_RESIZABLE)) @@ -238,7 +243,7 @@ spawn_shortcut (int i) } static void -handleMotionNotify (XMotionEvent * ev) +handleMotionNotify (ScreenData *md, XMotionEvent * ev) { int msx, msy, max; @@ -265,12 +270,12 @@ handleMotionNotify (XMotionEvent * ev) if (msx == 0) { XWarpPointer (md->dpy, None, md->xroot, 0, 0, 0, 0, max - 10, msy); - workspaceSwitch (md->current_ws - 1, NULL); + workspaceSwitch (md, md->current_ws - 1, NULL); } else if (msx == max) { XWarpPointer (md->dpy, None, md->xroot, 0, 0, 0, 0, 10, msy); - workspaceSwitch (md->current_ws + 1, NULL); + workspaceSwitch (md, md->current_ws + 1, NULL); } while (XCheckWindowEvent(md->dpy, ev->window, PointerMotionMask, (XEvent *) ev)) ; /* Skip event */ @@ -279,7 +284,7 @@ handleMotionNotify (XMotionEvent * ev) } static void -handleKeyPress (XKeyEvent * ev) +handleKeyPress (ScreenData *md, XKeyEvent * ev) { Client *c = NULL; int state, key; @@ -358,10 +363,10 @@ handleKeyPress (XKeyEvent * ev) clientPassGrabButton1 (NULL); break; case KEY_MOVE_NEXT_WORKSPACE: - workspaceSwitch (md->current_ws + 1, c); + workspaceSwitch (md, md->current_ws + 1, c); break; case KEY_MOVE_PREV_WORKSPACE: - workspaceSwitch (md->current_ws - 1, c); + workspaceSwitch (md, md->current_ws - 1, c); break; case KEY_MOVE_WORKSPACE_1: case KEY_MOVE_WORKSPACE_2: @@ -373,7 +378,7 @@ handleKeyPress (XKeyEvent * ev) case KEY_MOVE_WORKSPACE_8: case KEY_MOVE_WORKSPACE_9: clientRaise (c); - workspaceSwitch (key - KEY_MOVE_WORKSPACE_1, c); + workspaceSwitch (md, key - KEY_MOVE_WORKSPACE_1, c); break; default: break; @@ -396,16 +401,16 @@ handleKeyPress (XKeyEvent * ev) switch (key) { case KEY_NEXT_WORKSPACE: - workspaceSwitch (md->current_ws + 1, NULL); + workspaceSwitch (md, md->current_ws + 1, NULL); break; case KEY_PREV_WORKSPACE: - workspaceSwitch (md->current_ws - 1, NULL); + workspaceSwitch (md, md->current_ws - 1, NULL); break; case KEY_ADD_WORKSPACE: - workspaceSetCount (params.workspace_count + 1); + workspaceSetCount (md, params.workspace_count + 1); break; case KEY_DEL_WORKSPACE: - workspaceSetCount (params.workspace_count - 1); + workspaceSetCount (md, params.workspace_count - 1); break; case KEY_WORKSPACE_1: case KEY_WORKSPACE_2: @@ -416,7 +421,7 @@ handleKeyPress (XKeyEvent * ev) case KEY_WORKSPACE_7: case KEY_WORKSPACE_8: case KEY_WORKSPACE_9: - workspaceSwitch (key - KEY_WORKSPACE_1, NULL); + workspaceSwitch (md, key - KEY_WORKSPACE_1, NULL); break; case KEY_SHORTCUT_1: case KEY_SHORTCUT_2: @@ -447,7 +452,7 @@ edgeButton (Client * c, int part, XButtonEvent * ev) { XfwmButtonClickType tclick; - tclick = typeOfClick (c->frame, (XEvent *) ev, FALSE); + tclick = typeOfClick (c->md, c->frame, (XEvent *) ev, FALSE); if (tclick == XFWM_BUTTON_CLICK) { @@ -482,12 +487,12 @@ button1Action (Client * c, XButtonEvent * ev) g_return_if_fail (c != NULL); g_return_if_fail (ev != NULL); - clientSetFocus (c, ev->time, NO_FOCUS_FLAG); + clientSetFocus (c->md, c, ev->time, NO_FOCUS_FLAG); clientRaise (c); clientPassGrabButton1 (c); memcpy(©_event, ev, sizeof(XEvent)); - tclick = typeOfClick (c->frame, ©_event, TRUE); + tclick = typeOfClick (c->md, c->frame, ©_event, TRUE); if ((tclick == XFWM_BUTTON_DRAG) || (tclick == XFWM_BUTTON_CLICK_AND_DRAG)) @@ -517,9 +522,13 @@ button1Action (Client * c, XButtonEvent * ev) static void titleButton (Client * c, int state, XButtonEvent * ev) { + ScreenData *md; g_return_if_fail (c != NULL); g_return_if_fail (ev != NULL); + /* Get Screen data from the client itself */ + md = c->md; + if (ev->button == Button1) { button1Action (c, ev); @@ -540,7 +549,7 @@ titleButton (Client * c, int state, XButtonEvent * ev) XfwmButtonClickType tclick; memcpy(©_event, ev, sizeof(XEvent)); - tclick = typeOfClick (c->frame, ©_event, FALSE); + tclick = typeOfClick (c->md, c->frame, ©_event, FALSE); if (tclick == XFWM_BUTTON_DRAG) { @@ -548,7 +557,7 @@ titleButton (Client * c, int state, XButtonEvent * ev) } else { - clientSetFocus (c, ev->time, NO_FOCUS_FLAG); + clientSetFocus (c->md, c, ev->time, NO_FOCUS_FLAG); if (params.raise_on_click) { clientRaise (c); @@ -585,7 +594,7 @@ titleButton (Client * c, int state, XButtonEvent * ev) } static void -rootScrollButton (XButtonEvent * ev) +rootScrollButton (ScreenData *md, XButtonEvent * ev) { static Time lastscroll = (Time) 0; @@ -597,17 +606,17 @@ rootScrollButton (XButtonEvent * ev) lastscroll = ev->time; if (ev->button == Button4) { - workspaceSwitch (md->current_ws - 1, NULL); + workspaceSwitch (md, md->current_ws - 1, NULL); } else if (ev->button == Button5) { - workspaceSwitch (md->current_ws + 1, NULL); + workspaceSwitch (md, md->current_ws + 1, NULL); } } static void -handleButtonPress (XButtonEvent * ev) +handleButtonPress (ScreenData *md, XButtonEvent * ev) { Client *c = NULL; Window win; @@ -656,7 +665,7 @@ handleButtonPress (XButtonEvent * ev) { if (ev->button <= Button3) { - clientSetFocus (c, ev->time, NO_FOCUS_FLAG); + clientSetFocus (c->md, c, ev->time, NO_FOCUS_FLAG); if (params.raise_on_click) { clientRaise (c); @@ -682,7 +691,7 @@ handleButtonPress (XButtonEvent * ev) XfwmButtonClickType tclick; memcpy(©_event, ev, sizeof(XEvent)); - tclick = typeOfClick (c->frame, ©_event, TRUE); + tclick = typeOfClick (c->md, c->frame, ©_event, TRUE); if (tclick == XFWM_BUTTON_DOUBLE_CLICK) { @@ -690,7 +699,7 @@ handleButtonPress (XButtonEvent * ev) } else { - clientSetFocus (c, ev->time, NO_FOCUS_FLAG); + clientSetFocus (c->md, c, ev->time, NO_FOCUS_FLAG); if (params.raise_on_click) { clientRaise (c); @@ -759,7 +768,7 @@ handleButtonPress (XButtonEvent * ev) { clientPassGrabButton1 (c); } - clientSetFocus (c, ev->time, NO_FOCUS_FLAG); + clientSetFocus (c->md, c, ev->time, NO_FOCUS_FLAG); if ((params.raise_on_click) || !FLAG_TEST (c->flags, CLIENT_FLAG_HAS_BORDER)) { clientRaise (c); @@ -781,10 +790,9 @@ handleButtonPress (XButtonEvent * ev) XAllowEvents (md->dpy, SyncPointer, ev->time); } } - else if ((ev->window == md->xroot) && ((ev->button == Button4) - || (ev->button == Button5))) + else if ((ev->window == md->xroot) && ((ev->button == Button4) || (ev->button == Button5))) { - rootScrollButton (ev); + rootScrollButton (md, ev); } else { @@ -795,7 +803,7 @@ handleButtonPress (XButtonEvent * ev) } static void -handleButtonRelease (XButtonEvent * ev) +handleButtonRelease (ScreenData *md, XButtonEvent * ev) { TRACE ("entering handleButtonRelease"); @@ -803,7 +811,7 @@ handleButtonRelease (XButtonEvent * ev) } static void -handleDestroyNotify (XDestroyWindowEvent * ev) +handleDestroyNotify (ScreenData *md, XDestroyWindowEvent * ev) { Client *c = NULL; @@ -821,13 +829,13 @@ handleDestroyNotify (XDestroyWindowEvent * ev) if (c) { TRACE ("DestroyNotify for \"%s\" (0x%lx)", c->name, c->window); - clientPassFocus (c); + clientPassFocus (c->md, c); clientUnframe (c, FALSE); } } static void -handleMapRequest (XMapRequestEvent * ev) +handleMapRequest (ScreenData *md, XMapRequestEvent * ev) { Client *c = NULL; @@ -859,12 +867,12 @@ handleMapRequest (XMapRequestEvent * ev) else { TRACE ("handleMapRequest: clientFrame"); - clientFrame (ev->window, FALSE); + clientFrame (md, ev->window, FALSE); } } static void -handleMapNotify (XMapEvent * ev) +handleMapNotify (ScreenData *md, XMapEvent * ev) { Client *c = NULL; @@ -883,7 +891,7 @@ handleMapNotify (XMapEvent * ev) } static void -handleUnmapNotify (XUnmapEvent * ev) +handleUnmapNotify (ScreenData *md, XUnmapEvent * ev) { Client *c = NULL; @@ -919,7 +927,7 @@ handleUnmapNotify (XUnmapEvent * ev) return; } - clientPassFocus (c); + clientPassFocus (c->md, c); /* * ICCCM spec states that a client wishing to switch @@ -949,7 +957,7 @@ handleUnmapNotify (XUnmapEvent * ev) } static void -handleConfigureNotify (XConfigureEvent * ev) +handleConfigureNotify (ScreenData *md, XConfigureEvent * ev) { TRACE ("entering handleConfigureNotify"); @@ -962,13 +970,13 @@ handleConfigureNotify (XConfigureEvent * ev) md->xscreen->width = ev->width; md->xscreen->height = ev->height; #endif - placeSidewalks (params.wrap_workspaces); + placeSidewalks (md, params.wrap_workspaces); clientScreenResize (); } } static void -handleConfigureRequest (XConfigureRequestEvent * ev) +handleConfigureRequest (ScreenData *md, XConfigureRequestEvent * ev) { Client *c = NULL; XWindowChanges wc; @@ -1123,7 +1131,7 @@ handleConfigureRequest (XConfigureRequestEvent * ev) } static void -handleEnterNotify (XCrossingEvent * ev) +handleEnterNotify (ScreenData *md, XCrossingEvent * ev) { Client *c = NULL; @@ -1144,7 +1152,7 @@ handleEnterNotify (XCrossingEvent * ev) TRACE ("EnterNotify window is \"%s\"", c->name); if (!(c->type & (WINDOW_DOCK | WINDOW_DESKTOP))) { - clientSetFocus (c, ev->time, FOCUS_FORCE); + clientSetFocus (c->md, c, ev->time, FOCUS_FORCE); if (!(params.raise_on_click)) { clientPassGrabButton1 (c); @@ -1154,7 +1162,7 @@ handleEnterNotify (XCrossingEvent * ev) } static void -handleLeaveNotify (XCrossingEvent * ev) +handleLeaveNotify (ScreenData *md, XCrossingEvent * ev) { TRACE ("entering handleLeaveNotify"); @@ -1165,7 +1173,8 @@ handleLeaveNotify (XCrossingEvent * ev) return; } - if ((ev->window == md->sidewalk[0]) || (ev->window == md->sidewalk[1])) + if ((ev->window == MYWINDOW_XWINDOW (md->sidewalk[0])) || + (ev->window == MYWINDOW_XWINDOW (md->sidewalk[1]))) { TRACE ("Reset edge_scroll_x"); edge_scroll_x = 0; @@ -1173,7 +1182,7 @@ handleLeaveNotify (XCrossingEvent * ev) } static void -handleFocusIn (XFocusChangeEvent * ev) +handleFocusIn (ScreenData *md, XFocusChangeEvent * ev) { Client *c = NULL; @@ -1214,7 +1223,7 @@ handleFocusIn (XFocusChangeEvent * ev) c = clientGetFocus (); if (c) { - clientSetFocus (c, GDK_CURRENT_TIME, FOCUS_FORCE); + clientSetFocus (c->md, c, GDK_CURRENT_TIME, FOCUS_FORCE); } return; } @@ -1230,7 +1239,7 @@ handleFocusIn (XFocusChangeEvent * ev) if (c) { TRACE ("focus set to \"%s\" (0x%lx)", c->name, c->window); - clientUpdateFocus (c, FOCUS_SORT); + clientUpdateFocus (c->md, c, FOCUS_SORT); if (params.raise_on_focus && !params.click_to_focus) { reset_timeout (); @@ -1239,7 +1248,7 @@ handleFocusIn (XFocusChangeEvent * ev) } static void -handleFocusOut (XFocusChangeEvent * ev) +handleFocusOut (ScreenData *md, XFocusChangeEvent * ev) { Client *c = NULL; @@ -1280,7 +1289,7 @@ handleFocusOut (XFocusChangeEvent * ev) if ((c) && (c == clientGetFocus ())) { TRACE ("focus lost from \"%s\" (0x%lx)", c->name, c->window); - clientUpdateFocus (NULL, NO_FOCUS_FLAG); + clientUpdateFocus (md, NULL, NO_FOCUS_FLAG); clientPassGrabButton1 (NULL); /* Clear timeout */ clear_timeout (); @@ -1289,7 +1298,7 @@ handleFocusOut (XFocusChangeEvent * ev) } static void -handlePropertyNotify (XPropertyEvent * ev) +handlePropertyNotify (ScreenData *md, XPropertyEvent * ev) { Client *c = NULL; char *names; @@ -1406,12 +1415,12 @@ handlePropertyNotify (XPropertyEvent * ev) { TRACE ("root has received a gnome_panel_desktop_area notify"); getGnomeDesktopMargins (md->dpy, md->screen, md->gnome_margins); - workspaceUpdateArea (md->margins, md->gnome_margins); + workspaceUpdateArea (md); } } static void -handleClientMessage (XClientMessageEvent * ev) +handleClientMessage (ScreenData *md, XClientMessageEvent * ev) { Client *c = NULL; @@ -1524,7 +1533,7 @@ handleClientMessage (XClientMessageEvent * ev) clientSetWorkspace (c, md->current_ws, TRUE); clientShow (c, TRUE); clientRaise (c); - clientSetFocus (c, GDK_CURRENT_TIME, NO_FOCUS_FLAG); + clientSetFocus (c->md, c, GDK_CURRENT_TIME, NO_FOCUS_FLAG); clientPassGrabButton1 (c); } } @@ -1538,7 +1547,7 @@ handleClientMessage (XClientMessageEvent * ev) ("root has received a win_workspace or a net_current_desktop event"); if (ev->data.l[0] != md->current_ws) { - workspaceSwitch (ev->data.l[0], NULL); + workspaceSwitch (md, ev->data.l[0], NULL); } } else if (((ev->message_type == win_workspace_count) @@ -1548,7 +1557,7 @@ handleClientMessage (XClientMessageEvent * ev) TRACE ("root has received a win_workspace_count event"); if (ev->data.l[0] != params.workspace_count) { - workspaceSetCount (ev->data.l[0]); + workspaceSetCount (md, ev->data.l[0]); } } else if ((ev->message_type == net_system_tray_manager) @@ -1562,7 +1571,7 @@ handleClientMessage (XClientMessageEvent * ev) && (ev->format == 32)) { TRACE ("root has received a net_showing_desktop event"); - clientToggleShowDesktop (ev->data.l[0]); + clientToggleShowDesktop (md, ev->data.l[0]); setHint (md->dpy, md->xroot, net_showing_desktop, ev->data.l[0]); } else @@ -1574,7 +1583,7 @@ handleClientMessage (XClientMessageEvent * ev) } static void -handleShape (XShapeEvent * ev) +handleShape (ScreenData *md, XShapeEvent * ev) { Client *c = NULL; @@ -1588,7 +1597,7 @@ handleShape (XShapeEvent * ev) } static void -handleColormapNotify (XColormapEvent * ev) +handleColormapNotify (ScreenData *md, XColormapEvent * ev) { Client *c = NULL; @@ -1604,8 +1613,8 @@ handleColormapNotify (XColormapEvent * ev) } } -void -handleEvent (XEvent * ev) +static void +handleEvent (ScreenData *md, XEvent * ev) { TRACE ("entering handleEvent"); @@ -1613,70 +1622,70 @@ handleEvent (XEvent * ev) switch (ev->type) { case MotionNotify: - handleMotionNotify ((XMotionEvent *) ev); + handleMotionNotify (md, (XMotionEvent *) ev); break; case KeyPress: - handleKeyPress ((XKeyEvent *) ev); + handleKeyPress (md, (XKeyEvent *) ev); break; case ButtonPress: - handleButtonPress ((XButtonEvent *) ev); + handleButtonPress (md, (XButtonEvent *) ev); break; case ButtonRelease: - handleButtonRelease ((XButtonEvent *) ev); + handleButtonRelease (md, (XButtonEvent *) ev); break; case DestroyNotify: - handleDestroyNotify ((XDestroyWindowEvent *) ev); + handleDestroyNotify (md, (XDestroyWindowEvent *) ev); break; case UnmapNotify: - handleUnmapNotify ((XUnmapEvent *) ev); + handleUnmapNotify (md, (XUnmapEvent *) ev); break; case MapRequest: - handleMapRequest ((XMapRequestEvent *) ev); + handleMapRequest (md, (XMapRequestEvent *) ev); break; case MapNotify: - handleMapNotify ((XMapEvent *) ev); + handleMapNotify (md, (XMapEvent *) ev); break; case ConfigureNotify: - handleConfigureNotify ((XConfigureEvent *) ev); + handleConfigureNotify (md, (XConfigureEvent *) ev); break; case ConfigureRequest: - handleConfigureRequest ((XConfigureRequestEvent *) ev); + handleConfigureRequest (md, (XConfigureRequestEvent *) ev); break; case EnterNotify: - handleEnterNotify ((XCrossingEvent *) ev); + handleEnterNotify (md, (XCrossingEvent *) ev); break; case LeaveNotify: - handleLeaveNotify ((XCrossingEvent *) ev); + handleLeaveNotify (md, (XCrossingEvent *) ev); break; case FocusIn: - handleFocusIn ((XFocusChangeEvent *) ev); + handleFocusIn (md, (XFocusChangeEvent *) ev); break; case FocusOut: - handleFocusOut ((XFocusChangeEvent *) ev); + handleFocusOut (md, (XFocusChangeEvent *) ev); break; case PropertyNotify: - handlePropertyNotify ((XPropertyEvent *) ev); + handlePropertyNotify (md, (XPropertyEvent *) ev); break; case ClientMessage: - handleClientMessage ((XClientMessageEvent *) ev); + handleClientMessage (md, (XClientMessageEvent *) ev); break; case ColormapNotify: - handleColormapNotify ((XColormapEvent *) ev); + handleColormapNotify (md, (XColormapEvent *) ev); break; default: if (md->shape && (ev->type == md->shape_event)) { - handleShape ((XShapeEvent *) ev); + handleShape (md, (XShapeEvent *) ev); } } if (!gdk_events_pending () && !XPending (md->dpy)) { - if (md->reload) + if (xfwm4_reload) { - reloadSettings (UPDATE_ALL); - md->reload = FALSE; + reloadSettings (md, UPDATE_ALL); + xfwm4_reload = FALSE; } - else if (md->quit) + else if (xfwm4_quit) { gtk_main_quit (); } @@ -1686,8 +1695,12 @@ handleEvent (XEvent * ev) XfceFilterStatus xfwm4_event_filter (XEvent * xevent, gpointer data) { + ScreenData *md = (ScreenData *) data; + + g_assert (md); + TRACE ("entering xfwm4_event_filter"); - handleEvent (xevent); + handleEvent (md, xevent); TRACE ("leaving xfwm4_event_filter"); return XEV_FILTER_STOP; } @@ -1702,10 +1715,9 @@ menu_callback (Menu * menu, MenuOp op, Window client_xwindow, TRACE ("entering menu_callback"); - if (menu_event_window) + if (!myWindowDeleted(&menu_event_window)) { - removeTmpEventWin (menu_event_window); - menu_event_window = None; + myWindowDelete (&menu_event_window); } if (menu_data) @@ -1778,6 +1790,12 @@ menu_callback (Menu * menu, MenuOp op, Window client_xwindow, menu_free (menu); } +void +initMenuEventWin (void) +{ + myWindowInit (&menu_event_window); +} + static gboolean show_popup_cb (GtkWidget * widget, GdkEventButton * ev, gpointer data) { @@ -1903,18 +1921,17 @@ show_popup_cb (GtkWidget * widget, GdkEventButton * ev, gpointer data) if (button_handler_id) { - g_signal_handler_disconnect (GTK_OBJECT (xfce_get_default_gtk_widget (md->gtox_data)), + g_signal_handler_disconnect (GTK_OBJECT (xfce_get_default_gtk_widget (c->md->gtox_data)), button_handler_id); } button_handler_id = - g_signal_connect (GTK_OBJECT (xfce_get_default_gtk_widget (md->gtox_data)), + g_signal_connect (GTK_OBJECT (xfce_get_default_gtk_widget (c->md->gtox_data)), "button_press_event", GTK_SIGNAL_FUNC (show_popup_cb), (gpointer) NULL); - if (menu_event_window) + if (!myWindowDeleted(&menu_event_window)) { - removeTmpEventWin (menu_event_window); - menu_event_window = None; + myWindowDelete (&menu_event_window); } /* Since all button press/release events are catched by the windows frames, there is some @@ -1927,14 +1944,14 @@ show_popup_cb (GtkWidget * widget, GdkEventButton * ev, gpointer data) Don't forget to delete that window once the menu is closed, though, or we'll get in trouble. */ - menu_event_window = setTmpEventWin (0, 0, - gdk_screen_get_width (md->gscr), - gdk_screen_get_height (md->gscr), - NoEventMask); + myWindowTemp (c->md->dpy, c->md->xroot, &menu_event_window, 0, 0, + gdk_screen_get_width (c->md->gscr), + gdk_screen_get_height (c->md->gscr), + NoEventMask); menu = menu_default (ops, insensitive, menu_callback, c->win_workspace, params.workspace_count, params.workspace_names, - params.workspace_names_length, c); + params.workspace_names_length, c->md->gtox_data, c); if (!menu_popup (menu, x, y, ev->button, ev->time)) { @@ -1942,19 +1959,17 @@ show_popup_cb (GtkWidget * widget, GdkEventButton * ev, gpointer data) gdk_beep (); c->button_pressed[MENU_BUTTON] = FALSE; frameDraw (c, FALSE, FALSE); - removeTmpEventWin (menu_event_window); - menu_event_window = None; + myWindowDelete (&menu_event_window); menu_free (menu); } return (TRUE); } static gboolean -set_reload (void) +set_reload (ScreenData *md) { - TRACE - ("setting md->reload flag so all prefs will be reread at next event loop"); - md->reload = TRUE; + TRACE ("setting reload flag so all prefs will be reread at next event loop"); + xfwm4_reload = TRUE; return (TRUE); } @@ -1975,8 +1990,10 @@ dbl_click_time (void) } static gboolean -client_event_cb (GtkWidget * widget, GdkEventClient * ev) +client_event_cb (GtkWidget * widget, GdkEventClient * ev, gpointer data) { + ScreenData *md = (ScreenData *) data; + TRACE ("entering client_event_cb"); if (!atom_rcfiles) @@ -1986,32 +2003,31 @@ client_event_cb (GtkWidget * widget, GdkEventClient * ev) if (ev->message_type == atom_rcfiles) { - set_reload (); + set_reload (md); } return (FALSE); } void -initGtkCallbacks (void) +initGtkCallbacks (ScreenData *md) { GtkSettings *settings; button_handler_id = g_signal_connect (GTK_OBJECT (xfce_get_default_gtk_widget (md->gtox_data)), - "button_press_event", GTK_SIGNAL_FUNC (show_popup_cb), - (gpointer) NULL); + "button_press_event", GTK_SIGNAL_FUNC (show_popup_cb), (gpointer) md); g_signal_connect (GTK_OBJECT (xfce_get_default_gtk_widget (md->gtox_data)), "client_event", - GTK_SIGNAL_FUNC (client_event_cb), (gpointer) NULL); + GTK_SIGNAL_FUNC (client_event_cb), (gpointer) md); settings = gtk_settings_get_default (); if (settings) { g_signal_connect (settings, "notify::gtk-theme-name", - G_CALLBACK (set_reload), NULL); + G_CALLBACK (set_reload), (gpointer) md); g_signal_connect (settings, "notify::gtk-font-name", - G_CALLBACK (set_reload), NULL); + G_CALLBACK (set_reload), (gpointer) md); g_signal_connect (settings, "notify::gtk-double-click-time", - G_CALLBACK (dbl_click_time), NULL); + G_CALLBACK (dbl_click_time), (gpointer) md); } } diff --git a/src/events.h b/src/events.h index 40f5a8e45..a6a370053 100644 --- a/src/events.h +++ b/src/events.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -33,9 +33,10 @@ #include <glib.h> #include <libxfcegui4/libxfcegui4.h> +#include "screen.h" -void handleEvent (XEvent *); +void initMenuEventWin (void); XfceFilterStatus xfwm4_event_filter (XEvent * xevent, gpointer data); -void initGtkCallbacks (void); +void initGtkCallbacks (ScreenData *); #endif /* INC_EVENTS_H */ diff --git a/src/focus.c b/src/focus.c index b0f9d77a9..5e1ab7371 100644 --- a/src/focus.c +++ b/src/focus.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -34,7 +34,7 @@ #include <libxfce4util/libxfce4util.h> #include <libxfcegui4/libxfcegui4.h> -#include "main.h" +#include "screen.h" #include "focus.h" #include "misc.h" #include "client.h" @@ -56,7 +56,7 @@ static Client *pending_focus = NULL; static Client *last_ungrab = NULL; static ClientPair -clientGetTopMostFocusable (int layer, Client * exclude) +clientGetTopMostFocusable (ScreenData *md, int layer, Client * exclude) { ClientPair top_client; Client *c; @@ -98,18 +98,18 @@ clientGetTopMostFocusable (int layer, Client * exclude) } void -clientFocusTop (int layer) +clientFocusTop (ScreenData *md, int layer) { ClientPair top_client; - top_client = clientGetTopMostFocusable (layer, NULL); + top_client = clientGetTopMostFocusable (md, layer, NULL); if (top_client.prefered) { - clientSetFocus (top_client.prefered, GDK_CURRENT_TIME, NO_FOCUS_FLAG); + clientSetFocus (md, top_client.prefered, GDK_CURRENT_TIME, NO_FOCUS_FLAG); } else { - clientSetFocus (top_client.highest, GDK_CURRENT_TIME, NO_FOCUS_FLAG); + clientSetFocus (md, top_client.highest, GDK_CURRENT_TIME, NO_FOCUS_FLAG); } } @@ -143,7 +143,7 @@ clientFocusNew(Client * c) if (give_focus || FLAG_TEST(c->flags, CLIENT_FLAG_STATE_MODAL)) { - clientSetFocus (c, GDK_CURRENT_TIME, FOCUS_IGNORE_MODAL); + clientSetFocus (c->md, c, GDK_CURRENT_TIME, FOCUS_IGNORE_MODAL); clientPassGrabButton1 (c); } else @@ -176,7 +176,7 @@ clientSelectMask (Client * c, int mask) { okay = FALSE; } - if ((c->win_workspace != md->current_ws) && !(mask & INCLUDE_ALL_WORKSPACES)) + if ((c->win_workspace != c->md->current_ws) && !(mask & INCLUDE_ALL_WORKSPACES)) { okay = FALSE; } @@ -237,7 +237,7 @@ clientGetPrevious (Client * c, int mask) } void -clientPassFocus (Client * c) +clientPassFocus (ScreenData *md, Client * c) { Client *new_focus = NULL; Client *current_focus = client_focus; @@ -260,14 +260,14 @@ clientPassFocus (Client * c) return; } - top_most = clientGetTopMostFocusable (look_in_layer, c); + top_most = clientGetTopMostFocusable (md, look_in_layer, c); if (params.click_to_focus) { if ((c) && clientIsModal (c)) { /* If the window is a modal, send focus back to its parent window Modals are transients, and we aren"t interested in modal - for group, so it safe to sue clientGetTransient because + for group, so it safe to use clientGetTransient because it's really what we want... */ @@ -288,7 +288,7 @@ clientPassFocus (Client * c) { new_focus = top_most.prefered ? top_most.prefered : top_most.highest; } - clientSetFocus (new_focus, GDK_CURRENT_TIME, FOCUS_IGNORE_MODAL | FOCUS_FORCE); + clientSetFocus (md, new_focus, GDK_CURRENT_TIME, FOCUS_IGNORE_MODAL | FOCUS_FORCE); if (new_focus == top_most.highest) { clientPassGrabButton1 (new_focus); @@ -344,7 +344,7 @@ clientSortRing(Client *c) } void -clientUpdateFocus (Client * c, unsigned short flags) +clientUpdateFocus (ScreenData *md, Client * c, unsigned short flags) { Client *c2 = ((client_focus != c) ? client_focus : NULL); unsigned long data[2]; @@ -415,7 +415,7 @@ clientUpdateFocus (Client * c, unsigned short flags) } void -clientSetFocus (Client * c, Time timestamp, unsigned short flags) +clientSetFocus (ScreenData *md, Client * c, Time timestamp, unsigned short flags) { Client *c2; @@ -452,7 +452,7 @@ clientSetFocus (Client * c, Time timestamp, unsigned short flags) } if (FLAG_TEST(c->wm_flags, WM_FLAG_TAKEFOCUS)) { - sendClientMessage (c->window, wm_protocols, wm_takefocus, timestamp); + sendClientMessage (c->md, c->window, wm_protocols, wm_takefocus, timestamp); } XFlush (md->dpy); } @@ -462,16 +462,18 @@ clientSetFocus (Client * c, Time timestamp, unsigned short flags) TRACE ("setting focus to none"); + data[0] = data[1] = None; client_focus = NULL; if (c2) { frameDraw (c2, FALSE, FALSE); + XChangeProperty (c2->md->dpy, c2->md->xroot, net_active_window, XA_WINDOW, 32, + PropModeReplace, (unsigned char *) data, 2); } - XSetInputFocus (md->dpy, md->gnome_win, RevertToPointerRoot, GDK_CURRENT_TIME); - XFlush (md->dpy); - data[0] = data[1] = None; XChangeProperty (md->dpy, md->xroot, net_active_window, XA_WINDOW, 32, PropModeReplace, (unsigned char *) data, 2); + XSetInputFocus (md->dpy, md->gnome_win, RevertToPointerRoot, GDK_CURRENT_TIME); + XFlush (md->dpy); } } @@ -494,7 +496,7 @@ clientGrabButton1 (Client * c) TRACE ("entering clientGrabButton1"); TRACE ("grabbing buttons for client \"%s\" (0x%lx)", c->name, c->window); - grabButton(md->dpy, Button1, 0, c->window); + grabButton(c->md->dpy, Button1, 0, c->window); } void @@ -504,7 +506,7 @@ clientUngrabButton1 (Client * c) TRACE ("entering clientUngrabButton1"); TRACE ("ungrabing buttons for client \"%s\" (0x%lx)", c->name, c->window); - ungrabButton(md->dpy, Button1, 0, c->window); + ungrabButton(c->md->dpy, Button1, 0, c->window); } void diff --git a/src/focus.h b/src/focus.h index edf9162d4..59861c8a2 100644 --- a/src/focus.h +++ b/src/focus.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,6 +26,7 @@ #include <glib.h> #include <sys/time.h> +#include "screen.h" #include "client.h" #define NO_FOCUS_FLAG 0 @@ -33,16 +34,16 @@ #define FOCUS_IGNORE_MODAL (1<<1) #define FOCUS_FORCE (1<<2) -void clientFocusTop (int); +void clientFocusTop (ScreenData *, int); void clientFocusNew(Client *); gboolean clientSelectMask (Client *, int); Client *clientGetNext (Client *, int); Client *clientGetPrevious (Client *, int); -void clientPassFocus (Client *); +void clientPassFocus (ScreenData *, Client *); gboolean clientAcceptFocus (Client *); void clientSortRing(Client *); -void clientUpdateFocus (Client *, unsigned short); -void clientSetFocus (Client *, Time, unsigned short); +void clientUpdateFocus (ScreenData *, Client *, unsigned short); +void clientSetFocus (ScreenData *, Client *, Time, unsigned short); void clientClearFocus (void); Client *clientGetFocus (void); void clientGrabButton1 (Client *); diff --git a/src/frame.c b/src/frame.c index e69220151..5b2287759 100644 --- a/src/frame.c +++ b/src/frame.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -28,7 +28,7 @@ #include <pango/pango.h> #include <libxfce4util/libxfce4util.h> -#include "main.h" +#include "screen.h" #include "client.h" #include "settings.h" #include "mywindow.h" @@ -146,7 +146,7 @@ frameHeight (Client * c) } static void -fillRectangle (Display *dpy, Drawable d, Pixmap pm, int x, int y, int width, +fillRectangle (Display *dpy, int screen, Drawable d, Pixmap pm, int x, int y, int width, int height) { XGCValues gv; @@ -163,7 +163,7 @@ fillRectangle (Display *dpy, Drawable d, Pixmap pm, int x, int y, int width, gv.tile = pm; gv.ts_x_origin = x; gv.ts_y_origin = y; - gv.foreground = WhitePixel (dpy, md->screen); + gv.foreground = WhitePixel (dpy, screen); if (gv.tile != None) { mask = GCTile | GCFillStyle | GCTileStipXOrigin; @@ -231,7 +231,7 @@ frameCreateTitlePixmap (Client * c, int state, int left, int right, w2 = params.title[TITLE_2][ACTIVE].width; w4 = params.title[TITLE_4][ACTIVE].width; - layout = gtk_widget_create_pango_layout (xfce_get_default_gtk_widget (md->gtox_data), c->name); + layout = gtk_widget_create_pango_layout (xfce_get_default_gtk_widget (c->md->gtox_data), c->name); pango_layout_get_pixel_extents (layout, NULL, &logical_rect); if (params.full_width_title) @@ -290,23 +290,23 @@ frameCreateTitlePixmap (Client * c, int state, int left, int right, } } - myPixmapCreate (md->dpy, pm, width, frameTop (c)); + myPixmapCreate (c->md, pm, width, frameTop (c)); gpixmap = gdk_pixmap_foreign_new (pm->pixmap); gdk_drawable_set_colormap (gpixmap, gdk_colormap_get_system ()); gc = gdk_gc_new (gpixmap); if (w1 > 0) { - fillRectangle (md->dpy, pm->pixmap, params.title[TITLE_1][state].pixmap, + fillRectangle (c->md->dpy, c->md->screen, pm->pixmap, params.title[TITLE_1][state].pixmap, 0, 0, w1, frameTop (c)); - fillRectangle (md->dpy, pm->mask, params.title[TITLE_1][state].mask, 0, 0, + fillRectangle (c->md->dpy, c->md->screen, pm->mask, params.title[TITLE_1][state].mask, 0, 0, w1, frameTop (c)); x = x + w1; } - fillRectangle (md->dpy, pm->pixmap, params.title[TITLE_2][state].pixmap, x, 0, + fillRectangle (c->md->dpy, c->md->screen, pm->pixmap, params.title[TITLE_2][state].pixmap, x, 0, w2, frameTop (c)); - fillRectangle (md->dpy, pm->mask, params.title[TITLE_2][state].mask, x, 0, w2, + fillRectangle (c->md->dpy, c->md->screen, pm->mask, params.title[TITLE_2][state].mask, x, 0, w2, frameTop (c)); x = x + w2; @@ -320,9 +320,9 @@ frameCreateTitlePixmap (Client * c, int state, int left, int right, { voffset = params.title_vertical_offset_inactive; } - fillRectangle (md->dpy, pm->pixmap, params.title[TITLE_3][state].pixmap, + fillRectangle (c->md->dpy, c->md->screen, pm->pixmap, params.title[TITLE_3][state].pixmap, x, 0, w3, frameTop (c)); - fillRectangle (md->dpy, pm->mask, params.title[TITLE_3][state].mask, x, 0, + fillRectangle (c->md->dpy, c->md->screen, pm->mask, params.title[TITLE_3][state].mask, x, 0, w3, frameTop (c)); if (params.title_shadow[state]) { @@ -343,17 +343,17 @@ frameCreateTitlePixmap (Client * c, int state, int left, int right, { x = right - w4; } - fillRectangle (md->dpy, pm->pixmap, params.title[TITLE_4][state].pixmap, x, 0, + fillRectangle (c->md->dpy, c->md->screen, pm->pixmap, params.title[TITLE_4][state].pixmap, x, 0, w4, frameTop (c)); - fillRectangle (md->dpy, pm->mask, params.title[TITLE_4][state].mask, x, 0, w4, + fillRectangle (c->md->dpy, c->md->screen, pm->mask, params.title[TITLE_4][state].mask, x, 0, w4, frameTop (c)); x = x + w4; if (w5 > 0) { - fillRectangle (md->dpy, pm->pixmap, params.title[TITLE_5][state].pixmap, + fillRectangle (c->md->dpy, c->md->screen, pm->pixmap, params.title[TITLE_5][state].pixmap, x, 0, w5, frameTop (c)); - fillRectangle (md->dpy, pm->mask, params.title[TITLE_5][state].mask, x, 0, + fillRectangle (c->md->dpy, c->md->screen, pm->mask, params.title[TITLE_5][state].mask, x, 0, w5, frameTop (c)); } g_object_unref (G_OBJECT (gc)); @@ -510,13 +510,13 @@ frameSetShape (Client * c, int state, ClientPixmapCache * pm_cache, TRACE ("entering frameSetShape"); TRACE ("setting shape for client (0x%lx)", c->window); - if (!md->shape) + if (!c->md->shape) { return; } temp = - XCreateSimpleWindow (md->dpy, md->xroot, 0, 0, frameWidth (c), frameHeight (c), + XCreateSimpleWindow (c->md->dpy, c->md->xroot, 0, 0, frameWidth (c), frameHeight (c), 0, 0, 0); if (FLAG_TEST (c->flags, CLIENT_FLAG_SHADED)) @@ -525,40 +525,40 @@ frameSetShape (Client * c, int state, ClientPixmapCache * pm_cache, rect.y = 0; rect.width = frameWidth (c); rect.height = frameHeight (c); - XShapeCombineRectangles (md->dpy, temp, ShapeBounding, 0, 0, &rect, 1, + XShapeCombineRectangles (c->md->dpy, temp, ShapeBounding, 0, 0, &rect, 1, ShapeSubtract, 0); } else { - XShapeCombineShape (md->dpy, temp, ShapeBounding, frameLeft (c), + XShapeCombineShape (c->md->dpy, temp, ShapeBounding, frameLeft (c), frameTop (c), c->window, ShapeBounding, ShapeSet); } if (pm_cache) { - XShapeCombineMask (md->dpy, MYWINDOW_XWINDOW (c->title), ShapeBounding, 0, + XShapeCombineMask (c->md->dpy, MYWINDOW_XWINDOW (c->title), ShapeBounding, 0, 0, pm_cache->pm_title[state].mask, ShapeSet); if (!FLAG_TEST (c->flags, CLIENT_FLAG_SHADED)) { - XShapeCombineMask (md->dpy, MYWINDOW_XWINDOW (c->sides[SIDE_LEFT]), + XShapeCombineMask (c->md->dpy, MYWINDOW_XWINDOW (c->sides[SIDE_LEFT]), ShapeBounding, 0, 0, pm_cache->pm_sides[SIDE_LEFT][state].mask, ShapeSet); - XShapeCombineMask (md->dpy, MYWINDOW_XWINDOW (c->sides[SIDE_RIGHT]), + XShapeCombineMask (c->md->dpy, MYWINDOW_XWINDOW (c->sides[SIDE_RIGHT]), ShapeBounding, 0, 0, pm_cache->pm_sides[SIDE_RIGHT][state].mask, ShapeSet); } - XShapeCombineMask (md->dpy, MYWINDOW_XWINDOW (c->sides[SIDE_BOTTOM]), + XShapeCombineMask (c->md->dpy, MYWINDOW_XWINDOW (c->sides[SIDE_BOTTOM]), ShapeBounding, 0, 0, pm_cache->pm_sides[SIDE_BOTTOM][state].mask, ShapeSet); - XShapeCombineMask (md->dpy, + XShapeCombineMask (c->md->dpy, MYWINDOW_XWINDOW (c->corners[CORNER_BOTTOM_LEFT]), ShapeBounding, 0, 0, params.corners[CORNER_BOTTOM_LEFT][state].mask, ShapeSet); - XShapeCombineMask (md->dpy, + XShapeCombineMask (c->md->dpy, MYWINDOW_XWINDOW (c->corners[CORNER_BOTTOM_RIGHT]), ShapeBounding, 0, 0, params.corners[CORNER_BOTTOM_RIGHT][state].mask, ShapeSet); - XShapeCombineMask (md->dpy, + XShapeCombineMask (c->md->dpy, MYWINDOW_XWINDOW (c->corners[CORNER_TOP_LEFT]), ShapeBounding, 0, 0, params.corners[CORNER_TOP_LEFT][state].mask, ShapeSet); - XShapeCombineMask (md->dpy, + XShapeCombineMask (c->md->dpy, MYWINDOW_XWINDOW (c->corners[CORNER_TOP_RIGHT]), ShapeBounding, 0, 0, params.corners[CORNER_TOP_RIGHT][state].mask, ShapeSet); @@ -566,7 +566,7 @@ frameSetShape (Client * c, int state, ClientPixmapCache * pm_cache, { my_pixmap = frameGetPixmap (c, i, c->button_pressed[i] ? PRESSED : state); - XShapeCombineMask (md->dpy, MYWINDOW_XWINDOW (c->buttons[i]), + XShapeCombineMask (c->md->dpy, MYWINDOW_XWINDOW (c->buttons[i]), ShapeBounding, 0, 0, my_pixmap->mask, ShapeSet); } @@ -579,7 +579,7 @@ frameSetShape (Client * c, int state, ClientPixmapCache * pm_cache, rect.height = params.corners[CORNER_TOP_LEFT][ACTIVE].height - (frameHeight (c) - frameBottom (c) + 1); - XShapeCombineRectangles (md->dpy, + XShapeCombineRectangles (c->md->dpy, MYWINDOW_XWINDOW (c->corners[CORNER_TOP_LEFT]), ShapeBounding, 0, 0, &rect, 1, ShapeSubtract, 0); } @@ -592,7 +592,7 @@ frameSetShape (Client * c, int state, ClientPixmapCache * pm_cache, rect.height = params.corners[CORNER_TOP_RIGHT][ACTIVE].height - (frameHeight (c) - frameBottom (c) + 1); - XShapeCombineRectangles (md->dpy, + XShapeCombineRectangles (c->md->dpy, MYWINDOW_XWINDOW (c->corners[CORNER_TOP_RIGHT]), ShapeBounding, 0, 0, &rect, 1, ShapeSubtract, 0); } @@ -605,7 +605,7 @@ frameSetShape (Client * c, int state, ClientPixmapCache * pm_cache, rect.height = params.corners[CORNER_BOTTOM_LEFT][ACTIVE].height - (frameHeight (c) - frameTop (c) + 1); - XShapeCombineRectangles (md->dpy, + XShapeCombineRectangles (c->md->dpy, MYWINDOW_XWINDOW (c->corners[CORNER_BOTTOM_LEFT]), ShapeBounding, 0, 0, &rect, 1, ShapeSubtract, 0); } @@ -618,45 +618,45 @@ frameSetShape (Client * c, int state, ClientPixmapCache * pm_cache, rect.height = params.corners[CORNER_BOTTOM_RIGHT][ACTIVE].height - (frameHeight (c) - frameTop (c) + 1); - XShapeCombineRectangles (md->dpy, + XShapeCombineRectangles (c->md->dpy, MYWINDOW_XWINDOW (c->corners[CORNER_BOTTOM_RIGHT]), ShapeBounding, 0, 0, &rect, 1, ShapeSubtract, 0); } if (!FLAG_TEST (c->flags, CLIENT_FLAG_SHADED)) { - XShapeCombineShape (md->dpy, temp, ShapeBounding, 0, frameTop (c), + XShapeCombineShape (c->md->dpy, temp, ShapeBounding, 0, frameTop (c), MYWINDOW_XWINDOW (c->sides[SIDE_LEFT]), ShapeBounding, ShapeUnion); - XShapeCombineShape (md->dpy, temp, ShapeBounding, + XShapeCombineShape (c->md->dpy, temp, ShapeBounding, frameWidth (c) - frameRight (c), frameTop (c), MYWINDOW_XWINDOW (c->sides[SIDE_RIGHT]), ShapeBounding, ShapeUnion); } - XShapeCombineShape (md->dpy, temp, ShapeBounding, + XShapeCombineShape (c->md->dpy, temp, ShapeBounding, params.corners[CORNER_TOP_LEFT][ACTIVE].width, 0, MYWINDOW_XWINDOW (c->title), ShapeBounding, ShapeUnion); - XShapeCombineShape (md->dpy, temp, ShapeBounding, + XShapeCombineShape (c->md->dpy, temp, ShapeBounding, params.corners[CORNER_BOTTOM_LEFT][ACTIVE].width, frameHeight (c) - frameBottom (c), MYWINDOW_XWINDOW (c->sides[SIDE_BOTTOM]), ShapeBounding, ShapeUnion); - XShapeCombineShape (md->dpy, temp, ShapeBounding, 0, + XShapeCombineShape (c->md->dpy, temp, ShapeBounding, 0, frameHeight (c) - params.corners[CORNER_BOTTOM_LEFT][ACTIVE].height, MYWINDOW_XWINDOW (c->corners[CORNER_BOTTOM_LEFT]), ShapeBounding, ShapeUnion); - XShapeCombineShape (md->dpy, temp, ShapeBounding, + XShapeCombineShape (c->md->dpy, temp, ShapeBounding, frameWidth (c) - params.corners[CORNER_BOTTOM_RIGHT][ACTIVE].width, frameHeight (c) - params.corners[CORNER_BOTTOM_RIGHT][ACTIVE].height, MYWINDOW_XWINDOW (c->corners[CORNER_BOTTOM_RIGHT]), ShapeBounding, ShapeUnion); - XShapeCombineShape (md->dpy, temp, ShapeBounding, 0, 0, + XShapeCombineShape (c->md->dpy, temp, ShapeBounding, 0, 0, MYWINDOW_XWINDOW (c->corners[CORNER_TOP_LEFT]), ShapeBounding, ShapeUnion); - XShapeCombineShape (md->dpy, temp, ShapeBounding, + XShapeCombineShape (c->md->dpy, temp, ShapeBounding, frameWidth (c) - params.corners[CORNER_TOP_RIGHT][ACTIVE].width, 0, MYWINDOW_XWINDOW (c->corners[CORNER_TOP_RIGHT]), ShapeBounding, ShapeUnion); @@ -666,16 +666,16 @@ frameSetShape (Client * c, int state, ClientPixmapCache * pm_cache, char b = getLetterFromButton (i, c); if ((b) && strchr (params.button_layout, b)) { - XShapeCombineShape (md->dpy, temp, ShapeBounding, button_x[i], + XShapeCombineShape (c->md->dpy, temp, ShapeBounding, button_x[i], (frameTop (c) - params.buttons[i][ACTIVE].height) / 2, MYWINDOW_XWINDOW (c->buttons[i]), ShapeBounding, ShapeUnion); } } } - XShapeCombineShape (md->dpy, c->frame, ShapeBounding, 0, 0, temp, + XShapeCombineShape (c->md->dpy, c->frame, ShapeBounding, 0, 0, temp, ShapeBounding, ShapeSet); - XDestroyWindow (md->dpy, temp); + XDestroyWindow (c->md->dpy, temp); } void @@ -736,23 +736,19 @@ frameDraw (Client * c, gboolean invalidate_cache, gboolean force_shape_update) { if (c->pm_cache.previous_width != c->width) { - myPixmapFree (md->dpy, &c->pm_cache.pm_title[ACTIVE]); - myPixmapFree (md->dpy, &c->pm_cache.pm_title[INACTIVE]); - myPixmapFree (md->dpy, - &c->pm_cache.pm_sides[SIDE_BOTTOM][ACTIVE]); - myPixmapFree (md->dpy, - &c->pm_cache.pm_sides[SIDE_BOTTOM][INACTIVE]); + myPixmapFree (&c->pm_cache.pm_title[ACTIVE]); + myPixmapFree (&c->pm_cache.pm_title[INACTIVE]); + myPixmapFree (&c->pm_cache.pm_sides[SIDE_BOTTOM][ACTIVE]); + myPixmapFree (&c->pm_cache.pm_sides[SIDE_BOTTOM][INACTIVE]); c->pm_cache.previous_width = c->width; requires_clearing = TRUE; } if (c->pm_cache.previous_height != c->height) { - myPixmapFree (md->dpy, &c->pm_cache.pm_sides[SIDE_LEFT][ACTIVE]); - myPixmapFree (md->dpy, - &c->pm_cache.pm_sides[SIDE_LEFT][INACTIVE]); - myPixmapFree (md->dpy, &c->pm_cache.pm_sides[SIDE_RIGHT][ACTIVE]); - myPixmapFree (md->dpy, - &c->pm_cache.pm_sides[SIDE_RIGHT][INACTIVE]); + myPixmapFree (&c->pm_cache.pm_sides[SIDE_LEFT][ACTIVE]); + myPixmapFree (&c->pm_cache.pm_sides[SIDE_LEFT][INACTIVE]); + myPixmapFree (&c->pm_cache.pm_sides[SIDE_RIGHT][ACTIVE]); + myPixmapFree (&c->pm_cache.pm_sides[SIDE_RIGHT][INACTIVE]); c->pm_cache.previous_height = c->height; requires_clearing = TRUE; } @@ -784,7 +780,7 @@ frameDraw (Client * c, gboolean invalidate_cache, gboolean force_shape_update) c->button_pressed[button] ? PRESSED : state); if (my_pixmap->pixmap) { - XSetWindowBackgroundPixmap (md->dpy, + XSetWindowBackgroundPixmap (c->md->dpy, MYWINDOW_XWINDOW (c->buttons[button]), my_pixmap->pixmap); } @@ -817,7 +813,7 @@ frameDraw (Client * c, gboolean invalidate_cache, gboolean force_shape_update) c->button_pressed[button] ? PRESSED : state); if (my_pixmap->pixmap) { - XSetWindowBackgroundPixmap (md->dpy, + XSetWindowBackgroundPixmap (c->md->dpy, MYWINDOW_XWINDOW (c->buttons[button]), my_pixmap->pixmap); } @@ -856,64 +852,64 @@ frameDraw (Client * c, gboolean invalidate_cache, gboolean force_shape_update) if (c->pm_cache.pm_sides[SIDE_LEFT][state].pixmap == None) { - myPixmapCreate (md->dpy, &c->pm_cache.pm_sides[SIDE_LEFT][state], + myPixmapCreate (c->md, &c->pm_cache.pm_sides[SIDE_LEFT][state], frameLeft (c), left_height); requires_clearing = TRUE; } - fillRectangle (md->dpy, c->pm_cache.pm_sides[SIDE_LEFT][state].pixmap, + fillRectangle (c->md->dpy, c->md->screen, c->pm_cache.pm_sides[SIDE_LEFT][state].pixmap, params.sides[SIDE_LEFT][state].pixmap, 0, 0, frameLeft (c), left_height); - fillRectangle (md->dpy, c->pm_cache.pm_sides[SIDE_LEFT][state].mask, + fillRectangle (c->md->dpy, c->md->screen, c->pm_cache.pm_sides[SIDE_LEFT][state].mask, params.sides[SIDE_LEFT][state].mask, 0, 0, frameLeft (c), left_height); if (c->pm_cache.pm_sides[SIDE_RIGHT][state].pixmap == None) { - myPixmapCreate (md->dpy, &c->pm_cache.pm_sides[SIDE_RIGHT][state], + myPixmapCreate (c->md, &c->pm_cache.pm_sides[SIDE_RIGHT][state], frameRight (c), right_height); requires_clearing = TRUE; } - fillRectangle (md->dpy, c->pm_cache.pm_sides[SIDE_RIGHT][state].pixmap, + fillRectangle (c->md->dpy, c->md->screen, c->pm_cache.pm_sides[SIDE_RIGHT][state].pixmap, params.sides[SIDE_RIGHT][state].pixmap, 0, 0, frameRight (c), right_height); - fillRectangle (md->dpy, c->pm_cache.pm_sides[SIDE_RIGHT][state].mask, + fillRectangle (c->md->dpy, c->md->screen, c->pm_cache.pm_sides[SIDE_RIGHT][state].mask, params.sides[SIDE_RIGHT][state].mask, 0, 0, frameRight (c), right_height); if (c->pm_cache.pm_sides[SIDE_BOTTOM][state].pixmap == None) { - myPixmapCreate (md->dpy, &c->pm_cache.pm_sides[SIDE_BOTTOM][state], + myPixmapCreate (c->md, &c->pm_cache.pm_sides[SIDE_BOTTOM][state], bottom_width, frameBottom (c)); requires_clearing = TRUE; } - fillRectangle (md->dpy, c->pm_cache.pm_sides[SIDE_BOTTOM][state].pixmap, + fillRectangle (c->md->dpy, c->md->screen, c->pm_cache.pm_sides[SIDE_BOTTOM][state].pixmap, params.sides[SIDE_BOTTOM][state].pixmap, 0, 0, bottom_width, frameBottom (c)); - fillRectangle (md->dpy, c->pm_cache.pm_sides[SIDE_BOTTOM][state].mask, + fillRectangle (c->md->dpy, c->md->screen, c->pm_cache.pm_sides[SIDE_BOTTOM][state].mask, params.sides[SIDE_BOTTOM][state].mask, 0, 0, bottom_width, frameBottom (c)); - XSetWindowBackgroundPixmap (md->dpy, MYWINDOW_XWINDOW (c->title), + XSetWindowBackgroundPixmap (c->md->dpy, MYWINDOW_XWINDOW (c->title), c->pm_cache.pm_title[state].pixmap); - XSetWindowBackgroundPixmap (md->dpy, + XSetWindowBackgroundPixmap (c->md->dpy, MYWINDOW_XWINDOW (c->sides[SIDE_LEFT]), c->pm_cache.pm_sides[SIDE_LEFT][state].pixmap); - XSetWindowBackgroundPixmap (md->dpy, + XSetWindowBackgroundPixmap (c->md->dpy, MYWINDOW_XWINDOW (c->sides[SIDE_RIGHT]), c->pm_cache.pm_sides[SIDE_RIGHT][state].pixmap); - XSetWindowBackgroundPixmap (md->dpy, + XSetWindowBackgroundPixmap (c->md->dpy, MYWINDOW_XWINDOW (c->sides[SIDE_BOTTOM]), c->pm_cache.pm_sides[SIDE_BOTTOM][state].pixmap); - XSetWindowBackgroundPixmap (md->dpy, + XSetWindowBackgroundPixmap (c->md->dpy, MYWINDOW_XWINDOW (c->corners[CORNER_TOP_LEFT]), params.corners[CORNER_TOP_LEFT][state].pixmap); - XSetWindowBackgroundPixmap (md->dpy, + XSetWindowBackgroundPixmap (c->md->dpy, MYWINDOW_XWINDOW (c->corners[CORNER_TOP_RIGHT]), params.corners[CORNER_TOP_RIGHT][state].pixmap); - XSetWindowBackgroundPixmap (md->dpy, + XSetWindowBackgroundPixmap (c->md->dpy, MYWINDOW_XWINDOW (c->corners[CORNER_BOTTOM_LEFT]), params.corners[CORNER_BOTTOM_LEFT][state].pixmap); - XSetWindowBackgroundPixmap (md->dpy, + XSetWindowBackgroundPixmap (c->md->dpy, MYWINDOW_XWINDOW (c->corners[CORNER_BOTTOM_RIGHT]), params.corners[CORNER_BOTTOM_RIGHT][state].pixmap); diff --git a/src/frame.h b/src/frame.h index aa5579095..307b0138a 100644 --- a/src/frame.h +++ b/src/frame.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ diff --git a/src/hints.c b/src/hints.c index cf4e5908f..6fb243d4b 100644 --- a/src/hints.c +++ b/src/hints.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,7 +15,7 @@ oroborus - (c) 2001 Ken Lynch Metacity - (c) 2001 Havoc Pennington - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -1061,7 +1061,7 @@ getKDEIcon (Display * dpy, Window window, Pixmap * pixmap, Pixmap * mask) icons = NULL; if (XGetWindowProperty (dpy, window, kwm_win_icon, 0L, G_MAXLONG, FALSE, kwm_win_icon, &type, &format, &nitems, &bytes_after, - (unsigned char **)&icons) != Success) + (unsigned char **)&icons) != Success) { return FALSE; } @@ -1091,14 +1091,14 @@ getRGBIconData (Display * dpy, Window window, unsigned long **data, unsigned lon FALSE, XA_CARDINAL, &type, &format, nitems, &bytes_after, (unsigned char **)data) != Success) { - data = NULL; + data = NULL; return FALSE; } if (type != XA_CARDINAL) { XFree (*data); - data = NULL; + data = NULL; return FALSE; } diff --git a/src/hints.h b/src/hints.h index c4759775d..f3b0c362b 100644 --- a/src/hints.h +++ b/src/hints.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,7 +15,7 @@ oroborus - (c) 2001 Ken Lynch Metacity - (c) 2001 Havoc Pennington - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ diff --git a/src/icons.c b/src/icons.c index b4e07ad6d..ccf3840e4 100644 --- a/src/icons.c +++ b/src/icons.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,7 +15,7 @@ Metacity - (c) 2001 Havoc Pennington libwnck - (c) 2001 Havoc Pennington - xfwm4 - (c) 2004 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ #ifdef HAVE_CONFIG_H @@ -43,7 +43,7 @@ find_largest_sizes (gulong * data, gulong nitems, int *width, int *height) while (nitems > 0) { if (nitems < 3) - { + { return FALSE; /* no space for w, h */ } @@ -51,10 +51,10 @@ find_largest_sizes (gulong * data, gulong nitems, int *width, int *height) h = data[1]; if (nitems < ((w * h) + 2)) - { + { return FALSE; /* not enough data */ } - + *width = MAX (w, *width); *height = MAX (h, *height); @@ -128,18 +128,18 @@ find_best_size (gulong * data, gulong nitems, int ideal_width, int ideal_height, int this_size = (w + h) / 2; if ((best_size < ideal_size) && (this_size >= ideal_size)) - { - /* larger than desired is always better than smaller */ + { + /* larger than desired is always better than smaller */ replace = TRUE; } else if ((best_size < ideal_size) && (this_size > best_size)) { - /* if we have too small, pick anything bigger */ - replace = TRUE; + /* if we have too small, pick anything bigger */ + replace = TRUE; } else if ((best_size > ideal_size) && (this_size >= ideal_size) && (this_size < best_size)) { - /* if we have too large, pick anything smaller but still >= the ideal */ + /* if we have too large, pick anything smaller but still >= the ideal */ replace = TRUE; } } @@ -230,7 +230,6 @@ get_pixmap_geometry (Display *dpy, Pixmap pixmap, int *w, int *h) { Window root; int x, y; - guint width, height; guint border_width; guint depth; @@ -272,12 +271,12 @@ apply_mask (GdkPixbuf * pixbuf, GdkPixbuf * mask) * otherwise */ if (s[0] == 0) - { + { d[3] = 0; /* transparent */ } - else + else { - d[3] = 255; /* opaque */ + d[3] = 255; /* opaque */ } ++j; } diff --git a/src/icons.h b/src/icons.h index 0ddc26456..6e5be82e6 100644 --- a/src/icons.h +++ b/src/icons.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,7 +15,7 @@ Metacity - (c) 2001 Havoc Pennington libwnck - (c) 2001 Havoc Pennington - xfwm4 - (c) 2004 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ #ifdef HAVE_CONFIG_H diff --git a/src/keyboard.c b/src/keyboard.c index 862ac7f42..622d8703d 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ diff --git a/src/keyboard.h b/src/keyboard.h index 5d4b0d75d..c75896a3b 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ diff --git a/src/main.c b/src/main.c index 39bb67675..f874139fe 100644 --- a/src/main.c +++ b/src/main.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -41,7 +41,7 @@ #include <signal.h> #include <string.h> -#include "main.h" +#include "screen.h" #include "events.h" #include "frame.h" #include "settings.h" @@ -50,6 +50,7 @@ #include "focus.h" #include "keyboard.h" #include "workspaces.h" +#include "mywindow.h" #include "session.h" #include "startup_notification.h" #include "spinning_cursor.h" @@ -64,46 +65,36 @@ PropertyChangeMask|\ ColormapNotify -MainData *md = NULL; +static ScreenData *md = NULL; +gboolean xfwm4_quit = FALSE; +gboolean xfwm4_reload = FALSE; static int handleXError (Display * dpy, XErrorEvent * err) { #if DEBUG char buf[64]; + + XGetErrorText (dpy, err->error_code, buf, 63); + g_print ("XError: %s\n", buf); + g_print ("==> XID Ox%lx, Request %d, Error %d <==\n", + err->resourceid, err->request_code, err->error_code); #endif - switch (err->error_code) - { - case BadAccess: - if (err->resourceid == md->xroot) - { - g_message ("%s: Another window manager is running\n", - md->progname); - exit (1); - } - break; - default: -#if DEBUG - XGetErrorText (dpy, err->error_code, buf, 63); - g_print ("XError: %s\n", buf); - g_print ("==> XID Ox%lx, Request %d, Error %d <==\n", - err->resourceid, err->request_code, err->error_code); -#endif - break; - } return 0; } static void -cleanUp () +cleanUp (void) { int i; - + + g_return_if_fail (md); + TRACE ("entering cleanUp"); - clientUnframeAll (); + clientUnframeAll (md); sn_close_display (); - unloadSettings (); + unloadSettings (md); XFreeCursor (md->dpy, md->root_cursor); XFreeCursor (md->dpy, md->move_cursor); XFreeCursor (md->dpy, md->busy_cursor); @@ -122,11 +113,12 @@ cleanUp () } g_free (params.workspace_names); params.workspace_names = NULL; - removeTmpEventWin (md->sidewalk[0]); - removeTmpEventWin (md->sidewalk[1]); + myWindowDelete (&md->sidewalk[0]); + myWindowDelete (&md->sidewalk[1]); XSetInputFocus (md->dpy, md->xroot, RevertToPointerRoot, GDK_CURRENT_TIME); xfce_close_event_filter (md->gtox_data); g_free (md); + md = NULL; } static char *build_session_filename(SessionClient *client_session) @@ -190,7 +182,7 @@ static void session_die (gpointer client_data) { gtk_main_quit (); - md->quit = TRUE; + xfwm4_quit = TRUE; } static void @@ -203,11 +195,11 @@ handleSignal (int sig) case SIGINT: case SIGTERM: gtk_main_quit (); - md->quit = TRUE; + xfwm4_quit = TRUE; break; case SIGHUP: case SIGUSR1: - md->reload = TRUE; + xfwm4_reload = TRUE; break; case SIGSEGV: cleanUp (); @@ -230,17 +222,16 @@ initialize (int argc, char **argv) TRACE ("entering initialize"); - md = g_new0 (MainData, 1); + md = g_new0 (ScreenData, 1); - md->quit = FALSE; - md->reload = FALSE; - md->progname = argv[0]; - xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); gtk_set_locale (); gtk_init (&argc, &argv); + DBG ("xfwm4 starting, using GTK+-%d.%d.%d", gtk_major_version, + gtk_minor_version, gtk_micro_version); + md->gscr = gdk_screen_get_default (); if (!md->gscr) { @@ -255,24 +246,22 @@ initialize (int argc, char **argv) md->screen = gdk_screen_get_number (md->gscr); md->cmap = GDK_COLORMAP_XCOLORMAP(gdk_screen_get_rgb_colormap (md->gscr)); - DBG ("xfwm4 starting, using GTK+-%d.%d.%d", gtk_major_version, - gtk_minor_version, gtk_micro_version); - xfce_setenv ("DISPLAY", gdk_display_get_name (md->gdisplay), TRUE); md->depth = DefaultDepth (md->dpy, md->screen); - sn_init_display (md->dpy, md->screen); + sn_init_display (md); md->current_ws = 0; XSetErrorHandler (handleXError); md->shape = XShapeQueryExtension (md->dpy, &md->shape_event, &dummy); /* Create the side windows to detect edge movement */ - md->sidewalk[0] = setTmpEventWin (0, 0, + myWindowTemp (md->dpy, md->xroot, &md->sidewalk[0], 0, 0, 1, gdk_screen_get_height (md->gscr), LeaveWindowMask | PointerMotionMask); - md->sidewalk[1] = setTmpEventWin (gdk_screen_get_width (md->gscr) - 1, 0, + myWindowTemp (md->dpy, md->xroot, &md->sidewalk[1], + gdk_screen_get_width (md->gscr) - 1, 0, 1, gdk_screen_get_height (md->gscr), LeaveWindowMask | PointerMotionMask); @@ -307,17 +296,17 @@ initialize (int argc, char **argv) XDefineCursor (md->dpy, md->xroot, md->root_cursor); - md->gtox_data = xfce_init_event_filter (md->gscr, MAIN_EVENT_MASK, NULL, "xfwm"); + md->gtox_data = xfce_init_event_filter (md->gscr, MAIN_EVENT_MASK, (gpointer) md, "xfwm"); if (!md->gtox_data) { return -1; } - xfce_push_event_filter (md->gtox_data, xfwm4_event_filter, NULL); + xfce_push_event_filter (md->gtox_data, xfwm4_event_filter, (gpointer) md); md->gnome_win = xfce_get_default_XID (md->gtox_data); DBG ("Our event window is 0x%lx", md->gnome_win); - if (!initSettings ()) + if (!initSettings (md)) { return -2; } @@ -332,7 +321,7 @@ initialize (int argc, char **argv) getGnomeDesktopMargins (md->dpy, md->screen, md->gnome_margins); set_utf8_string_hint (md->dpy, md->gnome_win, net_wm_name, "Xfwm4"); setNetSupportedHint (md->dpy, md->screen, md->gnome_win); - workspaceUpdateArea (md->margins, md->gnome_margins); + workspaceUpdateArea (md); initNetDesktopParams (md->dpy, md->screen, md->current_ws, gdk_screen_get_width (md->gscr), @@ -342,7 +331,8 @@ initialize (int argc, char **argv) gdk_screen_get_height (md->gscr), md->margins); XSetInputFocus (md->dpy, md->gnome_win, RevertToPointerRoot, GDK_CURRENT_TIME); - initGtkCallbacks (); + initGtkCallbacks (md); + initMenuEventWin (); /* The first time the first Gtk application on a display uses pango, * pango grabs the XServer while it creates the font cache window. @@ -354,18 +344,14 @@ initialize (int argc, char **argv) g_object_unref (G_OBJECT (layout)); clientClearFocus (); - clientFrameAll (); + clientFrameAll (md); act.sa_handler = handleSignal; act.sa_flags = 0; - sigaction (SIGINT, &act, NULL); - sigaction (SIGTERM, &act, NULL); - sigaction (SIGHUP, &act, NULL); - sigaction (SIGUSR1, &act, NULL); sigaction (SIGSEGV, &act, NULL); - client_session = - client_session_new (argc, argv, NULL, SESSION_RESTART_IF_RUNNING, 20); + client_session = client_session_new (argc, argv, (gpointer) md, + SESSION_RESTART_IF_RUNNING, 20); client_session->data = (gpointer) client_session; client_session->save_phase_2 = save_phase_2; client_session->die = session_die; diff --git a/src/main.h b/src/main.h deleted file mode 100644 index 2356a7123..000000000 --- a/src/main.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan - - */ - -#ifndef INC_MAIN_H -#define INC_MAIN_H - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <sys/stat.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <signal.h> -#include <unistd.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xmd.h> -#include <X11/cursorfont.h> -#include <X11/extensions/shape.h> -#include <gtk/gtk.h> -#include <glib.h> -#include <libxfcegui4/libxfcegui4.h> -#include "client.h" -#include "misc.h" -#include "hints.h" -#include "keyboard.h" -#include "mypixmap.h" -#include "parserc.h" - -/* - * - * Global variables - * - */ - -typedef struct MainData -{ - Colormap cmap; - Cursor busy_cursor; - Cursor move_cursor; - Cursor resize_cursor[7]; - Cursor root_cursor; - Display *dpy; - GdkDisplay *gdisplay; - GdkScreen *gscr; - XfceFilterSetup *gtox_data; - Screen *xscreen; - Window gnome_win; - Window xroot; - Window sidewalk[2]; - Window systray; - char *progname; - int depth; - int gnome_margins[4]; - int margins[4]; - int quit; - int reload; - int screen; - int shape; - int shape_event; - int current_ws; -} -MainData; - -extern MainData *md; - -#endif /* INC_MAIN_H */ diff --git a/src/menu.c b/src/menu.c index ca52db914..8cec00479 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Metacity - (c) 2001 Havoc Pennington - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -32,7 +32,6 @@ #include <libxfce4util/libxfce4util.h> #include <libxfcegui4/libxfcegui4.h> #include "menu.h" -#include "main.h" static GtkWidget *menu_open = NULL; static MenuItem menuitems[] = { @@ -127,7 +126,7 @@ activate_cb (GtkWidget * menuitem, gpointer data) menudata = data; TRACE ("deactivating menu_filter"); - xfce_pop_event_filter (md->gtox_data); + xfce_pop_event_filter (menudata->menu->filter_setup); (*menudata->menu->func) (menudata->menu, menudata->op, menudata->client_xwindow, @@ -145,7 +144,7 @@ menu_closed (GtkMenu * widget, gpointer data) menu = data; menu_open = NULL; TRACE ("deactivating menu_filter"); - xfce_pop_event_filter (md->gtox_data); + xfce_pop_event_filter (menu->filter_setup); (*menu->func) (menu, 0, None, menu->data, NULL); return (FALSE); } @@ -204,7 +203,7 @@ menu_workspace (Menu * menu, MenuOp insensitive, gint ws, gint nws, gchar *wsn, Menu * menu_default (MenuOp ops, MenuOp insensitive, MenuFunc func, gint ws, - gint nws, gchar *wsn, gint wsnl, gpointer data) + gint nws, gchar *wsn, gint wsnl, XfceFilterSetup *filter_setup, gpointer data) { int i; Menu *menu; @@ -212,6 +211,7 @@ menu_default (MenuOp ops, MenuOp insensitive, MenuFunc func, gint ws, TRACE ("entering menu_new"); menu = g_new (Menu, 1); menu->func = func; + menu->filter_setup = filter_setup; menu->data = data; menu->ops = ops; menu->insensitive = insensitive; @@ -343,7 +343,7 @@ menu_check_and_close (void) } static gboolean -grab_available (guint32 timestamp) +grab_available (GdkWindow *win, guint32 timestamp) { GdkEventMask mask = GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | @@ -356,9 +356,8 @@ grab_available (guint32 timestamp) TRACE ("entering grab_available"); - g1 = gdk_pointer_grab (xfce_get_gdk_event_window (md->gtox_data), TRUE, mask, NULL, NULL, - timestamp); - g2 = gdk_keyboard_grab (xfce_get_gdk_event_window (md->gtox_data), TRUE, timestamp); + g1 = gdk_pointer_grab (win, TRUE, mask, NULL, NULL, timestamp); + g2 = gdk_keyboard_grab (win, TRUE, timestamp); while ((i++ < 100) && (grab_failed = ((g1 != GDK_GRAB_SUCCESS) || (g2 != GDK_GRAB_SUCCESS)))) @@ -367,12 +366,11 @@ grab_available (guint32 timestamp) g_usleep (100); if (g1 != GDK_GRAB_SUCCESS) { - g1 = gdk_pointer_grab (xfce_get_gdk_event_window (md->gtox_data), TRUE, mask, NULL, - NULL, timestamp); + g1 = gdk_pointer_grab (win, TRUE, mask, NULL, NULL, timestamp); } if (g2 != GDK_GRAB_SUCCESS) { - g2 = gdk_keyboard_grab (xfce_get_gdk_event_window (md->gtox_data), TRUE, timestamp); + g2 = gdk_keyboard_grab (win, TRUE, timestamp); } } @@ -405,7 +403,7 @@ menu_popup (Menu * menu, int root_x, int root_y, int button, if (!menu_check_and_close ()) { - if (!grab_available (timestamp)) + if (!grab_available (xfce_get_gdk_event_window (menu->filter_setup), timestamp)) { g_free (pt); TRACE ("Cannot get grab on pointer/keyboard, cancel."); @@ -413,7 +411,7 @@ menu_popup (Menu * menu, int root_x, int root_y, int button, } TRACE ("opening new menu"); menu_open = menu->menu; - xfce_push_event_filter (md->gtox_data, menu_filter, NULL); + xfce_push_event_filter (menu->filter_setup, menu_filter, NULL); gtk_menu_popup (GTK_MENU (menu->menu), NULL, NULL, popup_position_func, pt, 0, timestamp); @@ -424,7 +422,7 @@ menu_popup (Menu * menu, int root_x, int root_y, int button, g_get_prgname ()); gtk_menu_popdown (GTK_MENU (menu->menu)); menu_open = NULL; - xfce_pop_event_filter (md->gtox_data); + xfce_pop_event_filter (menu->filter_setup); return FALSE; } } diff --git a/src/menu.h b/src/menu.h index d59d03bc1..8161900fa 100644 --- a/src/menu.h +++ b/src/menu.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Metacity - (c) 2001 Havoc Pennington - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -25,9 +25,10 @@ # include "config.h" #endif -#include <gtk/gtk.h> -#include <gdk/gdk.h> #include <X11/Xlib.h> +#include <gdk/gdk.h> +#include <gtk/gtk.h> +#include <libxfcegui4/libxfcegui4.h> typedef enum { @@ -78,20 +79,32 @@ struct _MenuData struct _Menu { GtkWidget *menu; + XfceFilterSetup *filter_setup; MenuFunc func; gpointer data; MenuOp ops; MenuOp insensitive; }; -Menu *menu_default (MenuOp ops, MenuOp insensitive, MenuFunc func, - gint ws, gint nws, gchar *wsn, gint wsnl, gpointer data); -Menu *menu_connect (Menu * menu); -GtkWidget *menu_item_connect (GtkWidget * item, MenuData * item_data); -gboolean menu_is_opened (void); -gboolean menu_check_and_close (void); -gboolean menu_popup (Menu * menu, int root_x, int root_y, int button, - guint32 timestamp); -void menu_free (Menu * menu); +Menu *menu_default (MenuOp, + MenuOp, + MenuFunc, + gint, + gint, + gchar *, + gint, + XfceFilterSetup*, + gpointer); +Menu *menu_connect (Menu * menu); +GtkWidget *menu_item_connect (GtkWidget *, + MenuData *); +gboolean menu_is_opened (void); +gboolean menu_check_and_close (void); +gboolean menu_popup (Menu *, + int, + int, + int, + guint32); +void menu_free (Menu *); #endif /* INC_MENU_H */ diff --git a/src/misc.c b/src/misc.c index ba76a5f3c..b1b9e100e 100644 --- a/src/misc.c +++ b/src/misc.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -35,14 +35,15 @@ #include <unistd.h> #include <libxfce4util/libxfce4util.h> -#include "main.h" +#include "screen.h" +#include "mywindow.h" #include "client.h" #include "misc.h" static int xgrabcount = 0; void -getMouseXY (Window w, int *x2, int *y2) +getMouseXY (ScreenData *md, Window w, int *x2, int *y2) { Window w1, w2; gint x1, y1, m; @@ -53,7 +54,7 @@ getMouseXY (Window w, int *x2, int *y2) } Window -getMouseWindow (Window w) +getMouseWindow (ScreenData *md, Window w) { Window w1, w2; int x1, y1, x2, y2, m; @@ -65,7 +66,7 @@ getMouseWindow (Window w) } GC -createGC (Colormap cmap, char *col, int func, XFontStruct * font, +createGC (ScreenData *md, char *col, int func, XFontStruct * font, int line_width, gboolean inc_sw) { XGCValues gv; @@ -77,7 +78,7 @@ createGC (Colormap cmap, char *col, int func, XFontStruct * font, TRACE ("color=%s", col); mask = GCForeground | GCFunction; - XAllocNamedColor (md->dpy, cmap, col, &xc1, &xc2); + XAllocNamedColor (md->dpy, md->cmap, col, &xc1, &xc2); gv.foreground = xc2.pixel; gv.function = func; if (font) @@ -95,12 +96,12 @@ createGC (Colormap cmap, char *col, int func, XFontStruct * font, gv.line_width = line_width; mask = mask | GCLineWidth; } - gc = XCreateGC (md->dpy, XDefaultRootWindow (md->dpy), mask, &gv); + gc = XCreateGC (md->dpy, md->xroot, mask, &gv); return gc; } void -sendClientMessage (Window w, Atom a, Atom x, Time timestamp) +sendClientMessage (ScreenData *md, Window w, Atom a, Atom x, Time timestamp) { XClientMessageEvent ev; @@ -116,7 +117,7 @@ sendClientMessage (Window w, Atom a, Atom x, Time timestamp) } void -myXGrabServer (void) +myXGrabServer (ScreenData *md) { DBG ("entering myXGrabServer"); if (xgrabcount == 0) @@ -129,7 +130,7 @@ myXGrabServer (void) } void -myXUngrabServer (void) +myXUngrabServer (ScreenData *md) { DBG ("entering myXUngrabServer"); if (--xgrabcount < 0) /* should never happen */ @@ -150,7 +151,7 @@ myXUngrabServer (void) * Returns true if the given window is present and mapped on md->xroot */ gboolean -myCheckWindow(Window w) +myCheckWindow(ScreenData *md, Window w) { Window dummy_root, parent; Window *wins = NULL; @@ -168,51 +169,29 @@ myCheckWindow(Window w) return (!gdk_error_trap_pop () && (test != 0) && (dummy_root == parent)); } -Window -setTmpEventWin (int x, int y, unsigned int w, unsigned int h, long eventmask) -{ - Window win; - XSetWindowAttributes attributes; - - attributes.event_mask = eventmask; - attributes.override_redirect = TRUE; - win = XCreateWindow (md->dpy, md->xroot, x, y, w, h, 0, 0, - InputOnly, CopyFromParent, - CWEventMask | CWOverrideRedirect, &attributes); - XMapRaised (md->dpy, win); - XFlush (md->dpy); - return (win); -} - -void -removeTmpEventWin (Window w) -{ - XDestroyWindow (md->dpy, w); -} - void -placeSidewalks(gboolean activate) +placeSidewalks(ScreenData *md, gboolean activate) { - g_return_if_fail (md->sidewalk[0] != None); - g_return_if_fail (md->sidewalk[1] != None); + g_return_if_fail (MYWINDOW_XWINDOW (md->sidewalk[0]) != None); + g_return_if_fail (MYWINDOW_XWINDOW (md->sidewalk[1]) != None); if (activate) { - XMoveResizeWindow(md->dpy, md->sidewalk[0], - 0, 0, - 1, gdk_screen_get_height (md->gscr)); - XMoveResizeWindow(md->dpy, md->sidewalk[1], - gdk_screen_get_width (md->gscr) - 1, 0, - 1, gdk_screen_get_height (md->gscr)); + myWindowShow (&md->sidewalk[0], + 0, 0, + 1, gdk_screen_get_height (md->gscr), FALSE); + myWindowShow (&md->sidewalk[1], + gdk_screen_get_width (md->gscr) - 1, 0, + 1, gdk_screen_get_height (md->gscr), FALSE); } else { /* Place the windows off screen */ - XMoveResizeWindow(md->dpy, md->sidewalk[0], - -1, 0, - 1, gdk_screen_get_height (md->gscr)); - XMoveResizeWindow(md->dpy, md->sidewalk[1], - gdk_screen_get_width (md->gscr), 0, - 1, gdk_screen_get_height (md->gscr)); + myWindowShow (&md->sidewalk[0], + -1, 0, + 1, gdk_screen_get_height (md->gscr), FALSE); + myWindowShow (&md->sidewalk[1], + gdk_screen_get_width (md->gscr), 0, + 1, gdk_screen_get_height (md->gscr), FALSE); } } diff --git a/src/misc.h b/src/misc.h index 09808c2f3..1aef28819 100644 --- a/src/misc.h +++ b/src/misc.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -28,16 +28,15 @@ #include <sys/types.h> #include <X11/Xlib.h> #include <glib.h> +#include "screen.h" -void getMouseXY (Window, int *, int *); -Window getMouseWindow (Window); -GC createGC (Colormap, char *, int, XFontStruct *, int, gboolean); -void sendClientMessage (Window, Atom, Atom, Time); -void myXGrabServer (void); -void myXUngrabServer (void); -gboolean myCheckWindow(Window); -Window setTmpEventWin (int, int, unsigned int, unsigned int, long); -void removeTmpEventWin (Window); -void placeSidewalks(gboolean); +void getMouseXY (ScreenData *, Window, int *, int *); +Window getMouseWindow (ScreenData *, Window); +GC createGC (ScreenData *, char *, int, XFontStruct *, int, gboolean); +void sendClientMessage (ScreenData *, Window, Atom, Atom, Time); +void myXGrabServer (ScreenData *); +void myXUngrabServer (ScreenData *); +gboolean myCheckWindow(ScreenData *, Window); +void placeSidewalks(ScreenData *, gboolean); #endif /* INC_MISC_H */ diff --git a/src/mypixmap.c b/src/mypixmap.c index 555d7d75f..4daa16e7c 100644 --- a/src/mypixmap.c +++ b/src/mypixmap.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -31,7 +31,6 @@ #include <stdlib.h> #include <stdio.h> -#include "main.h" #include "mypixmap.h" static gboolean @@ -97,7 +96,7 @@ myPixmapCompose (MyPixmap * pm, gchar * dir, gchar * file) } else { - cmap = gdk_screen_get_rgb_colormap (md->gscr); + cmap = gdk_screen_get_rgb_colormap (pm->md->gscr); g_object_ref (G_OBJECT (cmap)); } } @@ -127,7 +126,7 @@ myPixmapCompose (MyPixmap * pm, gchar * dir, gchar * file) } gboolean -myPixmapLoad (Display * dpy, MyPixmap * pm, gchar * dir, gchar * file, +myPixmapLoad (ScreenData * md, MyPixmap * pm, gchar * dir, gchar * file, XpmColorSymbol * cs, gint n) { gchar *filename; @@ -139,6 +138,7 @@ myPixmapLoad (Display * dpy, MyPixmap * pm, gchar * dir, gchar * file, g_return_val_if_fail (dir != NULL, FALSE); g_return_val_if_fail (file != NULL, FALSE); + pm->md = md; pm->pixmap = None; pm->mask = None; pm->width = 1; @@ -148,15 +148,14 @@ myPixmapLoad (Display * dpy, MyPixmap * pm, gchar * dir, gchar * file, g_free (filexpm); attr.colorsymbols = cs; attr.numsymbols = n; - attr.colormap = md->cmap; + attr.colormap = pm->md->cmap; attr.closeness = 65535; attr.valuemask = XpmCloseness | XpmColormap | XpmSize; if (n > 0 && cs) { attr.valuemask = attr.valuemask | XpmColorSymbols; } - if (XpmReadFileToPixmap (dpy, XDefaultRootWindow (dpy), filename, - &pm->pixmap, &pm->mask, &attr)) + if (XpmReadFileToPixmap (md->dpy, md->xroot, filename, &pm->pixmap, &pm->mask, &attr)) { TRACE ("%s not found", filename); g_free (filename); @@ -174,17 +173,18 @@ myPixmapLoad (Display * dpy, MyPixmap * pm, gchar * dir, gchar * file, } void -myPixmapCreate (Display * dpy, MyPixmap * pm, gint width, gint height) +myPixmapCreate (ScreenData * md, MyPixmap * pm, gint width, gint height) { TRACE ("entering myPixmapCreate, width=%i, height=%i", width, height); - if ((width < 1) || (height < 1)) + if ((width < 1) || (height < 1) || (!md)) { myPixmapInit (pm); } else { - pm->pixmap = XCreatePixmap (dpy, md->xroot, width, height, md->depth); - pm->mask = XCreatePixmap (dpy, pm->pixmap, width, height, 1); + pm->md = md; + pm->pixmap = XCreatePixmap (md->dpy, md->xroot, width, height, md->depth); + pm->mask = XCreatePixmap (md->dpy, pm->pixmap, width, height, 1); pm->width = width; pm->height = height; } @@ -193,6 +193,7 @@ myPixmapCreate (Display * dpy, MyPixmap * pm, gint width, gint height) void myPixmapInit (MyPixmap * pm) { + pm->md = NULL; pm->pixmap = None; pm->mask = None; pm->width = 0; @@ -200,18 +201,18 @@ myPixmapInit (MyPixmap * pm) } void -myPixmapFree (Display * dpy, MyPixmap * pm) +myPixmapFree (MyPixmap * pm) { TRACE ("entering myPixmapFree"); if (pm->pixmap != None) { - XFreePixmap (dpy, pm->pixmap); + XFreePixmap (pm->md->dpy, pm->pixmap); pm->pixmap = None; } if (pm->mask != None) { - XFreePixmap (dpy, pm->mask); + XFreePixmap (pm->md->dpy, pm->mask); pm->mask = None; } } diff --git a/src/mypixmap.h b/src/mypixmap.h index 03bcd3806..779a053fa 100644 --- a/src/mypixmap.h +++ b/src/mypixmap.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -27,18 +27,20 @@ #include <X11/xpm.h> #include <glib.h> +#include "screen.h" typedef struct { + ScreenData *md; Pixmap pixmap, mask; gint width, height; } MyPixmap; -gboolean myPixmapLoad (Display *, MyPixmap *, gchar *, gchar *, +gboolean myPixmapLoad (ScreenData *, MyPixmap *, gchar *, gchar *, XpmColorSymbol *, gint); -void myPixmapCreate (Display *, MyPixmap *, gint, gint); +void myPixmapCreate (ScreenData *, MyPixmap *, gint, gint); void myPixmapInit (MyPixmap *); -void myPixmapFree (Display *, MyPixmap *); +void myPixmapFree (MyPixmap *); #endif /* INC_MYPIXMAP_H */ diff --git a/src/mywindow.c b/src/mywindow.c index 841bca95e..60ac3f56e 100644 --- a/src/mywindow.c +++ b/src/mywindow.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -13,7 +13,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - xfwm4 - (c) 2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -29,6 +29,18 @@ #include <glib.h> #include <libxfce4util/libxfce4util.h> #include "mywindow.h" + +void +myWindowInit (myWindow * win) +{ + win->window = None; + win->map = FALSE; + win->dpy = NULL; + win->x = 0; + win->y = 0; + win->w = 0; + win->h = 0; +} void myWindowCreate (Display * dpy, Window parent, myWindow * win, Cursor cursor) @@ -127,3 +139,42 @@ myWindowHide (myWindow * win) win->map = FALSE; } } + +gboolean +myWindowVisible (myWindow *win) +{ + g_return_val_if_fail (win, FALSE); + + return win->map; +} + +gboolean +myWindowDeleted (myWindow *win) +{ + g_return_val_if_fail (win, TRUE); + + return win->window == None; +} + +void +myWindowTemp (Display * dpy, Window parent, myWindow * win, + int x, int y, int w, int h, long eventmask) +{ + XSetWindowAttributes attributes; + + attributes.event_mask = eventmask; + attributes.override_redirect = TRUE; + win->window = XCreateWindow (dpy, parent, x, y, w, h, 0, 0, + InputOnly, CopyFromParent, + CWEventMask | CWOverrideRedirect, &attributes); + XMapRaised (dpy, win->window); + XFlush (dpy); + + win->map = TRUE; + win->dpy = dpy; + win->x = x; + win->y = y; + win->w = w; + win->h = h; +} + diff --git a/src/mywindow.h b/src/mywindow.h index 6baa7a3d3..7020655f9 100644 --- a/src/mywindow.h +++ b/src/mywindow.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -40,9 +40,30 @@ struct _myWindow gboolean map; }; -void myWindowCreate (Display *, Window, myWindow *, Cursor); -void myWindowDelete (myWindow *); -void myWindowShow (myWindow *, int, int, int, int, gboolean); -void myWindowHide (myWindow *); +void +myWindowInit (myWindow *); +void myWindowCreate (Display *, + Window, + myWindow *, + Cursor); +void myWindowTemp (Display *, + Window, + myWindow *, + int, + int, + int, + int, + long); +void myWindowDelete (myWindow *); +void myWindowShow (myWindow *, + int, + int, + int, + int, + gboolean); +void myWindowHide (myWindow *); +gboolean myWindowVisible (myWindow *); +gboolean myWindowDeleted (myWindow *); + #endif /* INC_MYWINDOW_H */ diff --git a/src/netwm.c b/src/netwm.c index 0539f866a..48aceabeb 100644 --- a/src/netwm.c +++ b/src/netwm.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -31,7 +31,7 @@ #include <libxfce4util/libxfce4util.h> #include <libxfcegui4/libxfcegui4.h> -#include "main.h" +#include "screen.h" #include "netwm.h" #include "misc.h" #include "client.h" @@ -113,13 +113,13 @@ clientSetNetState (Client * c) TRACE ("clientSetNetState : hidden"); data[i++] = net_wm_state_hidden; } - XChangeProperty (md->dpy, c->window, net_wm_state, XA_ATOM, 32, + XChangeProperty (c->md->dpy, c->window, net_wm_state, XA_ATOM, 32, PropModeReplace, (unsigned char *) data, i); /* We also set GNOME hint here for consistency and convenience, although the meaning of net_wm_state and win_state aren't the same. */ - setHint (md->dpy, c->window, win_state, c->win_state); + setHint (c->md->dpy, c->window, win_state, c->win_state); } void @@ -132,7 +132,7 @@ clientGetNetState (Client * c) TRACE ("entering clientGetNetState"); TRACE ("client \"%s\" (0x%lx)", c->name, c->window); - if (getAtomList (md->dpy, c->window, net_wm_state, &atoms, &n_atoms)) + if (getAtomList (c->md->dpy, c->window, net_wm_state, &atoms, &n_atoms)) { int i; TRACE ("clientGetNetState: %i atoms detected", n_atoms); @@ -510,8 +510,8 @@ clientUpdateFullscreenState (Client * c) cx = frameX (c) + (frameWidth (c) / 2); cy = frameY (c) + (frameHeight (c) / 2); - monitor_nbr = gdk_screen_get_monitor_at_point (md->gscr, cx, cy); - gdk_screen_get_monitor_geometry (md->gscr, monitor_nbr, &rect); + monitor_nbr = gdk_screen_get_monitor_at_point (c->md->gscr, cx, cy); + gdk_screen_get_monitor_geometry (c->md->gscr, monitor_nbr, &rect); c->fullscreen_old_x = c->x; c->fullscreen_old_y = c->y; @@ -542,10 +542,10 @@ clientUpdateFullscreenState (Client * c) grab focus in focus follow mouse mode. Grab the pointer to avoid these effects */ - XGrabPointer (md->dpy, md->gnome_win, FALSE, EnterWindowMask, GrabModeAsync, + XGrabPointer (c->md->dpy, c->md->gnome_win, FALSE, EnterWindowMask, GrabModeAsync, GrabModeAsync, None, None, GDK_CURRENT_TIME); clientConfigure (c, &wc, CWX | CWY | CWWidth | CWHeight, NO_CFG_FLAG); - XUngrabPointer (md->dpy, GDK_CURRENT_TIME); + XUngrabPointer (c->md->dpy, GDK_CURRENT_TIME); } else { @@ -571,7 +571,7 @@ clientGetNetWmType (Client * c) n_atoms = 0; atoms = NULL; - if (!getAtomList (md->dpy, c->window, net_wm_window_type, &atoms, &n_atoms)) + if (!getAtomList (c->md->dpy, c->window, net_wm_window_type, &atoms, &n_atoms)) { switch (c->win_layer) { @@ -644,9 +644,9 @@ clientGetInitialNetWmDesktop (Client * c) CLIENT_FLAG_SESSION_MANAGED | CLIENT_FLAG_WORKSPACE_SET)) { FLAG_SET (c->flags, CLIENT_FLAG_WORKSPACE_SET); - c->win_workspace = md->current_ws; + c->win_workspace = c->md->current_ws; } - if (getHint (md->dpy, c->window, net_wm_desktop, &val)) + if (getHint (c->md->dpy, c->window, net_wm_desktop, &val)) { TRACE ("atom net_wm_desktop detected"); if (val == (int) ALL_WORKSPACES) @@ -660,7 +660,7 @@ clientGetInitialNetWmDesktop (Client * c) FLAG_SET (c->flags, CLIENT_FLAG_STICKY); c->win_state |= WIN_STATE_STICKY; } - c->win_workspace = md->current_ws; + c->win_workspace = c->md->current_ws; } else { @@ -671,7 +671,7 @@ clientGetInitialNetWmDesktop (Client * c) } FLAG_SET (c->flags, CLIENT_FLAG_WORKSPACE_SET); } - else if (getHint (md->dpy, c->window, win_workspace, &val)) + else if (getHint (c->md->dpy, c->window, win_workspace, &val)) { TRACE ("atom win_workspace specifies window \"%s\" is on desk %i", c->name, (int) val); @@ -690,21 +690,19 @@ clientGetInitialNetWmDesktop (Client * c) } TRACE ("initial desktop for window \"%s\" is %i", c->name, c->win_workspace); - setHint (md->dpy, c->window, win_workspace, c->win_workspace); + setHint (c->md->dpy, c->window, win_workspace, c->win_workspace); if (FLAG_TEST (c->flags, CLIENT_FLAG_STICKY)) { - setHint (md->dpy, c->window, net_wm_desktop, - (unsigned long) ALL_WORKSPACES); + setHint (c->md->dpy, c->window, net_wm_desktop, (unsigned long) ALL_WORKSPACES); } else { - setHint (md->dpy, c->window, net_wm_desktop, - (unsigned long) c->win_workspace); + setHint (c->md->dpy, c->window, net_wm_desktop, (unsigned long) c->win_workspace); } } void -clientSetNetClientList (Atom a, GList * list) +clientSetNetClientList (ScreenData * md, Atom a, GList * list) { Window *listw; Window *index_dest; @@ -751,7 +749,7 @@ clientGetNetStruts (Client * c) FLAG_UNSET (c->flags, CLIENT_FLAG_HAS_STRUT); FLAG_UNSET (c->flags, CLIENT_FLAG_HAS_STRUT_PARTIAL); - if (getCardinalList (md->dpy, c->window, net_wm_strut_partial, &struts, &nitems)) + if (getCardinalList (c->md->dpy, c->window, net_wm_strut_partial, &struts, &nitems)) { if (nitems != 12) { @@ -767,9 +765,9 @@ clientGetNetStruts (Client * c) } XFree (struts); - workspaceUpdateArea (md->margins, md->gnome_margins); + workspaceUpdateArea (c->md); } - else if (getCardinalList (md->dpy, c->window, net_wm_strut, &struts, &nitems)) + else if (getCardinalList (c->md->dpy, c->window, net_wm_strut, &struts, &nitems)) { if (nitems != 4) { @@ -789,13 +787,13 @@ clientGetNetStruts (Client * c) /* Fill(in values as for partial struts */ c->struts[TOP_START_X] = c->struts[BOTTOM_START_X] = 0; c->struts[TOP_END_X] = c->struts[BOTTOM_END_X] = - gdk_screen_get_width (md->gscr); + gdk_screen_get_width (c->md->gscr); c->struts[LEFT_START_Y] = c->struts[RIGHT_START_Y] = 0; c->struts[LEFT_END_Y] = c->struts[RIGHT_END_Y] = - gdk_screen_get_height (md->gscr); + gdk_screen_get_height (c->md->gscr); XFree (struts); - workspaceUpdateArea (md->margins, md->gnome_margins); + workspaceUpdateArea (c->md); } } @@ -820,7 +818,7 @@ clientSetNetActions (Client * c) { atoms[i++] = net_wm_action_shade; } - XChangeProperty (md->dpy, c->window, net_wm_allowed_actions, XA_ATOM, 32, + XChangeProperty (c->md->dpy, c->window, net_wm_allowed_actions, XA_ATOM, 32, PropModeReplace, (unsigned char *) atoms, i); } diff --git a/src/netwm.h b/src/netwm.h index 3b3233d10..47ab7d8ff 100644 --- a/src/netwm.h +++ b/src/netwm.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,6 +27,7 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <glib.h> +#include "screen.h" #include "client.h" void clientSetNetState (Client *); @@ -35,7 +36,7 @@ void clientUpdateNetState (Client *, XClientMessageEvent *); void clientUpdateFullscreenState (Client *); void clientGetNetWmType (Client *); void clientGetInitialNetWmDesktop (Client *); -void clientSetNetClientList (Atom, GList *); +void clientSetNetClientList (ScreenData *, Atom, GList *); void clientGetNetStruts (Client *); void clientSetNetActions (Client *); void clientWindowType (Client *); diff --git a/src/parserc.c b/src/parserc.c index 9b8a7d781..9ff062d49 100644 --- a/src/parserc.c +++ b/src/parserc.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ diff --git a/src/parserc.h b/src/parserc.h index 0f948cffe..245c09dfa 100644 --- a/src/parserc.h +++ b/src/parserc.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ diff --git a/src/placement.c b/src/placement.c index cbdd0974d..3bf8de3ed 100644 --- a/src/placement.c +++ b/src/placement.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +26,7 @@ #include <glib.h> #include <libxfce4util/libxfce4util.h> -#include "main.h" +#include "screen.h" #include "misc.h" #include "client.h" #include "placement.h" @@ -52,18 +52,18 @@ clientStrutAreaOverlap (int x, int y, int w, int h, Client * c) c->struts[LEFT], c->struts[LEFT_END_Y]) + overlap (x, y, x + w, y + h, - gdk_screen_get_width (md->gscr) - c->struts[RIGHT], + gdk_screen_get_width (c->md->gscr) - c->struts[RIGHT], c->struts[RIGHT_START_Y], - gdk_screen_get_width (md->gscr), c->struts[RIGHT_END_Y]) + gdk_screen_get_width (c->md->gscr), c->struts[RIGHT_END_Y]) + overlap (x, y, x + w, y + h, c->struts[TOP_START_X], 0, c->struts[TOP_END_X], c->struts[TOP]) + overlap (x, y, x + w, y + h, c->struts[BOTTOM_START_X], - gdk_screen_get_height (md->gscr) - c->struts[BOTTOM], + gdk_screen_get_height (c->md->gscr) - c->struts[BOTTOM], c->struts[BOTTOM_END_X], - gdk_screen_get_height (md->gscr)); + gdk_screen_get_height (c->md->gscr)); } return sigma; } @@ -139,10 +139,10 @@ clientMaxSpace (int *x, int *y, int *w, int *h) /* Right */ if (overlap (*x, *y, *x + *w, *y + *h, - gdk_screen_get_width (md->gscr) - c2->struts[RIGHT], c2->struts[RIGHT_START_Y], - gdk_screen_get_width (md->gscr), c2->struts[RIGHT_END_Y])) + gdk_screen_get_width (c2->md->gscr) - c2->struts[RIGHT], c2->struts[RIGHT_START_Y], + gdk_screen_get_width (c2->md->gscr), c2->struts[RIGHT_END_Y])) { - delta = (*x + *w) - gdk_screen_get_width (md->gscr) + c2->struts[RIGHT]; + delta = (*x + *w) - gdk_screen_get_width (c2->md->gscr) + c2->struts[RIGHT]; *w = *w - delta; } @@ -157,10 +157,10 @@ clientMaxSpace (int *x, int *y, int *w, int *h) /* Bottom */ if (overlap (*x, *y, *x + *w, *y + *h, - c2->struts[BOTTOM_START_X], gdk_screen_get_height (md->gscr) - c2->struts[BOTTOM], - c2->struts[BOTTOM_END_X], gdk_screen_get_height (md->gscr))) + c2->struts[BOTTOM_START_X], gdk_screen_get_height (c2->md->gscr) - c2->struts[BOTTOM], + c2->struts[BOTTOM_END_X], gdk_screen_get_height (c2->md->gscr))) { - delta = (*y + *h) - gdk_screen_get_height (md->gscr) + c2->struts[BOTTOM]; + delta = (*y + *h) - gdk_screen_get_height (c2->md->gscr) + c2->struts[BOTTOM]; *h = *h - delta; } } @@ -217,8 +217,8 @@ clientConstrainPos (Client * c, gboolean show_full) cx = frame_x + (frame_width / 2); cy = frame_y + (frame_height / 2); - monitor_nbr = gdk_screen_get_monitor_at_point (md->gscr, cx, cy); - gdk_screen_get_monitor_geometry (md->gscr, monitor_nbr, &rect); + monitor_nbr = gdk_screen_get_monitor_at_point (c->md->gscr, cx, cy); + gdk_screen_get_monitor_geometry (c->md->gscr, monitor_nbr, &rect); disp_x = rect.x; disp_y = rect.y; @@ -269,9 +269,9 @@ clientConstrainPos (Client * c, gboolean show_full) if (overlapY (frame_y, frame_y + frame_height, c2->struts[RIGHT_START_Y], c2->struts[RIGHT_END_Y])) { if (overlapX (frame_x, frame_x + frame_width, - gdk_screen_get_width (md->gscr) - c2->struts[RIGHT], gdk_screen_get_width (md->gscr))) + gdk_screen_get_width (c->md->gscr) - c2->struts[RIGHT], gdk_screen_get_width (c->md->gscr))) { - c->x = gdk_screen_get_width (md->gscr) - c2->struts[RIGHT] - frame_width; + c->x = gdk_screen_get_width (c->md->gscr) - c2->struts[RIGHT] - frame_width; frame_x = frameX (c); } } @@ -290,9 +290,9 @@ clientConstrainPos (Client * c, gboolean show_full) if (overlapX (frame_x, frame_x + frame_width, c2->struts[BOTTOM_START_X], c2->struts[BOTTOM_END_X])) { if (overlapY (frame_y, frame_y + frame_height, - gdk_screen_get_height (md->gscr) - c2->struts[BOTTOM], gdk_screen_get_height (md->gscr))) + gdk_screen_get_height (c->md->gscr) - c2->struts[BOTTOM], gdk_screen_get_height (c->md->gscr))) { - c->y = gdk_screen_get_height (md->gscr) - c2->struts[BOTTOM] - frame_height; + c->y = gdk_screen_get_height (c->md->gscr) - c2->struts[BOTTOM] - frame_height; frame_y = frameY (c); } } @@ -345,9 +345,9 @@ clientConstrainPos (Client * c, gboolean show_full) /* Right */ if (overlapY (frame_y, frame_y + frame_height, c2->struts[RIGHT_START_Y], c2->struts[RIGHT_END_Y])) { - if (frame_x > gdk_screen_get_width (md->gscr) - c2->struts[RIGHT] - CLIENT_MIN_VISIBLE) + if (frame_x > gdk_screen_get_width (c->md->gscr) - c2->struts[RIGHT] - CLIENT_MIN_VISIBLE) { - c->x = gdk_screen_get_width (md->gscr) - c2->struts[RIGHT] - CLIENT_MIN_VISIBLE + frame_left; + c->x = gdk_screen_get_width (c->md->gscr) - c2->struts[RIGHT] - CLIENT_MIN_VISIBLE + frame_left; frame_x = frameX (c); } } @@ -370,9 +370,9 @@ clientConstrainPos (Client * c, gboolean show_full) /* Bottom */ if (overlapX (frame_x, frame_x + frame_width, c2->struts[BOTTOM_START_X], c2->struts[BOTTOM_END_X])) { - if (frame_y > gdk_screen_get_height (md->gscr) - c2->struts[BOTTOM] - CLIENT_MIN_VISIBLE) + if (frame_y > gdk_screen_get_height (c->md->gscr) - c2->struts[BOTTOM] - CLIENT_MIN_VISIBLE) { - c->y = gdk_screen_get_height (md->gscr) - c2->struts[BOTTOM] - CLIENT_MIN_VISIBLE + frame_top; + c->y = gdk_screen_get_height (c->md->gscr) - c2->struts[BOTTOM] - CLIENT_MIN_VISIBLE + frame_top; frame_y = frameY (c); } } @@ -401,10 +401,10 @@ clientKeepVisible (Client * c) /* Translate coodinates to center on physical screen */ - diff_x = abs (c->size->x - ((gdk_screen_get_width (md->gscr) - c->width) / 2)); - diff_y = abs (c->size->y - ((gdk_screen_get_height (md->gscr) - c->height) / 2)); + diff_x = abs (c->size->x - ((gdk_screen_get_width (c->md->gscr) - c->width) / 2)); + diff_y = abs (c->size->y - ((gdk_screen_get_height (c->md->gscr) - c->height) / 2)); - if (((gdk_screen_get_n_monitors (md->gscr) > 1) && (diff_x < 25) && (diff_y < 25)) || + if (((gdk_screen_get_n_monitors (c->md->gscr) > 1) && (diff_x < 25) && (diff_y < 25)) || ((frameX (c) == 0) && (frameY (c) == 0) && (c->type & (WINDOW_TYPE_DIALOG)) && !clientIsTransient (c))) { GdkRectangle rect; @@ -414,10 +414,10 @@ clientKeepVisible (Client * c) * Thus, will move it so its center on the current * physical screen */ - getMouseXY (md->xroot, &cx, &cy); + getMouseXY (c->md, c->md->xroot, &cx, &cy); - monitor_nbr = gdk_screen_get_monitor_at_point (md->gscr, cx, cy); - gdk_screen_get_monitor_geometry (md->gscr, monitor_nbr, &rect); + monitor_nbr = gdk_screen_get_monitor_at_point (c->md->gscr, cx, cy); + gdk_screen_get_monitor_geometry (c->md->gscr, monitor_nbr, &rect); c->x = rect.x + (rect.width - c->width) / 2; c->y = rect.y + (rect.height - c->height) / 2; @@ -466,10 +466,10 @@ clientInitPosition (Client * c) return; } - getMouseXY (md->xroot, &msx, &msy); + getMouseXY (c->md, c->md->xroot, &msx, &msy); - monitor_nbr = gdk_screen_get_monitor_at_point (md->gscr, msx, msy); - gdk_screen_get_monitor_geometry (md->gscr, monitor_nbr, &rect); + monitor_nbr = gdk_screen_get_monitor_at_point (c->md->gscr, msx, msy); + gdk_screen_get_monitor_geometry (c->md->gscr, monitor_nbr, &rect); frame_x = frameX (c); frame_y = frameY (c); @@ -480,9 +480,9 @@ clientInitPosition (Client * c) full_x = MAX (params.xfwm_margins[LEFT], rect.x); full_y = MAX (params.xfwm_margins[TOP], rect.y); - full_w = MIN (gdk_screen_get_width (md->gscr) - params.xfwm_margins[RIGHT], + full_w = MIN (gdk_screen_get_width (c->md->gscr) - params.xfwm_margins[RIGHT], rect.x + rect.width) - full_x; - full_h = MIN (gdk_screen_get_height (md->gscr) - params.xfwm_margins[BOTTOM], + full_h = MIN (gdk_screen_get_height (c->md->gscr) - params.xfwm_margins[BOTTOM], rect.y + rect.height) - full_y; /* Adjust size to the widest size available, not covering struts */ diff --git a/src/placement.h b/src/placement.h index c14c4d4cc..bfb78310a 100644 --- a/src/placement.h +++ b/src/placement.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/src/poswin.c b/src/poswin.c index 1cdb99482..7691b6d9f 100644 --- a/src/poswin.c +++ b/src/poswin.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -13,7 +13,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - xfwm4 - (c) 2004 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan based on a patch from Joshua Blanton <jblanton@irg.cs.ohiou.edu> */ diff --git a/src/poswin.h b/src/poswin.h index d85fc398c..b6efd1808 100644 --- a/src/poswin.h +++ b/src/poswin.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -13,7 +13,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - xfwm4 - (c) 2004 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan based on a patch from Joshua Blanton <jblanton@irg.cs.ohiou.edu> */ diff --git a/src/session.c b/src/session.c index 0e54a7ec6..c9743b3ed 100644 --- a/src/session.c +++ b/src/session.c @@ -1,16 +1,19 @@ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/* + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + xfwm4 - (c) 2002-2004 Olivier Fourdan */ /* Initially inspired by xfwm, fvwm2, enlightment and twm implementations */ @@ -32,7 +35,7 @@ #include <sys/types.h> #include <signal.h> -#include "main.h" +#include "screen.h" #include "hints.h" #include "client.h" #include "session.h" @@ -269,7 +272,7 @@ sessionSaveWindowStates (gchar * filename) { if (c->client_leader != None) { - getWindowRole (md->dpy, c->client_leader, &window_role); + getWindowRole (c->md->dpy, c->client_leader, &window_role); } else { @@ -278,7 +281,7 @@ sessionSaveWindowStates (gchar * filename) fprintf (f, "[CLIENT] 0x%lx\n", c->window); - getClientID (md->dpy, c->window, &client_id); + getClientID (c->md->dpy, c->window, &client_id); if (client_id) { fprintf (f, " [CLIENT_ID] %s\n", client_id); @@ -314,7 +317,7 @@ sessionSaveWindowStates (gchar * filename) } wm_command_count = 0; - getWindowCommand (md->dpy, c->window, &wm_command, &wm_command_count); + getWindowCommand (c->md->dpy, c->window, &wm_command, &wm_command_count); if ((wm_command_count > 0) && (wm_command)) { gint j; @@ -531,13 +534,13 @@ matchWin (Client * c, Match * m) g_return_val_if_fail (c != NULL, FALSE); found = FALSE; - getClientID (md->dpy, c->window, &client_id); + getClientID (c->md->dpy, c->window, &client_id); if (xstreq (client_id, m->client_id)) { /* client_id's match */ if (c->client_leader != None) { - getWindowRole (md->dpy, c->client_leader, &window_role); + getWindowRole (c->md->dpy, c->client_leader, &window_role); } else { @@ -569,7 +572,7 @@ matchWin (Client * c, Match * m) { /* for non-SM-aware clients we also compare WM_COMMAND */ wm_command_count = 0; - getWindowCommand (md->dpy, c->window, &wm_command, + getWindowCommand (c->md->dpy, c->window, &wm_command, &wm_command_count); if (wm_command_count == m->wm_command_count) { diff --git a/src/session.h b/src/session.h index cd2a548df..0fc56b32a 100644 --- a/src/session.h +++ b/src/session.h @@ -1,21 +1,22 @@ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/* + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - xfwm4 - (c) 2003 Olivier Fourdan + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + xfwm4 - (c) 2002-2004 Olivier Fourdan */ + #ifndef INC_SESSION_H #define INC_SESSION_H diff --git a/src/settings.c b/src/settings.c index dc94b9fb7..381539e63 100644 --- a/src/settings.c +++ b/src/settings.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ #ifdef HAVE_CONFIG_H @@ -30,7 +30,7 @@ #include <libxfcegui4/libxfcegui4.h> #include <libxfce4mcs/mcs-client.h> -#include "main.h" +#include "screen.h" #include "hints.h" #include "parserc.h" #include "client.h" @@ -53,7 +53,7 @@ static McsClient *client = NULL; static int mcs_initted = FALSE; static void -set_settings_margin (int idx, int value) +set_settings_margin (ScreenData *md, int idx, int value) { int val; @@ -100,12 +100,16 @@ static void notify_cb (const char *name, const char *channel_name, McsAction action, McsSetting * setting, void *data) { + ScreenData *md = (ScreenData *) data; + + g_return_if_fail (md != NULL); + if (!g_ascii_strcasecmp (CHANNEL1, channel_name)) { switch (action) { case MCS_ACTION_NEW: - /* The following is to reduce initial startup time and md->reloads */ + /* The following is to reduce initial startup time and reload */ if (!mcs_initted) { return; @@ -149,7 +153,7 @@ notify_cb (const char *name, const char *channel_name, McsAction action, else if (!strcmp (name, "Xfwm/WrapWorkspaces")) { params.wrap_workspaces = setting->data.v_int; - placeSidewalks (params.wrap_workspaces); + placeSidewalks (md, params.wrap_workspaces); } else if (!strcmp (name, "Xfwm/WrapWindows")) { @@ -172,27 +176,27 @@ notify_cb (const char *name, const char *channel_name, McsAction action, { if (!strcmp (name, "Xfwm/DblClickAction")) { - reloadSettings (NO_UPDATE_FLAG); + reloadSettings (md, NO_UPDATE_FLAG); } else if (!strcmp (name, "Xfwm/KeyThemeName")) { - reloadSettings (UPDATE_KEYGRABS); + reloadSettings (md, UPDATE_KEYGRABS); } else if (!strcmp (name, "Xfwm/ThemeName")) { - reloadSettings (UPDATE_GRAVITY | UPDATE_CACHE); + reloadSettings (md, UPDATE_GRAVITY | UPDATE_CACHE); } else if (!strcmp (name, "Xfwm/ButtonLayout")) { - reloadSettings (UPDATE_FRAME | UPDATE_CACHE); + reloadSettings (md, UPDATE_FRAME | UPDATE_CACHE); } if (!strcmp (name, "Xfwm/TitleAlign")) { - reloadSettings (UPDATE_FRAME | UPDATE_CACHE); + reloadSettings (md, UPDATE_FRAME | UPDATE_CACHE); } if (!strcmp (name, "Xfwm/TitleFont")) { - reloadSettings (UPDATE_FRAME | UPDATE_CACHE); + reloadSettings (md, UPDATE_FRAME | UPDATE_CACHE); } } break; @@ -206,7 +210,7 @@ notify_cb (const char *name, const char *channel_name, McsAction action, switch (action) { case MCS_ACTION_NEW: - /* The following is to reduce initial startup time and md->reloads */ + /* The following is to reduce initial startup time and reloads */ if (!mcs_initted) { return; @@ -216,22 +220,19 @@ notify_cb (const char *name, const char *channel_name, McsAction action, { if (!strcmp (name, "Xfwm/LeftMargin")) { - set_settings_margin (LEFT, - setting->data.v_int); + set_settings_margin (md, LEFT, setting->data.v_int); } else if (!strcmp (name, "Xfwm/RightMargin")) { - set_settings_margin (RIGHT, - setting->data.v_int); + set_settings_margin (md, RIGHT, setting->data.v_int); } else if (!strcmp (name, "Xfwm/BottomMargin")) { - set_settings_margin (BOTTOM, - setting->data.v_int); + set_settings_margin (md, BOTTOM, setting->data.v_int); } else if (!strcmp (name, "Xfwm/TopMargin")) { - set_settings_margin (TOP, setting->data.v_int); + set_settings_margin (md, TOP, setting->data.v_int); } } break; @@ -245,7 +246,7 @@ notify_cb (const char *name, const char *channel_name, McsAction action, switch (action) { case MCS_ACTION_NEW: - /* The following is to reduce initial startup time and md->reloads */ + /* The following is to reduce initial startup time and reloads */ if (!mcs_initted) { return; @@ -255,7 +256,7 @@ notify_cb (const char *name, const char *channel_name, McsAction action, { if (!strcmp (name, "Xfwm/WorkspaceCount")) { - workspaceSetCount(setting->data.v_int); + workspaceSetCount(md, setting->data.v_int); } } break; @@ -303,7 +304,7 @@ watch_cb (Window window, Bool is_start, long mask, void *cb_data) } static void -loadRcData (Settings rc[]) +loadRcData (ScreenData *md, Settings rc[]) { const gchar *homedir = xfce_get_userdir (); gchar *keytheme; @@ -311,7 +312,7 @@ loadRcData (Settings rc[]) if (!parseRc ("defaults", PACKAGE_DATADIR, rc)) { - g_warning (_("%s: Missing defaults file"), md->progname); + g_warning (_("%s: Missing defaults file"), g_get_prgname ()); exit (1); } keythemevalue = getValue ("keytheme", rc); @@ -325,7 +326,7 @@ loadRcData (Settings rc[]) } static void -loadMcsData (Settings rc[]) +loadMcsData (ScreenData *md, Settings rc[]) { McsSetting *setting; if (client) @@ -479,7 +480,7 @@ loadMcsData (Settings rc[]) } static void -loadTheme (Settings rc[]) +loadTheme (ScreenData *md, Settings rc[]) { gchar *theme; gchar *font; @@ -617,107 +618,107 @@ loadTheme (Settings rc[]) } } - myPixmapLoad (md->dpy, ¶ms.sides[SIDE_LEFT][ACTIVE], theme, + myPixmapLoad (md, ¶ms.sides[SIDE_LEFT][ACTIVE], theme, "left-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.sides[SIDE_LEFT][INACTIVE], theme, + myPixmapLoad (md, ¶ms.sides[SIDE_LEFT][INACTIVE], theme, "left-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.sides[SIDE_RIGHT][ACTIVE], theme, + myPixmapLoad (md, ¶ms.sides[SIDE_RIGHT][ACTIVE], theme, "right-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.sides[SIDE_RIGHT][INACTIVE], theme, + myPixmapLoad (md, ¶ms.sides[SIDE_RIGHT][INACTIVE], theme, "right-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.sides[SIDE_BOTTOM][ACTIVE], theme, + myPixmapLoad (md, ¶ms.sides[SIDE_BOTTOM][ACTIVE], theme, "bottom-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.sides[SIDE_BOTTOM][INACTIVE], theme, + myPixmapLoad (md, ¶ms.sides[SIDE_BOTTOM][INACTIVE], theme, "bottom-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.corners[CORNER_TOP_LEFT][ACTIVE], theme, + myPixmapLoad (md, ¶ms.corners[CORNER_TOP_LEFT][ACTIVE], theme, "top-left-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.corners[CORNER_TOP_LEFT][INACTIVE], theme, + myPixmapLoad (md, ¶ms.corners[CORNER_TOP_LEFT][INACTIVE], theme, "top-left-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.corners[CORNER_TOP_RIGHT][ACTIVE], theme, + myPixmapLoad (md, ¶ms.corners[CORNER_TOP_RIGHT][ACTIVE], theme, "top-right-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.corners[CORNER_TOP_RIGHT][INACTIVE], theme, + myPixmapLoad (md, ¶ms.corners[CORNER_TOP_RIGHT][INACTIVE], theme, "top-right-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.corners[CORNER_BOTTOM_LEFT][ACTIVE], theme, + myPixmapLoad (md, ¶ms.corners[CORNER_BOTTOM_LEFT][ACTIVE], theme, "bottom-left-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.corners[CORNER_BOTTOM_LEFT][INACTIVE], theme, + myPixmapLoad (md, ¶ms.corners[CORNER_BOTTOM_LEFT][INACTIVE], theme, "bottom-left-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.corners[CORNER_BOTTOM_RIGHT][ACTIVE], theme, + myPixmapLoad (md, ¶ms.corners[CORNER_BOTTOM_RIGHT][ACTIVE], theme, "bottom-right-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.corners[CORNER_BOTTOM_RIGHT][INACTIVE], theme, + myPixmapLoad (md, ¶ms.corners[CORNER_BOTTOM_RIGHT][INACTIVE], theme, "bottom-right-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[HIDE_BUTTON][ACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[HIDE_BUTTON][ACTIVE], theme, "hide-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[HIDE_BUTTON][INACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[HIDE_BUTTON][INACTIVE], theme, "hide-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[HIDE_BUTTON][PRESSED], theme, + myPixmapLoad (md, ¶ms.buttons[HIDE_BUTTON][PRESSED], theme, "hide-pressed", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[CLOSE_BUTTON][ACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[CLOSE_BUTTON][ACTIVE], theme, "close-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[CLOSE_BUTTON][INACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[CLOSE_BUTTON][INACTIVE], theme, "close-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[CLOSE_BUTTON][PRESSED], theme, + myPixmapLoad (md, ¶ms.buttons[CLOSE_BUTTON][PRESSED], theme, "close-pressed", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[MAXIMIZE_BUTTON][ACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[MAXIMIZE_BUTTON][ACTIVE], theme, "maximize-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[MAXIMIZE_BUTTON][INACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[MAXIMIZE_BUTTON][INACTIVE], theme, "maximize-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[MAXIMIZE_BUTTON][PRESSED], theme, + myPixmapLoad (md, ¶ms.buttons[MAXIMIZE_BUTTON][PRESSED], theme, "maximize-pressed", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[SHADE_BUTTON][ACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[SHADE_BUTTON][ACTIVE], theme, "shade-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[SHADE_BUTTON][INACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[SHADE_BUTTON][INACTIVE], theme, "shade-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[SHADE_BUTTON][PRESSED], theme, + myPixmapLoad (md, ¶ms.buttons[SHADE_BUTTON][PRESSED], theme, "shade-pressed", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[STICK_BUTTON][ACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[STICK_BUTTON][ACTIVE], theme, "stick-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[STICK_BUTTON][INACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[STICK_BUTTON][INACTIVE], theme, "stick-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[STICK_BUTTON][PRESSED], theme, + myPixmapLoad (md, ¶ms.buttons[STICK_BUTTON][PRESSED], theme, "stick-pressed", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[MENU_BUTTON][ACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[MENU_BUTTON][ACTIVE], theme, "menu-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[MENU_BUTTON][INACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[MENU_BUTTON][INACTIVE], theme, "menu-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[MENU_BUTTON][PRESSED], theme, + myPixmapLoad (md, ¶ms.buttons[MENU_BUTTON][PRESSED], theme, "menu-pressed", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[SHADE_BUTTON][T_ACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[SHADE_BUTTON][T_ACTIVE], theme, "shade-toggled-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[SHADE_BUTTON][T_INACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[SHADE_BUTTON][T_INACTIVE], theme, "shade-toggled-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[SHADE_BUTTON][T_PRESSED], theme, + myPixmapLoad (md, ¶ms.buttons[SHADE_BUTTON][T_PRESSED], theme, "shade-toggled-pressed", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[STICK_BUTTON][T_ACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[STICK_BUTTON][T_ACTIVE], theme, "stick-toggled-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[STICK_BUTTON][T_INACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[STICK_BUTTON][T_INACTIVE], theme, "stick-toggled-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[STICK_BUTTON][T_PRESSED], theme, + myPixmapLoad (md, ¶ms.buttons[STICK_BUTTON][T_PRESSED], theme, "stick-toggled-pressed", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[MAXIMIZE_BUTTON][T_ACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[MAXIMIZE_BUTTON][T_ACTIVE], theme, "maximize-toggled-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[MAXIMIZE_BUTTON][T_INACTIVE], theme, + myPixmapLoad (md, ¶ms.buttons[MAXIMIZE_BUTTON][T_INACTIVE], theme, "maximize-toggled-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.buttons[MAXIMIZE_BUTTON][T_PRESSED], theme, + myPixmapLoad (md, ¶ms.buttons[MAXIMIZE_BUTTON][T_PRESSED], theme, "maximize-toggled-pressed", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.title[TITLE_1][ACTIVE], theme, + myPixmapLoad (md, ¶ms.title[TITLE_1][ACTIVE], theme, "title-1-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.title[TITLE_1][INACTIVE], theme, + myPixmapLoad (md, ¶ms.title[TITLE_1][INACTIVE], theme, "title-1-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.title[TITLE_2][ACTIVE], theme, + myPixmapLoad (md, ¶ms.title[TITLE_2][ACTIVE], theme, "title-2-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.title[TITLE_2][INACTIVE], theme, + myPixmapLoad (md, ¶ms.title[TITLE_2][INACTIVE], theme, "title-2-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.title[TITLE_3][ACTIVE], theme, + myPixmapLoad (md, ¶ms.title[TITLE_3][ACTIVE], theme, "title-3-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.title[TITLE_3][INACTIVE], theme, + myPixmapLoad (md, ¶ms.title[TITLE_3][INACTIVE], theme, "title-3-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.title[TITLE_4][ACTIVE], theme, + myPixmapLoad (md, ¶ms.title[TITLE_4][ACTIVE], theme, "title-4-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.title[TITLE_4][INACTIVE], theme, + myPixmapLoad (md, ¶ms.title[TITLE_4][INACTIVE], theme, "title-4-inactive", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.title[TITLE_5][ACTIVE], theme, + myPixmapLoad (md, ¶ms.title[TITLE_5][ACTIVE], theme, "title-5-active", colsym, 20); - myPixmapLoad (md->dpy, ¶ms.title[TITLE_5][INACTIVE], theme, + myPixmapLoad (md, ¶ms.title[TITLE_5][INACTIVE], theme, "title-5-inactive", colsym, 20); if (!g_ascii_strcasecmp ("left", getValue ("title_alignment", rc))) @@ -750,7 +751,7 @@ loadTheme (Settings rc[]) params.title_horizontal_offset = TOINT (getValue ("title_horizontal_offset", rc)); - params.box_gc = createGC (md->cmap, "#FFFFFF", GXxor, NULL, 2, TRUE); + params.box_gc = createGC (md, "#FFFFFF", GXxor, NULL, 2, TRUE); g_free (theme); } @@ -779,7 +780,7 @@ loadShortcutCmd (Settings rc[]) } static gboolean -loadKeyBindings (Settings rc[]) +loadKeyBindings (ScreenData *md, Settings rc[]) { gchar *keytheme; gchar *keythemevalue; @@ -791,7 +792,7 @@ loadKeyBindings (Settings rc[]) if (!parseRc (KEYTHEMERC, keytheme, rc)) { g_warning (_("%s: specified key theme \"%s\" missing, using default"), - md->progname, keythemevalue); + g_get_prgname (), keythemevalue); g_free (keytheme); keytheme = getThemeDir (DEFAULT_KEYTHEME, KEYTHEMERC); parseRc (KEYTHEMERC, keytheme, rc); @@ -800,7 +801,7 @@ loadKeyBindings (Settings rc[]) if (!checkRc (rc)) { - g_warning (_("%s: Missing values in defaults file"), md->progname); + g_warning (_("%s: Missing values in defaults file"), g_get_prgname ()); return FALSE; } } @@ -941,7 +942,7 @@ loadKeyBindings (Settings rc[]) } gboolean -loadSettings (void) +loadSettings (ScreenData *md) { Settings rc[] = { /* Do not chnage the order of the following parameters */ @@ -1071,11 +1072,11 @@ loadSettings (void) TRACE ("entering loadSettings"); - loadRcData (rc); - loadMcsData (rc); - loadTheme (rc); + loadRcData (md, rc); + loadMcsData (md, rc); + loadTheme (md, rc); - if (!loadKeyBindings (rc)) + if (!loadKeyBindings (md, rc)) { freeRc (rc); return FALSE; @@ -1108,10 +1109,10 @@ loadSettings (void) params.snap_width = abs (TOINT (getValue ("snap_width", rc))); params.dbl_click_time = abs (TOINT (getValue ("dbl_click_time", rc))); - set_settings_margin (LEFT, TOINT (getValue ("margin_left", rc))); - set_settings_margin (RIGHT, TOINT (getValue ("margin_right", rc))); - set_settings_margin (BOTTOM, TOINT (getValue ("margin_bottom", rc))); - set_settings_margin (TOP, TOINT (getValue ("margin_top", rc))); + set_settings_margin (md, LEFT, TOINT (getValue ("margin_left", rc))); + set_settings_margin (md, RIGHT, TOINT (getValue ("margin_right", rc))); + set_settings_margin (md, BOTTOM, TOINT (getValue ("margin_bottom", rc))); + set_settings_margin (md, TOP, TOINT (getValue ("margin_top", rc))); g_value_init (&tmp_val, G_TYPE_INT); if (gdk_setting_get ("gtk-double-click-time", &tmp_val)) @@ -1148,7 +1149,7 @@ loadSettings (void) } g_message (_("%s: Workspace count not set, using rc value: %i"), g_get_prgname (), workspace_count); - workspaceSetCount (workspace_count); + workspaceSetCount (md, workspace_count); } params.wrap_workspaces = @@ -1162,34 +1163,34 @@ loadSettings (void) } static void -unloadTheme (void) +unloadTheme (ScreenData *md) { int i; TRACE ("entering unloadTheme"); for (i = 0; i < 3; i++) { - myPixmapFree (md->dpy, ¶ms.sides[i][ACTIVE]); - myPixmapFree (md->dpy, ¶ms.sides[i][INACTIVE]); + myPixmapFree (¶ms.sides[i][ACTIVE]); + myPixmapFree (¶ms.sides[i][INACTIVE]); } for (i = 0; i < 4; i++) { - myPixmapFree (md->dpy, ¶ms.corners[i][ACTIVE]); - myPixmapFree (md->dpy, ¶ms.corners[i][INACTIVE]); + myPixmapFree (¶ms.corners[i][ACTIVE]); + myPixmapFree (¶ms.corners[i][INACTIVE]); } for (i = 0; i < BUTTON_COUNT; i++) { - myPixmapFree (md->dpy, ¶ms.buttons[i][ACTIVE]); - myPixmapFree (md->dpy, ¶ms.buttons[i][INACTIVE]); - myPixmapFree (md->dpy, ¶ms.buttons[i][PRESSED]); - myPixmapFree (md->dpy, ¶ms.buttons[i][T_ACTIVE]); - myPixmapFree (md->dpy, ¶ms.buttons[i][T_INACTIVE]); - myPixmapFree (md->dpy, ¶ms.buttons[i][T_PRESSED]); + myPixmapFree (¶ms.buttons[i][ACTIVE]); + myPixmapFree (¶ms.buttons[i][INACTIVE]); + myPixmapFree (¶ms.buttons[i][PRESSED]); + myPixmapFree (¶ms.buttons[i][T_ACTIVE]); + myPixmapFree (¶ms.buttons[i][T_INACTIVE]); + myPixmapFree (¶ms.buttons[i][T_PRESSED]); } for (i = 0; i < 5; i++) { - myPixmapFree (md->dpy, ¶ms.title[i][ACTIVE]); - myPixmapFree (md->dpy, ¶ms.title[i][INACTIVE]); + myPixmapFree (¶ms.title[i][ACTIVE]); + myPixmapFree (¶ms.title[i][INACTIVE]); } if (params.box_gc != None) { @@ -1199,25 +1200,25 @@ unloadTheme (void) } gboolean -reloadSettings (int mask) +reloadSettings (ScreenData *md, int mask) { TRACE ("entering reloadSettings"); - unloadTheme (); - if (!loadSettings ()) + unloadTheme (md); + if (!loadSettings (md)) { return FALSE; } if (mask) { - clientUpdateAllFrames (mask); + clientUpdateAllFrames (md, mask); } return TRUE; } gboolean -initSettings (void) +initSettings (ScreenData *md) { int i; long val = 0; @@ -1267,7 +1268,7 @@ initSettings (void) { g_warning ("MCS manager not running"); } - client = mcs_client_new (md->dpy, md->screen, notify_cb, watch_cb, NULL); + client = mcs_client_new (md->dpy, md->screen, notify_cb, watch_cb, (gpointer) md); if (client) { mcs_client_add_channel (client, CHANNEL1); @@ -1283,11 +1284,11 @@ initSettings (void) if (getHint (md->dpy, md->xroot, net_number_of_desktops, &val)) { - workspaceSetCount (val); + workspaceSetCount (md, val); } else if (getHint (md->dpy, md->xroot, win_workspace_count, &val)) { - workspaceSetCount (val); + workspaceSetCount (md, val); } if (getUTF8String (md->dpy, md->xroot, net_desktop_names, &names, &i)) @@ -1300,19 +1301,19 @@ initSettings (void) params.workspace_names_length = 0; } - if (!loadSettings ()) + if (!loadSettings (md)) { return FALSE; } - placeSidewalks (params.wrap_workspaces); + placeSidewalks (md, params.wrap_workspaces); return TRUE; } void -unloadSettings (void) +unloadSettings (ScreenData *md) { TRACE ("entering unloadSettings"); - unloadTheme (); + unloadTheme (md); } diff --git a/src/settings.h b/src/settings.h index 8fd717c4e..244e33e94 100644 --- a/src/settings.h +++ b/src/settings.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -27,6 +27,7 @@ #include <glib.h> #include <gdk/gdk.h> +#include "screen.h" #include "keyboard.h" #include "mypixmap.h" @@ -189,9 +190,9 @@ struct _Params extern Params params; -gboolean loadSettings (void); -void unloadSettings (void); -gboolean reloadSettings (int); -gboolean initSettings (void); +gboolean loadSettings (ScreenData *); +void unloadSettings (ScreenData *); +gboolean reloadSettings (ScreenData *, int); +gboolean initSettings (ScreenData *); #endif /* INC_SETTINGS_H */ diff --git a/src/spinning_cursor.c b/src/spinning_cursor.c index fbf88dfde..703ba8d99 100644 --- a/src/spinning_cursor.c +++ b/src/spinning_cursor.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. mozilla - (c) 1998 mozilla.org - xfwm4 - (c) 2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ diff --git a/src/spinning_cursor.h b/src/spinning_cursor.h index 98acc02ca..ffb25824a 100644 --- a/src/spinning_cursor.h +++ b/src/spinning_cursor.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Metacity - (c) 2003 Havoc Pennington - xfwm4 - (c) 2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ diff --git a/src/stacking.c b/src/stacking.c index 106ad4a5e..2a660bd71 100644 --- a/src/stacking.c +++ b/src/stacking.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -23,7 +23,8 @@ #include <glib.h> #include <libxfce4util/libxfce4util.h> -#include "main.h" +#include "screen.h" +#include "mywindow.h" #include "client.h" #include "stacking.h" #include "netwm.h" @@ -36,7 +37,7 @@ static Client *last_raise = NULL; static GList *windows = NULL; void -clientApplyStackList (void) +clientApplyStackList (ScreenData *md) { Window *xwinstack; guint nwindows; @@ -46,8 +47,8 @@ clientApplyStackList (void) nwindows = g_list_length (windows_stack); xwinstack = g_new (Window, nwindows + 2); - xwinstack[i++] = md->sidewalk[0]; - xwinstack[i++] = md->sidewalk[1]; + xwinstack[i++] = MYWINDOW_XWINDOW (md->sidewalk[0]); + xwinstack[i++] = MYWINDOW_XWINDOW (md->sidewalk[1]); if (nwindows) { @@ -366,8 +367,8 @@ clientRaise (Client * c) /* Now, windows_stack contains the correct window stack We still need to tell the X Server to reflect the changes */ - clientApplyStackList (); - clientSetNetClientList (net_client_list_stacking, windows_stack); + clientApplyStackList (c->md); + clientSetNetClientList (c->md, net_client_list_stacking, windows_stack); last_raise = c; } } @@ -421,8 +422,8 @@ clientLower (Client * c) /* Now, windows_stack contains the correct window stack We still need to tell the X Server to reflect the changes */ - clientApplyStackList (); - clientSetNetClientList (net_client_list_stacking, windows_stack); + clientApplyStackList (c->md); + clientSetNetClientList (c->md, net_client_list_stacking, windows_stack); if (last_raise == c) { last_raise = NULL; @@ -487,9 +488,9 @@ clientAddToList (Client * c) } } - clientSetNetClientList (net_client_list, windows); - clientSetNetClientList (win_client_list, windows); - clientSetNetClientList (net_client_list_stacking, windows_stack); + clientSetNetClientList (c->md, net_client_list, windows); + clientSetNetClientList (c->md, win_client_list, windows); + clientSetNetClientList (c->md, net_client_list_stacking, windows_stack); FLAG_SET (c->flags, CLIENT_FLAG_MANAGED); } @@ -525,9 +526,9 @@ clientRemoveFromList (Client * c) c->window); windows_stack = g_list_remove (windows_stack, c); - clientSetNetClientList (net_client_list, windows); - clientSetNetClientList (win_client_list, windows); - clientSetNetClientList (net_client_list_stacking, windows_stack); + clientSetNetClientList (c->md, net_client_list, windows); + clientSetNetClientList (c->md, win_client_list, windows); + clientSetNetClientList (c->md, net_client_list_stacking, windows_stack); FLAG_UNSET (c->flags, CLIENT_FLAG_MANAGED); } diff --git a/src/stacking.h b/src/stacking.h index b4da206c9..ae50758db 100644 --- a/src/stacking.h +++ b/src/stacking.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,11 +25,12 @@ #endif #include <glib.h> +#include "screen.h" #include "client.h" extern GList *windows_stack; -void clientApplyStackList (void); +void clientApplyStackList (ScreenData *); gboolean clientTransientOrModalHasAncestor (Client *, int); Client *clientGetLowestTransient (Client *); Client *clientGetHighestTransientOrModalFor (Client *); diff --git a/src/startup_notification.c b/src/startup_notification.c index a84f732f6..6365b0cdb 100644 --- a/src/startup_notification.c +++ b/src/startup_notification.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Metacity - (c) 2003 Havoc Pennington - xfwm4 - (c) 2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -36,15 +36,12 @@ #include <glib.h> #include <libsn/sn.h> +#include "screen.h" #include "client.h" -#include "main.h" #define STARTUP_TIMEOUT (30 /* seconds */ * 1000) SnDisplay *sn_display; -SnMonitorContext *sn_context; -GSList *startup_sequences; -guint startup_sequence_timeout; typedef struct { @@ -58,28 +55,21 @@ static gboolean sn_startup_sequence_timeout (void *data); static void sn_error_trap_push (SnDisplay * sn_display, Display * dpy) { - g_return_if_fail (sn_display != NULL); - g_return_if_fail (sn_context != NULL); - gdk_error_trap_push (); } static void sn_error_trap_pop (SnDisplay * sn_display, Display * dpy) { - g_return_if_fail (sn_display != NULL); - g_return_if_fail (sn_context != NULL); - gdk_error_trap_pop (); } static void -sn_update_feedback (void) +sn_update_feedback (ScreenData *md) { - g_return_if_fail (sn_display != NULL); - g_return_if_fail (sn_context != NULL); + g_return_if_fail (md != NULL); - if (startup_sequences != NULL) + if (md->startup_sequences != NULL) { XDefineCursor (md->dpy, md->xroot, md->busy_cursor); } @@ -90,39 +80,39 @@ sn_update_feedback (void) } static void -sn_add_sequence (SnStartupSequence * sequence) +sn_add_sequence (ScreenData *md, SnStartupSequence * sequence) { g_return_if_fail (sn_display != NULL); - g_return_if_fail (sn_context != NULL); g_return_if_fail (sequence != NULL); + g_return_if_fail (md != NULL); sn_startup_sequence_ref (sequence); - startup_sequences = g_slist_prepend (startup_sequences, sequence); + md->startup_sequences = g_slist_prepend (md->startup_sequences, sequence); - if (startup_sequence_timeout == 0) + if (md->startup_sequence_timeout == 0) { - startup_sequence_timeout = - g_timeout_add (1000, sn_startup_sequence_timeout, NULL); + md->startup_sequence_timeout = + g_timeout_add (1000, sn_startup_sequence_timeout, md); } - sn_update_feedback (); + sn_update_feedback (md); } static void -sn_remove_sequence (SnStartupSequence * sequence) +sn_remove_sequence (ScreenData *md, SnStartupSequence * sequence) { g_return_if_fail (sn_display != NULL); - g_return_if_fail (sn_context != NULL); g_return_if_fail (sequence != NULL); + g_return_if_fail (md != NULL); - startup_sequences = g_slist_remove (startup_sequences, sequence); + md->startup_sequences = g_slist_remove (md->startup_sequences, sequence); sn_startup_sequence_unref (sequence); - if ((startup_sequences == NULL) && (startup_sequence_timeout != 0)) + if ((md->startup_sequences == NULL) && (md->startup_sequence_timeout != 0)) { - g_source_remove (startup_sequence_timeout); - startup_sequence_timeout = 0; + g_source_remove (md->startup_sequence_timeout); + md->startup_sequence_timeout = 0; } - sn_update_feedback (); + sn_update_feedback (md); } static void @@ -134,7 +124,6 @@ sn_collect_timed_out_foreach (void *element, void *data) double elapsed; g_return_if_fail (sn_display != NULL); - g_return_if_fail (sn_context != NULL); sn_startup_sequence_get_last_active_time (sequence, &tv_sec, &tv_usec); @@ -151,15 +140,16 @@ sn_collect_timed_out_foreach (void *element, void *data) static gboolean sn_startup_sequence_timeout (void *data) { + ScreenData * md = (ScreenData *) data; CollectTimedOutData ctod; GSList *tmp; g_return_val_if_fail (sn_display != NULL, FALSE); - g_return_val_if_fail (sn_context != NULL, FALSE); + g_return_val_if_fail (md != NULL, FALSE); ctod.list = NULL; g_get_current_time (&ctod.now); - g_slist_foreach (startup_sequences, sn_collect_timed_out_foreach, &ctod); + g_slist_foreach (md->startup_sequences, sn_collect_timed_out_foreach, &ctod); tmp = ctod.list; while (tmp != NULL) @@ -173,14 +163,14 @@ sn_startup_sequence_timeout (void *data) g_slist_free (ctod.list); - if (startup_sequences != NULL) + if (md->startup_sequences != NULL) { return TRUE; } else { /* remove */ - startup_sequence_timeout = 0; + md->startup_sequence_timeout = 0; return FALSE; } } @@ -190,10 +180,11 @@ sn_screen_event (SnMonitorEvent * event, void *user_data) { const char *wmclass; SnStartupSequence *sequence; - + ScreenData *md = (ScreenData *) user_data; + g_return_if_fail (sn_display != NULL); - g_return_if_fail (sn_context != NULL); g_return_if_fail (event != NULL); + g_return_if_fail (md != NULL); sequence = sn_monitor_event_get_startup_sequence (event); @@ -201,12 +192,11 @@ sn_screen_event (SnMonitorEvent * event, void *user_data) { case SN_MONITOR_EVENT_INITIATED: wmclass = sn_startup_sequence_get_wmclass (sequence); - sn_add_sequence (sequence); + sn_add_sequence (md, sequence); break; case SN_MONITOR_EVENT_COMPLETED: - sn_remove_sequence (sn_monitor_event_get_startup_sequence - (event)); + sn_remove_sequence (md, sn_monitor_event_get_startup_sequence (event)); break; case SN_MONITOR_EVENT_CHANGED: @@ -224,16 +214,17 @@ sn_client_startup_properties (Client * c) char *startup_id = NULL; GSList *tmp = NULL; SnStartupSequence *sequence; + ScreenData *md; + g_return_if_fail (c != NULL); g_return_if_fail (sn_display != NULL); - g_return_if_fail (sn_context != NULL); startup_id = clientGetStartupId (c); - + md = c->md; sequence = NULL; if (startup_id == NULL) { - tmp = startup_sequences; + tmp = md->startup_sequences; while (tmp != NULL) { const char *wmclass; @@ -267,7 +258,7 @@ sn_client_startup_properties (Client * c) if (sequence == NULL) { - tmp = startup_sequences; + tmp = md->startup_sequences; while (tmp != NULL) { const char *id; @@ -303,22 +294,22 @@ sn_client_startup_properties (Client * c) } void -sn_init_display (Display * dpy, int screen) +sn_init_display (ScreenData *md) { sn_display = NULL; - sn_context = NULL; - g_return_if_fail (dpy != NULL); + g_return_if_fail (md != NULL); + g_return_if_fail (md->dpy != NULL); - sn_display = sn_display_new (dpy, sn_error_trap_push, sn_error_trap_pop); + sn_display = sn_display_new (md->dpy, sn_error_trap_push, sn_error_trap_pop); + md->sn_context = NULL; if (sn_display != NULL) { - sn_context = - sn_monitor_context_new (sn_display, screen, sn_screen_event, NULL, - NULL); + md->sn_context = + sn_monitor_context_new (sn_display, md->screen, sn_screen_event, md, NULL); } - startup_sequences = NULL; - startup_sequence_timeout = 0; + md->startup_sequences = NULL; + md->startup_sequence_timeout = 0; } void diff --git a/src/startup_notification.h b/src/startup_notification.h index b80d4bb92..42dff6442 100644 --- a/src/startup_notification.h +++ b/src/startup_notification.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Metacity - (c) 2003 Havoc Pennington - xfwm4 - (c) 2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -30,17 +30,18 @@ #include <libsn/sn.h> +#include "screen.h" #include "client.h" void sn_client_startup_properties (Client *); -void sn_init_display (Display *, int); +void sn_init_display (ScreenData *md); void sn_close_display (void); void sn_process_event (XEvent * event); #else /* HAVE_LIBSTARTUP_NOTIFICATION */ #define sn_client_startup_properties(c) ; -#define sn_init_display(d,i) ; +#define sn_init_display(d) ; #define sn_close_display() ; #define sn_process_event(e) ; diff --git a/src/tabwin.c b/src/tabwin.c index 0c816c20a..bffbd91fb 100644 --- a/src/tabwin.c +++ b/src/tabwin.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -13,7 +13,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - xfwm4 - (c) 2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ diff --git a/src/tabwin.h b/src/tabwin.h index 9b33029c9..3319a5170 100644 --- a/src/tabwin.h +++ b/src/tabwin.h @@ -1,9 +1,9 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. - + the Free Software Foundation; either version 2, or (at your option) + any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -13,7 +13,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - xfwm4 - (c) 2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ diff --git a/src/transients.c b/src/transients.c index f0b235c90..c3a70f880 100644 --- a/src/transients.c +++ b/src/transients.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -24,7 +24,7 @@ #include <glib.h> #include <libxfce4util/libxfce4util.h> -#include "main.h" +#include "screen.h" #include "client.h" #include "stacking.h" @@ -37,7 +37,7 @@ clientGetTransient (Client * c) TRACE ("entering clientGetTransient"); - if ((c->transient_for) && (c->transient_for != md->xroot)) + if ((c->transient_for) && (c->transient_for != c->md->xroot)) { c2 = clientGetFromWindow (c->transient_for, WINDOW); return c2; @@ -52,8 +52,8 @@ clientIsTransient (Client * c) TRACE ("entering clientIsTransient"); - return (((c->transient_for != md->xroot) && (c->transient_for != None)) || - ((c->transient_for == md->xroot) && (c->group_leader != None))); + return (((c->transient_for != c->md->xroot) && (c->transient_for != None)) || + ((c->transient_for == c->md->xroot) && (c->group_leader != None))); } gboolean @@ -64,7 +64,7 @@ clientIsModal (Client * c) TRACE ("entering clientIsModal"); return (FLAG_TEST (c->flags, CLIENT_FLAG_STATE_MODAL) && - (((c->transient_for != md->xroot) && (c->transient_for != None)) || + (((c->transient_for != c->md->xroot) && (c->transient_for != None)) || (c->group_leader != None))); } @@ -103,7 +103,7 @@ clientIsTransientFor (Client * c1, Client * c2) if ((c1->transient_for) && (c1->serial >= c2->serial)) { - if (c1->transient_for != md->xroot) + if (c1->transient_for != c1->md->xroot) { return (c1->transient_for == c2->window); } @@ -148,7 +148,7 @@ clientIsTransientForGroup (Client * c) TRACE ("entering clientIsTransientForGroup"); - return ((c->transient_for == md->xroot) && (c->group_leader != None)); + return ((c->transient_for == c->md->xroot) && (c->group_leader != None)); } gboolean diff --git a/src/transients.h b/src/transients.h index 938d649da..38d727a90 100644 --- a/src/transients.h +++ b/src/transients.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/src/workspaces.c b/src/workspaces.c index d0a1a4429..602bdb9b2 100644 --- a/src/workspaces.c +++ b/src/workspaces.c @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -30,7 +30,7 @@ #include <gtk/gtk.h> #include <libxfce4util/libxfce4util.h> -#include "main.h" +#include "screen.h" #include "misc.h" #include "transients.h" #include "workspaces.h" @@ -41,7 +41,7 @@ #include "hints.h" void -workspaceSwitch (int new_ws, Client * c2) +workspaceSwitch (ScreenData *md, int new_ws, Client * c2) { Client *c, *new_focus = NULL; Client *previous; @@ -91,7 +91,7 @@ workspaceSwitch (int new_ws, Client * c2) if (c == previous) { FLAG_SET (previous->flags, CLIENT_FLAG_FOCUS); - clientSetFocus (NULL, GDK_CURRENT_TIME, FOCUS_IGNORE_MODAL); + clientSetFocus (md, NULL, GDK_CURRENT_TIME, FOCUS_IGNORE_MODAL); } if (!clientIsTransientOrModal (c)) { @@ -148,7 +148,7 @@ workspaceSwitch (int new_ws, Client * c2) data[0] = new_ws; XChangeProperty (md->dpy, md->xroot, net_current_desktop, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) data, 1); - workspaceUpdateArea (md->margins, md->gnome_margins); + workspaceUpdateArea (md); /* Ungrab the pointer we grabbed before mapping/unmapping all windows */ XUngrabPointer (md->dpy, GDK_CURRENT_TIME); @@ -164,7 +164,10 @@ workspaceSwitch (int new_ws, Client * c2) } } } - clientSetFocus (new_focus, GDK_CURRENT_TIME, NO_FOCUS_FLAG); + if (new_focus) + { + clientSetFocus (new_focus->md, new_focus, GDK_CURRENT_TIME, NO_FOCUS_FLAG); + } } void @@ -180,7 +183,7 @@ workspaceSetNames (char *names, int length) } void -workspaceSetCount (int count) +workspaceSetCount (ScreenData * md, int count) { Client *c; int i; @@ -209,7 +212,7 @@ workspaceSetCount (int count) } if (md->current_ws > count - 1) { - workspaceSwitch (count - 1, NULL); + workspaceSwitch (md, count - 1, NULL); } setNetWorkarea (md->dpy, md->screen, params.workspace_count, gdk_screen_get_width (md->gscr), @@ -218,73 +221,50 @@ workspaceSetCount (int count) } void -workspaceGetArea (int * m1, int * m2, Client * c) +workspaceUpdateArea (ScreenData *md) { - Client *c2; + Client *c; + int prev_top; + int prev_left; + int prev_right; + int prev_bottom; int i; - TRACE ("entering workspaceGetArea"); + g_return_if_fail (md != NULL); + g_return_if_fail (md->margins != NULL); + g_return_if_fail (md->gnome_margins != NULL); - g_return_if_fail (m1 != NULL); + TRACE ("entering workspaceUpdateArea"); + + prev_top = md->margins[TOP]; + prev_left = md->margins[LEFT]; + prev_right = md->margins[RIGHT]; + prev_bottom = md->margins[BOTTOM]; for (i = 0; i < 4; i++) { - if (m2 == NULL) - { - m1[i] = 0; - } - else - { - m1[i] = m2[i]; - } + md->margins[i] = md->gnome_margins[i]; } - for (c2 = clients, i = 0; i < client_count; c2 = c2->next, i++) + for (c = clients, i = 0; i < client_count; c = c->next, i++) { - if (((!c) || (c != c2)) - && FLAG_TEST_ALL (c2->flags, - CLIENT_FLAG_HAS_STRUT | CLIENT_FLAG_VISIBLE)) + if (FLAG_TEST_ALL (c->flags, CLIENT_FLAG_HAS_STRUT | CLIENT_FLAG_VISIBLE)) { - m1[TOP] = MAX (m1[TOP], c2->struts[TOP]); - m1[LEFT] = MAX (m1[LEFT], c2->struts[LEFT]); - m1[RIGHT] = - MAX (m1[RIGHT], c2->struts[RIGHT]); - m1[BOTTOM] = - MAX (m1[BOTTOM], c2->struts[BOTTOM]); + md->margins[TOP] = MAX (md->margins[TOP], c->struts[TOP]); + md->margins[LEFT] = MAX (md->margins[LEFT], c->struts[LEFT]); + md->margins[RIGHT] = MAX (md->margins[RIGHT], c->struts[RIGHT]); + md->margins[BOTTOM] = MAX (md->margins[BOTTOM], c->struts[BOTTOM]); } } -} - -void -workspaceUpdateArea (int * m1, int * m2) -{ - int prev_top; - int prev_left; - int prev_right; - int prev_bottom; - - g_return_if_fail (m1 != NULL); - g_return_if_fail (m2 != NULL); - - TRACE ("entering workspaceUpdateArea"); - - prev_top = m1[TOP]; - prev_left = m1[LEFT]; - prev_right = m1[RIGHT]; - prev_bottom = m1[BOTTOM]; - - workspaceGetArea (m1, m2, NULL); - TRACE ("Desktop area computed : (%d,%d,%d,%d)", (int) m1[0], (int) m1[1], - (int) m1[2], (int) m1[3]); - if ((prev_top != m1[TOP]) || (prev_left != m1[LEFT]) - || (prev_right != m1[RIGHT]) - || (prev_bottom != m1[BOTTOM])) + if ((prev_top != md->margins[TOP]) || (prev_left != md->margins[LEFT]) + || (prev_right != md->margins[RIGHT]) + || (prev_bottom != md->margins[BOTTOM])) { TRACE ("Margins have changed, updating net_workarea"); setNetWorkarea (md->dpy, md->screen, params.workspace_count, gdk_screen_get_width (md->gscr), gdk_screen_get_height (md->gscr), - m1); + md->margins); } } diff --git a/src/workspaces.h b/src/workspaces.h index c78159956..78ddaae42 100644 --- a/src/workspaces.h +++ b/src/workspaces.h @@ -1,8 +1,8 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; You may only use version 2 of the License, - you have no option to use any other version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2003 Olivier Fourdan + xfwm4 - (c) 2002-2004 Olivier Fourdan */ @@ -28,12 +28,12 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xmd.h> +#include "screen.h" #include "client.h" -void workspaceSwitch (int, Client *); +void workspaceSwitch (ScreenData *, int, Client *); void workspaceSetNames (char *, int); -void workspaceSetCount (int); -void workspaceGetArea (int *, int *, Client *); -void workspaceUpdateArea (int *, int *); +void workspaceSetCount (ScreenData *, int); +void workspaceUpdateArea (ScreenData *); #endif /* INC_WORKSPACES_H */ |