summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Fourdan <fourdan.olivier@wanadoo.fr>2004-09-28 21:55:55 +0000
committerOlivier Fourdan <fourdan.olivier@wanadoo.fr>2004-09-28 21:55:55 +0000
commitc3fd2a0efbae741d47d4bbda8b3c80e6e38edb7f (patch)
tree89bcaba8fe8f2c719ff29ad35f8a8b5b8cccca68
parentf6c00d955c317172f1ac7e02e306d7c1d28d6652 (diff)
downloadxfwm4-c3fd2a0efbae741d47d4bbda8b3c80e6e38edb7f.tar.gz
Don't grab the server when cycling windows (but still show the frame shadow),
Add a "--help" usage message. (Old svn revision: 11997)
-rw-r--r--src/Makefile.am4
-rw-r--r--src/Makefile.in32
-rw-r--r--src/client.c54
-rw-r--r--src/main.c44
-rw-r--r--src/wireframe.c127
-rw-r--r--src/wireframe.h37
6 files changed, 253 insertions, 45 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index b942889df..33302672c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -55,7 +55,9 @@ xfwm4_SOURCES = \
transients.c \
transients.h \
workspaces.c \
- workspaces.h
+ workspaces.h \
+ wireframe.c \
+ wireframe.h
xfwm4_CFLAGS = \
@LIBX11_CFLAGS@ \
diff --git a/src/Makefile.in b/src/Makefile.in
index 01847e9a8..062a92979 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -66,7 +66,7 @@ am_xfwm4_OBJECTS = xfwm4-client.$(OBJEXT) xfwm4-compositor.$(OBJEXT) \
xfwm4-settings.$(OBJEXT) xfwm4-spinning_cursor.$(OBJEXT) \
xfwm4-stacking.$(OBJEXT) xfwm4-startup_notification.$(OBJEXT) \
xfwm4-tabwin.$(OBJEXT) xfwm4-transients.$(OBJEXT) \
- xfwm4-workspaces.$(OBJEXT)
+ xfwm4-workspaces.$(OBJEXT) xfwm4-wireframe.$(OBJEXT)
xfwm4_OBJECTS = $(am_xfwm4_OBJECTS)
xfwm4_DEPENDENCIES =
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
@@ -98,6 +98,7 @@ am__depfiles_maybe = depfiles
@AMDEP_TRUE@ ./$(DEPDIR)/xfwm4-startup_notification.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/xfwm4-tabwin.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/xfwm4-transients.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/xfwm4-wireframe.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/xfwm4-workspaces.Po
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -320,7 +321,9 @@ xfwm4_SOURCES = \
transients.c \
transients.h \
workspaces.c \
- workspaces.h
+ workspaces.h \
+ wireframe.c \
+ wireframe.h
xfwm4_CFLAGS = \
@LIBX11_CFLAGS@ \
@@ -447,6 +450,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfwm4-startup_notification.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfwm4-tabwin.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfwm4-transients.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfwm4-wireframe.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfwm4-workspaces.Po@am__quote@
.c.o:
@@ -1121,6 +1125,30 @@ xfwm4-workspaces.lo: workspaces.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfwm4_CFLAGS) $(CFLAGS) -c -o xfwm4-workspaces.lo `test -f 'workspaces.c' || echo '$(srcdir)/'`workspaces.c
+xfwm4-wireframe.o: wireframe.c
+@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfwm4_CFLAGS) $(CFLAGS) -MT xfwm4-wireframe.o -MD -MP -MF "$(DEPDIR)/xfwm4-wireframe.Tpo" -c -o xfwm4-wireframe.o `test -f 'wireframe.c' || echo '$(srcdir)/'`wireframe.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfwm4-wireframe.Tpo" "$(DEPDIR)/xfwm4-wireframe.Po"; else rm -f "$(DEPDIR)/xfwm4-wireframe.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='wireframe.c' object='xfwm4-wireframe.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/xfwm4-wireframe.Po' tmpdepfile='$(DEPDIR)/xfwm4-wireframe.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfwm4_CFLAGS) $(CFLAGS) -c -o xfwm4-wireframe.o `test -f 'wireframe.c' || echo '$(srcdir)/'`wireframe.c
+
+xfwm4-wireframe.obj: wireframe.c
+@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfwm4_CFLAGS) $(CFLAGS) -MT xfwm4-wireframe.obj -MD -MP -MF "$(DEPDIR)/xfwm4-wireframe.Tpo" -c -o xfwm4-wireframe.obj `if test -f 'wireframe.c'; then $(CYGPATH_W) 'wireframe.c'; else $(CYGPATH_W) '$(srcdir)/wireframe.c'; fi`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfwm4-wireframe.Tpo" "$(DEPDIR)/xfwm4-wireframe.Po"; else rm -f "$(DEPDIR)/xfwm4-wireframe.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='wireframe.c' object='xfwm4-wireframe.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/xfwm4-wireframe.Po' tmpdepfile='$(DEPDIR)/xfwm4-wireframe.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfwm4_CFLAGS) $(CFLAGS) -c -o xfwm4-wireframe.obj `if test -f 'wireframe.c'; then $(CYGPATH_W) 'wireframe.c'; else $(CYGPATH_W) '$(srcdir)/wireframe.c'; fi`
+
+xfwm4-wireframe.lo: wireframe.c
+@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfwm4_CFLAGS) $(CFLAGS) -MT xfwm4-wireframe.lo -MD -MP -MF "$(DEPDIR)/xfwm4-wireframe.Tpo" -c -o xfwm4-wireframe.lo `test -f 'wireframe.c' || echo '$(srcdir)/'`wireframe.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfwm4-wireframe.Tpo" "$(DEPDIR)/xfwm4-wireframe.Plo"; else rm -f "$(DEPDIR)/xfwm4-wireframe.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='wireframe.c' object='xfwm4-wireframe.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/xfwm4-wireframe.Plo' tmpdepfile='$(DEPDIR)/xfwm4-wireframe.TPlo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfwm4_CFLAGS) $(CFLAGS) -c -o xfwm4-wireframe.lo `test -f 'wireframe.c' || echo '$(srcdir)/'`wireframe.c
+
mostlyclean-libtool:
-rm -f *.lo
diff --git a/src/client.c b/src/client.c
index 2a2545101..8b1fe3028 100644
--- a/src/client.c
+++ b/src/client.c
@@ -34,26 +34,27 @@
#include <libxfce4util/libxfce4util.h>
#include <libxfcegui4/libxfcegui4.h>
-#include "screen.h"
-#include "misc.h"
#include "client.h"
+#include "compositor.h"
+#include "focus.h"
#include "frame.h"
#include "hints.h"
-#include "workspaces.h"
+#include "icons.h"
+#include "misc.h"
#include "mypixmap.h"
#include "mywindow.h"
-#include "settings.h"
-#include "tabwin.h"
+#include "netwm.h"
+#include "placement.h"
#include "poswin.h"
+#include "screen.h"
#include "session.h"
-#include "netwm.h"
-#include "focus.h"
-#include "transients.h"
+#include "settings.h"
#include "stacking.h"
-#include "placement.h"
-#include "icons.h"
#include "startup_notification.h"
-#include "compositor.h"
+#include "tabwin.h"
+#include "transients.h"
+#include "wireframe.h"
+#include "workspaces.h"
/* Event mask definition */
@@ -115,6 +116,7 @@ struct _ClientCycleData
{
Client *c;
Tabwin *tabwin;
+ Window wireframe;
int cycle_range;
};
@@ -3569,9 +3571,6 @@ clientCycle_event_filter (XEvent * xevent, gpointer data)
case KeyPress:
if (gone || key_pressed)
{
- /* Hide frame draw */
- clientDrawOutline (c);
-
if (key_pressed)
{
/* If KEY_CYCLE_WINDOWS has Shift, then do not reverse */
@@ -3588,13 +3587,18 @@ clientCycle_event_filter (XEvent * xevent, gpointer data)
passdata->c = c;
}
}
+ else if (gone)
+ {
+
+ c = clientGetPrevious (c, passdata->cycle_range);
+ passdata->c = c;
+ }
if (c)
{
GdkPixbuf *icon;
- /* Redraw frame draw */
- clientDrawOutline (c);
+ wireframeUpdate (c, passdata->wireframe);
icon = getAppIcon (clientGetXDisplay (c), c->window, 32, 32);
tabwinSetLabel (passdata->tabwin, icon,
c->class.res_class, c->name);
@@ -3609,7 +3613,7 @@ clientCycle_event_filter (XEvent * xevent, gpointer data)
{
int keysym = XKeycodeToKeysym (clientGetXDisplay (c), xevent->xkey.keycode, 0);
- /* If KEY_CYCE_WINDOWS has Shift, then stop cycling on Shift
+ /* If KEY_CYCLE_WINDOWS has Shift, then stop cycling on Shift
* release.
*/
if (IsModifierKey (keysym)
@@ -3674,7 +3678,6 @@ clientCycle (Client * c, XEvent * e)
return;
}
- myDisplayGrabServer (display_info);
if (screen_info->params->cycle_hidden)
{
passdata.cycle_range = INCLUDE_HIDDEN;
@@ -3692,28 +3695,19 @@ clientCycle (Client * c, XEvent * e)
{
GdkPixbuf *icon;
+ TRACE ("entering cycle loop");
+ passdata.wireframe = wireframeCreate (passdata.c);
icon = getAppIcon (display_info->dpy, passdata.c->window, 32, 32);
passdata.tabwin = tabwinCreate (passdata.c->screen_info->gscr, icon,
passdata.c->class.res_class, passdata.c->name);
-
- TRACE ("entering cycle loop");
- /* Draw frame draw */
- clientDrawOutline (passdata.c);
xfce_push_event_filter (display_info->xfilter, clientCycle_event_filter, &passdata);
gtk_main ();
xfce_pop_event_filter (display_info->xfilter);
- if (passdata.c)
- {
- /* Hide frame draw */
- clientDrawOutline (passdata.c);
- }
-
-
+ wireframeDelete (screen_info, passdata.wireframe);
TRACE ("leaving cycle loop");
tabwinDestroy (passdata.tabwin);
g_free (passdata.tabwin);
}
- myDisplayUngrabServer (display_info);
XUngrabKeyboard (display_info->dpy, GDK_CURRENT_TIME);
XUngrabPointer (display_info->dpy, GDK_CURRENT_TIME);
diff --git a/src/main.c b/src/main.c
index cc6b56cab..3c1fba055 100644
--- a/src/main.c
+++ b/src/main.c
@@ -95,7 +95,8 @@ cleanUp (void)
display_info = NULL;
}
-static char *build_session_filename(SessionClient *client_session)
+static char *
+build_session_filename(SessionClient *client_session)
{
gchar *filename, *path, *file, *tmp;
GError *error = NULL;
@@ -173,7 +174,7 @@ handleSignal (int sig)
break;
case SIGSEGV:
cleanUp ();
- g_error (_("%s: Segmentation fault"), g_get_prgname ());
+ g_error (_("%s: Segmentation fault"), PACKAGE);
break;
default:
break;
@@ -274,6 +275,27 @@ ensure_basedir_spec (void)
g_free (old);
}
+static void
+print_usage (void)
+{
+ g_print ("%s [--sm-client-id=ID] [--display=DISPLAY] \
+[--disable-compositor] [--daemon] [--version|-V] \
+[--help|-H]\n", PACKAGE);
+ exit (0);
+}
+
+static void
+print_version (void)
+{
+ g_print ("\tThis is %s version %s for Xfce %s\n",
+ PACKAGE, VERSION, xfce_version_string());
+ g_print ("\tbuilt with GTK+-%d.%d.%d, ",
+ GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
+ g_print ("linked with GTK+-%d.%d.%d.\n",
+ gtk_major_version, gtk_minor_version, gtk_micro_version);
+ exit (0);
+}
+
static int
initialize (int argc, char **argv, gboolean enable_compositor)
{
@@ -397,13 +419,11 @@ main (int argc, char **argv)
}
else if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-V"))
{
- g_print ("\tThis is %s version %s for Xfce %s\n",
- PACKAGE, VERSION, xfce_version_string());
- g_print ("\tbuilt with GTK+-%d.%d.%d, ",
- GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
- g_print ("linked with GTK+-%d.%d.%d.\n",
- gtk_major_version, gtk_minor_version, gtk_micro_version);
- exit (0);
+ print_version ();
+ }
+ else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-H"))
+ {
+ print_usage ();
}
}
@@ -412,12 +432,12 @@ main (int argc, char **argv)
{
case -1:
g_warning (_("%s: Another Window Manager is already running"),
- g_get_prgname ());
+ PACKAGE);
exit (1);
break;
case -2:
g_warning (_("%s: Missing data from default files"),
- g_get_prgname ());
+ PACKAGE);
exit (1);
break;
case 0:
@@ -455,7 +475,7 @@ main (int argc, char **argv)
gtk_main ();
break;
default:
- g_warning (_("%s: Unknown error occured"), g_get_prgname ());
+ g_warning (_("%s: Unknown error occured"), PACKAGE);
exit (1);
break;
}
diff --git a/src/wireframe.c b/src/wireframe.c
new file mode 100644
index 000000000..b6a4c12e5
--- /dev/null
+++ b/src/wireframe.c
@@ -0,0 +1,127 @@
+/* $Id$
+
+ 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.
+
+ metacity - (c) 2001 Anders Carlsson, Havoc Pennington
+ xfwm4 - (c) 2002-2004 Olivier Fourdan
+
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/extensions/shape.h>
+
+#include "screen.h"
+#include "client.h"
+
+#ifndef OUTLINE_WIDTH
+#define OUTLINE_WIDTH 3
+#endif
+
+void
+wireframeUpdate (Client *c, Window xwindow)
+{
+ g_return_if_fail (c != NULL);
+ g_return_if_fail (xwindow != None);
+
+ TRACE ("entering wireframeUpdate 0x%lx", xwindow);
+ XMoveResizeWindow (clientGetXDisplay (c), xwindow,
+ frameX (c), frameY (c), frameWidth (c), frameHeight (c));
+
+ if ((frameWidth (c) > OUTLINE_WIDTH * 2) && (frameHeight (c) > OUTLINE_WIDTH * 2))
+ {
+ XRectangle xrect;
+ Region inner_xregion;
+ Region outer_xregion;
+
+ inner_xregion = XCreateRegion ();
+ outer_xregion = XCreateRegion ();
+
+ xrect.x = 0;
+ xrect.y = 0;
+ xrect.width = frameWidth (c);
+ xrect.height = frameHeight (c);
+
+ XUnionRectWithRegion (&xrect, outer_xregion, outer_xregion);
+
+ xrect.x += OUTLINE_WIDTH;
+ xrect.y += OUTLINE_WIDTH;
+ xrect.width -= OUTLINE_WIDTH * 2;
+ xrect.height -= OUTLINE_WIDTH * 2;
+
+ XUnionRectWithRegion (&xrect, inner_xregion, inner_xregion);
+
+ XSubtractRegion (outer_xregion, inner_xregion, outer_xregion);
+
+ XShapeCombineRegion (clientGetXDisplay (c), xwindow, ShapeBounding,
+ 0, 0, outer_xregion, ShapeSet);
+
+ XDestroyRegion (outer_xregion);
+ XDestroyRegion (inner_xregion);
+ }
+ else
+ {
+ /* Unset the shape */
+ XShapeCombineMask (clientGetXDisplay (c), xwindow,
+ ShapeBounding, 0, 0, None, ShapeSet);
+ }
+}
+
+Window
+wireframeCreate (Client *c)
+{
+ ScreenInfo *screen_info;
+ XSetWindowAttributes attrs;
+ Window xwindow;
+
+ g_return_val_if_fail (c != NULL, None);
+
+ TRACE ("entering wireframeCreate");
+
+ screen_info = c->screen_info;
+ attrs.override_redirect = True;
+ attrs.background_pixel = BlackPixel (clientGetXDisplay (c),
+ screen_info->screen);
+
+ xwindow = XCreateWindow (clientGetXDisplay (c),
+ screen_info->xroot,
+ frameX (c), frameY (c),
+ frameWidth (c), frameHeight (c),
+ 0, CopyFromParent, CopyFromParent,
+ (Visual *) CopyFromParent,
+ CWOverrideRedirect | CWBackPixel, &attrs);
+
+ wireframeUpdate (c, xwindow);
+ XMapWindow (clientGetXDisplay (c), xwindow);
+
+ return (xwindow);
+}
+
+void
+wireframeDelete (ScreenInfo *screen_info, Window xwindow)
+{
+ g_return_if_fail (screen_info != NULL);
+ g_return_if_fail (xwindow != None);
+
+ TRACE ("entering wireframeDelete 0x%lx", xwindow);
+ XUnmapWindow (myScreenGetXDisplay (screen_info), xwindow);
+ XDestroyWindow (myScreenGetXDisplay (screen_info), xwindow);
+}
+
diff --git a/src/wireframe.h b/src/wireframe.h
new file mode 100644
index 000000000..2b8b4be0c
--- /dev/null
+++ b/src/wireframe.h
@@ -0,0 +1,37 @@
+/* $Id$
+
+ 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.
+
+ metacity - (c) 2001 Anders Carlsson, Havoc Pennington
+ xfwm4 - (c) 2002-2004 Olivier Fourdan
+
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifndef INC_WIREFRAME_H
+#define INC_WIREFRAME_H
+
+#include <X11/Xlib.h>
+#include "screen.h"
+#include "client.h"
+
+void wireframeUpdate (Client *c, Window xwindow);
+Window wireframeCreate (Client *c);
+void wireframeDestroy (ScreenInfo *screen_info, Window xwindow);
+
+#endif /* INC_WIREFRAME_H */