From: Calvin Walton Add support for hiding/showing window decorations when maximizing windows. This patch adds support for hiding and showing window decorations of maximized windows by manipulating X properties. Most window managers (metacity in particular) are supported. This uses code copied from devilspie, http://burtonini.com/blog/computers/devilspie to handle switching window decorations on and off. Devil's Pie is licensed under GPL 2 or any higher version, and is thus compatible with the GPL 3 that windowapplets is licensed under. To apply this patch, run (in the windowapplets source directory) patch -p1 +#include +#include + /* Prototypes */ static void applet_change_background (PanelApplet *, PanelAppletBackgroundType, GdkColor *, GdkPixmap *); static void active_workspace_changed (WnckScreen *, WnckWorkspace *, gpointer); @@ -243,11 +248,76 @@ } } +static GHashTable *atom_hash = NULL; +static GHashTable *reverse_atom_hash = NULL; + +Atom +my_wnck_atom_get (const char *atom_name) +{ + Atom retval; + + g_return_val_if_fail (atom_name != NULL, None); + + if (!atom_hash) + { + atom_hash = g_hash_table_new (g_str_hash, g_str_equal); + reverse_atom_hash = g_hash_table_new (NULL, NULL); + } + + retval = GPOINTER_TO_UINT (g_hash_table_lookup (atom_hash, atom_name)); + if (!retval) + { + retval = XInternAtom (gdk_display, atom_name, FALSE); + + if (retval != None) + { + char *name_copy; + + name_copy = g_strdup (atom_name); + + g_hash_table_insert (atom_hash, + name_copy, + GUINT_TO_POINTER (retval)); + g_hash_table_insert (reverse_atom_hash, + GUINT_TO_POINTER (retval), + name_copy); + } + } + + return retval; +} + +static void set_decorations(WnckWindow *window, gboolean decorate) { +#define PROP_MOTIF_WM_HINTS_ELEMENTS 5 +#define MWM_HINTS_DECORATIONS (1L << 1) + struct { + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long inputMode; + unsigned long status; + } hints = {0,}; + + hints.flags = MWM_HINTS_DECORATIONS; + hints.decorations = decorate ? 1 : 0; + + /* Set Motif hints, most window managers handle these */ + XChangeProperty(GDK_DISPLAY(), wnck_window_get_xid (window), + my_wnck_atom_get ("_MOTIF_WM_HINTS"), + my_wnck_atom_get ("_MOTIF_WM_HINTS"), 32, PropModeReplace, + (unsigned char *)&hints, PROP_MOTIF_WM_HINTS_ELEMENTS); +} + /* Updates the images according to preferences and the current window situation */ void updateImages (WBApplet *wbapplet) { WnckWindow *controlledwindow; int i; + if (wbapplet->activewindow) { + set_decorations(wbapplet->activewindow, + !wnck_window_is_maximized(wbapplet->activewindow)); + } + if (wbapplet->prefs->only_maximized) { controlledwindow = wbapplet->currentwindow; } else {