missing
.dirstamp
openbox/openbox
-parser/obparser-3.0.pc
+parser/obparser-4.0.pc
po/Makefile.in.in
po/Makevars.template
po/POTFILES
po/en@quot.insert-header
po/remove-potcdate.sed
*.gmo
-render/obrender-3.0.pc
+render/obrender-4.0.pc
+obt/obt-4.0.pc
tools/gnome-panel-control/gnome-panel-control
version.h
.libs
xsessionsdir = $(datadir)/xsessions
gnomewmfilesdir = $(datadir)/gnome/wm-properties
pkgconfigdir = $(libdir)/pkgconfig
-pubincludedir = $(includedir)/openbox/@OB_VERSION@/openbox
+obtpubincludedir= $(includedir)/openbox/@OBT_VERSION@/obt
+rrpubincludedir = $(includedir)/openbox/@RR_VERSION@/render
pixmapdir = $(datadir)/pixmaps
xsddir = $(datadir)/openbox
render/rendertest
lib_LTLIBRARIES = \
- parser/libobparser.la \
- render/libobrender.la
+ render/libobrender.la \
+ obt/libobt.la
bin_PROGRAMS = \
openbox/openbox \
$(GLIB_CFLAGS) \
-DG_LOG_DOMAIN=\"RenderTest\"
render_rendertest_LDADD = \
- parser/libobparser.la \
+ obt/libobt.la \
render/libobrender.la \
$(GLIB_LIBS) \
$(PANGO_LIBS) \
-DG_LOG_DOMAIN=\"ObRender\" \
-DDEFAULT_THEME=\"$(theme)\"
render_libobrender_la_LDFLAGS = \
- -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
+ -version-info $(RR_CURRENT):$(RR_REVISION):$(RR_AGE)
render_libobrender_la_LIBADD = \
- parser/libobparser.la \
+ obt/libobt.la \
$(X_LIBS) \
$(PANGO_LIBS) \
$(XFT_LIBS) \
render/icon.h \
render/image.h \
render/image.c \
+ render/imagecache.h \
+ render/imagecache.c \
render/instance.h \
render/instance.c \
render/mask.h \
render/theme.h \
render/theme.c
-## parser ##
+## obt ##
-parser_libobparser_la_CPPFLAGS = \
+obt_libobt_la_CPPFLAGS = \
+ $(XINERAMA_CFLAGS) \
+ $(XKB_CFLAGS) \
+ $(XRANDR_CFLAGS) \
+ $(XSHAPE_CFLAGS) \
+ $(XSYNC_CFLAGS) \
$(GLIB_CFLAGS) \
$(XML_CFLAGS) \
- -DG_LOG_DOMAIN=\"ObParser\" \
+ -DG_LOG_DOMAIN=\"Obt\" \
-DLOCALEDIR=\"$(localedir)\" \
-DDATADIR=\"$(datadir)\" \
-DCONFIGDIR=\"$(configdir)\"
-parser_libobparser_la_LDFLAGS = \
- -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
-parser_libobparser_la_LIBADD = \
+obt_libobt_la_LDFLAGS = \
+ -version-info $(OBT_CURRENT):$(OBT_REVISION):$(OBT_AGE)
+obt_libobt_la_LIBADD = \
+ $(XINERAMA_LIBS) \
+ $(XKB_LIBS) \
+ $(XRANDR_LIBS) \
+ $(XSHAPE_LIBS) \
+ $(XSYNC_LIBS) \
$(GLIB_LIBS) \
- $(XML_LIBS)
-parser_libobparser_la_SOURCES = \
- parser/parse.h \
- parser/parse.c
+ $(XML_LIBS)
+obt_libobt_la_SOURCES = \
+ obt/display.h \
+ obt/display.c \
+ obt/internal.h \
+ obt/keyboard.h \
+ obt/keyboard.c \
+ obt/mainloop.h \
+ obt/mainloop.c \
+ obt/parse.h \
+ obt/parse.c \
+ obt/paths.h \
+ obt/paths.c \
+ obt/prop.h \
+ obt/prop.c \
+ obt/util.h \
+ obt/xevent.h \
+ obt/xevent.c
## openbox ##
openbox_openbox_CPPFLAGS = \
$(SM_CFLAGS) \
- $(XINERAMA_CFLAGS) \
- $(XKB_CFLAGS) \
- $(XRANDR_CFLAGS) \
- $(XSHAPE_CFLAGS) \
- $(XSYNC_CFLAGS) \
$(X_CFLAGS) \
$(XCURSOR_CFLAGS) \
$(SM_CFLAGS) \
-DG_LOG_DOMAIN=\"Openbox\"
openbox_openbox_LDADD = \
$(SM_LIBS) \
- $(XINERAMA_LIBS) \
- $(XKB_LIBS) \
- $(XRANDR_LIBS) \
- $(XSHAPE_LIBS) \
- $(XSYNC_LIBS) \
$(GLIB_LIBS) \
$(X_LIBS) \
$(XCURSOR_LIBS) \
$(EFENCE_LIBS) \
$(LIBINTL) \
render/libobrender.la \
- parser/libobparser.la
+ obt/libobt.la
openbox_openbox_LDFLAGS = -export-dynamic
openbox_openbox_SOURCES = \
gettext.h \
openbox/dock.h \
openbox/event.c \
openbox/event.h \
- openbox/extensions.c \
- openbox/extensions.h \
openbox/focus.c \
openbox/focus.h \
openbox/focus_cycle.c \
openbox/keyboard.h \
openbox/keytree.c \
openbox/keytree.h \
- openbox/mainloop.c \
- openbox/mainloop.h \
openbox/menuframe.c \
openbox/menuframe.h \
openbox/menu.c \
openbox/menu.h \
openbox/misc.h \
- openbox/modkeys.c \
- openbox/modkeys.h \
openbox/mouse.c \
openbox/mouse.h \
openbox/moveresize.c \
openbox/prompt.h \
openbox/popup.c \
openbox/popup.h \
- openbox/prop.c \
- openbox/prop.h \
openbox/resist.c \
openbox/resist.h \
openbox/screen.c \
openbox/translate.c \
openbox/translate.h \
openbox/window.c \
- openbox/window.h \
- openbox/xerror.c \
- openbox/xerror.h
-
+ openbox/window.h
## gnome-panel-control ##
## public headers ##
-pubinclude_HEADERS = \
+rrpubinclude_HEADERS = \
render/color.h \
render/font.h \
render/geom.h \
render/mask.h \
render/render.h \
render/theme.h \
- parser/parse.h
-
-nodist_pubinclude_HEADERS = \
- version.h
+ render/version.h
+
+obtpubinclude_HEADERS = \
+ obt/display.h \
+ obt/keyboard.h \
+ obt/mainloop.h \
+ obt/parse.h \
+ obt/paths.h \
+ obt/prop.h \
+ obt/util.h \
+ obt/version.h \
+ obt/xevent.h
nodist_pkgconfig_DATA = \
- render/obrender-3.0.pc \
- parser/obparser-3.0.pc
+ render/obrender-4.0.pc \
+ obt/obt-4.0.pc
## data ##
data/xsession/openbox-kde.desktop
dist_noinst_DATA = \
- version.h.in \
data/rc.xsd \
data/menu.xsd \
data/xsession/openbox.desktop.in \
doc/openbox-gnome-session.1.in \
doc/openbox-kde-session.1.sgml \
doc/openbox-kde-session.1.in \
- render/obrender-3.0.pc.in \
- parser/obparser-3.0.pc.in \
+ render/version.h.in \
+ render/obrender-4.0.pc.in \
+ obt/obt-4.0.pc.in \
+ obt/version.h.in \
tools/themeupdate/themeupdate.py \
tests/hideshow.py \
tests/Makefile \
# $(MAKE) -$(MAKEFLAGS) -C doc/doxygen doc
distclean-local:
- for d in . m4 po render; do \
+ for d in . m4 po render parser obt openbox; do \
for p in core core.* gmon.out *\~ *.orig *.rej .\#*; do \
rm -f "$$d/$$p"; \
done \
A C Compiler (GNU GCC 3.2+ suggested)
GNU Gettext 0.14.4
GNU Autoconf 2.50+
-GNU Automake 1.9+
+GNU Automake 1.9 (no more, no less)
GNU Libtool
Xlib library/headers (devel package)
Pkg-Config
AC_CONFIG_SRCDIR([openbox/openbox.c])
dnl Making releases:
-dnl OB_MICRO_VERSION += 1;
-dnl OB_INTERFACE_AGE += 1;
-dnl OB_BINARY_AGE += 1;
-dnl if any functions have been added, set OB_INTERFACE_AGE to 0.
+dnl RR_MICRO_VERSION += 1;
+dnl RR_INTERFACE_AGE += 1;
+dnl R_BINARY_AGE += 1;
+dnl if any functions have been added, set RR_INTERFACE_AGE to 0.
dnl if backwards compatibility has been broken,
-dnl set OB_BINARY_AGE and OB_INTERFACE_AGE to 0.
+dnl set RR_BINARY_AGE and RR_INTERFACE_AGE to 0.
dnl
dnl if MAJOR or MINOR version changes, be sure to change AC_INIT above to match
dnl
-OB_MAJOR_VERSION=3
-OB_MINOR_VERSION=4
-OB_MICRO_VERSION=16
-OB_INTERFACE_AGE=0
-OB_BINARY_AGE=0
-OB_VERSION=$OB_MAJOR_VERSION.$OB_MINOR_VERSION
-
-AC_SUBST(OB_MAJOR_VERSION)
-AC_SUBST(OB_MINOR_VERSION)
-AC_SUBST(OB_MICRO_VERSION)
-AC_SUBST(OB_INTERFACE_AGE)
-AC_SUBST(OB_BINARY_AGE)
-AC_SUBST(OB_VERSION)
+RR_MAJOR_VERSION=4
+RR_MINOR_VERSION=0
+RR_MICRO_VERSION=17
+RR_INTERFACE_AGE=0
+RR_BINARY_AGE=0
+RR_VERSION=$RR_MAJOR_VERSION.$RR_MINOR_VERSION
+
+OBT_MAJOR_VERSION=4
+OBT_MINOR_VERSION=0
+OBT_MICRO_VERSION=0
+OBT_INTERFACE_AGE=0
+OBT_BINARY_AGE=0
+OBT_VERSION=$OBT_MAJOR_VERSION.$OBT_MINOR_VERSION
+
+AC_SUBST(RR_MAJOR_VERSION)
+AC_SUBST(RR_MINOR_VERSION)
+AC_SUBST(RR_MICRO_VERSION)
+AC_SUBST(RR_INTERFACE_AGE)
+AC_SUBST(RR_BINARY_AGE)
+AC_SUBST(RR_VERSION)
+AC_SUBST(OBT_MAJOR_VERSION)
+AC_SUBST(OBT_MINOR_VERSION)
+AC_SUBST(OBT_MICRO_VERSION)
+AC_SUBST(OBT_INTERFACE_AGE)
+AC_SUBST(OBT_BINARY_AGE)
+AC_SUBST(OBT_VERSION)
dnl Libtool versioning
-LT_RELEASE=$OB_MAJOR_VERSION.$OB_MINOR_VERSION
-LT_CURRENT=`expr $OB_MICRO_VERSION - $OB_INTERFACE_AGE`
-LT_REVISION=$OB_INTERFACE_AGE
-LT_AGE=`expr $OB_BINARY_AGE - $OB_INTERFACE_AGE`
-LT_CURRENT_MINUS_AGE=`expr $LT_CURRENT - $LT_AGE`
-
-AC_SUBST(LT_RELEASE)
-AC_SUBST(LT_CURRENT)
-AC_SUBST(LT_REVISION)
-AC_SUBST(LT_AGE)
-AC_SUBST(LT_CURRENT_MINUS_AGE)
+RR_RELEASE=$RR_MAJOR_VERSION.$RR_MINOR_VERSION
+RR_CURRENT=`expr $RR_MICRO_VERSION - $RR_INTERFACE_AGE`
+RR_REVISION=$RR_INTERFACE_AGE
+RR_AGE=`expr $RR_BINARY_AGE - $RR_INTERFACE_AGE`
+RR_CURRENT_MINUS_AGE=`expr $RR_CURRENT - $RR_AGE`
+
+OBT_RELEASE=$OBT_MAJOR_VERSION.$OBT_MINOR_VERSION
+OBT_CURRENT=`expr $OBT_MICRO_VERSION - $OBT_INTERFACE_AGE`
+OBT_REVISION=$OBT_INTERFACE_AGE
+OBT_AGE=`expr $OBT_BINARY_AGE - $OBT_INTERFACE_AGE`
+OBT_CURRENT_MINUS_AGE=`expr $OBT_CURRENT - $OBT_AGE`
+
+AC_SUBST(RR_RELEASE)
+AC_SUBST(RR_CURRENT)
+AC_SUBST(RR_REVISION)
+AC_SUBST(RR_AGE)
+AC_SUBST(RR_CURRENT_MINUS_AGE)
+AC_SUBST(OBT_RELEASE)
+AC_SUBST(OBT_CURRENT)
+AC_SUBST(OBT_REVISION)
+AC_SUBST(OBT_AGE)
+AC_SUBST(OBT_CURRENT_MINUS_AGE)
AC_PREFIX_DEFAULT([/usr/local])
test "$prefix" = "NONE" && prefix=$ac_default_prefix
Makefile
m4/Makefile
po/Makefile.in
- render/obrender-3.0.pc
- parser/obparser-3.0.pc
- version.h
+ render/obrender-4.0.pc
+ obt/obt-4.0.pc
+ render/version.h
+ obt/version.h
])
AC_CONFIG_COMMANDS([doc],
[test -d doc || mkdir doc])
</mousebind>
<mousebind button="Up" action="Click">
- <action name="Shade"/>
- <action name="FocusToBottom"/>
- <action name="Unfocus"/>
- <action name="Lower"/>
+ <action name="if">
+ <shaded>no</shaded>
+ <then>
+ <action name="Shade"/>
+ <action name="FocusToBottom"/>
+ <action name="Unfocus"/>
+ <action name="Lower"/>
+ </then>
+ </action>
</mousebind>
<mousebind button="Down" action="Click">
- <action name="Unshade"/>
- <action name="Raise"/>
+ <action name="if">
+ <shaded>yes</shaded>
+ <then>
+ <action name="Unshade"/>
+ <action name="Raise"/>
+ </then>
+ </action>
</mousebind>
<mousebind button="Right" action="Press">
</context>
<context name="Desktop">
- <mousebind button="Up" action="Press">
+ <mousebind button="Up" action="Click">
<action name="GoToDesktop"><to>previous</to></action>
</mousebind>
- <mousebind button="Down" action="Press">
+ <mousebind button="Down" action="Click">
<action name="GoToDesktop"><to>next</to></action>
</mousebind>
- <mousebind button="A-Up" action="Press">
+ <mousebind button="A-Up" action="Click">
<action name="GoToDesktop"><to>previous</to></action>
</mousebind>
- <mousebind button="A-Down" action="Press">
+ <mousebind button="A-Down" action="Click">
<action name="GoToDesktop"><to>next</to></action>
</mousebind>
- <mousebind button="C-A-Up" action="Press">
+ <mousebind button="C-A-Up" action="Click">
<action name="GoToDesktop"><to>previous</to></action>
</mousebind>
- <mousebind button="C-A-Down" action="Press">
+ <mousebind button="C-A-Down" action="Click">
<action name="GoToDesktop"><to>next</to></action>
</mousebind>
</context>
<context name="MoveResize">
- <mousebind button="Up" action="Press">
+ <mousebind button="Up" action="Click">
<action name="GoToDesktop"><to>previous</to></action>
</mousebind>
- <mousebind button="Down" action="Press">
+ <mousebind button="Down" action="Click">
<action name="GoToDesktop"><to>next</to></action>
</mousebind>
- <mousebind button="A-Up" action="Press">
+ <mousebind button="A-Up" action="Click">
<action name="GoToDesktop"><to>previous</to></action>
</mousebind>
- <mousebind button="A-Down" action="Press">
+ <mousebind button="A-Down" action="Click">
<action name="GoToDesktop"><to>next</to></action>
</mousebind>
</context>
if test "$GCC" = "yes"; then
AC_MSG_RESULT([yes])
if test "$DEBUG" = "yes"; then
- FLAGS="$FLAGS -O0 -g3 -fno-inline -Wwrite-strings"
+ FLAGS="$FLAGS -O0 -ggdb -fno-inline -Wwrite-strings"
FLAGS="$FLAGS -Wall -Wsign-compare -Waggregate-return"
FLAGS="$FLAGS -Wcast-qual -Wbad-function-cast -Wpointer-arith"
# for Python.h
--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ obt/display.c for the Openbox window manager
+ Copyright (c) 2007 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#include "obt/display.h"
+#include "obt/prop.h"
+#include "obt/internal.h"
+#include "obt/keyboard.h"
+
+#ifdef HAVE_STRING_H
+# include <string.h>
+#endif
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+Display* obt_display = NULL;
+
+gboolean obt_display_error_occured = FALSE;
+
+gboolean obt_display_extension_xkb = FALSE;
+gint obt_display_extension_xkb_basep;
+gboolean obt_display_extension_shape = FALSE;
+gint obt_display_extension_shape_basep;
+gboolean obt_display_extension_xinerama = FALSE;
+gint obt_display_extension_xinerama_basep;
+gboolean obt_display_extension_randr = FALSE;
+gint obt_display_extension_randr_basep;
+gboolean obt_display_extension_sync = FALSE;
+gint obt_display_extension_sync_basep;
+
+static gint xerror_handler(Display *d, XErrorEvent *e);
+
+static gboolean xerror_ignore = FALSE;
+
+gboolean obt_display_open(const char *display_name)
+{
+ gchar *n;
+ Display *d = NULL;
+
+ n = display_name ? g_strdup(display_name) : NULL;
+ obt_display = d = XOpenDisplay(n);
+ if (d) {
+ gint junk;
+ (void)junk;
+
+ if (fcntl(ConnectionNumber(d), F_SETFD, 1) == -1)
+ g_message("Failed to set display as close-on-exec");
+ XSetErrorHandler(xerror_handler);
+
+ /* read what extensions are present */
+#ifdef XKB
+ obt_display_extension_xkb =
+ XkbQueryExtension(d, &junk,
+ &obt_display_extension_xkb_basep, &junk,
+ NULL, NULL);
+ if (!obt_display_extension_xkb)
+ g_message("XKB extension is not present on the server");
+#endif
+
+#ifdef SHAPE
+ obt_display_extension_shape =
+ XShapeQueryExtension(d, &obt_display_extension_shape_basep,
+ &junk);
+ if (!obt_display_extension_shape)
+ g_message("X Shape extension is not present on the server");
+#endif
+
+#ifdef XINERAMA
+ obt_display_extension_xinerama =
+ XineramaQueryExtension(d,
+ &obt_display_extension_xinerama_basep,
+ &junk) && XineramaIsActive(d);
+ if (!obt_display_extension_xinerama)
+ g_message("Xinerama extension is not present on the server");
+#endif
+
+#ifdef XRANDR
+ obt_display_extension_randr =
+ XRRQueryExtension(d, &obt_display_extension_randr_basep,
+ &junk);
+ if (!obt_display_extension_randr)
+ g_message("XRandR extension is not present on the server");
+#endif
+
+#ifdef SYNC
+ obt_display_extension_sync =
+ XSyncQueryExtension(d, &obt_display_extension_sync_basep,
+ &junk) && XSyncInitialize(d, &junk, &junk);
+ if (!obt_display_extension_sync)
+ g_message("X Sync extension is not present on the server or is an "
+ "incompatible version");
+#endif
+
+ obt_prop_startup();
+ obt_keyboard_reload();
+ }
+ g_free(n);
+
+ return obt_display != NULL;
+}
+
+void obt_display_close()
+{
+ obt_keyboard_shutdown();
+ if (obt_display) XCloseDisplay(obt_display);
+}
+
+static gint xerror_handler(Display *d, XErrorEvent *e)
+{
+#ifdef DEBUG
+ gchar errtxt[128];
+
+ XGetErrorText(d, e->error_code, errtxt, 127);
+ if (!xerror_ignore) {
+ if (e->error_code == BadWindow)
+ /*g_message(_("X Error: %s\n"), errtxt)*/;
+ else
+ g_error("X Error: %s", errtxt);
+ } else
+ g_message("Ignoring XError code %d '%s'", e->error_code, errtxt);
+#else
+ (void)d; (void)e;
+#endif
+
+ obt_display_error_occured = TRUE;
+ return 0;
+}
+
+void obt_display_ignore_errors(gboolean ignore)
+{
+ XSync(obt_display, FALSE);
+ xerror_ignore = ignore;
+ if (ignore) obt_display_error_occured = FALSE;
+}
--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ obt/display.h for the Openbox window manager
+ Copyright (c) 2007 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#ifndef __obt_display_h
+#define __obt_display_h
+
+#include <X11/Xlib.h>
+#include <glib.h>
+
+#include <X11/Xutil.h> /* shape.h uses Region which is in here */
+#ifdef XKB
+#include <X11/XKBlib.h>
+#endif
+#ifdef SHAPE
+#include <X11/extensions/shape.h>
+#endif
+#ifdef XINERAMA
+#include <X11/extensions/Xinerama.h>
+#endif
+#ifdef XRANDR
+#include <X11/extensions/Xrandr.h>
+#endif
+#ifdef SYNC
+#include <X11/extensions/sync.h>
+#endif
+
+G_BEGIN_DECLS
+
+extern gboolean obt_display_error_occured;
+
+extern gboolean obt_display_extension_xkb;
+extern gint obt_display_extension_xkb_basep;
+extern gboolean obt_display_extension_shape;
+extern gint obt_display_extension_shape_basep;
+extern gboolean obt_display_extension_xinerama;
+extern gint obt_display_extension_xinerama_basep;
+extern gboolean obt_display_extension_randr;
+extern gint obt_display_extension_randr_basep;
+extern gboolean obt_display_extension_sync;
+extern gint obt_display_extension_sync_basep;
+
+extern Display* obt_display;
+
+gboolean obt_display_open(const char *display_name);
+void obt_display_close();
+
+void obt_display_ignore_errors(gboolean ignore);
+
+#define obt_root(screen) (RootWindow(obt_display, screen))
+
+G_END_DECLS
+
+#endif /*__obt_display_h*/
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
- xerror.h for the Openbox window manager
+ obt/internal.h for the Openbox window manager
+ Copyright (c) 2006 Mikael Magnusson
Copyright (c) 2003-2007 Dana Jansens
This program is free software; you can redistribute it and/or modify
See the COPYING file for a copy of the GNU General Public License.
*/
-#ifndef __xerror_h
-#define __xerror_h
+#ifndef __obt_internal_h
+#define __obt_internal_h
-#include <X11/Xlib.h>
-#include <glib.h>
+void obt_prop_startup();
-/* can be used to track errors */
-extern gboolean xerror_occured;
+void obt_keyboard_shutdown();
-gint xerror_handler(Display *, XErrorEvent *);
-
-void xerror_set_ignore(gboolean ignore);
-
-#endif
+#endif /* __obt_internal_h */
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
- modkeys.c for the Openbox window manager
+ obt/keyboard.c for the Openbox window manager
Copyright (c) 2007 Dana Jansens
This program is free software; you can redistribute it and/or modify
See the COPYING file for a copy of the GNU General Public License.
*/
-#include "modkeys.h"
-#include "openbox.h"
+#include "obt/display.h"
+#include "obt/keyboard.h"
#include <X11/Xlib.h>
#include <X11/keysym.h>
#define nth_mask(n) (1 << n)
static void set_modkey_mask(guchar mask, KeySym sym);
+void obt_keyboard_shutdown();
static XModifierKeymap *modmap;
static KeySym *keymap;
static gint min_keycode, max_keycode, keysyms_per_keycode;
/* This is a bitmask of the different masks for each modifier key */
-static guchar modkeys_keys[OB_MODKEY_NUM_KEYS];
+static guchar modkeys_keys[OBT_KEYBOARD_NUM_MODKEYS];
static gboolean alt_l = FALSE;
static gboolean meta_l = FALSE;
static gboolean super_l = FALSE;
static gboolean hyper_l = FALSE;
-void modkeys_startup(gboolean reconfigure)
+static gboolean started = FALSE;
+
+void obt_keyboard_reload()
{
gint i, j, k;
+ if (started) obt_keyboard_shutdown(); /* free stuff */
+ started = TRUE;
+
/* reset the keys to not be bound to any masks */
- for (i = 0; i < OB_MODKEY_NUM_KEYS; ++i)
+ for (i = 0; i < OBT_KEYBOARD_NUM_MODKEYS; ++i)
modkeys_keys[i] = 0;
- modmap = XGetModifierMapping(ob_display);
+ modmap = XGetModifierMapping(obt_display);
g_assert(modmap->max_keypermod > 0);
- XDisplayKeycodes(ob_display, &min_keycode, &max_keycode);
- keymap = XGetKeyboardMapping(ob_display, min_keycode,
+ XDisplayKeycodes(obt_display, &min_keycode, &max_keycode);
+ keymap = XGetKeyboardMapping(obt_display, min_keycode,
max_keycode - min_keycode + 1,
&keysyms_per_keycode);
}
/* CapsLock, Shift, and Control are special and hard-coded */
- modkeys_keys[OB_MODKEY_KEY_CAPSLOCK] = LockMask;
- modkeys_keys[OB_MODKEY_KEY_SHIFT] = ShiftMask;
- modkeys_keys[OB_MODKEY_KEY_CONTROL] = ControlMask;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_CAPSLOCK] = LockMask;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_SHIFT] = ShiftMask;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_CONTROL] = ControlMask;
}
-void modkeys_shutdown(gboolean reconfigure)
+void obt_keyboard_shutdown()
{
XFreeModifiermap(modmap);
+ modmap = NULL;
XFree(keymap);
+ keymap = NULL;
+ started = FALSE;
}
-guint modkeys_keycode_to_mask(guint keycode)
+guint obt_keyboard_keycode_to_modmask(guint keycode)
{
gint i, j;
guint mask = 0;
return mask;
}
-guint modkeys_only_modifier_masks(guint mask)
+guint obt_keyboard_only_modmasks(guint mask)
{
mask &= ALL_MASKS;
/* strip off these lock keys. they shouldn't affect key bindings */
because you could bind it to something else and it
should work as that modifier then. i think capslock
is weird in xkb. */
- mask &= ~modkeys_key_to_mask(OB_MODKEY_KEY_NUMLOCK);
- mask &= ~modkeys_key_to_mask(OB_MODKEY_KEY_SCROLLLOCK);
+ mask &= ~obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_NUMLOCK);
+ mask &= ~obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SCROLLLOCK);
return mask;
}
-guint modkeys_key_to_mask(ObModkeysKey key)
+guint obt_keyboard_modkey_to_modmask(ObtModkeysKey key)
{
return modkeys_keys[key];
}
/* find what key this is, and bind it to the mask */
if (sym == XK_Num_Lock)
- modkeys_keys[OB_MODKEY_KEY_NUMLOCK] |= mask;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_NUMLOCK] |= mask;
else if (sym == XK_Scroll_Lock)
- modkeys_keys[OB_MODKEY_KEY_SCROLLLOCK] |= mask;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_SCROLLLOCK] |= mask;
else if (sym == XK_Super_L && super_l)
- modkeys_keys[OB_MODKEY_KEY_SUPER] |= mask;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_SUPER] |= mask;
else if (sym == XK_Super_L && !super_l)
/* left takes precident over right, so erase any masks the right
key may have set */
- modkeys_keys[OB_MODKEY_KEY_SUPER] = mask, super_l = TRUE;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_SUPER] = mask, super_l = TRUE;
else if (sym == XK_Super_R && !super_l)
- modkeys_keys[OB_MODKEY_KEY_SUPER] |= mask;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_SUPER] |= mask;
else if (sym == XK_Hyper_L && hyper_l)
- modkeys_keys[OB_MODKEY_KEY_HYPER] |= mask;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_HYPER] |= mask;
else if (sym == XK_Hyper_L && !hyper_l)
- modkeys_keys[OB_MODKEY_KEY_HYPER] = mask, hyper_l = TRUE;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_HYPER] = mask, hyper_l = TRUE;
else if (sym == XK_Hyper_R && !hyper_l)
- modkeys_keys[OB_MODKEY_KEY_HYPER] |= mask;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_HYPER] |= mask;
else if (sym == XK_Alt_L && alt_l)
- modkeys_keys[OB_MODKEY_KEY_ALT] |= mask;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_ALT] |= mask;
else if (sym == XK_Alt_L && !alt_l)
- modkeys_keys[OB_MODKEY_KEY_ALT] = mask, alt_l = TRUE;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_ALT] = mask, alt_l = TRUE;
else if (sym == XK_Alt_R && !alt_l)
- modkeys_keys[OB_MODKEY_KEY_ALT] |= mask;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_ALT] |= mask;
else if (sym == XK_Meta_L && meta_l)
- modkeys_keys[OB_MODKEY_KEY_META] |= mask;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_META] |= mask;
else if (sym == XK_Meta_L && !meta_l)
- modkeys_keys[OB_MODKEY_KEY_META] = mask, meta_l = TRUE;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_META] = mask, meta_l = TRUE;
else if (sym == XK_Meta_R && !meta_l)
- modkeys_keys[OB_MODKEY_KEY_META] |= mask;
+ modkeys_keys[OBT_KEYBOARD_MODKEY_META] |= mask;
/* CapsLock, Shift, and Control are special and hard-coded */
}
-KeyCode modkeys_sym_to_code(KeySym sym)
+KeyCode obt_keyboard_keysym_to_keycode(KeySym sym)
{
gint i, j;
return 0;
}
+gchar *obt_keyboard_keycode_to_string(guint keycode)
+{
+ KeySym sym;
+
+ if ((sym = XKeycodeToKeysym(obt_display, keycode, 0)) != NoSymbol)
+ return g_locale_to_utf8(XKeysymToString(sym), -1, NULL, NULL, NULL);
+ return NULL;
+}
+
+gunichar obt_keyboard_keycode_to_unichar(guint keycode)
+{
+ gunichar unikey = 0;
+ char *key;
+
+ if ((key = obt_keyboard_keycode_to_string(keycode)) != NULL &&
+ /* don't accept keys that aren't a single letter, like "space" */
+ key[1] == '\0')
+ {
+ unikey = g_utf8_get_char_validated(key, -1);
+ if (unikey == (gunichar)-1 || unikey == (gunichar)-2 || unikey == 0)
+ unikey = 0;
+ }
+ g_free(key);
+ return unikey;
+}
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
- masks.h for the Openbox window manager
+ obt/keyboard.h for the Openbox window manager
Copyright (c) 2007 Dana Jansens
This program is free software; you can redistribute it and/or modify
See the COPYING file for a copy of the GNU General Public License.
*/
-#ifndef ob__modkeys_h
-#define ob__modkeys_h
+#ifndef __obt_keyboard_h
+#define __obt_keyboard_h
#include <glib.h>
#include <X11/Xlib.h>
+G_BEGIN_DECLS
+
/*! These keys are bound to the modifier masks in any fashion,
except for CapsLock, Shift, and Control. */
typedef enum {
- OB_MODKEY_KEY_CAPSLOCK,
- OB_MODKEY_KEY_NUMLOCK,
- OB_MODKEY_KEY_SCROLLLOCK,
- OB_MODKEY_KEY_SHIFT,
- OB_MODKEY_KEY_CONTROL,
- OB_MODKEY_KEY_SUPER,
- OB_MODKEY_KEY_HYPER,
- OB_MODKEY_KEY_META,
- OB_MODKEY_KEY_ALT,
-
- OB_MODKEY_NUM_KEYS
-} ObModkeysKey;
-
-void modkeys_startup(gboolean reconfigure);
-void modkeys_shutdown(gboolean reconfigure);
-
-/*! Get the modifier masks for a keycode. (eg. a keycode bound to Alt_L could
+ OBT_KEYBOARD_MODKEY_CAPSLOCK,
+ OBT_KEYBOARD_MODKEY_NUMLOCK,
+ OBT_KEYBOARD_MODKEY_SCROLLLOCK,
+ OBT_KEYBOARD_MODKEY_SHIFT,
+ OBT_KEYBOARD_MODKEY_CONTROL,
+ OBT_KEYBOARD_MODKEY_SUPER,
+ OBT_KEYBOARD_MODKEY_HYPER,
+ OBT_KEYBOARD_MODKEY_META,
+ OBT_KEYBOARD_MODKEY_ALT,
+
+ OBT_KEYBOARD_NUM_MODKEYS
+} ObtModkeysKey;
+
+void obt_keyboard_reload();
+
+/*! Get the modifier mask(s) for a KeyCode. (eg. a keycode bound to Alt_L could
return a mask of (Mod1Mask | Mask3Mask)) */
-guint modkeys_keycode_to_mask(guint keycode);
+guint obt_keyboard_keycode_to_modmask(guint keycode);
/*! Strip off all modifiers except for the modifier keys. This strips stuff
- like Button1Mask, and also LockMask, NumLockMask, and ScrollLockMask */
-guint modkeys_only_modifier_masks(guint mask);
+ like Button1Mask, and also LockMask, NumlockMask, and ScrolllockMask */
+guint obt_keyboard_only_modmasks(guint mask);
/*! Get the modifier masks for a modifier key. This includes both the left and
right keys when there are both. */
-guint modkeys_key_to_mask(ObModkeysKey key);
+guint obt_keyboard_modkey_to_modmask(ObtModkeysKey key);
/*! Convert a KeySym to a KeyCode, because the X function is terrible - says
valgrind. */
-KeyCode modkeys_sym_to_code(KeySym sym);
+KeyCode obt_keyboard_keysym_to_keycode(KeySym sym);
+
+/*! Give the string form of a KeyCode */
+gchar *obt_keyboard_keycode_to_string(guint keycode);
+
+/*! Translate a KeyCode to the unicode character it represents */
+gunichar obt_keyboard_keycode_to_unichar(guint keycode);
+
+
+G_END_DECLS
-#endif
+#endif /* __obt_keyboard_h */
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
- mainloop.c for the Openbox window manager
+ obt/mainloop.c for the Openbox window manager
Copyright (c) 2006 Mikael Magnusson
Copyright (c) 2003-2007 Dana Jansens
See the COPYING file for a copy of the GNU General Public License.
*/
-#include "mainloop.h"
-#include "event.h"
+#include "obt/mainloop.h"
+#include "obt/display.h"
+#include "obt/util.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/select.h>
#include <signal.h>
-typedef struct _ObMainLoopTimer ObMainLoopTimer;
-typedef struct _ObMainLoopSignal ObMainLoopSignal;
-typedef struct _ObMainLoopSignalHandlerType ObMainLoopSignalHandlerType;
-typedef struct _ObMainLoopXHandlerType ObMainLoopXHandlerType;
-typedef struct _ObMainLoopFdHandlerType ObMainLoopFdHandlerType;
+typedef struct _ObtMainLoopTimer ObtMainLoopTimer;
+typedef struct _ObtMainLoopSignal ObtMainLoopSignal;
+typedef struct _ObtMainLoopSignalHandlerType ObtMainLoopSignalHandlerType;
+typedef struct _ObtMainLoopXHandlerType ObtMainLoopXHandlerType;
+typedef struct _ObtMainLoopFdHandlerType ObtMainLoopFdHandlerType;
/* this should be more than the number of possible signals on any
architecture... */
#define NUM_SIGNALS 99
-/* all created ObMainLoops. Used by the signal handler to pass along signals */
+/* all created ObtMainLoops. Used by the signal handler to pass along
+ signals */
static GSList *all_loops;
/* signals are global to all loops */
#define NUM_CORE_SIGNALS (sizeof(core_signals) / sizeof(core_signals[0]))
static void sighandler(gint sig);
-static void timer_dispatch(ObMainLoop *loop, GTimeVal **wait);
+static void timer_dispatch(ObtMainLoop *loop, GTimeVal **wait);
static void fd_handler_destroy(gpointer data);
+static void calc_max_fd(ObtMainLoop *loop);
-struct _ObMainLoop
+struct _ObtMainLoop
{
+ gint ref;
Display *display;
gboolean run; /* do keep running */
GSList *signal_handlers[NUM_SIGNALS];
};
-struct _ObMainLoopTimer
+struct _ObtMainLoopTimer
{
gulong delay;
GSourceFunc func;
gboolean fired;
};
-struct _ObMainLoopSignalHandlerType
+struct _ObtMainLoopSignalHandlerType
{
- ObMainLoop *loop;
+ ObtMainLoop *loop;
gint signal;
gpointer data;
- ObMainLoopSignalHandler func;
+ ObtMainLoopSignalHandler func;
GDestroyNotify destroy;
};
-struct _ObMainLoopXHandlerType
+struct _ObtMainLoopXHandlerType
{
- ObMainLoop *loop;
+ ObtMainLoop *loop;
gpointer data;
- ObMainLoopXHandler func;
+ ObtMainLoopXHandler func;
GDestroyNotify destroy;
};
-struct _ObMainLoopFdHandlerType
+struct _ObtMainLoopFdHandlerType
{
- ObMainLoop *loop;
+ ObtMainLoop *loop;
gint fd;
gpointer data;
- ObMainLoopFdHandler func;
+ ObtMainLoopFdHandler func;
GDestroyNotify destroy;
};
-ObMainLoop *ob_main_loop_new(Display *display)
+ObtMainLoop *obt_main_loop_new()
{
- ObMainLoop *loop;
+ ObtMainLoop *loop;
- loop = g_new0(ObMainLoop, 1);
- loop->display = display;
- loop->fd_x = ConnectionNumber(display);
+ loop = g_new0(ObtMainLoop, 1);
+ loop->ref = 1;
FD_ZERO(&loop->fd_set);
- FD_SET(loop->fd_x, &loop->fd_set);
- loop->fd_max = loop->fd_x;
+ loop->fd_x = -1;
+ loop->fd_max = -1;
loop->fd_handlers = g_hash_table_new_full(g_int_hash, g_int_equal,
NULL, fd_handler_destroy);
return loop;
}
-void ob_main_loop_destroy(ObMainLoop *loop)
+void obt_main_loop_ref(ObtMainLoop *loop)
+{
+ ++loop->ref;
+}
+
+void obt_main_loop_unref(ObtMainLoop *loop)
{
guint i;
GSList *it, *next;
- if (loop) {
+ if (loop && --loop->ref == 0) {
g_assert(loop->running == FALSE);
for (it = loop->x_handlers; it; it = next) {
- ObMainLoopXHandlerType *h = it->data;
+ ObtMainLoopXHandlerType *h = it->data;
next = g_slist_next(it);
- ob_main_loop_x_remove(loop, h->func);
+ obt_main_loop_x_remove(loop, h->func);
}
g_hash_table_destroy(loop->fd_handlers);
for (it = loop->timers; it; it = g_slist_next(it)) {
- ObMainLoopTimer *t = it->data;
+ ObtMainLoopTimer *t = it->data;
if (t->destroy) t->destroy(t->data);
g_free(t);
}
for (i = 0; i < NUM_SIGNALS; ++i)
for (it = loop->signal_handlers[i]; it; it = next) {
- ObMainLoopSignalHandlerType *h = it->data;
+ ObtMainLoopSignalHandlerType *h = it->data;
next = g_slist_next(it);
- ob_main_loop_signal_remove(loop, h->func);
+ obt_main_loop_signal_remove(loop, h->func);
}
all_loops = g_slist_remove(all_loops, loop);
}
}
- g_free(loop);
+ obt_free0(loop, ObtMainLoop, 1);
}
}
gpointer value,
gpointer data)
{
- ObMainLoopFdHandlerType *h = value;
+ ObtMainLoopFdHandlerType *h = value;
fd_set *set = data;
if (FD_ISSET(h->fd, set))
h->func(h->fd, h->data);
}
-void ob_main_loop_run(ObMainLoop *loop)
+void obt_main_loop_run(ObtMainLoop *loop)
{
XEvent e;
struct timeval *wait;
while (loop->signals_fired[i]) {
for (it = loop->signal_handlers[i];
it; it = g_slist_next(it)) {
- ObMainLoopSignalHandlerType *h = it->data;
+ ObtMainLoopSignalHandlerType *h = it->data;
h->func(i, h->data);
}
loop->signals_fired[i]--;
loop->signal_fired = FALSE;
sigprocmask(SIG_SETMASK, &oldset, NULL);
- } else if (XPending(loop->display)) {
+ } else if (loop->display && XPending(loop->display)) {
do {
XNextEvent(loop->display, &e);
for (it = loop->x_handlers; it; it = g_slist_next(it)) {
- ObMainLoopXHandlerType *h = it->data;
+ ObtMainLoopXHandlerType *h = it->data;
h->func(&e, h->data);
}
} while (XPending(loop->display) && loop->run);
loop->running = FALSE;
}
-void ob_main_loop_exit(ObMainLoop *loop)
+void obt_main_loop_exit(ObtMainLoop *loop)
{
loop->run = FALSE;
}
/*** XEVENT WATCHERS ***/
-void ob_main_loop_x_add(ObMainLoop *loop,
- ObMainLoopXHandler handler,
- gpointer data,
- GDestroyNotify notify)
+void obt_main_loop_x_add(ObtMainLoop *loop,
+ ObtMainLoopXHandler handler,
+ gpointer data,
+ GDestroyNotify notify)
{
- ObMainLoopXHandlerType *h;
+ ObtMainLoopXHandlerType *h;
- h = g_new(ObMainLoopXHandlerType, 1);
+ h = g_new(ObtMainLoopXHandlerType, 1);
h->loop = loop;
h->func = handler;
h->data = data;
h->destroy = notify;
+
+ if (!loop->x_handlers) {
+ g_assert(obt_display); /* is the display open? */
+
+ loop->display = obt_display;
+ loop->fd_x = ConnectionNumber(loop->display);
+ FD_SET(loop->fd_x, &loop->fd_set);
+ calc_max_fd(loop);
+ }
+
loop->x_handlers = g_slist_prepend(loop->x_handlers, h);
}
-void ob_main_loop_x_remove(ObMainLoop *loop,
- ObMainLoopXHandler handler)
+void obt_main_loop_x_remove(ObtMainLoop *loop,
+ ObtMainLoopXHandler handler)
{
GSList *it, *next;
for (it = loop->x_handlers; it; it = next) {
- ObMainLoopXHandlerType *h = it->data;
+ ObtMainLoopXHandlerType *h = it->data;
next = g_slist_next(it);
if (h->func == handler) {
loop->x_handlers = g_slist_delete_link(loop->x_handlers, it);
g_free(h);
}
}
+
+ if (!loop->x_handlers) {
+ FD_CLR(loop->fd_x, &loop->fd_set);
+ calc_max_fd(loop);
+ }
}
/*** SIGNAL WATCHERS ***/
}
for (it = all_loops; it; it = g_slist_next(it)) {
- ObMainLoop *loop = it->data;
+ ObtMainLoop *loop = it->data;
loop->signal_fired = TRUE;
loop->signals_fired[sig]++;
}
}
-void ob_main_loop_signal_add(ObMainLoop *loop,
- gint signal,
- ObMainLoopSignalHandler handler,
- gpointer data,
- GDestroyNotify notify)
+void obt_main_loop_signal_add(ObtMainLoop *loop,
+ gint signal,
+ ObtMainLoopSignalHandler handler,
+ gpointer data,
+ GDestroyNotify notify)
{
- ObMainLoopSignalHandlerType *h;
+ ObtMainLoopSignalHandlerType *h;
g_return_if_fail(signal < NUM_SIGNALS);
- h = g_new(ObMainLoopSignalHandlerType, 1);
+ h = g_new(ObtMainLoopSignalHandlerType, 1);
h->loop = loop;
h->signal = signal;
h->func = handler;
all_signals[signal].installed++;
}
-void ob_main_loop_signal_remove(ObMainLoop *loop,
- ObMainLoopSignalHandler handler)
+void obt_main_loop_signal_remove(ObtMainLoop *loop,
+ ObtMainLoopSignalHandler handler)
{
guint i;
GSList *it, *next;
for (i = 0; i < NUM_SIGNALS; ++i) {
for (it = loop->signal_handlers[i]; it; it = next) {
- ObMainLoopSignalHandlerType *h = it->data;
+ ObtMainLoopSignalHandlerType *h = it->data;
next = g_slist_next(it);
static void max_fd_func(gpointer key, gpointer value, gpointer data)
{
- ObMainLoop *loop = data;
+ ObtMainLoop *loop = data;
/* key is the fd */
loop->fd_max = MAX(loop->fd_max, *(gint*)key);
}
-static void calc_max_fd(ObMainLoop *loop)
+static void calc_max_fd(ObtMainLoop *loop)
{
loop->fd_max = loop->fd_x;
g_hash_table_foreach(loop->fd_handlers, max_fd_func, loop);
}
-void ob_main_loop_fd_add(ObMainLoop *loop,
- gint fd,
- ObMainLoopFdHandler handler,
- gpointer data,
- GDestroyNotify notify)
+void obt_main_loop_fd_add(ObtMainLoop *loop,
+ gint fd,
+ ObtMainLoopFdHandler handler,
+ gpointer data,
+ GDestroyNotify notify)
{
- ObMainLoopFdHandlerType *h;
+ ObtMainLoopFdHandlerType *h;
- h = g_new(ObMainLoopFdHandlerType, 1);
+ h = g_new(ObtMainLoopFdHandlerType, 1);
h->loop = loop;
h->fd = fd;
h->func = handler;
static void fd_handler_destroy(gpointer data)
{
- ObMainLoopFdHandlerType *h = data;
+ ObtMainLoopFdHandlerType *h = data;
FD_CLR(h->fd, &h->loop->fd_set);
h->destroy(h->data);
}
-void ob_main_loop_fd_remove(ObMainLoop *loop,
- gint fd)
+void obt_main_loop_fd_remove(ObtMainLoop *loop,
+ gint fd)
{
g_hash_table_remove(loop->fd_handlers, &fd);
+ calc_max_fd(loop);
}
/*** TIMEOUTS ***/
#define NEAREST_TIMEOUT(loop) \
- (((ObMainLoopTimer*)(loop)->timers->data)->timeout)
+ (((ObtMainLoopTimer*)(loop)->timers->data)->timeout)
static glong timecompare(GTimeVal *a, GTimeVal *b)
{
return a->tv_usec - b->tv_usec;
}
-static void insert_timer(ObMainLoop *loop, ObMainLoopTimer *ins)
+static void insert_timer(ObtMainLoop *loop, ObtMainLoopTimer *ins)
{
GSList *it;
for (it = loop->timers; it; it = g_slist_next(it)) {
- ObMainLoopTimer *t = it->data;
+ ObtMainLoopTimer *t = it->data;
if (timecompare(&ins->timeout, &t->timeout) <= 0) {
loop->timers = g_slist_insert_before(loop->timers, it, ins);
break;
loop->timers = g_slist_append(loop->timers, ins);
}
-void ob_main_loop_timeout_add(ObMainLoop *loop,
- gulong microseconds,
- GSourceFunc handler,
- gpointer data,
- GEqualFunc cmp,
- GDestroyNotify notify)
+void obt_main_loop_timeout_add(ObtMainLoop *loop,
+ gulong microseconds,
+ GSourceFunc handler,
+ gpointer data,
+ GEqualFunc cmp,
+ GDestroyNotify notify)
{
- ObMainLoopTimer *t = g_new(ObMainLoopTimer, 1);
+ ObtMainLoopTimer *t = g_new(ObtMainLoopTimer, 1);
g_assert(microseconds > 0); /* if it's 0 it'll cause an infinite loop */
insert_timer(loop, t);
}
-void ob_main_loop_timeout_remove(ObMainLoop *loop,
- GSourceFunc handler)
+void obt_main_loop_timeout_remove(ObtMainLoop *loop,
+ GSourceFunc handler)
{
GSList *it;
for (it = loop->timers; it; it = g_slist_next(it)) {
- ObMainLoopTimer *t = it->data;
+ ObtMainLoopTimer *t = it->data;
if (t->func == handler)
t->del_me = TRUE;
}
}
-void ob_main_loop_timeout_remove_data(ObMainLoop *loop, GSourceFunc handler,
- gpointer data, gboolean cancel_dest)
+void obt_main_loop_timeout_remove_data(ObtMainLoop *loop, GSourceFunc handler,
+ gpointer data, gboolean cancel_dest)
{
GSList *it;
for (it = loop->timers; it; it = g_slist_next(it)) {
- ObMainLoopTimer *t = it->data;
+ ObtMainLoopTimer *t = it->data;
if (t->func == handler && t->equal(t->data, data)) {
t->del_me = TRUE;
if (cancel_dest)
}
/* find the time to wait for the nearest timeout */
-static gboolean nearest_timeout_wait(ObMainLoop *loop, GTimeVal *tm)
+static gboolean nearest_timeout_wait(ObtMainLoop *loop, GTimeVal *tm)
{
if (loop->timers == NULL)
return FALSE;
return TRUE;
}
-static void timer_dispatch(ObMainLoop *loop, GTimeVal **wait)
+static void timer_dispatch(ObtMainLoop *loop, GTimeVal **wait)
{
GSList *it, *next;
g_get_current_time(&loop->now);
for (it = loop->timers; it; it = next) {
- ObMainLoopTimer *curr;
+ ObtMainLoopTimer *curr;
next = g_slist_next(it);
--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ obt/mainloop.h for the Openbox window manager
+ Copyright (c) 2006 Mikael Magnusson
+ Copyright (c) 2003-2007 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#ifndef __obt_mainloop_h
+#define __obt_mainloop_h
+
+#include <X11/Xlib.h>
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct _ObtMainLoop ObtMainLoop;
+
+ObtMainLoop *obt_main_loop_new();
+void obt_main_loop_ref(ObtMainLoop *loop);
+void obt_main_loop_unref(ObtMainLoop *loop);
+
+typedef void (*ObtMainLoopXHandler) (const XEvent *e, gpointer data);
+
+void obt_main_loop_x_add(ObtMainLoop *loop,
+ ObtMainLoopXHandler handler,
+ gpointer data,
+ GDestroyNotify notify);
+void obt_main_loop_x_remove(ObtMainLoop *loop,
+ ObtMainLoopXHandler handler);
+
+typedef void (*ObtMainLoopFdHandler) (gint fd, gpointer data);
+
+void obt_main_loop_fd_add(ObtMainLoop *loop,
+ gint fd,
+ ObtMainLoopFdHandler handler,
+ gpointer data,
+ GDestroyNotify notify);
+void obt_main_loop_fd_remove(ObtMainLoop *loop,
+ gint fd);
+
+typedef void (*ObtMainLoopSignalHandler) (gint signal, gpointer data);
+
+void obt_main_loop_signal_add(ObtMainLoop *loop,
+ gint signal,
+ ObtMainLoopSignalHandler handler,
+ gpointer data,
+ GDestroyNotify notify);
+void obt_main_loop_signal_remove(ObtMainLoop *loop,
+ ObtMainLoopSignalHandler handler);
+
+void obt_main_loop_timeout_add(ObtMainLoop *loop,
+ gulong microseconds,
+ GSourceFunc handler,
+ gpointer data,
+ GEqualFunc cmp,
+ GDestroyNotify notify);
+void obt_main_loop_timeout_remove(ObtMainLoop *loop,
+ GSourceFunc handler);
+void obt_main_loop_timeout_remove_data(ObtMainLoop *loop,
+ GSourceFunc handler,
+ gpointer data,
+ gboolean cancel_dest);
+
+void obt_main_loop_run(ObtMainLoop *loop);
+void obt_main_loop_exit(ObtMainLoop *loop);
+
+G_END_DECLS
+
+#endif
--- /dev/null
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+xcflags=@X_CFLAGS@
+xlibs=@X_LIBS@
+
+Name: Obt
+Description: Openbox Toolkit Library
+Version: @VERSION@
+Requires: glib-2.0
+Libs: -L${libdir} -lobrender ${xlibs}
+Cflags: -I${includedir}/openbox/@OB_VERSION@ ${xcflags}
--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ obt/parse.c for the Openbox window manager
+ Copyright (c) 2003-2007 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#include "obt/parse.h"
+#include "obt/paths.h"
+
+#include <glib.h>
+
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+struct Callback {
+ gchar *tag;
+ ObtParseCallback func;
+ gpointer data;
+};
+
+struct _ObtParseInst {
+ gint ref;
+ ObtPaths *xdg_paths;
+ GHashTable *callbacks;
+ xmlDocPtr doc;
+ xmlNodePtr root;
+ gchar *path;
+};
+
+static void destfunc(struct Callback *c)
+{
+ g_free(c->tag);
+ g_free(c);
+}
+
+ObtParseInst* obt_parse_instance_new(void)
+{
+ ObtParseInst *i = g_new(ObtParseInst, 1);
+ i->ref = 1;
+ i->xdg_paths = obt_paths_new();
+ i->callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+ (GDestroyNotify)destfunc);
+ i->doc = NULL;
+ i->root = NULL;
+ i->path = NULL;
+ return i;
+}
+
+void obt_parse_instance_ref(ObtParseInst *i)
+{
+ ++i->ref;
+}
+
+void obt_parse_instance_unref(ObtParseInst *i)
+{
+ if (i && --i->ref == 0) {
+ obt_paths_unref(i->xdg_paths);
+ g_hash_table_destroy(i->callbacks);
+ g_free(i);
+ }
+}
+
+xmlDocPtr obt_parse_doc(ObtParseInst *i)
+{
+ g_assert(i->doc); /* a doc is open? */
+ return i->doc;
+}
+
+xmlNodePtr obt_parse_root(ObtParseInst *i)
+{
+ g_assert(i->doc); /* a doc is open? */
+ return i->root;
+}
+
+void obt_parse_register(ObtParseInst *i, const gchar *tag,
+ ObtParseCallback func, gpointer data)
+{
+ struct Callback *c;
+
+ if ((c = g_hash_table_lookup(i->callbacks, tag))) {
+ g_error("Tag '%s' already registered", tag);
+ return;
+ }
+
+ c = g_new(struct Callback, 1);
+ c->tag = g_strdup(tag);
+ c->func = func;
+ c->data = data;
+ g_hash_table_insert(i->callbacks, c->tag, c);
+}
+
+static gboolean load_file(ObtParseInst *i,
+ const gchar *domain,
+ const gchar *filename,
+ const gchar *root_node,
+ GSList *paths)
+{
+ GSList *it;
+ gboolean r = FALSE;
+
+ g_assert(i->doc == NULL); /* another doc isn't open already? */
+
+ for (it = paths; !r && it; it = g_slist_next(it)) {
+ gchar *path;
+ struct stat s;
+
+ if (!domain && !filename) /* given a full path to the file */
+ path = g_strdup(it->data);
+ else
+ path = g_build_filename(it->data, domain, filename, NULL);
+
+ if (stat(path, &s) >= 0) {
+ /* XML_PARSE_BLANKS is needed apparently, or the tree can end up
+ with extra nodes in it. */
+ i->doc = xmlReadFile(path, NULL, (XML_PARSE_NOBLANKS |
+ XML_PARSE_RECOVER));
+ if (i->doc) {
+ i->root = xmlDocGetRootElement(i->doc);
+ if (!i->root) {
+ xmlFreeDoc(i->doc);
+ i->doc = NULL;
+ g_message("%s is an empty XML document", path);
+ }
+ else if (xmlStrcmp(i->root->name,
+ (const xmlChar*)root_node)) {
+ xmlFreeDoc(i->doc);
+ i->doc = NULL;
+ i->root = NULL;
+ g_message("XML document %s is of wrong type. Root "
+ "node is not '%s'", path, root_node);
+ }
+ else {
+ i->path = g_strdup(path);
+ r = TRUE; /* ok! */
+ }
+ }
+ }
+
+ g_free(path);
+ }
+
+ return r;
+}
+
+gboolean obt_parse_load_file(ObtParseInst *i,
+ const gchar *path,
+ const gchar *root_node)
+{
+ GSList *paths;
+ gboolean r;
+
+ paths = g_slist_append(NULL, g_strdup(path));
+
+ r = load_file(i, NULL, NULL, root_node, paths);
+
+ while (paths) {
+ g_free(paths->data);
+ paths = g_slist_delete_link(paths, paths);
+ }
+ return r;
+}
+
+gboolean obt_parse_load_config_file(ObtParseInst *i,
+ const gchar *domain,
+ const gchar *filename,
+ const gchar *root_node)
+{
+ GSList *it, *paths = NULL;
+ gboolean r;
+
+ for (it = obt_paths_config_dirs(i->xdg_paths); it; it = g_slist_next(it))
+ paths = g_slist_append(paths, g_strdup(it->data));
+
+ r = load_file(i, domain, filename, root_node, paths);
+
+ while (paths) {
+ g_free(paths->data);
+ paths = g_slist_delete_link(paths, paths);
+ }
+ return r;
+}
+
+gboolean obt_parse_load_data_file(ObtParseInst *i,
+ const gchar *domain,
+ const gchar *filename,
+ const gchar *root_node)
+{
+ GSList *it, *paths = NULL;
+ gboolean r;
+
+ for (it = obt_paths_data_dirs(i->xdg_paths); it; it = g_slist_next(it))
+ paths = g_slist_append(paths, g_strdup(it->data));
+
+ r = load_file(i, domain, filename, root_node, paths);
+
+ while (paths) {
+ g_free(paths->data);
+ paths = g_slist_delete_link(paths, paths);
+ }
+ return r;
+}
+
+gboolean obt_parse_load_theme_file(ObtParseInst *i,
+ const gchar *theme,
+ const gchar *domain,
+ const gchar *filename,
+ const gchar *root_node)
+{
+ GSList *it, *paths = NULL;
+ gboolean r;
+
+ /* use ~/.themes for backwards compatibility */
+ paths = g_slist_append
+ (paths, g_build_filename(g_get_home_dir(), ".themes", theme, NULL));
+
+ for (it = obt_paths_data_dirs(i->xdg_paths); it; it = g_slist_next(it))
+ paths = g_slist_append
+ (paths, g_build_filename(it->data, "themes", theme, NULL));
+
+ r = load_file(i, domain, filename, root_node, paths);
+
+ while (paths) {
+ g_free(paths->data);
+ paths = g_slist_delete_link(paths, paths);
+ }
+ return r;
+}
+
+
+gboolean obt_parse_load_mem(ObtParseInst *i,
+ gpointer data, guint len, const gchar *root_node)
+{
+ gboolean r = FALSE;
+
+ g_assert(i->doc == NULL); /* another doc isn't open already? */
+
+ i->doc = xmlParseMemory(data, len);
+ if (i) {
+ i->root = xmlDocGetRootElement(i->doc);
+ if (!i->root) {
+ xmlFreeDoc(i->doc);
+ i->doc = NULL;
+ g_message("Given memory is an empty document");
+ }
+ else if (xmlStrcmp(i->root->name, (const xmlChar*)root_node)) {
+ xmlFreeDoc(i->doc);
+ i->doc = NULL;
+ i->root = NULL;
+ g_message("XML Document in given memory is of wrong "
+ "type. Root node is not '%s'\n", root_node);
+ }
+ else
+ r = TRUE; /* ok ! */
+ }
+ return r;
+}
+
+void obt_parse_close(ObtParseInst *i)
+{
+ if (i && i->doc) {
+ xmlFreeDoc(i->doc);
+ g_free(i->path);
+ i->doc = NULL;
+ i->root = NULL;
+ i->path = NULL;
+ }
+}
+
+void obt_parse_tree(ObtParseInst *i, xmlNodePtr node)
+{
+ g_assert(i->doc); /* a doc is open? */
+
+ while (node) {
+ struct Callback *c = g_hash_table_lookup(i->callbacks, node->name);
+ if (c) c->func(node, c->data);
+ node = node->next;
+ }
+}
+
+void obt_parse_tree_from_root(ObtParseInst *i)
+{
+ obt_parse_tree(i, i->root->children);
+}
+
+gchar *obt_parse_node_string(xmlNodePtr node)
+{
+ xmlChar *c = xmlNodeGetContent(node);
+ gchar *s = g_strdup(c ? (gchar*)c : "");
+ xmlFree(c);
+ return s;
+}
+
+gint obt_parse_node_int(xmlNodePtr node)
+{
+ xmlChar *c = xmlNodeGetContent(node);
+ gint i = c ? atoi((gchar*)c) : 0;
+ xmlFree(c);
+ return i;
+}
+
+gboolean obt_parse_node_bool(xmlNodePtr node)
+{
+ xmlChar *c = xmlNodeGetContent(node);
+ gboolean b = FALSE;
+ if (c && !xmlStrcasecmp(c, (const xmlChar*) "true"))
+ b = TRUE;
+ else if (c && !xmlStrcasecmp(c, (const xmlChar*) "yes"))
+ b = TRUE;
+ else if (c && !xmlStrcasecmp(c, (const xmlChar*) "on"))
+ b = TRUE;
+ xmlFree(c);
+ return b;
+}
+
+gboolean obt_parse_node_contains(xmlNodePtr node, const gchar *val)
+{
+ xmlChar *c = xmlNodeGetContent(node);
+ gboolean r;
+ r = !xmlStrcasecmp(c, (const xmlChar*) val);
+ xmlFree(c);
+ return r;
+}
+
+xmlNodePtr obt_parse_find_node(xmlNodePtr node, const gchar *tag)
+{
+ while (node) {
+ if (!xmlStrcmp(node->name, (const xmlChar*) tag))
+ return node;
+ node = node->next;
+ }
+ return NULL;
+}
+
+gboolean obt_parse_attr_bool(xmlNodePtr node, const gchar *name,
+ gboolean *value)
+{
+ xmlChar *c = xmlGetProp(node, (const xmlChar*) name);
+ gboolean r = FALSE;
+ if (c) {
+ if (!xmlStrcasecmp(c, (const xmlChar*) "true"))
+ *value = TRUE, r = TRUE;
+ else if (!xmlStrcasecmp(c, (const xmlChar*) "yes"))
+ *value = TRUE, r = TRUE;
+ else if (!xmlStrcasecmp(c, (const xmlChar*) "on"))
+ *value = TRUE, r = TRUE;
+ else if (!xmlStrcasecmp(c, (const xmlChar*) "false"))
+ *value = FALSE, r = TRUE;
+ else if (!xmlStrcasecmp(c, (const xmlChar*) "no"))
+ *value = FALSE, r = TRUE;
+ else if (!xmlStrcasecmp(c, (const xmlChar*) "off"))
+ *value = FALSE, r = TRUE;
+ }
+ xmlFree(c);
+ return r;
+}
+
+gboolean obt_parse_attr_int(xmlNodePtr node, const gchar *name, gint *value)
+{
+ xmlChar *c = xmlGetProp(node, (const xmlChar*) name);
+ gboolean r = FALSE;
+ if (c) {
+ *value = atoi((gchar*)c);
+ r = TRUE;
+ }
+ xmlFree(c);
+ return r;
+}
+
+gboolean obt_parse_attr_string(xmlNodePtr node, const gchar *name,
+ gchar **value)
+{
+ xmlChar *c = xmlGetProp(node, (const xmlChar*) name);
+ gboolean r = FALSE;
+ if (c) {
+ *value = g_strdup((gchar*)c);
+ r = TRUE;
+ }
+ xmlFree(c);
+ return r;
+}
+
+gboolean obt_parse_attr_contains(xmlNodePtr node, const gchar *name,
+ const gchar *val)
+{
+ xmlChar *c = xmlGetProp(node, (const xmlChar*) name);
+ gboolean r = FALSE;
+ if (c)
+ r = !xmlStrcasecmp(c, (const xmlChar*) val);
+ xmlFree(c);
+ return r;
+}
--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ obt/parse.h for the Openbox window manager
+ Copyright (c) 2003-2007 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#ifndef __obt_parse_h
+#define __obt_parse_h
+
+#include <libxml/parser.h>
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct _ObtParseInst ObtParseInst;
+
+typedef void (*ObtParseCallback)(xmlNodePtr node, gpointer data);
+
+ObtParseInst* obt_parse_instance_new();
+void obt_parse_instance_ref(ObtParseInst *inst);
+void obt_parse_instance_unref(ObtParseInst *inst);
+
+gboolean obt_parse_load_file(ObtParseInst *inst,
+ const gchar *path,
+ const gchar *root_node);
+gboolean obt_parse_load_config_file(ObtParseInst *inst,
+ const gchar *domain,
+ const gchar *filename,
+ const gchar *root_node);
+gboolean obt_parse_load_data_file(ObtParseInst *inst,
+ const gchar *domain,
+ const gchar *filename,
+ const gchar *root_node);
+gboolean obt_parse_load_theme_file(ObtParseInst *inst,
+ const gchar *theme,
+ const gchar *domain,
+ const gchar *filename,
+ const gchar *root_node);
+gboolean obt_parse_load_mem(ObtParseInst *inst,
+ gpointer data, guint len, const gchar *root_node);
+
+xmlDocPtr obt_parse_doc(ObtParseInst *inst);
+xmlNodePtr obt_parse_root(ObtParseInst *inst);
+
+void obt_parse_close(ObtParseInst *inst);
+
+void obt_parse_register(ObtParseInst *inst, const gchar *tag,
+ ObtParseCallback func, gpointer data);
+void obt_parse_tree(ObtParseInst *i, xmlNodePtr node);
+void obt_parse_tree_from_root(ObtParseInst *i);
+
+
+/* helpers */
+
+xmlNodePtr obt_parse_find_node(xmlNodePtr node, const gchar *name);
+
+gboolean obt_parse_node_contains (xmlNodePtr node, const gchar *val);
+gchar *obt_parse_node_string (xmlNodePtr node);
+gint obt_parse_node_int (xmlNodePtr node);
+gboolean obt_parse_node_bool (xmlNodePtr node);
+
+gboolean obt_parse_attr_contains (xmlNodePtr node, const gchar *name,
+ const gchar *val);
+gboolean obt_parse_attr_string (xmlNodePtr node, const gchar *name,
+ gchar **value);
+gboolean obt_parse_attr_int (xmlNodePtr node, const gchar *name,
+ gint *value);
+gboolean obt_parse_attr_bool (xmlNodePtr node, const gchar *name,
+ gboolean *value);
+
+G_END_DECLS
+
+#endif
--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ obt/paths.c for the Openbox window manager
+ Copyright (c) 2003-2007 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#include "obt/paths.h"
+#include "obt/util.h"
+
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_STRING_H
+# include <string.h>
+#endif
+
+struct _ObtPaths
+{
+ gint ref;
+ gchar *config_home;
+ gchar *data_home;
+ gchar *cache_home;
+ GSList *config_dirs;
+ GSList *data_dirs;
+};
+
+static gint slist_path_cmp(const gchar *a, const gchar *b)
+{
+ return strcmp(a, b);
+}
+
+typedef GSList* (*GSListFunc) (gpointer list, gconstpointer data);
+
+static GSList* slist_path_add(GSList *list, gpointer data, GSListFunc func)
+{
+ g_assert(func);
+
+ if (!data)
+ return list;
+
+ if (!g_slist_find_custom(list, data, (GCompareFunc) slist_path_cmp))
+ list = func(list, data);
+ else
+ g_free(data);
+
+ return list;
+}
+
+static GSList* split_paths(const gchar *paths)
+{
+ GSList *list = NULL;
+ gchar **spl, **it;
+
+ if (!paths)
+ return NULL;
+ spl = g_strsplit(paths, ":", -1);
+ for (it = spl; *it; ++it)
+ list = slist_path_add(list, *it, (GSListFunc) g_slist_append);
+ g_free(spl);
+ return list;
+}
+
+ObtPaths* obt_paths_new(void)
+{
+ ObtPaths *p;
+ const gchar *path;
+
+ p = g_new0(ObtPaths, 1);
+ p->ref = 1;
+
+ path = g_getenv("XDG_CONFIG_HOME");
+ if (path && path[0] != '\0') /* not unset or empty */
+ p->config_home = g_build_filename(path, NULL);
+ else
+ p->config_home = g_build_filename(g_get_home_dir(), ".config", NULL);
+
+ path = g_getenv("XDG_DATA_HOME");
+ if (path && path[0] != '\0') /* not unset or empty */
+ p->data_home = g_build_filename(path, NULL);
+ else
+ p->data_home = g_build_filename(g_get_home_dir(), ".local",
+ "share", NULL);
+
+ path = g_getenv("XDG_CACHE_HOME");
+ if (path && path[0] != '\0') /* not unset or empty */
+ p->cache_home = g_build_filename(path, NULL);
+ else
+ p->cache_home = g_build_filename(g_get_home_dir(), ".cache", NULL);
+
+ path = g_getenv("XDG_CONFIG_DIRS");
+ if (path && path[0] != '\0') /* not unset or empty */
+ p->config_dirs = split_paths(path);
+ else {
+ p->config_dirs = slist_path_add(p->config_dirs,
+ g_strdup(CONFIGDIR),
+ (GSListFunc) g_slist_append);
+ p->config_dirs = slist_path_add(p->config_dirs,
+ g_build_filename
+ (G_DIR_SEPARATOR_S,
+ "etc", "xdg", NULL),
+ (GSListFunc) g_slist_append);
+ }
+ p->config_dirs = slist_path_add(p->config_dirs,
+ g_strdup(p->config_home),
+ (GSListFunc) g_slist_prepend);
+
+ path = g_getenv("XDG_DATA_DIRS");
+ if (path && path[0] != '\0') /* not unset or empty */
+ p->data_dirs = split_paths(path);
+ else {
+ p->data_dirs = slist_path_add(p->data_dirs,
+ g_strdup(DATADIR),
+ (GSListFunc) g_slist_append);
+ p->data_dirs = slist_path_add(p->data_dirs,
+ g_build_filename
+ (G_DIR_SEPARATOR_S,
+ "usr", "local", "share", NULL),
+ (GSListFunc) g_slist_append);
+ p->data_dirs = slist_path_add(p->data_dirs,
+ g_build_filename
+ (G_DIR_SEPARATOR_S,
+ "usr", "share", NULL),
+ (GSListFunc) g_slist_append);
+ }
+ p->data_dirs = slist_path_add(p->data_dirs,
+ g_strdup(p->data_home),
+ (GSListFunc) g_slist_prepend);
+ return p;
+}
+
+void obt_paths_ref(ObtPaths *p)
+{
+ ++p->ref;
+}
+
+void obt_paths_unref(ObtPaths *p)
+{
+ if (p && --p->ref == 0) {
+ GSList *it;
+
+ for (it = p->config_dirs; it; it = g_slist_next(it))
+ g_free(it->data);
+ g_slist_free(p->config_dirs);
+ for (it = p->data_dirs; it; it = g_slist_next(it))
+ g_free(it->data);
+ g_slist_free(p->data_dirs);
+ g_free(p->config_home);
+ g_free(p->data_home);
+ g_free(p->cache_home);
+
+ obt_free0(p, ObtPaths, 1);
+ }
+}
+
+gchar *obt_paths_expand_tilde(const gchar *f)
+{
+ gchar **spl;
+ gchar *ret;
+
+ if (!f)
+ return NULL;
+ spl = g_strsplit(f, "~", 0);
+ ret = g_strjoinv(g_get_home_dir(), spl);
+ g_strfreev(spl);
+ return ret;
+}
+
+gboolean obt_paths_mkdir(const gchar *path, gint mode)
+{
+ gboolean ret = TRUE;
+
+ g_return_val_if_fail(path != NULL, FALSE);
+ g_return_val_if_fail(path[0] != '\0', FALSE);
+
+ if (!g_file_test(path, G_FILE_TEST_IS_DIR))
+ if (mkdir(path, mode) == -1)
+ ret = FALSE;
+
+ return ret;
+}
+
+gboolean obt_paths_mkdir_path(const gchar *path, gint mode)
+{
+ gboolean ret = TRUE;
+
+ g_return_val_if_fail(path != NULL, FALSE);
+ g_return_val_if_fail(path[0] == '/', FALSE);
+
+ if (!g_file_test(path, G_FILE_TEST_IS_DIR)) {
+ gchar *c, *e;
+
+ c = g_strdup(path);
+ e = c;
+ while ((e = strchr(e + 1, '/'))) {
+ *e = '\0';
+ if (!(ret = obt_paths_mkdir(c, mode)))
+ goto parse_mkdir_path_end;
+ *e = '/';
+ }
+ ret = obt_paths_mkdir(c, mode);
+
+ parse_mkdir_path_end:
+ g_free(c);
+ }
+
+ return ret;
+}
+
+const gchar* obt_paths_config_home(ObtPaths *p)
+{
+ return p->config_home;
+}
+
+const gchar* obt_paths_data_home(ObtPaths *p)
+{
+ return p->data_home;
+}
+
+const gchar* obt_paths_cache_home(ObtPaths *p)
+{
+ return p->cache_home;
+}
+
+GSList* obt_paths_config_dirs(ObtPaths *p)
+{
+ return p->config_dirs;
+}
+
+GSList* obt_paths_data_dirs(ObtPaths *p)
+{
+ return p->data_dirs;
+}
--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ obt/paths.h for the Openbox window manager
+ Copyright (c) 2003-2007 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#ifndef __obt_paths_h
+#define __obt_paths_h
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct _ObtPaths ObtPaths;
+
+ObtPaths* obt_paths_new();
+void obt_paths_ref(ObtPaths *p);
+void obt_paths_unref(ObtPaths *p);
+
+const gchar* obt_paths_config_home(ObtPaths *p);
+const gchar* obt_paths_data_home(ObtPaths *p);
+const gchar* obt_paths_cache_home(ObtPaths *p);
+GSList* obt_paths_config_dirs(ObtPaths *p);
+GSList* obt_paths_data_dirs(ObtPaths *p);
+
+gchar *obt_paths_expand_tilde(const gchar *f);
+gboolean obt_paths_mkdir(const gchar *path, gint mode);
+gboolean obt_paths_mkdir_path(const gchar *path, gint mode);
+
+G_END_DECLS
+
+#endif
--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ obt/prop.c for the Openbox window manager
+ Copyright (c) 2006 Mikael Magnusson
+ Copyright (c) 2003-2007 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#include "obt/prop.h"
+#include "obt/display.h"
+
+#include <X11/Xatom.h>
+#ifdef HAVE_STRING_H
+# include <string.h>
+#endif
+
+Atom prop_atoms[OBT_PROP_NUM_ATOMS];
+gboolean prop_started = FALSE;
+
+#define CREATE_NAME(var, name) (prop_atoms[OBT_PROP_##var] = \
+ XInternAtom((obt_display), (name), FALSE))
+#define CREATE(var) CREATE_NAME(var, #var)
+#define CREATE_(var) CREATE_NAME(var, "_" #var)
+
+void obt_prop_startup()
+{
+ if (prop_started) return;
+ prop_started = TRUE;
+
+ g_assert(obt_display);
+
+ CREATE(CARDINAL);
+ CREATE(WINDOW);
+ CREATE(PIXMAP);
+ CREATE(ATOM);
+ CREATE(STRING);
+ CREATE_NAME(UTF8, "UTF8_STRING");
+
+ CREATE(MANAGER);
+
+ CREATE(WM_COLORMAP_WINDOWS);
+ CREATE(WM_PROTOCOLS);
+ CREATE(WM_STATE);
+ CREATE(WM_CHANGE_STATE);
+ CREATE(WM_DELETE_WINDOW);
+ CREATE(WM_TAKE_FOCUS);
+ CREATE(WM_NAME);
+ CREATE(WM_ICON_NAME);
+ CREATE(WM_CLASS);
+ CREATE(WM_WINDOW_ROLE);
+ CREATE(WM_CLIENT_MACHINE);
+ CREATE(WM_COMMAND);
+ CREATE(WM_CLIENT_LEADER);
+ CREATE_(MOTIF_WM_HINTS);
+
+ CREATE(SM_CLIENT_ID);
+
+ CREATE_(NET_WM_FULL_PLACEMENT);
+
+ CREATE_(NET_SUPPORTED);
+ CREATE_(NET_CLIENT_LIST);
+ CREATE_(NET_CLIENT_LIST_STACKING);
+ CREATE_(NET_NUMBER_OF_DESKTOPS);
+ CREATE_(NET_DESKTOP_GEOMETRY);
+ CREATE_(NET_DESKTOP_VIEWPORT);
+ CREATE_(NET_CURRENT_DESKTOP);
+ CREATE_(NET_DESKTOP_NAMES);
+ CREATE_(NET_ACTIVE_WINDOW);
+/* CREATE_(NET_RESTACK_WINDOW);*/
+ CREATE_(NET_WORKAREA);
+ CREATE_(NET_SUPPORTING_WM_CHECK);
+ CREATE_(NET_DESKTOP_LAYOUT);
+ CREATE_(NET_SHOWING_DESKTOP);
+
+ CREATE_(NET_CLOSE_WINDOW);
+ CREATE_(NET_WM_MOVERESIZE);
+ CREATE_(NET_MOVERESIZE_WINDOW);
+ CREATE_(NET_REQUEST_FRAME_EXTENTS);
+ CREATE_(NET_RESTACK_WINDOW);
+
+ CREATE_(NET_STARTUP_ID);
+
+ CREATE_(NET_WM_NAME);
+ CREATE_(NET_WM_VISIBLE_NAME);
+ CREATE_(NET_WM_ICON_NAME);
+ CREATE_(NET_WM_VISIBLE_ICON_NAME);
+ CREATE_(NET_WM_DESKTOP);
+ CREATE_(NET_WM_WINDOW_TYPE);
+ CREATE_(NET_WM_STATE);
+ CREATE_(NET_WM_STRUT);
+ CREATE_(NET_WM_STRUT_PARTIAL);
+ CREATE_(NET_WM_ICON);
+ CREATE_(NET_WM_ICON_GEOMETRY);
+ CREATE_(NET_WM_PID);
+ CREATE_(NET_WM_ALLOWED_ACTIONS);
+ CREATE_(NET_WM_USER_TIME);
+/* CREATE_(NET_WM_USER_TIME_WINDOW); */
+ CREATE_(KDE_NET_WM_FRAME_STRUT);
+ CREATE_(NET_FRAME_EXTENTS);
+
+ CREATE_(NET_WM_PING);
+#ifdef SYNC
+ CREATE_(NET_WM_SYNC_REQUEST);
+ CREATE_(NET_WM_SYNC_REQUEST_COUNTER);
+#endif
+
+ CREATE_(NET_WM_WINDOW_TYPE_DESKTOP);
+ CREATE_(NET_WM_WINDOW_TYPE_DOCK);
+ CREATE_(NET_WM_WINDOW_TYPE_TOOLBAR);
+ CREATE_(NET_WM_WINDOW_TYPE_MENU);
+ CREATE_(NET_WM_WINDOW_TYPE_UTILITY);
+ CREATE_(NET_WM_WINDOW_TYPE_SPLASH);
+ CREATE_(NET_WM_WINDOW_TYPE_DIALOG);
+ CREATE_(NET_WM_WINDOW_TYPE_NORMAL);
+
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOPLEFT] = 0;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOP] = 1;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOPRIGHT] = 2;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_RIGHT] = 3;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT] = 4;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOM] = 5;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT] = 6;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_LEFT] = 7;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_MOVE] = 8;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_KEYBOARD] = 9;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_MOVE_KEYBOARD] = 10;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_CANCEL] = 11;
+
+ CREATE_(NET_WM_ACTION_MOVE);
+ CREATE_(NET_WM_ACTION_RESIZE);
+ CREATE_(NET_WM_ACTION_MINIMIZE);
+ CREATE_(NET_WM_ACTION_SHADE);
+ CREATE_(NET_WM_ACTION_MAXIMIZE_HORZ);
+ CREATE_(NET_WM_ACTION_MAXIMIZE_VERT);
+ CREATE_(NET_WM_ACTION_FULLSCREEN);
+ CREATE_(NET_WM_ACTION_CHANGE_DESKTOP);
+ CREATE_(NET_WM_ACTION_CLOSE);
+ CREATE_(NET_WM_ACTION_ABOVE);
+ CREATE_(NET_WM_ACTION_BELOW);
+
+ CREATE_(NET_WM_STATE_MODAL);
+/* CREATE_(NET_WM_STATE_STICKY);*/
+ CREATE_(NET_WM_STATE_MAXIMIZED_VERT);
+ CREATE_(NET_WM_STATE_MAXIMIZED_HORZ);
+ CREATE_(NET_WM_STATE_SHADED);
+ CREATE_(NET_WM_STATE_SKIP_TASKBAR);
+ CREATE_(NET_WM_STATE_SKIP_PAGER);
+ CREATE_(NET_WM_STATE_HIDDEN);
+ CREATE_(NET_WM_STATE_FULLSCREEN);
+ CREATE_(NET_WM_STATE_ABOVE);
+ CREATE_(NET_WM_STATE_BELOW);
+ CREATE_(NET_WM_STATE_DEMANDS_ATTENTION);
+
+ prop_atoms[OBT_PROP_NET_WM_STATE_ADD] = 1;
+ prop_atoms[OBT_PROP_NET_WM_STATE_REMOVE] = 0;
+ prop_atoms[OBT_PROP_NET_WM_STATE_TOGGLE] = 2;
+
+ prop_atoms[OBT_PROP_NET_WM_ORIENTATION_HORZ] = 0;
+ prop_atoms[OBT_PROP_NET_WM_ORIENTATION_VERT] = 1;
+ prop_atoms[OBT_PROP_NET_WM_TOPLEFT] = 0;
+ prop_atoms[OBT_PROP_NET_WM_TOPRIGHT] = 1;
+ prop_atoms[OBT_PROP_NET_WM_BOTTOMRIGHT] = 2;
+ prop_atoms[OBT_PROP_NET_WM_BOTTOMLEFT] = 3;
+
+ CREATE_(KDE_WM_CHANGE_STATE);
+ CREATE_(KDE_NET_WM_WINDOW_TYPE_OVERRIDE);
+
+/*
+ CREATE_NAME(ROOTPMAPId, "_XROOTPMAP_ID");
+ CREATE_NAME(ESETROOTId, "ESETROOT_PMAP_ID");
+*/
+
+ CREATE_(OPENBOX_PID);
+ CREATE_(OB_THEME);
+ CREATE_(OB_CONFIG_FILE);
+ CREATE_(OB_WM_ACTION_UNDECORATE);
+ CREATE_(OB_WM_STATE_UNDECORATED);
+ CREATE_(OB_CONTROL);
+}
+
+Atom obt_prop_atom(ObtPropAtom a)
+{
+ g_assert(prop_started);
+ g_assert(a < OBT_PROP_NUM_ATOMS);
+ return prop_atoms[a];
+}
+
+static gboolean get_prealloc(Window win, Atom prop, Atom type, gint size,
+ guchar *data, gulong num)
+{
+ gboolean ret = FALSE;
+ gint res;
+ guchar *xdata = NULL;
+ Atom ret_type;
+ gint ret_size;
+ gulong ret_items, bytes_left;
+ glong num32 = 32 / size * num; /* num in 32-bit elements */
+
+ res = XGetWindowProperty(obt_display, win, prop, 0l, num32,
+ FALSE, type, &ret_type, &ret_size,
+ &ret_items, &bytes_left, &xdata);
+ if (res == Success && ret_items && xdata) {
+ if (ret_size == size && ret_items >= num) {
+ guint i;
+ for (i = 0; i < num; ++i)
+ switch (size) {
+ case 8:
+ data[i] = xdata[i];
+ break;
+ case 16:
+ ((guint16*)data)[i] = ((gushort*)xdata)[i];
+ break;
+ case 32:
+ ((guint32*)data)[i] = ((gulong*)xdata)[i];
+ break;
+ default:
+ g_assert_not_reached(); /* unhandled size */
+ }
+ ret = TRUE;
+ }
+ XFree(xdata);
+ }
+ return ret;
+}
+
+static gboolean get_all(Window win, Atom prop, Atom type, gint size,
+ guchar **data, guint *num)
+{
+ gboolean ret = FALSE;
+ gint res;
+ guchar *xdata = NULL;
+ Atom ret_type;
+ gint ret_size;
+ gulong ret_items, bytes_left;
+
+ res = XGetWindowProperty(obt_display, win, prop, 0l, G_MAXLONG,
+ FALSE, type, &ret_type, &ret_size,
+ &ret_items, &bytes_left, &xdata);
+ if (res == Success) {
+ if (ret_size == size && ret_items > 0) {
+ guint i;
+
+ *data = g_malloc(ret_items * (size / 8));
+ for (i = 0; i < ret_items; ++i)
+ switch (size) {
+ case 8:
+ (*data)[i] = xdata[i];
+ break;
+ case 16:
+ ((guint16*)*data)[i] = ((gushort*)xdata)[i];
+ break;
+ case 32:
+ ((guint32*)*data)[i] = ((gulong*)xdata)[i];
+ break;
+ default:
+ g_assert_not_reached(); /* unhandled size */
+ }
+ *num = ret_items;
+ ret = TRUE;
+ }
+ XFree(xdata);
+ }
+ return ret;
+}
+
+static gboolean get_stringlist(Window win, Atom prop, gchar ***list, gint *nstr)
+{
+ XTextProperty tprop;
+ gboolean ret = FALSE;
+
+ if (XGetTextProperty(obt_display, win, &tprop, prop) && tprop.nitems) {
+ if (XTextPropertyToStringList(&tprop, list, nstr))
+ ret = TRUE;
+ XFree(tprop.value);
+ }
+ return ret;
+}
+
+gboolean obt_prop_get32(Window win, Atom prop, Atom type, guint32 *ret)
+{
+ return get_prealloc(win, prop, type, 32, (guchar*)ret, 1);
+}
+
+gboolean obt_prop_get_array32(Window win, Atom prop, Atom type, guint32 **ret,
+ guint *nret)
+{
+ return get_all(win, prop, type, 32, (guchar**)ret, nret);
+}
+
+gboolean obt_prop_get_string_locale(Window win, Atom prop, gchar **ret)
+{
+ gchar **list;
+ gint nstr;
+ gchar *s;
+
+ if (get_stringlist(win, prop, &list, &nstr) && nstr) {
+ s = g_locale_to_utf8(list[0], -1, NULL, NULL, NULL);
+ XFreeStringList(list);
+ if (s) {
+ *ret = s;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+gboolean obt_prop_get_strings_locale(Window win, Atom prop, gchar ***ret)
+{
+ GSList *strs = NULL, *it;
+ gchar *raw, *p;
+ guint num, i, count = 0;
+
+ if (get_all(win, prop, OBT_PROP_ATOM(STRING), 8,
+ (guchar**)&raw, &num))
+ {
+ p = raw;
+ while (p < raw + num) {
+ ++count;
+ strs = g_slist_append(strs, p);
+ p += strlen(p) + 1; /* next string */
+ }
+
+ *ret = g_new0(gchar*, count + 1);
+ (*ret)[count] = NULL; /* null terminated list */
+
+ for (i = 0, it = strs; it; ++i, it = g_slist_next(it)) {
+ (*ret)[i] = g_locale_to_utf8(it->data, -1, NULL, NULL, NULL);
+ /* make sure translation did not fail */
+ if (!(*ret)[i])
+ (*ret)[i] = g_strdup("");
+ }
+ g_free(raw);
+ g_slist_free(strs);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+gboolean obt_prop_get_string_utf8(Window win, Atom prop, gchar **ret)
+{
+ gchar *raw;
+ gchar *str;
+ guint num;
+
+ if (get_all(win, prop, OBT_PROP_ATOM(UTF8), 8,
+ (guchar**)&raw, &num))
+ {
+ str = g_strndup(raw, num); /* grab the first string from the list */
+ g_free(raw);
+ if (g_utf8_validate(str, -1, NULL)) {
+ *ret = str;
+ return TRUE;
+ }
+ g_free(str);
+ }
+ return FALSE;
+}
+
+gboolean obt_prop_get_strings_utf8(Window win, Atom prop, gchar ***ret)
+{
+ GSList *strs = NULL, *it;
+ gchar *raw, *p;
+ guint num, i, count = 0;
+
+ if (get_all(win, prop, OBT_PROP_ATOM(UTF8), 8,
+ (guchar**)&raw, &num))
+ {
+ p = raw;
+ while (p < raw + num) {
+ ++count;
+ strs = g_slist_append(strs, p);
+ p += strlen(p) + 1; /* next string */
+ }
+
+ *ret = g_new0(gchar*, count + 1);
+
+ for (i = 0, it = strs; it; ++i, it = g_slist_next(it)) {
+ if (g_utf8_validate(it->data, -1, NULL))
+ (*ret)[i] = g_strdup(it->data);
+ else
+ (*ret)[i] = g_strdup("");
+ }
+ g_free(raw);
+ g_slist_free(strs);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void obt_prop_set32(Window win, Atom prop, Atom type, gulong val)
+{
+ XChangeProperty(obt_display, win, prop, type, 32, PropModeReplace,
+ (guchar*)&val, 1);
+}
+
+void obt_prop_set_array32(Window win, Atom prop, Atom type, gulong *val,
+ guint num)
+{
+ XChangeProperty(obt_display, win, prop, type, 32, PropModeReplace,
+ (guchar*)val, num);
+}
+
+void obt_prop_set_string_locale(Window win, Atom prop, const gchar *val)
+{
+ gchar const *s[2] = { val, NULL };
+ obt_prop_set_strings_locale(win, prop, s);
+}
+
+void obt_prop_set_strings_locale(Window win, Atom prop, const gchar **strs)
+{
+ gint i, count;
+ gchar **lstrs;
+ XTextProperty tprop;
+
+ /* count the strings in strs, and convert them to the locale format */
+ for (count = 0; strs[count]; ++count);
+ lstrs = g_new0(char*, count);
+ for (i = 0; i < count; ++i) {
+ lstrs[i] = g_locale_from_utf8(strs[i], -1, NULL, NULL, NULL);
+ if (!lstrs[i]) {
+ lstrs[i] = g_strdup(""); /* make it an empty string */
+ g_warning("Unable to translate string '%s' from UTF8 to locale "
+ "format", strs[i]);
+ }
+ }
+
+
+ XStringListToTextProperty(lstrs, count, &tprop);
+ XSetTextProperty(obt_display, win, &tprop, prop);
+ XFree(tprop.value);
+}
+
+void obt_prop_set_string_utf8(Window win, Atom prop, const gchar *val)
+{
+ XChangeProperty(obt_display, win, prop, OBT_PROP_ATOM(UTF8), 8,
+ PropModeReplace, (const guchar*)val, strlen(val));
+}
+
+void obt_prop_set_strings_utf8(Window win, Atom prop, const gchar **strs)
+{
+ GString *str;
+ gchar const **s;
+
+ str = g_string_sized_new(0);
+ for (s = strs; *s; ++s) {
+ str = g_string_append(str, *s);
+ str = g_string_append_c(str, '\0');
+ }
+ XChangeProperty(obt_display, win, prop, obt_prop_atom(OBT_PROP_UTF8), 8,
+ PropModeReplace, (guchar*)str->str, str->len);
+ g_string_free(str, TRUE);
+}
+
+void obt_prop_erase(Window win, Atom prop)
+{
+ XDeleteProperty(obt_display, win, prop);
+}
+
+void obt_prop_message(gint screen, Window about, Atom messagetype,
+ glong data0, glong data1, glong data2, glong data3,
+ glong data4, glong mask)
+{
+ obt_prop_message_to(obt_root(screen), about, messagetype,
+ data0, data1, data2, data3, data4, mask);
+}
+
+void obt_prop_message_to(Window to, Window about,
+ Atom messagetype,
+ glong data0, glong data1, glong data2, glong data3,
+ glong data4, glong mask)
+{
+ XEvent ce;
+ ce.xclient.type = ClientMessage;
+ ce.xclient.message_type = messagetype;
+ ce.xclient.display = obt_display;
+ ce.xclient.window = about;
+ ce.xclient.format = 32;
+ ce.xclient.data.l[0] = data0;
+ ce.xclient.data.l[1] = data1;
+ ce.xclient.data.l[2] = data2;
+ ce.xclient.data.l[3] = data3;
+ ce.xclient.data.l[4] = data4;
+ XSendEvent(obt_display, to, FALSE, mask, &ce);
+}
--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ obt/prop.h for the Openbox window manager
+ Copyright (c) 2006 Mikael Magnusson
+ Copyright (c) 2003-2007 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#ifndef __obt_prop_h
+#define __obt_prop_h
+
+#include <X11/Xlib.h>
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+ /* types */
+ OBT_PROP_CARDINAL, /*!< The atom which represents the Cardinal data type */
+ OBT_PROP_WINDOW, /*!< The atom which represents window ids */
+ OBT_PROP_PIXMAP, /*!< The atom which represents pixmap ids */
+ OBT_PROP_ATOM, /*!< The atom which represents atom values */
+ OBT_PROP_STRING, /*!< The atom which represents ascii strings */
+ OBT_PROP_UTF8, /*!< The atom which represents utf8-encoded strings */
+
+ /* selection stuff */
+ OBT_PROP_MANAGER,
+
+ /* window hints */
+ OBT_PROP_WM_COLORMAP_WINDOWS,
+ OBT_PROP_WM_PROTOCOLS,
+ OBT_PROP_WM_STATE,
+ OBT_PROP_WM_DELETE_WINDOW,
+ OBT_PROP_WM_TAKE_FOCUS,
+ OBT_PROP_WM_CHANGE_STATE,
+ OBT_PROP_WM_NAME,
+ OBT_PROP_WM_ICON_NAME,
+ OBT_PROP_WM_CLASS,
+ OBT_PROP_WM_WINDOW_ROLE,
+ OBT_PROP_WM_CLIENT_MACHINE,
+ OBT_PROP_WM_COMMAND,
+ OBT_PROP_WM_CLIENT_LEADER,
+ OBT_PROP_MOTIF_WM_HINTS,
+
+ /* SM atoms */
+ OBT_PROP_SM_CLIENT_ID,
+
+ /* NETWM atoms */
+
+ /* Atoms that are used inside messages - these don't go in net_supported */
+
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOPLEFT,
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOP,
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOPRIGHT,
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_RIGHT,
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT,
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOM,
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT,
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_LEFT,
+ OBT_PROP_NET_WM_MOVERESIZE_MOVE,
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_KEYBOARD,
+ OBT_PROP_NET_WM_MOVERESIZE_MOVE_KEYBOARD,
+ OBT_PROP_NET_WM_MOVERESIZE_CANCEL,
+
+ OBT_PROP_NET_WM_STATE_ADD,
+ OBT_PROP_NET_WM_STATE_REMOVE,
+ OBT_PROP_NET_WM_STATE_TOGGLE,
+
+ OBT_PROP_NET_WM_ORIENTATION_HORZ,
+ OBT_PROP_NET_WM_ORIENTATION_VERT,
+ OBT_PROP_NET_WM_TOPLEFT,
+ OBT_PROP_NET_WM_TOPRIGHT,
+ OBT_PROP_NET_WM_BOTTOMRIGHT,
+ OBT_PROP_NET_WM_BOTTOMLEFT,
+
+ OBT_PROP_PRIVATE_PADDING1,
+ OBT_PROP_PRIVATE_PADDING2,
+ OBT_PROP_PRIVATE_PADDING3,
+ OBT_PROP_PRIVATE_PADDING4,
+ OBT_PROP_PRIVATE_PADDING5,
+ OBT_PROP_PRIVATE_PADDING6,
+ OBT_PROP_PRIVATE_PADDING7,
+ OBT_PROP_PRIVATE_PADDING8,
+ OBT_PROP_PRIVATE_PADDING9,
+ OBT_PROP_PRIVATE_PADDING10,
+ OBT_PROP_PRIVATE_PADDING11,
+ OBT_PROP_PRIVATE_PADDING12,
+
+ /* Everything below here must go in net_supported on the root window */
+
+ /* root window properties */
+ OBT_PROP_NET_SUPPORTED,
+ OBT_PROP_NET_CLIENT_LIST,
+ OBT_PROP_NET_CLIENT_LIST_STACKING,
+ OBT_PROP_NET_NUMBER_OF_DESKTOPS,
+ OBT_PROP_NET_DESKTOP_GEOMETRY,
+ OBT_PROP_NET_DESKTOP_VIEWPORT,
+ OBT_PROP_NET_CURRENT_DESKTOP,
+ OBT_PROP_NET_DESKTOP_NAMES,
+ OBT_PROP_NET_ACTIVE_WINDOW,
+/* Atom net_restack_window;*/
+ OBT_PROP_NET_WORKAREA,
+ OBT_PROP_NET_SUPPORTING_WM_CHECK,
+ OBT_PROP_NET_DESKTOP_LAYOUT,
+ OBT_PROP_NET_SHOWING_DESKTOP,
+
+ /* root window messages */
+ OBT_PROP_NET_CLOSE_WINDOW,
+ OBT_PROP_NET_WM_MOVERESIZE,
+ OBT_PROP_NET_MOVERESIZE_WINDOW,
+ OBT_PROP_NET_REQUEST_FRAME_EXTENTS,
+ OBT_PROP_NET_RESTACK_WINDOW,
+
+ /* helpful hints to apps that aren't used for anything */
+ OBT_PROP_NET_WM_FULL_PLACEMENT,
+
+ /* startup-notification extension */
+ OBT_PROP_NET_STARTUP_ID,
+
+ /* application window properties */
+ OBT_PROP_NET_WM_NAME,
+ OBT_PROP_NET_WM_VISIBLE_NAME,
+ OBT_PROP_NET_WM_ICON_NAME,
+ OBT_PROP_NET_WM_VISIBLE_ICON_NAME,
+ OBT_PROP_NET_WM_DESKTOP,
+ OBT_PROP_NET_WM_WINDOW_TYPE,
+ OBT_PROP_NET_WM_STATE,
+ OBT_PROP_NET_WM_STRUT,
+ OBT_PROP_NET_WM_STRUT_PARTIAL,
+ OBT_PROP_NET_WM_ICON,
+ OBT_PROP_NET_WM_ICON_GEOMETRY,
+ OBT_PROP_NET_WM_PID,
+ OBT_PROP_NET_WM_ALLOWED_ACTIONS,
+ OBT_PROP_NET_WM_USER_TIME,
+/* OBT_PROP_NET_WM_USER_TIME_WINDOW, */
+ OBT_PROP_NET_FRAME_EXTENTS,
+
+ /* application protocols */
+ OBT_PROP_NET_WM_PING,
+#ifdef SYNC
+ OBT_PROP_NET_WM_SYNC_REQUEST,
+ OBT_PROP_NET_WM_SYNC_REQUEST_COUNTER,
+#endif
+
+ OBT_PROP_NET_WM_WINDOW_TYPE_DESKTOP,
+ OBT_PROP_NET_WM_WINDOW_TYPE_DOCK,
+ OBT_PROP_NET_WM_WINDOW_TYPE_TOOLBAR,
+ OBT_PROP_NET_WM_WINDOW_TYPE_MENU,
+ OBT_PROP_NET_WM_WINDOW_TYPE_UTILITY,
+ OBT_PROP_NET_WM_WINDOW_TYPE_SPLASH,
+ OBT_PROP_NET_WM_WINDOW_TYPE_DIALOG,
+ OBT_PROP_NET_WM_WINDOW_TYPE_NORMAL,
+
+ OBT_PROP_NET_WM_ACTION_MOVE,
+ OBT_PROP_NET_WM_ACTION_RESIZE,
+ OBT_PROP_NET_WM_ACTION_MINIMIZE,
+ OBT_PROP_NET_WM_ACTION_SHADE,
+/* OBT_PROP_NET_WM_ACTION_STICK,*/
+ OBT_PROP_NET_WM_ACTION_MAXIMIZE_HORZ,
+ OBT_PROP_NET_WM_ACTION_MAXIMIZE_VERT,
+ OBT_PROP_NET_WM_ACTION_FULLSCREEN,
+ OBT_PROP_NET_WM_ACTION_CHANGE_DESKTOP,
+ OBT_PROP_NET_WM_ACTION_CLOSE,
+ OBT_PROP_NET_WM_ACTION_ABOVE,
+ OBT_PROP_NET_WM_ACTION_BELOW,
+
+ OBT_PROP_NET_WM_STATE_MODAL,
+/* OBT_PROP_NET_WM_STATE_STICKY,*/
+ OBT_PROP_NET_WM_STATE_MAXIMIZED_VERT,
+ OBT_PROP_NET_WM_STATE_MAXIMIZED_HORZ,
+ OBT_PROP_NET_WM_STATE_SHADED,
+ OBT_PROP_NET_WM_STATE_SKIP_TASKBAR,
+ OBT_PROP_NET_WM_STATE_SKIP_PAGER,
+ OBT_PROP_NET_WM_STATE_HIDDEN,
+ OBT_PROP_NET_WM_STATE_FULLSCREEN,
+ OBT_PROP_NET_WM_STATE_ABOVE,
+ OBT_PROP_NET_WM_STATE_BELOW,
+ OBT_PROP_NET_WM_STATE_DEMANDS_ATTENTION,
+
+ /* KDE atoms */
+
+ OBT_PROP_KDE_WM_CHANGE_STATE,
+ OBT_PROP_KDE_NET_WM_FRAME_STRUT,
+ OBT_PROP_KDE_NET_WM_WINDOW_TYPE_OVERRIDE,
+
+/*
+ OBT_PROP_ROOTPMAPID,
+ OBT_PROP_ESETROOTID,
+*/
+
+ /* Openbox specific atoms */
+
+ OBT_PROP_OB_WM_ACTION_UNDECORATE,
+ OBT_PROP_OB_WM_STATE_UNDECORATED,
+ OBT_PROP_OPENBOX_PID, /* this is depreecated in favour of ob_control */
+ OBT_PROP_OB_THEME,
+ OBT_PROP_OB_CONFIG_FILE,
+ OBT_PROP_OB_CONTROL,
+
+ OBT_PROP_NUM_ATOMS
+} ObtPropAtom;
+
+Atom obt_prop_atom(ObtPropAtom a);
+
+gboolean obt_prop_get32(Window win, Atom prop, Atom type, guint32 *ret);
+gboolean obt_prop_get_array32(Window win, Atom prop, Atom type, guint32 **ret,
+ guint *nret);
+gboolean obt_prop_get_string_locale(Window win, Atom prop, gchar **ret);
+gboolean obt_prop_get_string_utf8(Window win, Atom prop, gchar **ret);
+gboolean obt_prop_get_strings_locale(Window win, Atom prop, gchar ***ret);
+gboolean obt_prop_get_strings_utf8(Window win, Atom prop, gchar ***ret);
+
+void obt_prop_set32(Window win, Atom prop, Atom type, gulong val);
+void obt_prop_set_array32(Window win, Atom prop, Atom type, gulong *val,
+ guint num);
+void obt_prop_set_string_locale(Window win, Atom prop, const gchar *val);
+void obt_prop_set_string_utf8(Window win, Atom prop, const gchar *val);
+void obt_prop_set_strings_locale(Window win, Atom prop, const gchar **strs);
+void obt_prop_set_strings_utf8(Window win, Atom prop, const gchar **strs);
+
+void obt_prop_erase(Window win, Atom prop);
+
+void obt_prop_message(gint screen, Window about, Atom messagetype,
+ glong data0, glong data1, glong data2, glong data3,
+ glong data4, glong mask);
+void obt_prop_message_to(Window to, Window about, Atom messagetype,
+ glong data0, glong data1, glong data2, glong data3,
+ glong data4, glong mask);
+
+#define OBT_PROP_ATOM(prop) obt_prop_atom(OBT_PROP_##prop)
+
+#define OBT_PROP_GET32(win, prop, type, ret) \
+ (obt_prop_get32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), ret))
+#define OBT_PROP_GETA32(win, prop, type, ret, nret) \
+ (obt_prop_get_array32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), \
+ ret, nret))
+#define OBT_PROP_GETS(win, prop, type, ret) \
+ (obt_prop_get_string_##type(win, OBT_PROP_ATOM(prop), ret))
+#define OBT_PROP_GETSS(win, prop, type, ret) \
+ (obt_prop_get_strings_##type(win, OBT_PROP_ATOM(prop), ret))
+
+#define OBT_PROP_SET32(win, prop, type, val) \
+ (obt_prop_set32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), val))
+#define OBT_PROP_SETA32(win, prop, type, val, num) \
+ (obt_prop_set_array32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), \
+ val, num))
+#define OBT_PROP_SETS(win, prop, type, val) \
+ (obt_prop_set_string_##type(win, OBT_PROP_ATOM(prop), val))
+#define OBT_PROP_SETSS(win, prop, type, strs) \
+ (obt_prop_set_strings_##type(win, OBT_PROP_ATOM(prop), strs))
+
+#define OBT_PROP_ERASE(win, prop) (obt_prop_erase(win, OBT_PROP_ATOM(prop)))
+
+#define OBT_PROP_MSG(screen, about, msgtype, data0, data1, data2, data3, \
+ data4) \
+ (obt_prop_message(screen, about, OBT_PROP_ATOM(msgtype), \
+ data0, data1, data2, data3, data4, \
+ SubstructureNotifyMask | SubstructureRedirectMask))
+
+#define OBT_PROP_MSG_TO(to, about, msgtype, data0, data1, data2, data3, \
+ data4, mask) \
+ (obt_prop_message_to(to, about, OBT_PROP_ATOM(msgtype), \
+ data0, data1, data2, data3, data4, mask))
+
+G_END_DECLS
+
+#endif /* __obt_prop_h */
--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ obt/util.h for the Openbox window manager
+ Copyright (c) 2007 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#ifndef __obt_util_h
+#define __obt_util_h
+
+#include <glib.h>
+
+#ifdef HAVE_STRING_H
+# include <string.h> /* for memset() */
+#endif
+
+G_BEGIN_DECLS
+
+/* Util funcs */
+#define obt_free g_free
+#define obt_free0(p, type, num) memset((p), 0, sizeof(type) * (num)), g_free(p)
+
+G_END_DECLS
+
+
+#endif /*__obt_util_h*/
--- /dev/null
+#ifndef obt__version_h
+#define obt__version_h
+
+#define OBT_MAJOR_VERSION @OBT_MAJOR_VERSION@
+#define OBT_MINOR_VERSION @OBT_MINOR_VERSION@
+#define OBT_MICRO_VERSION @OBT_MICRO_VERSION@
+#define OBT_VERSION OBT_MAJOR_VERSION.OBT_MINOR_VERSION.OBT_MICRO_VERSION
+
+#define OBT_CHECK_VERSION(major,minor,micro) \
+ (OBT_MAJOR_VERSION > (major) || \
+ (OBT_MAJOR_VERSION == (major) && OBT_MINOR_VERSION > (minor)) || \
+ (OBT_MAJOR_VERSION == (major) && OBT_MINOR_VERSION == (minor) && \
+ OBT_MICRO_VERSION >= (micro)))
+
+#endif
--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ obt/xevent.c for the Openbox window manager
+ Copyright (c) 2007 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#include "obt/xevent.h"
+#include "obt/mainloop.h"
+#include "obt/util.h"
+
+typedef struct _ObtXEventBinding ObtXEventBinding;
+
+struct _ObtXEventHandler
+{
+ gint ref;
+ ObtMainLoop *loop;
+
+ /* An array of hash tables where the key is the window, and the value is
+ the ObtXEventBinding */
+ GHashTable **bindings;
+ gint num_event_types; /* the length of the bindings array */
+};
+
+struct _ObtXEventBinding
+{
+ Window win;
+ ObtXEventCallback func;
+ gpointer data;
+};
+
+static void xevent_handler(const XEvent *e, gpointer data);
+static guint window_hash(Window *w) { return *w; }
+static gboolean window_comp(Window *w1, Window *w2) { return *w1 == *w2; }
+
+ObtXEventHandler* xevent_new()
+{
+ ObtXEventHandler *h;
+
+ h = g_new0(ObtXEventHandler, 1);
+ h->ref = 1;
+
+ return h;
+}
+
+void xevent_ref(ObtXEventHandler *h)
+{
+ ++h->ref;
+}
+
+void xevent_unref(ObtXEventHandler *h)
+{
+ if (h && --h->ref == 0) {
+ gint i;
+
+ if (h->loop)
+ obt_main_loop_x_remove(h->loop, xevent_handler);
+ for (i = 0; i < h->num_event_types; ++i)
+ g_hash_table_destroy(h->bindings[i]);
+ g_free(h->bindings);
+
+ obt_free0(h, ObtXEventHandler, 1);
+ }
+}
+
+void xevent_register(ObtXEventHandler *h, ObtMainLoop *loop)
+{
+ h->loop = loop;
+ obt_main_loop_x_add(loop, xevent_handler, h, NULL);
+}
+
+void xevent_set_handler(ObtXEventHandler *h, gint type, Window win,
+ ObtXEventCallback func, gpointer data)
+{
+ ObtXEventBinding *b;
+
+ g_assert(func);
+
+ /* make sure we have a spot for the event */
+ if (type + 1 < h->num_event_types) {
+ gint i;
+ h->bindings = g_renew(GHashTable*, h->bindings, type + 1);
+ for (i = h->num_event_types; i < type + 1; ++i)
+ h->bindings[i] = g_hash_table_new_full((GHashFunc)window_hash,
+ (GEqualFunc)window_comp,
+ NULL, g_free);
+ h->num_event_types = type + 1;
+ }
+
+ b = g_new(ObtXEventBinding, 1);
+ b->win = win;
+ b->func = func;
+ b->data = data;
+ g_hash_table_replace(h->bindings[type], &b->win, b);
+}
+
+void xevent_remove_handler(ObtXEventHandler *h, gint type, Window win)
+{
+ g_assert(type < h->num_event_types);
+ g_assert(win);
+
+ g_hash_table_remove(h->bindings[type], &win);
+}
+
+static void xevent_handler(const XEvent *e, gpointer data)
+{
+ ObtXEventHandler *h;
+ ObtXEventBinding *b;
+
+ h = data;
+
+ if (e->type < h->num_event_types) {
+ const gint all = OBT_XEVENT_ALL_WINDOWS;
+ /* run the all_windows handler first */
+ b = g_hash_table_lookup(h->bindings[e->xany.type], &all);
+ if (b) b->func(e, b->data);
+ /* then run the per-window handler */
+ b = g_hash_table_lookup(h->bindings[e->xany.type], &e->xany.window);
+ if (b) b->func(e, b->data);
+ }
+ else
+ g_message("Unhandled X Event type %d", e->xany.type);
+}
--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ obt/xevent.h for the Openbox window manager
+ Copyright (c) 2007 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#ifndef __obt_xevent_h
+#define __obt_xevent_h
+
+#include <X11/Xlib.h>
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+struct _ObtMainLoop;
+
+typedef struct _ObtXEventHandler ObtXEventHandler;
+
+typedef void (*ObtXEventCallback) (const XEvent *e, gpointer data);
+
+ObtXEventHandler* xevent_new();
+void xevent_ref(ObtXEventHandler *h);
+void xevent_unref(ObtXEventHandler *h);
+
+void xevent_register(ObtXEventHandler *h,
+ struct _ObtMainLoop *loop);
+
+#define OBT_XEVENT_ALL_WINDOWS None
+
+void xevent_set_handler(ObtXEventHandler *h, gint type, Window win,
+ ObtXEventCallback func, gpointer data);
+void xevent_remove_handler(ObtXEventHandler *h, gint type, Window win);
+
+G_END_DECLS
+
+#endif /*__obt_xevent_h*/
if ((act = actions_build_act_from_string(name)))
if (act->def->setup)
- act->options = act->def->setup(NULL, NULL, NULL);
+ act->options = act->def->setup(NULL);
return act;
}
-ObActionsAct* actions_parse(ObParseInst *i,
- xmlDocPtr doc,
- xmlNodePtr node)
+ObActionsAct* actions_parse(xmlNodePtr node)
{
gchar *name;
ObActionsAct *act = NULL;
- if (parse_attr_string("name", node, &name)) {
+ if (obt_parse_attr_string(node, "name", &name)) {
if ((act = actions_build_act_from_string(name)))
/* there is more stuff to parse here */
if (act->def->setup)
- act->options = act->def->setup(i, doc, node->xmlChildrenNode);
+ act->options = act->def->setup(node->children);
g_free(name);
}
#include "misc.h"
#include "frame.h"
-#include "parser/parse.h"
+#include "obt/parse.h"
+
#include <glib.h>
#include <X11/Xlib.h>
typedef struct _ObActionsClientData ObActionsClientData;
typedef struct _ObActionsSelectorData ObActionsSelectorData;
-typedef gpointer (*ObActionsDataSetupFunc)(ObParseInst *i,
- xmlDocPtr doc, xmlNodePtr node);
+typedef gpointer (*ObActionsDataSetupFunc)(xmlNodePtr node);
typedef void (*ObActionsDataFreeFunc)(gpointer options);
typedef gboolean (*ObActionsRunFunc)(ObActionsData *data,
gpointer options);
ObActionsInteractiveInputFunc i_input,
ObActionsInteractiveCancelFunc i_cancel);
-ObActionsAct* actions_parse(ObParseInst *i,
- xmlDocPtr doc,
- xmlNodePtr node);
+ObActionsAct* actions_parse(xmlNodePtr node);
ObActionsAct* actions_parse_string(const gchar *name);
gboolean actions_act_is_interactive(ObActionsAct *act);
gboolean add;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_add_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_remove_func(ObParseInst *i,
- xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
+static gpointer setup_add_func(xmlNodePtr node);
+static gpointer setup_remove_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_addremovedesktop_startup(void)
{
- actions_register("AddDesktop",
- setup_add_func,
- free_func,
- run_func,
+ actions_register("AddDesktop", setup_add_func, g_free, run_func,
NULL, NULL);
- actions_register("RemoveDesktop",
- setup_remove_func,
- free_func,
- run_func,
+ actions_register("RemoveDesktop", setup_remove_func, g_free, run_func,
NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("where", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "where"))) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "last"))
o->current = FALSE;
else if (!g_ascii_strcasecmp(s, "current"))
return o;
}
-static gpointer setup_add_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_add_func(xmlNodePtr node)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node);
o->add = TRUE;
return o;
}
-static gpointer setup_remove_func(ObParseInst *i,
- xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_remove_func(xmlNodePtr node)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node);
o->add = FALSE;
return o;
}
-static void free_func(gpointer options)
-{
- Options *o = options;
-
- g_free(o);
-}
-
/* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options)
{
typedef struct {
gboolean linear;
- gboolean dialog;
gboolean dock_windows;
gboolean desktop_windows;
gboolean all_desktops;
gboolean forward;
gboolean bar;
gboolean raise;
+ ObFocusCyclePopupMode dialog_mode;
GSList *actions;
} Options;
static gboolean cycling = FALSE;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_forward_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
-static gpointer setup_backward_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
+static gpointer setup_forward_func(xmlNodePtr node);
+static gpointer setup_backward_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
static gboolean i_input_func(guint initial_state,
run_func, i_input_func, i_cancel_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- o->dialog = TRUE;
o->bar = TRUE;
-
- if ((n = parse_find_node("linear", node)))
- o->linear = parse_bool(doc, n);
- if ((n = parse_find_node("dialog", node)))
- o->dialog = parse_bool(doc, n);
- if ((n = parse_find_node("bar", node)))
- o->bar = parse_bool(doc, n);
- if ((n = parse_find_node("raise", node)))
- o->raise = parse_bool(doc, n);
- if ((n = parse_find_node("panels", node)))
- o->dock_windows = parse_bool(doc, n);
- if ((n = parse_find_node("desktop", node)))
- o->desktop_windows = parse_bool(doc, n);
- if ((n = parse_find_node("allDesktops", node)))
- o->all_desktops = parse_bool(doc, n);
-
- if ((n = parse_find_node("finalactions", node))) {
+ o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_LIST;
+
+ if ((n = obt_parse_find_node(node, "linear")))
+ o->linear = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "dialog"))) {
+ if (obt_parse_node_contains(n, "none"))
+ o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_NONE;
+ else if (obt_parse_node_contains(n, "icons"))
+ o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_ICONS;
+ }
+ if ((n = obt_parse_find_node(node, "bar")))
+ o->bar = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "raise")))
+ o->raise = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "panels")))
+ o->dock_windows = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "desktop")))
+ o->desktop_windows = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "allDesktops")))
+ o->all_desktops = obt_parse_node_bool(n);
+
+ if ((n = obt_parse_find_node(node, "finalactions"))) {
xmlNodePtr m;
- m = parse_find_node("action", n->xmlChildrenNode);
+ m = obt_parse_find_node(n->children, "action");
while (m) {
- ObActionsAct *action = actions_parse(i, doc, m);
+ ObActionsAct *action = actions_parse(m);
if (action) o->actions = g_slist_prepend(o->actions, action);
- m = parse_find_node("action", m->next);
+ m = obt_parse_find_node(m->next, "action");
}
}
else {
return o;
}
-static gpointer setup_forward_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_forward_func(xmlNodePtr node)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node);
o->forward = TRUE;
return o;
}
-static gpointer setup_backward_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_backward_func(xmlNodePtr node)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node);
o->forward = FALSE;
return o;
}
o->linear,
TRUE,
o->bar,
- o->dialog,
+ o->dialog_mode,
FALSE, FALSE);
cycling = TRUE;
o->linear,
TRUE,
o->bar,
- o->dialog,
+ o->dialog_mode,
TRUE, cancel);
cycling = FALSE;
gchar *str;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_debug_startup(void)
{
- actions_register("Debug",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("Debug", setup_func, free_func, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("string", node)))
- o->str = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "string")))
+ o->str = obt_parse_node_string(n);
return o;
}
static void free_func(gpointer options)
{
Options *o = options;
-
- if (o) {
- g_free(o->str);
- g_free(o);
- }
+ g_free(o->str);
+ g_free(o);
}
/* Always return FALSE because its not interactive */
gboolean follow;
} Options;
-static gpointer setup_go_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
-static gpointer setup_send_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
+static gpointer setup_go_func(xmlNodePtr node);
+static gpointer setup_send_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_desktop_startup(void)
NULL, NULL);
}
-static gpointer setup_go_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_go_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
/* wrap by default - it's handy! */
o->rel.wrap = TRUE;
- if ((n = parse_find_node("to", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "to"))) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "last"))
o->type = LAST;
else if (!g_ascii_strcasecmp(s, "next")) {
}
else {
o->type = ABSOLUTE;
- o->abs.desktop = parse_int(doc, n) - 1;
+ o->abs.desktop = obt_parse_node_int(n) - 1;
}
g_free(s);
}
- if ((n = parse_find_node("wrap", node)))
- o->rel.wrap = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(node, "wrap")))
+ o->rel.wrap = obt_parse_node_bool(n);
return o;
}
-static gpointer setup_send_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_send_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
- o = setup_go_func(i, doc, node);
+ o = setup_go_func(node);
o->send = TRUE;
o->follow = TRUE;
- if ((n = parse_find_node("follow", node)))
- o->follow = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(node, "follow")))
+ o->follow = obt_parse_node_bool(n);
return o;
}
static gboolean cycling = FALSE;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_cycle_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
-static gpointer setup_target_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
+static gpointer setup_cycle_func(xmlNodePtr node);
+static gpointer setup_target_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
static gboolean i_input_func(guint initial_state,
run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o->dialog = TRUE;
o->bar = TRUE;
- if ((n = parse_find_node("dialog", node)))
- o->dialog = parse_bool(doc, n);
- if ((n = parse_find_node("bar", node)))
- o->bar = parse_bool(doc, n);
- if ((n = parse_find_node("raise", node)))
- o->raise = parse_bool(doc, n);
- if ((n = parse_find_node("panels", node)))
- o->dock_windows = parse_bool(doc, n);
- if ((n = parse_find_node("desktop", node)))
- o->desktop_windows = parse_bool(doc, n);
- if ((n = parse_find_node("direction", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "dialog")))
+ o->dialog = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "bar")))
+ o->bar = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "raise")))
+ o->raise = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "panels")))
+ o->dock_windows = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "desktop")))
+ o->desktop_windows = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "direction"))) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "north") ||
!g_ascii_strcasecmp(s, "up"))
o->direction = OB_DIRECTION_NORTH;
g_free(s);
}
- if ((n = parse_find_node("finalactions", node))) {
+ if ((n = obt_parse_find_node(node, "finalactions"))) {
xmlNodePtr m;
- m = parse_find_node("action", n->xmlChildrenNode);
+ m = obt_parse_find_node(n->children, "action");
while (m) {
- ObActionsAct *action = actions_parse(i, doc, m);
+ ObActionsAct *action = actions_parse(m);
if (action) o->actions = g_slist_prepend(o->actions, action);
- m = parse_find_node("action", m->next);
+ m = obt_parse_find_node(m->next, "action");
}
}
else {
return o;
}
-static gpointer setup_cycle_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_cycle_func(xmlNodePtr node)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node);
o->interactive = TRUE;
return o;
}
-static gpointer setup_target_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_target_func(xmlNodePtr node)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node);
o->interactive = FALSE;
return o;
}
#include "openbox/event.h"
#include "openbox/startupnotify.h"
#include "openbox/screen.h"
+#include "obt/paths.h"
#include "gettext.h"
#ifdef HAVE_STDLIB_H
gchar *sn_wmclass;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
/*
void action_execute_startup(void)
{
- actions_register("Execute",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("Execute", setup_func, free_func, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("command", node)) ||
- (n = parse_find_node("execute", node)))
+ if ((n = obt_parse_find_node(node, "command")) ||
+ (n = obt_parse_find_node(node, "execute")))
{
- gchar *s = parse_string(doc, n);
- o->cmd = parse_expand_tilde(s);
+ gchar *s = obt_parse_node_string(n);
+ o->cmd = obt_paths_expand_tilde(s);
g_free(s);
}
- if ((n = parse_find_node("startupnotify", node))) {
+ if ((n = obt_parse_find_node(node, "startupnotify"))) {
xmlNodePtr m;
- if ((m = parse_find_node("enabled", n->xmlChildrenNode)))
- o->sn = parse_bool(doc, m);
- if ((m = parse_find_node("name", n->xmlChildrenNode)))
- o->sn_name = parse_string(doc, m);
- if ((m = parse_find_node("icon", n->xmlChildrenNode)))
- o->sn_icon = parse_string(doc, m);
- if ((m = parse_find_node("wmclass", n->xmlChildrenNode)))
- o->sn_wmclass = parse_string(doc, m);
+ if ((m = obt_parse_find_node(n->children, "enabled")))
+ o->sn = obt_parse_node_bool(m);
+ if ((m = obt_parse_find_node(n->children, "name")))
+ o->sn_name = obt_parse_node_string(m);
+ if ((m = obt_parse_find_node(n->children, "icon")))
+ o->sn_icon = obt_parse_node_string(m);
+ if ((m = obt_parse_find_node(n->children, "wmclass")))
+ o->sn_wmclass = obt_parse_node_string(m);
}
return o;
}
gboolean here;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_focus_startup(void)
{
- actions_register("Focus",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("Focus", setup_func, g_free, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("here", node)))
- o->here = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(node, "here")))
+ o->here = obt_parse_node_bool(n);
return o;
}
-static void free_func(gpointer options)
-{
- Options *o = options;
-
- g_free(o);
-}
-
/* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options)
{
typedef struct {
ObDirection dir;
+ gboolean shrink;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
+static gpointer setup_shrink_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_growtoedge_startup(void)
{
- actions_register("GrowToEdge",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("GrowToEdge", setup_func,
+ g_free, run_func, NULL, NULL);
+ actions_register("ShrinkToEdge", setup_shrink_func,
+ g_free, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
o->dir = OB_DIRECTION_NORTH;
+ o->shrink = FALSE;
- if ((n = parse_find_node("direction", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "direction"))) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "north") ||
!g_ascii_strcasecmp(s, "up"))
o->dir = OB_DIRECTION_NORTH;
return o;
}
-static void free_func(gpointer options)
+static gpointer setup_shrink_func(xmlNodePtr node)
{
- Options *o = options;
+ Options *o;
- g_free(o);
+ o = setup_func(node);
+ o->shrink = TRUE;
+
+ return o;
}
static gboolean do_grow(ObActionsData *data, gint x, gint y, gint w, gint h)
return FALSE;
}
- /* try grow */
- client_find_resize_directional(data->client, o->dir, TRUE,
- &x, &y, &w, &h);
- if (do_grow(data, x, y, w, h))
- return FALSE;
+ if (!o->shrink) {
+ /* try grow */
+ client_find_resize_directional(data->client, o->dir, TRUE,
+ &x, &y, &w, &h);
+ if (do_grow(data, x, y, w, h))
+ return FALSE;
+ }
/* we couldn't grow, so try shrink! */
opp = (o->dir == OB_DIRECTION_NORTH ? OB_DIRECTION_SOUTH :
GSList *elseacts;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_if_startup(void)
{
- actions_register("If",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("If", setup_func, free_func, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("shaded", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_parse_find_node(node, "shaded"))) {
+ if (obt_parse_node_bool(n))
o->shaded_on = TRUE;
else
o->shaded_off = TRUE;
}
- if ((n = parse_find_node("maximized", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_parse_find_node(node, "maximized"))) {
+ if (obt_parse_node_bool(n))
o->maxfull_on = TRUE;
else
o->maxfull_off = TRUE;
}
- if ((n = parse_find_node("maximizedhorizontal", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_parse_find_node(node, "maximizedhorizontal"))) {
+ if (obt_parse_node_bool(n))
o->maxhorz_on = TRUE;
else
o->maxhorz_off = TRUE;
}
- if ((n = parse_find_node("maximizedvertical", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_parse_find_node(node, "maximizedvertical"))) {
+ if (obt_parse_node_bool(n))
o->maxvert_on = TRUE;
else
o->maxvert_off = TRUE;
}
- if ((n = parse_find_node("iconified", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_parse_find_node(node, "iconified"))) {
+ if (obt_parse_node_bool(n))
o->iconic_on = TRUE;
else
o->iconic_off = TRUE;
}
- if ((n = parse_find_node("focused", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_parse_find_node(node, "focused"))) {
+ if (obt_parse_node_bool(n))
o->focused = TRUE;
else
o->unfocused = TRUE;
}
- if ((n = parse_find_node("then", node))) {
+ if ((n = obt_parse_find_node(node, "then"))) {
xmlNodePtr m;
- m = parse_find_node("action", n->xmlChildrenNode);
+ m = obt_parse_find_node(n->children, "action");
while (m) {
- ObActionsAct *action = actions_parse(i, doc, m);
+ ObActionsAct *action = actions_parse(m);
if (action) o->thenacts = g_slist_prepend(o->thenacts, action);
- m = parse_find_node("action", m->next);
+ m = obt_parse_find_node(m->next, "action");
}
}
- if ((n = parse_find_node("else", node))) {
+ if ((n = obt_parse_find_node(node, "else"))) {
xmlNodePtr m;
- m = parse_find_node("action", n->xmlChildrenNode);
+ m = obt_parse_find_node(n->children, "action");
while (m) {
- ObActionsAct *action = actions_parse(i, doc, m);
+ ObActionsAct *action = actions_parse(m);
if (action) o->elseacts = g_slist_prepend(o->elseacts, action);
- m = parse_find_node("action", m->next);
+ m = obt_parse_find_node(m->next, "action");
}
}
{
Options *o = options;
+ while (o->thenacts) {
+ actions_act_unref(o->thenacts->data);
+ o->thenacts = g_slist_delete_link(o->thenacts, o->thenacts);
+ }
+ while (o->elseacts) {
+ actions_act_unref(o->elseacts->data);
+ o->elseacts = g_slist_delete_link(o->elseacts, o->elseacts);
+ }
+
g_free(o);
}
gboolean toggle;
} Options;
-static gpointer setup_func_top(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_func_bottom(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
-static gpointer setup_func_send(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
+static gpointer setup_func_top(xmlNodePtr node);
+static gpointer setup_func_bottom(xmlNodePtr node);
+static gpointer setup_func_send(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_layer_startup(void)
run_func, NULL, NULL);
}
-static gpointer setup_func_top(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func_top(xmlNodePtr node)
{
Options *o = g_new0(Options, 1);
o->layer = 1;
return o;
}
-static gpointer setup_func_bottom(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_func_bottom(xmlNodePtr node)
{
Options *o = g_new0(Options, 1);
o->layer = -1;
return o;
}
-static gpointer setup_func_send(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_func_send(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("layer", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "layer"))) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "above") ||
!g_ascii_strcasecmp(s, "top"))
o->layer = 1;
MaxDirection dir;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func_on(ObActionsData *data, gpointer options);
static gboolean run_func_off(ObActionsData *data, gpointer options);
static gboolean run_func_toggle(ObActionsData *data, gpointer options);
NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
o->dir = BOTH;
- if ((n = parse_find_node("direction", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "direction"))) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "vertical") ||
!g_ascii_strcasecmp(s, "vert"))
o->dir = VERT;
#include "openbox/actions.h"
-#include "openbox/prop.h"
#include "openbox/moveresize.h"
+#include "obt/prop.h"
static gboolean run_func(ObActionsData *data, gpointer options);
guint32 corner;
corner = data->button != 0 ?
- prop_atoms.net_wm_moveresize_move :
- prop_atoms.net_wm_moveresize_move_keyboard;
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE) :
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE_KEYBOARD);
moveresize_start(data->client, data->x, data->y, data->button, corner);
}
gint y;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_moverelative_startup(void)
{
- actions_register("MoveRelative",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("MoveRelative", setup_func, g_free, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("x", node)))
- o->x = parse_int(doc, n);
- if ((n = parse_find_node("y", node)))
- o->y = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "x")))
+ o->x = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "y")))
+ o->y = obt_parse_node_int(n);
return o;
}
-static void free_func(gpointer options)
-{
- Options *o = options;
-
- g_free(o);
-}
-
/* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options)
{
gint monitor;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_moveresizeto_startup(void)
{
- actions_register("MoveResizeTo",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("MoveResizeTo", setup_func, g_free, run_func, NULL, NULL);
}
-static void parse_coord(xmlDocPtr doc, xmlNodePtr n, gint *pos,
+static void parse_coord(xmlNodePtr n, gint *pos,
gboolean *opposite, gboolean *center)
{
- gchar *s = parse_string(doc, n);
+ gchar *s = obt_parse_node_string(n);
if (g_ascii_strcasecmp(s, "current") != 0) {
if (!g_ascii_strcasecmp(s, "center"))
*center = TRUE;
g_free(s);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o->h = G_MININT;
o->monitor = CURRENT_MONITOR;
- if ((n = parse_find_node("x", node)))
- parse_coord(doc, n, &o->x, &o->xopposite, &o->xcenter);
+ if ((n = obt_parse_find_node(node, "x")))
+ parse_coord(n, &o->x, &o->xopposite, &o->xcenter);
- if ((n = parse_find_node("y", node)))
- parse_coord(doc, n, &o->y, &o->yopposite, &o->ycenter);
+ if ((n = obt_parse_find_node(node, "y")))
+ parse_coord(n, &o->y, &o->yopposite, &o->ycenter);
- if ((n = parse_find_node("width", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "width"))) {
+ gchar *s = obt_parse_node_string(n);
if (g_ascii_strcasecmp(s, "current") != 0)
- o->w = parse_int(doc, n);
+ o->w = obt_parse_node_int(n);
g_free(s);
}
- if ((n = parse_find_node("height", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "height"))) {
+ gchar *s = obt_parse_node_string(n);
if (g_ascii_strcasecmp(s, "current") != 0)
- o->h = parse_int(doc, n);
+ o->h = obt_parse_node_int(n);
g_free(s);
}
- if ((n = parse_find_node("monitor", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "monitor"))) {
+ gchar *s = obt_parse_node_string(n);
if (g_ascii_strcasecmp(s, "current") != 0) {
if (!g_ascii_strcasecmp(s, "all"))
o->monitor = ALL_MONITORS;
else
- o->monitor = parse_int(doc, n) - 1;
+ o->monitor = obt_parse_node_int(n) - 1;
}
g_free(s);
}
return o;
}
-static void free_func(gpointer options)
-{
- Options *o = options;
-
- g_free(o);
-}
-
/* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options)
{
ObDirection dir;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_movetoedge_startup(void)
{
- actions_register("MoveToEdge",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("MoveToEdge", setup_func, g_free, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
o->dir = OB_DIRECTION_NORTH;
- if ((n = parse_find_node("direction", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "direction"))) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "north") ||
!g_ascii_strcasecmp(s, "up"))
o->dir = OB_DIRECTION_NORTH;
return o;
}
-static void free_func(gpointer options)
-{
- Options *o = options;
-
- g_free(o);
-}
-
/* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options)
{
#include "openbox/actions.h"
-#include "openbox/prop.h"
#include "openbox/moveresize.h"
#include "openbox/client.h"
#include "openbox/frame.h"
+#include "obt/prop.h"
typedef struct {
gboolean corner_specified;
guint32 corner;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch,
void action_resize_startup(void)
{
- actions_register("Resize",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("Resize", setup_func, g_free, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("edge", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "edge"))) {
+ gchar *s = obt_parse_node_string(n);
o->corner_specified = TRUE;
if (!g_ascii_strcasecmp(s, "top"))
- o->corner = prop_atoms.net_wm_moveresize_size_top;
+ o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP);
else if (!g_ascii_strcasecmp(s, "bottom"))
- o->corner = prop_atoms.net_wm_moveresize_size_bottom;
+ o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOM);
else if (!g_ascii_strcasecmp(s, "left"))
- o->corner = prop_atoms.net_wm_moveresize_size_left;
+ o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT);
else if (!g_ascii_strcasecmp(s, "right"))
- o->corner = prop_atoms.net_wm_moveresize_size_right;
+ o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT);
else if (!g_ascii_strcasecmp(s, "topleft"))
- o->corner = prop_atoms.net_wm_moveresize_size_topleft;
+ o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT);
else if (!g_ascii_strcasecmp(s, "topright"))
- o->corner = prop_atoms.net_wm_moveresize_size_topright;
+ o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT);
else if (!g_ascii_strcasecmp(s, "bottomleft"))
- o->corner = prop_atoms.net_wm_moveresize_size_bottomleft;
+ o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT);
else if (!g_ascii_strcasecmp(s, "bottomright"))
- o->corner = prop_atoms.net_wm_moveresize_size_bottomright;
+ o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT);
else
o->corner_specified = FALSE;
return o;
}
-static void free_func(gpointer options)
-{
- Options *o = options;
-
- g_free(o);
-}
-
/* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options)
{
guint32 corner;
if (!data->button)
- corner = prop_atoms.net_wm_moveresize_size_keyboard;
+ corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_KEYBOARD);
else if (o->corner_specified)
corner = o->corner; /* it was specified in the binding */
else
if (shaded) {
/* for shaded windows, you can only resize west/east and move */
if (b)
- return prop_atoms.net_wm_moveresize_size_left;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT);
if (c)
- return prop_atoms.net_wm_moveresize_size_right;
- return prop_atoms.net_wm_moveresize_move;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT);
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE);
}
if (y < A && y >= C)
- return prop_atoms.net_wm_moveresize_size_topleft;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT);
else if (y >= A && y >= B && a)
- return prop_atoms.net_wm_moveresize_size_top;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP);
else if (y < B && y >= D)
- return prop_atoms.net_wm_moveresize_size_topright;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT);
else if (y < C && y >= E && b)
- return prop_atoms.net_wm_moveresize_size_left;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT);
else if (y < D && y >= F && c)
- return prop_atoms.net_wm_moveresize_size_right;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT);
else if (y < E && y >= G)
- return prop_atoms.net_wm_moveresize_size_bottomleft;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT);
else if (y < G && y < H && d)
- return prop_atoms.net_wm_moveresize_size_bottom;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOM);
else if (y >= H && y < F)
- return prop_atoms.net_wm_moveresize_size_bottomright;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT);
else
- return prop_atoms.net_wm_moveresize_move;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE);
#undef X
#undef A
gint bottom;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_resizerelative_startup(void)
{
- actions_register("ResizeRelative",
- setup_func,
- free_func,
- run_func,
+ actions_register("ResizeRelative", setup_func, g_free, run_func,
NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("left", node)))
- o->left = parse_int(doc, n);
- if ((n = parse_find_node("right", node)))
- o->right = parse_int(doc, n);
- if ((n = parse_find_node("top", node)) ||
- (n = parse_find_node("up", node)))
- o->top = parse_int(doc, n);
- if ((n = parse_find_node("bottom", node)) ||
- (n = parse_find_node("down", node)))
- o->bottom = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "left")))
+ o->left = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "right")))
+ o->right = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "top")) ||
+ (n = obt_parse_find_node(node, "up")))
+ o->top = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "bottom")) ||
+ (n = obt_parse_find_node(node, "down")))
+ o->bottom = obt_parse_node_int(n);
return o;
}
-static void free_func(gpointer options)
-{
- Options *o = options;
-
- g_free(o);
-}
-
/* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options)
{
#include "openbox/actions.h"
#include "openbox/openbox.h"
+#include "obt/paths.h"
typedef struct {
gchar *cmd;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_restart_startup(void)
{
- actions_register("Restart",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("Restart", setup_func, free_func, run_func, NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("command", node)) ||
- (n = parse_find_node("execute", node)))
+ if ((n = obt_parse_find_node(node, "command")) ||
+ (n = obt_parse_find_node(node, "execute")))
{
- gchar *s = parse_string(doc, n);
- o->cmd = parse_expand_tilde(s);
+ gchar *s = obt_parse_node_string(n);
+ o->cmd = obt_paths_expand_tilde(s);
g_free(s);
}
return o;
static void free_func(gpointer options)
{
Options *o = options;
-
- if (o) {
- g_free(o->cmd);
- g_free(o);
- }
+ g_free(o->cmd);
+ g_free(o);
}
/* Always return FALSE because its not interactive */
gchar *name;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
NULL, NULL);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("menu", node)))
- o->name = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "menu")))
+ o->name = obt_parse_node_string(n);
return o;
}
#include "debug.h"
#include "startupnotify.h"
#include "dock.h"
-#include "xerror.h"
#include "screen.h"
#include "moveresize.h"
#include "ping.h"
#include "place.h"
-#include "prop.h"
-#include "extensions.h"
#include "frame.h"
#include "session.h"
#include "event.h"
#include "mouse.h"
#include "render/render.h"
#include "gettext.h"
+#include "obt/display.h"
+#include "obt/prop.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
gpointer data;
} ClientCallback;
-GList *client_list = NULL;
+GList *client_list = NULL;
-static GSList *client_destroy_notifies = NULL;
+static GSList *client_destroy_notifies = NULL;
+static RrImage *client_default_icon = NULL;
static void client_get_all(ObClient *self, gboolean real);
static void client_get_startup_id(ObClient *self);
void client_startup(gboolean reconfig)
{
+ if ((client_default_icon = RrImageCacheFind(ob_rr_icons,
+ ob_rr_theme->def_win_icon,
+ ob_rr_theme->def_win_icon_w,
+ ob_rr_theme->def_win_icon_h)))
+ RrImageRef(client_default_icon);
+ else {
+ client_default_icon = RrImageNew(ob_rr_icons);
+ RrImageAddPicture(client_default_icon,
+ ob_rr_theme->def_win_icon,
+ ob_rr_theme->def_win_icon_w,
+ ob_rr_theme->def_win_icon_h);
+ }
+
if (reconfig) return;
client_set_list();
void client_shutdown(gboolean reconfig)
{
+ RrImageUnref(client_default_icon);
+ client_default_icon = NULL;
+
if (reconfig) return;
}
} else
windows = NULL;
- PROP_SETA32(RootWindow(ob_display, ob_screen),
- net_client_list, window, (gulong*)windows, size);
+ OBT_PROP_SETA32(obt_root(ob_screen), NET_CLIENT_LIST, WINDOW,
+ (gulong*)windows, size);
if (windows)
g_free(windows);
stacking_set_list();
}
-void client_manage_all(void)
-{
- guint i, j, nchild;
- Window w, *children;
- XWMHints *wmhints;
- XWindowAttributes attrib;
-
- XQueryTree(ob_display, RootWindow(ob_display, ob_screen),
- &w, &w, &children, &nchild);
-
- /* remove all icon windows from the list */
- for (i = 0; i < nchild; i++) {
- if (children[i] == None) continue;
- wmhints = XGetWMHints(ob_display, children[i]);
- if (wmhints) {
- if ((wmhints->flags & IconWindowHint) &&
- (wmhints->icon_window != children[i]))
- for (j = 0; j < nchild; j++)
- if (children[j] == wmhints->icon_window) {
- children[j] = None;
- break;
- }
- XFree(wmhints);
- }
- }
-
- /* manage windows in reverse order from how they were originally mapped.
- this is an attempt to manage children windows before their parents, so
- that when the parent is mapped, it can find the child */
- for (i = 0; i < nchild; ++i) {
- if (children[i] == None)
- continue;
- if (XGetWindowAttributes(ob_display, children[i], &attrib)) {
- if (attrib.override_redirect) continue;
-
- if (attrib.map_state != IsUnmapped)
- client_manage(children[i], NULL);
- }
- }
- XFree(children);
-}
-
void client_manage(Window window, ObPrompt *prompt)
{
ObClient *self;
- XEvent e;
- XWindowAttributes attrib;
XSetWindowAttributes attrib_set;
- XWMHints *wmhint;
gboolean activate = FALSE;
ObAppSettings *settings;
gboolean transient = FALSE;
Rect place, *monitor;
Time launch_time, map_time;
- grab_server(TRUE);
-
- /* check if it has already been unmapped by the time we started
- mapping. the grab does a sync so we don't have to here */
- if (XCheckTypedWindowEvent(ob_display, window, DestroyNotify, &e) ||
- XCheckTypedWindowEvent(ob_display, window, UnmapNotify, &e))
- {
- XPutBackEvent(ob_display, &e);
-
- ob_debug("Trying to manage unmapped window. Aborting that.\n");
- grab_server(FALSE);
- return; /* don't manage it */
- }
-
- /* make sure it isn't an override-redirect window */
- if (!XGetWindowAttributes(ob_display, window, &attrib) ||
- attrib.override_redirect)
- {
- grab_server(FALSE);
- return; /* don't manage it */
- }
-
- /* is the window a docking app */
- if ((wmhint = XGetWMHints(ob_display, window))) {
- if ((wmhint->flags & StateHint) &&
- wmhint->initial_state == WithdrawnState)
- {
- dock_add(window, wmhint);
- grab_server(FALSE);
- XFree(wmhint);
- return;
- }
- XFree(wmhint);
- }
-
- ob_debug("Managing window: 0x%lx\n", window);
+ ob_debug("Managing window: 0x%lx", window);
map_time = event_get_server_time();
attrib_set.event_mask = CLIENT_EVENTMASK |
(prompt ? prompt->event_mask : 0);
attrib_set.do_not_propagate_mask = CLIENT_NOPROPAGATEMASK;
- XChangeWindowAttributes(ob_display, window,
+ XChangeWindowAttributes(obt_display, window,
CWEventMask|CWDontPropagate, &attrib_set);
/* create the ObClient struct, and populate it from the hints on the
window */
self = g_new0(ObClient, 1);
- self->obwin.type = Window_Client;
+ self->obwin.type = OB_WINDOW_CLASS_CLIENT;
self->window = window;
self->prompt = prompt;
/* get all the stuff off the window */
client_get_all(self, TRUE);
- ob_debug("Window type: %d\n", self->type);
- ob_debug("Window group: 0x%x\n", self->group?self->group->leader:0);
+ ob_debug("Window type: %d", self->type);
+ ob_debug("Window group: 0x%x", self->group?self->group->leader:0);
/* now we have all of the window's information so we can set this up.
do this before creating the frame, so it can tell that we are still
should be reparented back to root automatically, unless we are managing
an internal ObPrompt window */
if (!self->prompt)
- XChangeSaveSet(ob_display, window, SetModeInsert);
+ XChangeSaveSet(obt_display, window, SetModeInsert);
/* create the decoration frame for the client window */
self->frame = frame_new(self);
}
/* remove the client's border */
- XSetWindowBorderWidth(ob_display, self->window, 0);
+ XSetWindowBorderWidth(obt_display, self->window, 0);
/* adjust the frame to the client's size before showing or placing
the window */
/* figure out placement for the window if the window is new */
if (ob_state() == OB_STATE_RUNNING) {
- ob_debug("Positioned: %s @ %d %d\n",
+ ob_debug("Positioned: %s @ %d %d",
(!self->positioned ? "no" :
(self->positioned == PPosition ? "program specified" :
(self->positioned == USPosition ? "user specified" :
"program + user specified" :
"BADNESS !?")))), place.x, place.y);
- ob_debug("Sized: %s @ %d %d\n",
+ ob_debug("Sized: %s @ %d %d",
(!self->sized ? "no" :
(self->sized == PSize ? "program specified" :
(self->sized == USSize ? "user specified" :
place.width = MIN(place.width, a->width);
place.height = MIN(place.height, a->height);
- ob_debug("setting window size to %dx%d\n", place.width, place.height);
+ ob_debug("setting window size to %dx%d", place.width, place.height);
/* get the size of the client back */
place.width -= self->frame->size.left + self->frame->size.right;
}
ob_debug("placing window 0x%x at %d, %d with size %d x %d. "
- "some restrictions may apply\n",
+ "some restrictions may apply",
self->window, place.x, place.y, place.width, place.height);
if (self->session)
ob_debug(" but session requested %d, %d %d x %d instead, "
- "overriding\n",
+ "overriding",
self->session->x, self->session->y,
self->session->w, self->session->h);
g_free(monitor);
monitor = NULL;
- ob_debug_type(OB_DEBUG_FOCUS, "Going to try activate new window? %s\n",
+ ob_debug_type(OB_DEBUG_FOCUS, "Going to try activate new window? %s",
activate ? "yes" : "no");
if (activate) {
gboolean raise = FALSE;
/* This is focus stealing prevention */
ob_debug_type(OB_DEBUG_FOCUS,
"Want to focus new window 0x%x at time %u "
- "launched at %u (last user interaction time %u)\n",
+ "launched at %u (last user interaction time %u)",
self->window, map_time, launch_time,
event_last_user_time);
ob_debug_type(OB_DEBUG_FOCUS,
"Not focusing the window because the user is inside "
"an Openbox menu or is move/resizing a window and "
- "we don't want to interrupt them\n");
+ "we don't want to interrupt them");
}
/* if it's on another desktop */
raise = TRUE;
ob_debug_type(OB_DEBUG_FOCUS,
"Not focusing the window because its on another "
- "desktop\n");
+ "desktop");
}
/* If something is focused, and it's not our relative... */
else if (focus_client && client_search_focus_tree_full(self) == NULL &&
activate = FALSE;
ob_debug_type(OB_DEBUG_FOCUS,
"Not focusing the window because the user is "
- "working in another window\n");
+ "working in another window");
}
/* If its a transient (and its parents aren't focused) */
else if (client_has_parent(self)) {
activate = FALSE;
ob_debug_type(OB_DEBUG_FOCUS,
"Not focusing the window because it is a "
- "transient, and its relatives aren't focused\n");
+ "transient, and its relatives aren't focused");
}
/* Don't steal focus from globally active clients.
I stole this idea from KWin. It seems nice.
activate = FALSE;
ob_debug_type(OB_DEBUG_FOCUS,
"Not focusing the window because a globally "
- "active client has focus\n");
+ "active client has focus");
}
/* Don't move focus if it's not going to go to this window
anyway */
raise = TRUE;
ob_debug_type(OB_DEBUG_FOCUS,
"Not focusing the window because another window "
- "would get the focus anyway\n");
+ "would get the focus anyway");
}
else if (!(self->desktop == screen_desktop ||
self->desktop == DESKTOP_ALL))
if (!activate) {
ob_debug_type(OB_DEBUG_FOCUS,
"Focus stealing prevention activated for %s at "
- "time %u (last user interactioon time %u)\n",
+ "time %u (last user interactioon time %u)",
self->title, map_time, event_last_user_time);
/* if the client isn't focused, then hilite it so the user
knows it is there */
/* add to client list/map */
client_list = g_list_append(client_list, self);
- g_hash_table_insert(window_map, &self->window, self);
+ window_add(&self->window, CLIENT_AS_WINDOW(self));
/* this has to happen after we're in the client_list */
if (STRUT_EXISTS(self->strut))
/* free the ObAppSettings shallow copy */
g_free(settings);
- ob_debug("Managed window 0x%lx plate 0x%x (%s)\n",
+ ob_debug("Managed window 0x%lx plate 0x%x (%s)",
window, self->frame->window, self->class);
-
- return;
}
ObClient *self;
ObAppSettings *settings;
- ob_debug("Pretend-managing window: %lx\n", window);
+ ob_debug("Pretend-managing window: %lx", window);
/* do this minimal stuff to figure out the client's decorations */
self->frame = frame_new(self);
frame_adjust_area(self->frame, FALSE, TRUE, TRUE);
- ob_debug("gave extents left %d right %d top %d bottom %d\n",
+ ob_debug("gave extents left %d right %d top %d bottom %d",
self->frame->size.left, self->frame->size.right,
self->frame->size.top, self->frame->size.bottom);
void client_unmanage(ObClient *self)
{
- guint j;
GSList *it;
gulong ignore_start;
- ob_debug("Unmanaging window: 0x%x plate 0x%x (%s) (%s)\n",
+ ob_debug("Unmanaging window: 0x%x plate 0x%x (%s) (%s)",
self->window, self->frame->window,
self->class, self->title ? self->title : "");
/* we dont want events no more. do this before hiding the frame so we
don't generate more events */
- XSelectInput(ob_display, self->window, NoEventMask);
+ XSelectInput(obt_display, self->window, NoEventMask);
/* ignore enter events from the unmap so it doesnt mess with the focus */
if (!config_focus_under_mouse)
frame_hide(self->frame);
/* flush to send the hide to the server quickly */
- XFlush(ob_display);
+ XFlush(obt_display);
if (!config_focus_under_mouse)
event_end_ignore_all_enters(ignore_start);
/* remove the window from our save set, unless we are managing an internal
ObPrompt window */
if (!self->prompt)
- XChangeSaveSet(ob_display, self->window, SetModeDelete);
+ XChangeSaveSet(obt_display, self->window, SetModeDelete);
/* update the focus lists */
focus_order_remove(self);
client_list = g_list_remove(client_list, self);
stacking_remove(self);
- g_hash_table_remove(window_map, &self->window);
+ window_remove(self->window);
/* once the client is out of the list, update the struts to remove its
influence */
self->decorations = 0; /* unmanaged windows have no decor */
/* give the client its border back */
- XSetWindowBorderWidth(ob_display, self->window, self->border_width);
+ XSetWindowBorderWidth(obt_display, self->window, self->border_width);
client_move_resize(self, a.x, a.y, a.width, a.height);
}
if (ob_state() != OB_STATE_EXITING) {
/* these values should not be persisted across a window
unmapping/mapping */
- PROP_ERASE(self->window, net_wm_desktop);
- PROP_ERASE(self->window, net_wm_state);
- PROP_ERASE(self->window, wm_state);
+ OBT_PROP_ERASE(self->window, NET_WM_DESKTOP);
+ OBT_PROP_ERASE(self->window, NET_WM_STATE);
+ OBT_PROP_ERASE(self->window, WM_STATE);
} else {
/* if we're left in an unmapped state, the client wont be mapped.
this is bad, since we will no longer be managing the window on
restart */
- XMapWindow(ob_display, self->window);
+ XMapWindow(obt_display, self->window);
}
/* these should not be left on the window ever. other window managers
don't necessarily use them and it will mess them up (like compiz) */
- PROP_ERASE(self->window, net_wm_visible_name);
- PROP_ERASE(self->window, net_wm_visible_icon_name);
+ OBT_PROP_ERASE(self->window, NET_WM_VISIBLE_NAME);
+ OBT_PROP_ERASE(self->window, NET_WM_VISIBLE_ICON_NAME);
/* update the list hints */
client_set_list();
- ob_debug("Unmanaged window 0x%lx\n", self->window);
+ ob_debug("Unmanaged window 0x%lx", self->window);
/* free all data allocated in the client struct */
+ RrImageUnref(self->icon_set);
g_slist_free(self->transients);
- for (j = 0; j < self->nicons; ++j)
- g_free(self->icons[j].data);
- if (self->nicons > 0)
- g_free(self->icons);
g_free(self->startup_id);
g_free(self->wm_command);
g_free(self->title);
match = FALSE;
if (match) {
- ob_debug("Window matching: %s\n", app->name);
+ ob_debug("Window matching: %s", app->name);
/* copy the settings to our struct, overriding the existing
settings if they are not defaults */
GList *it;
ob_debug_type(OB_DEBUG_SM,
- "Restore session for client %s\n", self->title);
+ "Restore session for client %s", self->title);
if (!(it = session_state_find(self))) {
ob_debug_type(OB_DEBUG_SM,
- "Session data not found for client %s\n", self->title);
+ "Session data not found for client %s", self->title);
return;
}
self->session = it->data;
- ob_debug_type(OB_DEBUG_SM, "Session data loaded for client %s\n",
+ ob_debug_type(OB_DEBUG_SM, "Session data loaded for client %s",
self->title);
RECT_SET_POINT(self->area, self->session->x, self->session->y);
self->area.width = self->session->w;
if (self->session->h > 0)
self->area.height = self->session->h;
- XResizeWindow(ob_display, self->window,
+ XResizeWindow(obt_display, self->window,
self->area.width, self->area.height);
self->desktop = (self->session->desktop == DESKTOP_ALL ?
self->session->desktop :
MIN(screen_num_desktops - 1, self->session->desktop));
- PROP_SET32(self->window, net_wm_desktop, cardinal, self->desktop);
+ OBT_PROP_SET32(self->window, NET_WM_DESKTOP, CARDINAL, self->desktop);
self->shaded = self->session->shaded;
self->iconic = self->session->iconic;
static void client_get_startup_id(ObClient *self)
{
- if (!(PROP_GETS(self->window, net_startup_id, utf8, &self->startup_id)))
+ if (!(OBT_PROP_GETS(self->window, NET_STARTUP_ID, utf8,
+ &self->startup_id)))
if (self->group)
- PROP_GETS(self->group->leader,
- net_startup_id, utf8, &self->startup_id);
+ OBT_PROP_GETS(self->group->leader,
+ NET_STARTUP_ID, utf8, &self->startup_id);
}
static void client_get_area(ObClient *self)
XWindowAttributes wattrib;
Status ret;
- ret = XGetWindowAttributes(ob_display, self->window, &wattrib);
+ ret = XGetWindowAttributes(obt_display, self->window, &wattrib);
g_assert(ret != BadWindow);
RECT_SET(self->area, wattrib.x, wattrib.y, wattrib.width, wattrib.height);
POINT_SET(self->root_pos, wattrib.x, wattrib.y);
self->border_width = wattrib.border_width;
- ob_debug("client area: %d %d %d %d bw %d\n", wattrib.x, wattrib.y,
+ ob_debug("client area: %d %d %d %d bw %d", wattrib.x, wattrib.y,
wattrib.width, wattrib.height, wattrib.border_width);
}
{
guint32 d = screen_num_desktops; /* an always-invalid value */
- if (PROP_GET32(self->window, net_wm_desktop, cardinal, &d)) {
+ if (OBT_PROP_GET32(self->window, NET_WM_DESKTOP, CARDINAL, &d)) {
if (d >= screen_num_desktops && d != DESKTOP_ALL)
self->desktop = screen_num_desktops - 1;
else
self->desktop = d;
- ob_debug("client requested desktop 0x%x\n", self->desktop);
+ ob_debug("client requested desktop 0x%x", self->desktop);
} else {
GSList *it;
gboolean first = TRUE;
if (all != screen_num_desktops) {
self->desktop = all;
- ob_debug("client desktop set from parents: 0x%x\n",
+ ob_debug("client desktop set from parents: 0x%x",
self->desktop);
}
/* try get from the startup-notification protocol */
if (self->desktop >= screen_num_desktops &&
self->desktop != DESKTOP_ALL)
self->desktop = screen_num_desktops - 1;
- ob_debug("client desktop set from startup-notification: 0x%x\n",
+ ob_debug("client desktop set from startup-notification: 0x%x",
self->desktop);
}
/* defaults to the current desktop */
else {
self->desktop = screen_desktop;
- ob_debug("client desktop set to the current desktop: %d\n",
+ ob_debug("client desktop set to the current desktop: %d",
self->desktop);
}
}
guint32 *state;
guint num;
- if (PROP_GETA32(self->window, net_wm_state, atom, &state, &num)) {
+ if (OBT_PROP_GETA32(self->window, NET_WM_STATE, ATOM, &state, &num)) {
gulong i;
for (i = 0; i < num; ++i) {
- if (state[i] == prop_atoms.net_wm_state_modal)
+ if (state[i] == OBT_PROP_ATOM(NET_WM_STATE_MODAL))
self->modal = TRUE;
- else if (state[i] == prop_atoms.net_wm_state_shaded)
+ else if (state[i] == OBT_PROP_ATOM(NET_WM_STATE_SHADED))
self->shaded = TRUE;
- else if (state[i] == prop_atoms.net_wm_state_hidden)
+ else if (state[i] == OBT_PROP_ATOM(NET_WM_STATE_HIDDEN))
self->iconic = TRUE;
- else if (state[i] == prop_atoms.net_wm_state_skip_taskbar)
+ else if (state[i] == OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR))
self->skip_taskbar = TRUE;
- else if (state[i] == prop_atoms.net_wm_state_skip_pager)
+ else if (state[i] == OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER))
self->skip_pager = TRUE;
- else if (state[i] == prop_atoms.net_wm_state_fullscreen)
+ else if (state[i] == OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN))
self->fullscreen = TRUE;
- else if (state[i] == prop_atoms.net_wm_state_maximized_vert)
+ else if (state[i] == OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT))
self->max_vert = TRUE;
- else if (state[i] == prop_atoms.net_wm_state_maximized_horz)
+ else if (state[i] == OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ))
self->max_horz = TRUE;
- else if (state[i] == prop_atoms.net_wm_state_above)
+ else if (state[i] == OBT_PROP_ATOM(NET_WM_STATE_ABOVE))
self->above = TRUE;
- else if (state[i] == prop_atoms.net_wm_state_below)
+ else if (state[i] == OBT_PROP_ATOM(NET_WM_STATE_BELOW))
self->below = TRUE;
- else if (state[i] == prop_atoms.net_wm_state_demands_attention)
+ else if (state[i] == OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION))
self->demands_attention = TRUE;
- else if (state[i] == prop_atoms.ob_wm_state_undecorated)
+ else if (state[i] == OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED))
self->undecorated = TRUE;
}
{
self->shaped = FALSE;
#ifdef SHAPE
- if (extensions_shape) {
+ if (obt_display_extension_shape) {
gint foo;
guint ufoo;
gint s;
- XShapeSelectInput(ob_display, self->window, ShapeNotifyMask);
+ XShapeSelectInput(obt_display, self->window, ShapeNotifyMask);
- XShapeQueryExtents(ob_display, self->window, &s, &foo,
+ XShapeQueryExtents(obt_display, self->window, &s, &foo,
&foo, &ufoo, &ufoo, &foo, &foo, &foo, &ufoo,
&ufoo);
self->shaped = (s != 0);
ObClient *target = NULL;
gboolean trangroup = FALSE;
- if (XGetTransientForHint(ob_display, self->window, &t)) {
+ if (XGetTransientForHint(obt_display, self->window, &t)) {
if (t != self->window) { /* cant be transient to itself! */
- target = g_hash_table_lookup(window_map, &t);
+ ObWindow *tw = window_find(t);
/* if this happens then we need to check for it*/
- g_assert(target != self);
- if (target && !WINDOW_IS_CLIENT(target)) {
- /* this can happen when a dialog is a child of
- a dockapp, for example */
- target = NULL;
+ g_assert(tw != CLIENT_AS_WINDOW(self));
+ if (tw && WINDOW_IS_CLIENT(tw)) {
+ /* watch out for windows with a parent that is something
+ different, like a dockapp for example */
+ target = WINDOW_AS_CLIENT(tw);
}
}
/* Setting the transient_for to Root is actually illegal, however
applications from time have done this to specify transient for
their group */
- if (!target && self->group && t == RootWindow(ob_display, ob_screen))
+ if (!target && self->group && t == obt_root(ob_screen))
trangroup = TRUE;
} else if (self->group && self->transient)
trangroup = TRUE;
self->mwmhints.flags = 0; /* default to none */
- if (PROP_GETA32(self->window, motif_wm_hints, motif_wm_hints,
- &hints, &num)) {
+ if (OBT_PROP_GETA32(self->window, MOTIF_WM_HINTS, MOTIF_WM_HINTS,
+ &hints, &num)) {
if (num >= OB_MWM_ELEMENTS) {
self->mwmhints.flags = hints[0];
self->mwmhints.functions = hints[1];
self->type = -1;
self->transient = FALSE;
- if (PROP_GETA32(self->window, net_wm_window_type, atom, &val, &num)) {
+ if (OBT_PROP_GETA32(self->window, NET_WM_WINDOW_TYPE, ATOM, &val, &num)) {
/* use the first value that we know about in the array */
for (i = 0; i < num; ++i) {
- if (val[i] == prop_atoms.net_wm_window_type_desktop)
+ if (val[i] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DESKTOP))
self->type = OB_CLIENT_TYPE_DESKTOP;
- else if (val[i] == prop_atoms.net_wm_window_type_dock)
+ else if (val[i] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DOCK))
self->type = OB_CLIENT_TYPE_DOCK;
- else if (val[i] == prop_atoms.net_wm_window_type_toolbar)
+ else if (val[i] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_TOOLBAR))
self->type = OB_CLIENT_TYPE_TOOLBAR;
- else if (val[i] == prop_atoms.net_wm_window_type_menu)
+ else if (val[i] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_MENU))
self->type = OB_CLIENT_TYPE_MENU;
- else if (val[i] == prop_atoms.net_wm_window_type_utility)
+ else if (val[i] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_UTILITY))
self->type = OB_CLIENT_TYPE_UTILITY;
- else if (val[i] == prop_atoms.net_wm_window_type_splash)
+ else if (val[i] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_SPLASH))
self->type = OB_CLIENT_TYPE_SPLASH;
- else if (val[i] == prop_atoms.net_wm_window_type_dialog)
+ else if (val[i] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DIALOG))
self->type = OB_CLIENT_TYPE_DIALOG;
- else if (val[i] == prop_atoms.net_wm_window_type_normal)
+ else if (val[i] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_NORMAL))
self->type = OB_CLIENT_TYPE_NORMAL;
- else if (val[i] == prop_atoms.kde_net_wm_window_type_override) {
+ else if (val[i] == OBT_PROP_ATOM(KDE_NET_WM_WINDOW_TYPE_OVERRIDE))
+ {
/* prevent this window from getting any decor or
functionality */
self->mwmhints.flags &= (OB_MWM_FLAG_FUNCTIONS |
g_free(val);
}
- if (XGetTransientForHint(ob_display, self->window, &t))
+ if (XGetTransientForHint(obt_display, self->window, &t))
self->transient = TRUE;
if (self->type == (ObClientType) -1) {
void client_update_protocols(ObClient *self)
{
guint32 *proto;
- guint num_return, i;
+ guint num_ret, i;
self->focus_notify = FALSE;
self->delete_window = FALSE;
- if (PROP_GETA32(self->window, wm_protocols, atom, &proto, &num_return)) {
- for (i = 0; i < num_return; ++i) {
- if (proto[i] == prop_atoms.wm_delete_window)
+ if (OBT_PROP_GETA32(self->window, WM_PROTOCOLS, ATOM, &proto, &num_ret)) {
+ for (i = 0; i < num_ret; ++i) {
+ if (proto[i] == OBT_PROP_ATOM(WM_DELETE_WINDOW))
/* this means we can request the window to close */
self->delete_window = TRUE;
- else if (proto[i] == prop_atoms.wm_take_focus)
+ else if (proto[i] == OBT_PROP_ATOM(WM_TAKE_FOCUS))
/* if this protocol is requested, then the window will be
notified whenever we want it to receive focus */
self->focus_notify = TRUE;
- else if (proto[i] == prop_atoms.net_wm_ping)
+ else if (proto[i] == OBT_PROP_ATOM(NET_WM_PING))
/* if this protocol is requested, then the window will allow
pings to determine if it is still alive */
self->ping = TRUE;
#ifdef SYNC
- else if (proto[i] == prop_atoms.net_wm_sync_request)
+ else if (proto[i] == OBT_PROP_ATOM(NET_WM_SYNC_REQUEST))
/* if this protocol is requested, then resizing the
window will be synchronized between the frame and the
client */
{
guint32 i;
- if (PROP_GET32(self->window, net_wm_sync_request_counter, cardinal, &i)) {
+ if (OBT_PROP_GET32(self->window, NET_WM_SYNC_REQUEST_COUNTER, CARDINAL,&i))
+ {
self->sync_counter = i;
} else
self->sync_counter = None;
{
XWindowAttributes wa;
- if (XGetWindowAttributes(ob_display, self->window, &wa))
+ if (XGetWindowAttributes(obt_display, self->window, &wa))
client_update_colormap(self, wa.colormap);
}
{
if (colormap == self->colormap) return;
- ob_debug("Setting client %s colormap: 0x%x\n", self->title, colormap);
+ ob_debug("Setting client %s colormap: 0x%x", self->title, colormap);
if (client_focused(self)) {
screen_install_colormap(self, FALSE); /* uninstall old one */
SIZE_SET(self->max_size, G_MAXINT, G_MAXINT);
/* get the hints from the window */
- if (XGetWMNormalHints(ob_display, self->window, &size, &ret)) {
+ if (XGetWMNormalHints(obt_display, self->window, &size, &ret)) {
/* normal windows can't request placement! har har
if (!client_normal(self))
*/
if (size.flags & PResizeInc && size.width_inc && size.height_inc)
SIZE_SET(self->size_inc, size.width_inc, size.height_inc);
- ob_debug("Normal hints: min size (%d %d) max size (%d %d)\n "
- "size inc (%d %d) base size (%d %d)\n",
+ ob_debug("Normal hints: min size (%d %d) max size (%d %d)",
self->min_size.width, self->min_size.height,
- self->max_size.width, self->max_size.height,
+ self->max_size.width, self->max_size.height);
+ ob_debug("size inc (%d %d) base size (%d %d)",
self->size_inc.width, self->size_inc.height,
self->base_size.width, self->base_size.height);
}
else
- ob_debug("Normal hints: not set\n");
+ ob_debug("Normal hints: not set");
}
void client_setup_decor_and_functions(ObClient *self, gboolean reconfig)
/* desktop windows are kept on all desktops */
if (self->type != OB_CLIENT_TYPE_DESKTOP)
- actions[num++] = prop_atoms.net_wm_action_change_desktop;
+ actions[num++] = OBT_PROP_ATOM(NET_WM_ACTION_CHANGE_DESKTOP);
if (self->functions & OB_CLIENT_FUNC_SHADE)
- actions[num++] = prop_atoms.net_wm_action_shade;
+ actions[num++] = OBT_PROP_ATOM(NET_WM_ACTION_SHADE);
if (self->functions & OB_CLIENT_FUNC_CLOSE)
- actions[num++] = prop_atoms.net_wm_action_close;
+ actions[num++] = OBT_PROP_ATOM(NET_WM_ACTION_CLOSE);
if (self->functions & OB_CLIENT_FUNC_MOVE)
- actions[num++] = prop_atoms.net_wm_action_move;
+ actions[num++] = OBT_PROP_ATOM(NET_WM_ACTION_MOVE);
if (self->functions & OB_CLIENT_FUNC_ICONIFY)
- actions[num++] = prop_atoms.net_wm_action_minimize;
+ actions[num++] = OBT_PROP_ATOM(NET_WM_ACTION_MINIMIZE);
if (self->functions & OB_CLIENT_FUNC_RESIZE)
- actions[num++] = prop_atoms.net_wm_action_resize;
+ actions[num++] = OBT_PROP_ATOM(NET_WM_ACTION_RESIZE);
if (self->functions & OB_CLIENT_FUNC_FULLSCREEN)
- actions[num++] = prop_atoms.net_wm_action_fullscreen;
+ actions[num++] = OBT_PROP_ATOM(NET_WM_ACTION_FULLSCREEN);
if (self->functions & OB_CLIENT_FUNC_MAXIMIZE) {
- actions[num++] = prop_atoms.net_wm_action_maximize_horz;
- actions[num++] = prop_atoms.net_wm_action_maximize_vert;
+ actions[num++] = OBT_PROP_ATOM(NET_WM_ACTION_MAXIMIZE_HORZ);
+ actions[num++] = OBT_PROP_ATOM(NET_WM_ACTION_MAXIMIZE_VERT);
}
if (self->functions & OB_CLIENT_FUNC_ABOVE)
- actions[num++] = prop_atoms.net_wm_action_above;
+ actions[num++] = OBT_PROP_ATOM(NET_WM_ACTION_ABOVE);
if (self->functions & OB_CLIENT_FUNC_BELOW)
- actions[num++] = prop_atoms.net_wm_action_below;
+ actions[num++] = OBT_PROP_ATOM(NET_WM_ACTION_BELOW);
if (self->functions & OB_CLIENT_FUNC_UNDECORATE)
- actions[num++] = prop_atoms.ob_wm_action_undecorate;
+ actions[num++] = OBT_PROP_ATOM(OB_WM_ACTION_UNDECORATE);
- PROP_SETA32(self->window, net_wm_allowed_actions, atom, actions, num);
+ OBT_PROP_SETA32(self->window, NET_WM_ALLOWED_ACTIONS, ATOM, actions, num);
- /* make sure the window isn't breaking any rules now
+ /* make sure the window isn't breaking any rules now
- don't check ICONIFY here. just cuz a window can't iconify doesnt mean
- it can't be iconified with its parent
- */
+ don't check ICONIFY here. just cuz a window can't iconify doesnt mean
+ it can't be iconified with its parent
+ */
if (!(self->functions & OB_CLIENT_FUNC_SHADE) && self->shaded) {
if (self->frame) client_shade(self, FALSE);
/* assume a window takes input if it doesnt specify */
self->can_focus = TRUE;
- if ((hints = XGetWMHints(ob_display, self->window)) != NULL) {
+ if ((hints = XGetWMHints(obt_display, self->window)) != NULL) {
gboolean ur;
if (hints->flags & InputHint)
g_free(self->original_title);
/* try netwm */
- if (!PROP_GETS(self->window, net_wm_name, utf8, &data)) {
+ if (!OBT_PROP_GETS(self->window, NET_WM_NAME, utf8, &data)) {
/* try old x stuff */
- if (!(PROP_GETS(self->window, wm_name, locale, &data)
- || PROP_GETS(self->window, wm_name, utf8, &data))) {
+ if (!(OBT_PROP_GETS(self->window, WM_NAME, locale, &data)
+ || OBT_PROP_GETS(self->window, WM_NAME, utf8, &data))) {
if (self->transient) {
/*
GNOME alert windows are not given titles:
g_free(data);
}
- PROP_SETS(self->window, net_wm_visible_name, visible);
+ OBT_PROP_SETS(self->window, NET_WM_VISIBLE_NAME, utf8, visible);
self->title = visible;
if (self->frame)
g_free(self->icon_title);
/* try netwm */
- if (!PROP_GETS(self->window, net_wm_icon_name, utf8, &data))
+ if (!OBT_PROP_GETS(self->window, NET_WM_ICON_NAME, utf8, &data))
/* try old x stuff */
- if (!(PROP_GETS(self->window, wm_icon_name, locale, &data) ||
- PROP_GETS(self->window, wm_icon_name, utf8, &data)))
+ if (!(OBT_PROP_GETS(self->window, WM_ICON_NAME, locale, &data) ||
+ OBT_PROP_GETS(self->window, WM_ICON_NAME, utf8, &data)))
data = g_strdup(self->title);
if (self->client_machine) {
g_free(data);
}
- PROP_SETS(self->window, net_wm_visible_icon_name, visible);
+ OBT_PROP_SETS(self->window, NET_WM_VISIBLE_ICON_NAME, utf8, visible);
self->icon_title = visible;
}
gboolean got = FALSE;
StrutPartial strut;
- if (PROP_GETA32(self->window, net_wm_strut_partial, cardinal,
- &data, &num)) {
+ if (OBT_PROP_GETA32(self->window, NET_WM_STRUT_PARTIAL, CARDINAL,
+ &data, &num))
+ {
if (num == 12) {
got = TRUE;
STRUT_PARTIAL_SET(strut,
}
if (!got &&
- PROP_GETA32(self->window, net_wm_strut, cardinal, &data, &num)) {
+ OBT_PROP_GETA32(self->window, NET_WM_STRUT, CARDINAL, &data, &num)) {
if (num == 4) {
Rect *a;
}
}
-/* Avoid storing icons above this size if possible */
-#define AVOID_ABOVE 64
-
void client_update_icons(ObClient *self)
{
guint num;
guint32 *data;
guint w, h, i, j;
guint num_seen; /* number of icons present */
- guint num_small_seen; /* number of icons small enough present */
- guint smallest, smallest_area;
+ RrImage *img;
- for (i = 0; i < self->nicons; ++i)
- g_free(self->icons[i].data);
- if (self->nicons > 0)
- g_free(self->icons);
- self->nicons = 0;
+ img = NULL;
- if (PROP_GETA32(self->window, net_wm_icon, cardinal, &data, &num)) {
+ /* grab the server, because we might be setting the window's icon and
+ we don't want them to set it in between and we overwrite their own
+ icon */
+ grab_server(TRUE);
+
+ if (OBT_PROP_GETA32(self->window, NET_WM_ICON, CARDINAL, &data, &num)) {
/* figure out how many valid icons are in here */
i = 0;
- num_seen = num_small_seen = 0;
- smallest = smallest_area = 0;
- if (num > 2)
- while (i < num) {
+ num_seen = 0;
+ while (i + 2 < num) { /* +2 is to make sure there is a w and h */
+ w = data[i++];
+ h = data[i++];
+ /* watch for the data being too small for the specified size,
+ or for zero sized icons. */
+ if (i + w*h > num || w == 0 || h == 0) break;
+
+ /* convert it to the right bit order for ObRender */
+ for (j = 0; j < w*h; ++j)
+ data[i+j] =
+ (((data[i+j] >> 24) & 0xff) << RrDefaultAlphaOffset) +
+ (((data[i+j] >> 16) & 0xff) << RrDefaultRedOffset) +
+ (((data[i+j] >> 8) & 0xff) << RrDefaultGreenOffset) +
+ (((data[i+j] >> 0) & 0xff) << RrDefaultBlueOffset);
+
+ /* is it in the cache? */
+ img = RrImageCacheFind(ob_rr_icons, &data[i], w, h);
+ if (img) RrImageRef(img); /* own it */
+
+ i += w*h;
+ ++num_seen;
+
+ /* don't bother looping anymore if we already found it in the cache
+ since we'll just use that! */
+ if (img) break;
+ }
+
+ /* if it's not in the cache yet, then add it to the cache now.
+ we have already converted it to the correct bit order above */
+ if (!img && num_seen > 0) {
+ img = RrImageNew(ob_rr_icons);
+ i = 0;
+ for (j = 0; j < num_seen; ++j) {
w = data[i++];
h = data[i++];
- i += w * h;
- /* watch for it being too small for the specified size, or for
- zero sized icons. */
- if (i > num || w == 0 || h == 0) break;
-
- if (!smallest_area || w*h < smallest_area) {
- smallest = num_seen;
- smallest_area = w*h;
- }
- ++num_seen;
- if (w <= AVOID_ABOVE && h <= AVOID_ABOVE)
- ++num_small_seen;
- }
- if (num_small_seen > 0)
- self->nicons = num_small_seen;
- else if (num_seen)
- self->nicons = 1;
-
- self->icons = g_new(ObClientIcon, self->nicons);
-
- /* store the icons */
- i = 0;
- for (j = 0; j < self->nicons;) {
- guint x, y, t;
-
- w = self->icons[j].width = data[i++];
- h = self->icons[j].height = data[i++];
-
- /* if there are some icons smaller than the threshold, we're
- skipping all the ones above */
- if (num_small_seen > 0) {
- if (w > AVOID_ABOVE || h > AVOID_ABOVE) {
- i += w*h;
- continue;
- }
- }
- /* if there were no icons smaller than the threshold, then we are
- only taking the smallest available one we saw */
- else if (j != smallest) {
+ RrImageAddPicture(img, &data[i], w, h);
i += w*h;
- continue;
- }
-
- self->icons[j].data = g_new(RrPixel32, w * h);
- for (x = 0, y = 0, t = 0; t < w * h; ++t, ++x, ++i) {
- if (x >= w) {
- x = 0;
- ++y;
- }
- self->icons[j].data[t] =
- (((data[i] >> 24) & 0xff) << RrDefaultAlphaOffset) +
- (((data[i] >> 16) & 0xff) << RrDefaultRedOffset) +
- (((data[i] >> 8) & 0xff) << RrDefaultGreenOffset) +
- (((data[i] >> 0) & 0xff) << RrDefaultBlueOffset);
}
- g_assert(i <= num);
-
- ++j;
}
g_free(data);
- } else {
+ }
+
+ /* if we didn't find an image from the NET_WM_ICON stuff, then try the
+ legacy X hints */
+ if (!img) {
XWMHints *hints;
- if ((hints = XGetWMHints(ob_display, self->window))) {
+ if ((hints = XGetWMHints(obt_display, self->window))) {
if (hints->flags & IconPixmapHint) {
- self->nicons = 1;
- self->icons = g_new(ObClientIcon, self->nicons);
- xerror_set_ignore(TRUE);
- if (!RrPixmapToRGBA(ob_rr_inst,
- hints->icon_pixmap,
- (hints->flags & IconMaskHint ?
- hints->icon_mask : None),
- &self->icons[0].width,
- &self->icons[0].height,
- &self->icons[0].data))
- {
- g_free(self->icons);
- self->nicons = 0;
+ gboolean xicon;
+ obt_display_ignore_errors(TRUE);
+ xicon = RrPixmapToRGBA(ob_rr_inst,
+ hints->icon_pixmap,
+ (hints->flags & IconMaskHint ?
+ hints->icon_mask : None),
+ (gint*)&w, (gint*)&h, &data);
+ obt_display_ignore_errors(FALSE);
+
+
+ if (xicon) {
+ if (w > 0 && h > 0) {
+ /* is this icon in the cache yet? */
+ img = RrImageCacheFind(ob_rr_icons, data, w, h);
+ if (img) RrImageRef(img); /* own it */
+
+ /* if not, then add it */
+ if (!img) {
+ img = RrImageNew(ob_rr_icons);
+ RrImageAddPicture(img, data, w, h);
+ }
+ }
+
+ g_free(data);
}
- xerror_set_ignore(FALSE);
}
XFree(hints);
}
}
- /* set the default icon onto the window
- in theory, this could be a race, but if a window doesn't set an icon
- or removes it entirely, it's not very likely it is going to set one
- right away afterwards
+ /* set the client's icons to be whatever we found */
+ RrImageUnref(self->icon_set);
+ self->icon_set = img;
- if it has parents, then one of them will have an icon already
+ /* if the client has no icon at all, then we set a default icon onto it.
+ but, if it has parents, then one of them will have an icon already
*/
- if (self->nicons == 0 && !self->parents) {
+ if (!self->icon_set && !self->parents) {
RrPixel32 *icon = ob_rr_theme->def_win_icon;
- gulong *data;
-
- data = g_new(gulong, 48*48+2);
- data[0] = data[1] = 48;
- for (i = 0; i < 48*48; ++i)
- data[i+2] = (((icon[i] >> RrDefaultAlphaOffset) & 0xff) << 24) +
+ gulong *ldata; /* use a long here to satisfy OBT_PROP_SETA32 */
+
+ w = ob_rr_theme->def_win_icon_w;
+ h = ob_rr_theme->def_win_icon_h;
+ ldata = g_new(gulong, w*h+2);
+ ldata[0] = w;
+ ldata[1] = h;
+ for (i = 0; i < w*h; ++i)
+ ldata[i+2] = (((icon[i] >> RrDefaultAlphaOffset) & 0xff) << 24) +
(((icon[i] >> RrDefaultRedOffset) & 0xff) << 16) +
(((icon[i] >> RrDefaultGreenOffset) & 0xff) << 8) +
(((icon[i] >> RrDefaultBlueOffset) & 0xff) << 0);
- PROP_SETA32(self->window, net_wm_icon, cardinal, data, 48*48+2);
- g_free(data);
+ OBT_PROP_SETA32(self->window, NET_WM_ICON, CARDINAL, ldata, w*h+2);
+ g_free(ldata);
} else if (self->frame)
/* don't draw the icon empty if we're just setting one now anyways,
we'll get the property change any second */
frame_adjust_icon(self->frame);
+
+ grab_server(FALSE);
}
void client_update_icon_geometry(ObClient *self)
RECT_SET(self->icon_geometry, 0, 0, 0, 0);
- if (PROP_GETA32(self->window, net_wm_icon_geometry, cardinal, &data, &num))
+ if (OBT_PROP_GETA32(self->window, NET_WM_ICON_GEOMETRY, CARDINAL,
+ &data, &num))
{
if (num == 4)
/* don't let them set it with an area < 0 */
gchar *s;
gchar **ss;
- if (!PROP_GET32(self->window, wm_client_leader, window, &leader))
+ if (!OBT_PROP_GET32(self->window, WM_CLIENT_LEADER, WINDOW, &leader))
leader = None;
/* get the SM_CLIENT_ID */
got = FALSE;
if (leader)
- got = PROP_GETS(leader, sm_client_id, locale, &self->sm_client_id);
+ got = OBT_PROP_GETS(leader, SM_CLIENT_ID, locale, &self->sm_client_id);
if (!got)
- PROP_GETS(self->window, sm_client_id, locale, &self->sm_client_id);
+ OBT_PROP_GETS(self->window, SM_CLIENT_ID, locale, &self->sm_client_id);
/* get the WM_CLASS (name and class). make them "" if they are not
provided */
got = FALSE;
if (leader)
- got = PROP_GETSS(leader, wm_class, locale, &ss);
+ got = OBT_PROP_GETSS(leader, WM_CLASS, locale, &ss);
if (!got)
- got = PROP_GETSS(self->window, wm_class, locale, &ss);
+ got = OBT_PROP_GETSS(self->window, WM_CLASS, locale, &ss);
if (got) {
if (ss[0]) {
/* get the WM_WINDOW_ROLE. make it "" if it is not provided */
got = FALSE;
if (leader)
- got = PROP_GETS(leader, wm_window_role, locale, &s);
+ got = OBT_PROP_GETS(leader, WM_WINDOW_ROLE, locale, &s);
if (!got)
- got = PROP_GETS(self->window, wm_window_role, locale, &s);
+ got = OBT_PROP_GETS(self->window, WM_WINDOW_ROLE, locale, &s);
if (got)
self->role = s;
got = FALSE;
if (leader)
- got = PROP_GETSS(leader, wm_command, locale, &ss);
+ got = OBT_PROP_GETSS(leader, WM_COMMAND, locale, &ss);
if (!got)
- got = PROP_GETSS(self->window, wm_command, locale, &ss);
+ got = OBT_PROP_GETSS(self->window, WM_COMMAND, locale, &ss);
if (got) {
/* merge/mash them all together */
/* get the WM_CLIENT_MACHINE */
got = FALSE;
if (leader)
- got = PROP_GETS(leader, wm_client_machine, locale, &s);
+ got = OBT_PROP_GETS(leader, WM_CLIENT_MACHINE, locale, &s);
if (!got)
- got = PROP_GETS(self->window, wm_client_machine, locale, &s);
+ got = OBT_PROP_GETS(self->window, WM_CLIENT_MACHINE, locale, &s);
if (got) {
gchar localhost[128];
/* see if it has the PID set too (the PID requires that the
WM_CLIENT_MACHINE be set) */
- if (PROP_GET32(self->window, net_wm_pid, cardinal, &pid))
+ if (OBT_PROP_GET32(self->window, NET_WM_PID, CARDINAL, &pid))
self->pid = pid;
}
}
self->wmstate = NormalState;
if (old != self->wmstate) {
- PROP_MSG(self->window, kde_wm_change_state,
- self->wmstate, 1, 0, 0);
+ OBT_PROP_MSG(ob_screen, self->window, KDE_WM_CHANGE_STATE,
+ self->wmstate, 1, 0, 0, 0);
state[0] = self->wmstate;
state[1] = None;
- PROP_SETA32(self->window, wm_state, wm_state, state, 2);
+ OBT_PROP_SETA32(self->window, WM_STATE, WM_STATE, state, 2);
}
}
num = 0;
if (self->modal)
- netstate[num++] = prop_atoms.net_wm_state_modal;
+ netstate[num++] = OBT_PROP_ATOM(NET_WM_STATE_MODAL);
if (self->shaded)
- netstate[num++] = prop_atoms.net_wm_state_shaded;
+ netstate[num++] = OBT_PROP_ATOM(NET_WM_STATE_SHADED);
if (self->iconic)
- netstate[num++] = prop_atoms.net_wm_state_hidden;
+ netstate[num++] = OBT_PROP_ATOM(NET_WM_STATE_HIDDEN);
if (self->skip_taskbar)
- netstate[num++] = prop_atoms.net_wm_state_skip_taskbar;
+ netstate[num++] = OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR);
if (self->skip_pager)
- netstate[num++] = prop_atoms.net_wm_state_skip_pager;
+ netstate[num++] = OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER);
if (self->fullscreen)
- netstate[num++] = prop_atoms.net_wm_state_fullscreen;
+ netstate[num++] = OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN);
if (self->max_vert)
- netstate[num++] = prop_atoms.net_wm_state_maximized_vert;
+ netstate[num++] = OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT);
if (self->max_horz)
- netstate[num++] = prop_atoms.net_wm_state_maximized_horz;
+ netstate[num++] = OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ);
if (self->above)
- netstate[num++] = prop_atoms.net_wm_state_above;
+ netstate[num++] = OBT_PROP_ATOM(NET_WM_STATE_ABOVE);
if (self->below)
- netstate[num++] = prop_atoms.net_wm_state_below;
+ netstate[num++] = OBT_PROP_ATOM(NET_WM_STATE_BELOW);
if (self->demands_attention)
- netstate[num++] = prop_atoms.net_wm_state_demands_attention;
+ netstate[num++] = OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION);
if (self->undecorated)
- netstate[num++] = prop_atoms.ob_wm_state_undecorated;
- PROP_SETA32(self->window, net_wm_state, atom, netstate, num);
+ netstate[num++] = OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED);
+ OBT_PROP_SETA32(self->window, NET_WM_STATE, ATOM, netstate, num);
if (self->frame)
frame_adjust_state(self->frame);
pre-max/pre-fullscreen values
*/
client_try_configure(self, &x, &y, &w, &h, &l, &l, FALSE);
- ob_debug("placed window 0x%x at %d, %d with size %d x %d\n",
+ ob_debug("placed window 0x%x at %d, %d with size %d x %d",
self->window, x, y, w, h);
/* save the area, and make it where it should be for the premax stuff */
oldarea = self->area;
client_configure(self, x, y, w, h, FALSE, TRUE, FALSE);
/* set the desktop hint, to make sure that it always exists */
- PROP_SET32(self->window, net_wm_desktop, cardinal, self->desktop);
+ OBT_PROP_SET32(self->window, NET_WM_DESKTOP, CARDINAL, self->desktop);
/* nothing to do for the other states:
skip_taskbar
/* if the client is enlarging, then resize the client before the frame */
if (send_resize_client && (w > oldw || h > oldh)) {
- XMoveResizeWindow(ob_display, self->window,
+ XMoveResizeWindow(obt_display, self->window,
self->frame->size.left, self->frame->size.top,
MAX(w, oldw), MAX(h, oldh));
frame_adjust_client_area(self->frame);
XEvent event;
event.type = ConfigureNotify;
- event.xconfigure.display = ob_display;
+ event.xconfigure.display = obt_display;
event.xconfigure.event = self->window;
event.xconfigure.window = self->window;
- ob_debug("Sending ConfigureNotify to %s for %d,%d %dx%d\n",
+ ob_debug("Sending ConfigureNotify to %s for %d,%d %dx%d",
self->title, self->root_pos.x, self->root_pos.y, w, h);
/* root window real coords */
*/
if (send_resize_client && (w <= oldw || h <= oldh)) {
frame_adjust_client_area(self->frame);
- XMoveResizeWindow(ob_display, self->window,
+ XMoveResizeWindow(obt_display, self->window,
self->frame->size.left, self->frame->size.top, w, h);
}
- XFlush(ob_display);
+ XFlush(obt_display);
/* if it moved between monitors, then this can affect the stacking
layer of this window or others - for fullscreen windows */
RECT_SET(self->pre_fullscreen_area, 0, 0, 0, 0);
}
- ob_debug("Window %s going fullscreen (%d)\n",
+ ob_debug("Window %s going fullscreen (%d)",
self->title, self->fullscreen);
client_setup_decor_and_functions(self, FALSE);
if (self->iconic != iconic) {
- ob_debug("%sconifying window: 0x%lx\n", (iconic ? "I" : "Uni"),
+ ob_debug("%sconifying window: 0x%lx", (iconic ? "I" : "Uni"),
self->window);
if (iconic) {
if (!self->delete_window)
/* don't use client_kill(), we should only kill based on PID in
response to a lack of PING replies */
- XKillClient(ob_display, self->window);
+ XKillClient(obt_display, self->window);
else {
/* request the client to close with WM_DELETE_WINDOW */
- PROP_MSG_TO(self->window, self->window, wm_protocols,
- prop_atoms.wm_delete_window, event_curtime, 0, 0, 0,
- NoEventMask);
+ OBT_PROP_MSG_TO(self->window, self->window, WM_PROTOCOLS,
+ OBT_PROP_ATOM(WM_DELETE_WINDOW), event_curtime,
+ 0, 0, 0, NoEventMask);
/* we're trying to close the window, so see if it is responding. if it
is not, then we will let them kill the window */
client_update_title(self);
}
else {
- ob_debug("killing window 0x%x with pid %lu, with SIGKILL\n",
+ ob_debug("killing window 0x%x with pid %lu, with SIGKILL",
self->window, self->pid);
kill(self->pid, SIGKILL); /* kill -9 */
}
}
else {
/* running on a remote host */
- XKillClient(ob_display, self->window);
+ XKillClient(obt_display, self->window);
}
}
if (target != self->desktop && self->type != OB_CLIENT_TYPE_DESKTOP) {
- ob_debug("Setting desktop %u\n", target+1);
+ ob_debug("Setting desktop %u", target+1);
g_assert(target < screen_num_desktops || target == DESKTOP_ALL);
old = self->desktop;
self->desktop = target;
- PROP_SET32(self->window, net_wm_desktop, cardinal, target);
+ OBT_PROP_SET32(self->window, NET_WM_DESKTOP, CARDINAL, target);
/* the frame can display the current desktop state */
frame_adjust_state(self->frame);
/* 'move' the window to the new desktop */
{
XEvent e;
- XSync(ob_display, FALSE); /* get all events on the server */
+ XSync(obt_display, FALSE); /* get all events on the server */
- if (XCheckTypedWindowEvent(ob_display, self->window, DestroyNotify, &e) ||
- XCheckTypedWindowEvent(ob_display, self->window, UnmapNotify, &e)) {
- XPutBackEvent(ob_display, &e);
+ if (XCheckTypedWindowEvent(obt_display, self->window, DestroyNotify, &e) ||
+ XCheckTypedWindowEvent(obt_display, self->window, UnmapNotify, &e))
+ {
+ XPutBackEvent(obt_display, &e);
return FALSE;
}
gboolean below = self->below;
gint i;
- if (!(action == prop_atoms.net_wm_state_add ||
- action == prop_atoms.net_wm_state_remove ||
- action == prop_atoms.net_wm_state_toggle))
+ if (!(action == OBT_PROP_ATOM(NET_WM_STATE_ADD) ||
+ action == OBT_PROP_ATOM(NET_WM_STATE_REMOVE) ||
+ action == OBT_PROP_ATOM(NET_WM_STATE_TOGGLE)))
/* an invalid action was passed to the client message, ignore it */
return;
if (!state) continue;
/* if toggling, then pick whether we're adding or removing */
- if (action == prop_atoms.net_wm_state_toggle) {
- if (state == prop_atoms.net_wm_state_modal)
- action = modal ? prop_atoms.net_wm_state_remove :
- prop_atoms.net_wm_state_add;
- else if (state == prop_atoms.net_wm_state_maximized_vert)
- action = self->max_vert ? prop_atoms.net_wm_state_remove :
- prop_atoms.net_wm_state_add;
- else if (state == prop_atoms.net_wm_state_maximized_horz)
- action = self->max_horz ? prop_atoms.net_wm_state_remove :
- prop_atoms.net_wm_state_add;
- else if (state == prop_atoms.net_wm_state_shaded)
- action = shaded ? prop_atoms.net_wm_state_remove :
- prop_atoms.net_wm_state_add;
- else if (state == prop_atoms.net_wm_state_skip_taskbar)
+ if (action == OBT_PROP_ATOM(NET_WM_STATE_TOGGLE)) {
+ if (state == OBT_PROP_ATOM(NET_WM_STATE_MODAL))
+ action = modal ? OBT_PROP_ATOM(NET_WM_STATE_REMOVE) :
+ OBT_PROP_ATOM(NET_WM_STATE_ADD);
+ else if (state == OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT))
+ action = self->max_vert ? OBT_PROP_ATOM(NET_WM_STATE_REMOVE) :
+ OBT_PROP_ATOM(NET_WM_STATE_ADD);
+ else if (state == OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ))
+ action = self->max_horz ? OBT_PROP_ATOM(NET_WM_STATE_REMOVE) :
+ OBT_PROP_ATOM(NET_WM_STATE_ADD);
+ else if (state == OBT_PROP_ATOM(NET_WM_STATE_SHADED))
+ action = shaded ? OBT_PROP_ATOM(NET_WM_STATE_REMOVE) :
+ OBT_PROP_ATOM(NET_WM_STATE_ADD);
+ else if (state == OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR))
action = self->skip_taskbar ?
- prop_atoms.net_wm_state_remove :
- prop_atoms.net_wm_state_add;
- else if (state == prop_atoms.net_wm_state_skip_pager)
+ OBT_PROP_ATOM(NET_WM_STATE_REMOVE) :
+ OBT_PROP_ATOM(NET_WM_STATE_ADD);
+ else if (state == OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER))
action = self->skip_pager ?
- prop_atoms.net_wm_state_remove :
- prop_atoms.net_wm_state_add;
- else if (state == prop_atoms.net_wm_state_hidden)
+ OBT_PROP_ATOM(NET_WM_STATE_REMOVE) :
+ OBT_PROP_ATOM(NET_WM_STATE_ADD);
+ else if (state == OBT_PROP_ATOM(NET_WM_STATE_HIDDEN))
action = self->iconic ?
- prop_atoms.net_wm_state_remove :
- prop_atoms.net_wm_state_add;
- else if (state == prop_atoms.net_wm_state_fullscreen)
+ OBT_PROP_ATOM(NET_WM_STATE_REMOVE) :
+ OBT_PROP_ATOM(NET_WM_STATE_ADD);
+ else if (state == OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN))
action = fullscreen ?
- prop_atoms.net_wm_state_remove :
- prop_atoms.net_wm_state_add;
- else if (state == prop_atoms.net_wm_state_above)
- action = self->above ? prop_atoms.net_wm_state_remove :
- prop_atoms.net_wm_state_add;
- else if (state == prop_atoms.net_wm_state_below)
- action = self->below ? prop_atoms.net_wm_state_remove :
- prop_atoms.net_wm_state_add;
- else if (state == prop_atoms.net_wm_state_demands_attention)
+ OBT_PROP_ATOM(NET_WM_STATE_REMOVE) :
+ OBT_PROP_ATOM(NET_WM_STATE_ADD);
+ else if (state == OBT_PROP_ATOM(NET_WM_STATE_ABOVE))
+ action = self->above ? OBT_PROP_ATOM(NET_WM_STATE_REMOVE) :
+ OBT_PROP_ATOM(NET_WM_STATE_ADD);
+ else if (state == OBT_PROP_ATOM(NET_WM_STATE_BELOW))
+ action = self->below ? OBT_PROP_ATOM(NET_WM_STATE_REMOVE) :
+ OBT_PROP_ATOM(NET_WM_STATE_ADD);
+ else if (state == OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION))
action = self->demands_attention ?
- prop_atoms.net_wm_state_remove :
- prop_atoms.net_wm_state_add;
- else if (state == prop_atoms.ob_wm_state_undecorated)
- action = undecorated ? prop_atoms.net_wm_state_remove :
- prop_atoms.net_wm_state_add;
+ OBT_PROP_ATOM(NET_WM_STATE_REMOVE) :
+ OBT_PROP_ATOM(NET_WM_STATE_ADD);
+ else if (state == OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED))
+ action = undecorated ? OBT_PROP_ATOM(NET_WM_STATE_REMOVE) :
+ OBT_PROP_ATOM(NET_WM_STATE_ADD);
}
- if (action == prop_atoms.net_wm_state_add) {
- if (state == prop_atoms.net_wm_state_modal) {
+ if (action == OBT_PROP_ATOM(NET_WM_STATE_ADD)) {
+ if (state == OBT_PROP_ATOM(NET_WM_STATE_MODAL)) {
modal = TRUE;
- } else if (state == prop_atoms.net_wm_state_maximized_vert) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT)) {
max_vert = TRUE;
- } else if (state == prop_atoms.net_wm_state_maximized_horz) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ)) {
max_horz = TRUE;
- } else if (state == prop_atoms.net_wm_state_shaded) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_SHADED)) {
shaded = TRUE;
- } else if (state == prop_atoms.net_wm_state_skip_taskbar) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR)) {
self->skip_taskbar = TRUE;
- } else if (state == prop_atoms.net_wm_state_skip_pager) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER)) {
self->skip_pager = TRUE;
- } else if (state == prop_atoms.net_wm_state_hidden) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_HIDDEN)) {
iconic = TRUE;
- } else if (state == prop_atoms.net_wm_state_fullscreen) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN)) {
fullscreen = TRUE;
- } else if (state == prop_atoms.net_wm_state_above) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_ABOVE)) {
above = TRUE;
below = FALSE;
- } else if (state == prop_atoms.net_wm_state_below) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_BELOW)) {
above = FALSE;
below = TRUE;
- } else if (state == prop_atoms.net_wm_state_demands_attention) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION)){
demands_attention = TRUE;
- } else if (state == prop_atoms.ob_wm_state_undecorated) {
+ } else if (state == OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED)) {
undecorated = TRUE;
}
- } else { /* action == prop_atoms.net_wm_state_remove */
- if (state == prop_atoms.net_wm_state_modal) {
+ } else { /* action == OBT_PROP_ATOM(NET_WM_STATE_REMOVE) */
+ if (state == OBT_PROP_ATOM(NET_WM_STATE_MODAL)) {
modal = FALSE;
- } else if (state == prop_atoms.net_wm_state_maximized_vert) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT)) {
max_vert = FALSE;
- } else if (state == prop_atoms.net_wm_state_maximized_horz) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ)) {
max_horz = FALSE;
- } else if (state == prop_atoms.net_wm_state_shaded) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_SHADED)) {
shaded = FALSE;
- } else if (state == prop_atoms.net_wm_state_skip_taskbar) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR)) {
self->skip_taskbar = FALSE;
- } else if (state == prop_atoms.net_wm_state_skip_pager) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER)) {
self->skip_pager = FALSE;
- } else if (state == prop_atoms.net_wm_state_hidden) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_HIDDEN)) {
iconic = FALSE;
- } else if (state == prop_atoms.net_wm_state_fullscreen) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN)) {
fullscreen = FALSE;
- } else if (state == prop_atoms.net_wm_state_above) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_ABOVE)) {
above = FALSE;
- } else if (state == prop_atoms.net_wm_state_below) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_BELOW)) {
below = FALSE;
- } else if (state == prop_atoms.net_wm_state_demands_attention) {
+ } else if (state == OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION)){
demands_attention = FALSE;
- } else if (state == prop_atoms.ob_wm_state_undecorated) {
+ } else if (state == OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED)) {
undecorated = FALSE;
}
}
if (!client_can_focus(self)) {
ob_debug_type(OB_DEBUG_FOCUS,
- "Client %s can't be focused\n", self->title);
+ "Client %s can't be focused", self->title);
return FALSE;
}
ob_debug_type(OB_DEBUG_FOCUS,
- "Focusing client \"%s\" (0x%x) at time %u\n",
+ "Focusing client \"%s\" (0x%x) at time %u",
self->title, self->window, event_curtime);
/* if using focus_delay, stop the timer now so that focus doesn't
*/
event_cancel_all_key_grabs();
- xerror_set_ignore(TRUE);
- xerror_occured = FALSE;
+ obt_display_ignore_errors(TRUE);
if (self->can_focus) {
/* This can cause a BadMatch error with CurrentTime, or if an app
passed in a bad time for _NET_WM_ACTIVE_WINDOW. */
- XSetInputFocus(ob_display, self->window, RevertToPointerRoot,
+ XSetInputFocus(obt_display, self->window, RevertToPointerRoot,
event_curtime);
}
if (self->focus_notify) {
XEvent ce;
ce.xclient.type = ClientMessage;
- ce.xclient.message_type = prop_atoms.wm_protocols;
- ce.xclient.display = ob_display;
+ ce.xclient.message_type = OBT_PROP_ATOM(WM_PROTOCOLS);
+ ce.xclient.display = obt_display;
ce.xclient.window = self->window;
ce.xclient.format = 32;
- ce.xclient.data.l[0] = prop_atoms.wm_take_focus;
+ ce.xclient.data.l[0] = OBT_PROP_ATOM(WM_TAKE_FOCUS);
ce.xclient.data.l[1] = event_curtime;
ce.xclient.data.l[2] = 0l;
ce.xclient.data.l[3] = 0l;
ce.xclient.data.l[4] = 0l;
- XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce);
+ XSendEvent(obt_display, self->window, FALSE, NoEventMask, &ce);
}
- xerror_set_ignore(FALSE);
+ obt_display_ignore_errors(FALSE);
- ob_debug_type(OB_DEBUG_FOCUS, "Error focusing? %d\n", xerror_occured);
- return !xerror_occured;
+ ob_debug_type(OB_DEBUG_FOCUS, "Error focusing? %d",
+ obt_display_error_occured);
+ return !obt_display_error_occured;
}
static void client_present(ObClient *self, gboolean here, gboolean raise,
return self == focus_client;
}
-static ObClientIcon* client_icon_recursive(ObClient *self, gint w, gint h)
-{
- guint i;
- gulong min_diff, min_i;
-
- if (!self->nicons) {
- ObClientIcon *parent = NULL;
- GSList *it;
- for (it = self->parents; it; it = g_slist_next(it)) {
- ObClient *c = it->data;
- if ((parent = client_icon_recursive(c, w, h)))
- break;
- }
- return parent;
- }
-
- /* some kind of crappy approximation to find the icon closest in size to
- what we requested, but icons are generally all the same ratio as
- eachother so it's good enough. */
-
- min_diff = ABS(self->icons[0].width - w) + ABS(self->icons[0].height - h);
- min_i = 0;
-
- for (i = 1; i < self->nicons; ++i) {
- gulong diff;
-
- diff = ABS(self->icons[i].width - w) + ABS(self->icons[i].height - h);
- if (diff < min_diff) {
- min_diff = diff;
- min_i = i;
- }
- }
- return &self->icons[min_i];
-}
-
-const ObClientIcon* client_icon(ObClient *self, gint w, gint h)
+RrImage* client_icon(ObClient *self)
{
- ObClientIcon *ret;
- static ObClientIcon deficon;
+ RrImage *ret = NULL;
- if (!(ret = client_icon_recursive(self, w, h))) {
- deficon.width = deficon.height = 48;
- deficon.data = ob_rr_theme->def_win_icon;
- ret = &deficon;
+ if (self->icon_set)
+ ret = self->icon_set;
+ else if (self->parents) {
+ GSList *it;
+ for (it = self->parents; it && !ret; it = g_slist_next(it))
+ ret = client_icon(it->data);
}
+ if (!ret)
+ ret = client_default_icon;
return ret;
}
g_assert_not_reached();
}
- ob_debug("my head %d size %d\n", my_head, my_size);
- ob_debug("head %d tail %d deest %d\n", head, tail, *dest);
+ ob_debug("my head %d size %d", my_head, my_size);
+ ob_debug("head %d tail %d deest %d", head, tail, *dest);
if (!skip_head) {
- ob_debug("using near edge %d\n", head);
+ ob_debug("using near edge %d", head);
*dest = head;
*near_edge = TRUE;
}
else if (!skip_tail) {
- ob_debug("using far edge %d\n", tail);
+ ob_debug("using far edge %d", tail);
*dest = tail;
*near_edge = FALSE;
}
cur->desktop != screen_desktop)
continue;
- ob_debug("trying window %s\n", cur->title);
+ ob_debug("trying window %s", cur->title);
detect_edge(cur->frame->area, dir, my_head, my_size, my_edge_start,
my_edge_size, dest, near_edge);
g_assert_not_reached();
}
- ob_debug("head %d dir %d\n", head, dir);
+ ob_debug("head %d dir %d", head, dir);
client_find_edge_directional(self, dir, head, 1,
e_start, e_size, &e, &near);
- ob_debug("edge %d\n", e);
+ ob_debug("edge %d", e);
*x = self->frame->area.x;
*y = self->frame->area.y;
*w = self->frame->area.width;
struct _ObPrompt;
typedef struct _ObClient ObClient;
-typedef struct _ObClientIcon ObClientIcon;
-
-/*! Holds an icon in ARGB format */
-struct _ObClientIcon
-{
- gint width;
- gint height;
- RrPixel32 *data;
-};
/*! Possible window types */
typedef enum
*/
guint functions;
- /*! Icons for the client as specified on the client window */
- ObClientIcon *icons;
- /*! The number of icons in icons */
- guint nicons;
+ /* The window's icon, in a variety of shapes and sizes */
+ RrImage *icon_set;
/*! Where the window should iconify to/from */
Rect icon_geometry;
void client_add_destroy_notify(ObClientCallback func, gpointer data);
void client_remove_destroy_notify(ObClientCallback func);
-/*! Manages all existing windows */
-void client_manage_all();
/*! Manages a given window
@param prompt This specifies an ObPrompt which is being managed. It is
possible to manage Openbox-owned windows through this.
/*! Sets the window's type and transient flag */
void client_get_type_and_transientness(ObClient *self);
-const ObClientIcon *client_icon(ObClient *self, gint w, gint h);
+/*! Returns a client's icon set, or its parents (recursively) if it doesn't
+ have one
+*/
+RrImage* client_icon(ObClient *self);
/*! Return TRUE if the client is transient for some other window. Return
FALSE if it's not transient or there is no window for it to be
if (client_normal(c) && (!c->skip_taskbar || c->iconic) &&
(c->desktop == desktop || c->desktop == DESKTOP_ALL))
{
- const ObClientIcon *icon;
-
empty = FALSE;
if (c->iconic) {
e = menu_add_normal(menu, desktop, c->title, NULL, FALSE);
}
- if (config_menu_client_list_icons
- && (icon = client_icon(c, 32, 32))) {
- e->data.normal.icon_width = icon->width;
- e->data.normal.icon_height = icon->height;
- e->data.normal.icon_data = icon->data;
+ if (config_menu_client_list_icons) {
+ e->data.normal.icon = client_icon(c);
+ RrImageRef(e->data.normal.icon);
e->data.normal.icon_alpha =
c->iconic ? OB_ICONIC_ALPHA : 0xff;
}
(c->desktop == d->desktop || c->desktop == DESKTOP_ALL))
{
ObMenuEntry *e;
- const ObClientIcon *icon;
empty = FALSE;
e = menu_add_normal(menu, d->desktop, c->title, NULL, FALSE);
}
- if (config_menu_client_list_icons
- && (icon = client_icon(c, 32, 32))) {
- e->data.normal.icon_width = icon->width;
- e->data.normal.icon_height = icon->height;
- e->data.normal.icon_data = icon->data;
+ if (config_menu_client_list_icons) {
+ e->data.normal.icon = client_icon(c);
+ RrImageRef(e->data.normal.icon);
e->data.normal.icon_alpha = c->iconic ? OB_ICONIC_ALPHA : 0xff;
}
#include "frame.h"
#include "moveresize.h"
#include "event.h"
-#include "prop.h"
#include "gettext.h"
+#include "obt/prop.h"
#include <glib.h>
screen_pointer_pos(&x, &y);
moveresize_start(c, x, y, 0,
- prop_atoms.net_wm_moveresize_move_keyboard);
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE_KEYBOARD));
break;
case CLIENT_RESIZE:
/* this needs to grab the keyboard so hide the menu */
screen_pointer_pos(&x, &y);
moveresize_start(c, x, y, 0,
- prop_atoms.net_wm_moveresize_size_keyboard);
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_KEYBOARD));
break;
case CLIENT_CLOSE:
client_close(c);
#include "keyboard.h"
#include "mouse.h"
#include "actions.h"
-#include "prop.h"
#include "translate.h"
#include "client.h"
#include "screen.h"
-#include "parser/parse.h"
#include "openbox.h"
#include "gettext.h"
+#include "obt/paths.h"
gboolean config_focus_new;
gboolean config_focus_follow;
}
}
-static void config_parse_gravity_coord(xmlDocPtr doc, xmlNodePtr node,
- GravityCoord *c)
+static void config_parse_gravity_coord(xmlNodePtr node, GravityCoord *c)
{
- gchar *s = parse_string(doc, node);
+ gchar *s = obt_parse_node_string(node);
if (!g_ascii_strcasecmp(s, "center"))
c->center = TRUE;
else {
the monitor, so <position><x>center</x></position><monitor>2</monitor>
will center the window on the second monitor.
*/
-static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
- xmlNodePtr node, gpointer data)
+static void parse_per_app_settings(xmlNodePtr node, gpointer d)
{
- xmlNodePtr app = parse_find_node("application", node->children);
+ xmlNodePtr app = obt_parse_find_node(node->children, "application");
gchar *name = NULL, *class = NULL, *role = NULL, *type = NULL;
gboolean name_set, class_set, type_set;
gboolean x_pos_given;
while (app) {
name_set = class_set = type_set = x_pos_given = FALSE;
- class_set = parse_attr_string("class", app, &class);
- name_set = parse_attr_string("name", app, &name);
- type_set = parse_attr_string("type", app, &type);
+ class_set = obt_parse_attr_string(app, "class", &class);
+ name_set = obt_parse_attr_string(app, "name", &name);
+ type_set = obt_parse_attr_string(app, "type", &type);
if (class_set || name_set) {
xmlNodePtr n, c;
ObAppSettings *settings = config_create_app_settings();;
settings->type = OB_CLIENT_TYPE_DESKTOP;
}
- if (parse_attr_string("role", app, &role))
+ if (obt_parse_attr_string(app, "role", &role))
settings->role = g_pattern_spec_new(role);
- if ((n = parse_find_node("decor", app->children)))
- if (!parse_contains("default", doc, n))
- settings->decor = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(app->children, "decor")))
+ if (!obt_parse_node_contains(n, "default"))
+ settings->decor = obt_parse_node_bool(n);
- if ((n = parse_find_node("shade", app->children)))
- if (!parse_contains("default", doc, n))
- settings->shade = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(app->children, "shade")))
+ if (!obt_parse_node_contains(n, "default"))
+ settings->shade = obt_parse_node_bool(n);
- if ((n = parse_find_node("position", app->children))) {
- if ((c = parse_find_node("x", n->children)))
- if (!parse_contains("default", doc, c)) {
- config_parse_gravity_coord(doc, c,
- &settings->position.x);
+ if ((n = obt_parse_find_node(app->children, "position"))) {
+ if ((c = obt_parse_find_node(n->children, "x")))
+ if (!obt_parse_node_contains(c, "default")) {
+ config_parse_gravity_coord(c, &settings->position.x);
x_pos_given = TRUE;
}
- if (x_pos_given && (c = parse_find_node("y", n->children)))
- if (!parse_contains("default", doc, c)) {
- config_parse_gravity_coord(doc, c,
- &settings->position.y);
+ if (x_pos_given && (c = obt_parse_find_node(n->children, "y")))
+ if (!obt_parse_node_contains(c, "default")) {
+ config_parse_gravity_coord(c, &settings->position.y);
settings->pos_given = TRUE;
}
if (settings->pos_given &&
- (c = parse_find_node("monitor", n->children)))
- if (!parse_contains("default", doc, c)) {
- gchar *s = parse_string(doc, c);
+ (c = obt_parse_find_node(n->children, "monitor")))
+ if (!obt_parse_node_contains(c, "default")) {
+ gchar *s = obt_parse_node_string(c);
if (!g_ascii_strcasecmp(s, "mouse"))
settings->monitor = 0;
else
- settings->monitor = parse_int(doc, c) + 1;
+ settings->monitor = obt_parse_node_int(c) + 1;
g_free(s);
}
- parse_attr_bool("force", n, &settings->pos_force);
+ obt_parse_attr_bool(n, "force", &settings->pos_force);
}
- if ((n = parse_find_node("focus", app->children)))
- if (!parse_contains("default", doc, n))
- settings->focus = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(app->children, "focus")))
+ if (!obt_parse_node_contains(n, "default"))
+ settings->focus = obt_parse_node_bool(n);
- if ((n = parse_find_node("desktop", app->children))) {
- if (!parse_contains("default", doc, n)) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(app->children, "desktop"))) {
+ if (!obt_parse_node_contains(n, "default")) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "all"))
settings->desktop = DESKTOP_ALL;
else {
- gint i = parse_int(doc, n);
+ gint i = obt_parse_node_int(n);
if (i > 0)
settings->desktop = i;
}
}
}
- if ((n = parse_find_node("layer", app->children)))
- if (!parse_contains("default", doc, n)) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(app->children, "layer")))
+ if (!obt_parse_node_contains(n, "default")) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "above"))
settings->layer = 1;
else if (!g_ascii_strcasecmp(s, "below"))
g_free(s);
}
- if ((n = parse_find_node("iconic", app->children)))
- if (!parse_contains("default", doc, n))
- settings->iconic = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(app->children, "iconic")))
+ if (!obt_parse_node_contains(n, "default"))
+ settings->iconic = obt_parse_node_bool(n);
- if ((n = parse_find_node("skip_pager", app->children)))
- if (!parse_contains("default", doc, n))
- settings->skip_pager = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(app->children, "skip_pager")))
+ if (!obt_parse_node_contains(n, "default"))
+ settings->skip_pager = obt_parse_node_bool(n);
- if ((n = parse_find_node("skip_taskbar", app->children)))
- if (!parse_contains("default", doc, n))
- settings->skip_taskbar = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(app->children, "skip_taskbar")))
+ if (!obt_parse_node_contains(n, "default"))
+ settings->skip_taskbar = obt_parse_node_bool(n);
- if ((n = parse_find_node("fullscreen", app->children)))
- if (!parse_contains("default", doc, n))
- settings->fullscreen = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(app->children, "fullscreen")))
+ if (!obt_parse_node_contains(n, "default"))
+ settings->fullscreen = obt_parse_node_bool(n);
- if ((n = parse_find_node("maximized", app->children)))
- if (!parse_contains("default", doc, n)) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_parse_find_node(app->children, "maximized")))
+ if (!obt_parse_node_contains(n, "default")) {
+ gchar *s = obt_parse_node_string(n);
if (!g_ascii_strcasecmp(s, "horizontal")) {
settings->max_horz = TRUE;
settings->max_vert = FALSE;
settings->max_vert = TRUE;
} else
settings->max_horz = settings->max_vert =
- parse_bool(doc, n);
+ obt_parse_node_bool(n);
g_free(s);
}
name = class = role = NULL;
}
- app = parse_find_node("application", app->next);
+ app = obt_parse_find_node(app->next, "application");
}
}
*/
-static void parse_key(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- GList *keylist)
+static void parse_key(xmlNodePtr node, GList *keylist)
{
gchar *key;
xmlNodePtr n;
gboolean is_chroot = FALSE;
- if (!parse_attr_string("key", node, &key))
+ if (!obt_parse_attr_string(node, "key", &key))
return;
- parse_attr_bool("chroot", node, &is_chroot);
+ obt_parse_attr_bool(node, "chroot", &is_chroot);
keylist = g_list_append(keylist, key);
- if ((n = parse_find_node("keybind", node->children))) {
+ if ((n = obt_parse_find_node(node->children, "keybind"))) {
while (n) {
- parse_key(i, doc, n, keylist);
- n = parse_find_node("keybind", n->next);
+ parse_key(n, keylist);
+ n = obt_parse_find_node(n->next, "keybind");
}
}
- else if ((n = parse_find_node("action", node->children))) {
+ else if ((n = obt_parse_find_node(node->children, "action"))) {
while (n) {
ObActionsAct *action;
- action = actions_parse(i, doc, n);
+ action = actions_parse(n);
if (action)
keyboard_bind(keylist, action);
- n = parse_find_node("action", n->next);
+ n = obt_parse_find_node(n->next, "action");
}
}
keylist = g_list_delete_link(keylist, g_list_last(keylist));
}
-static void parse_keyboard(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_keyboard(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
gchar *key;
keyboard_unbind_all();
- if ((n = parse_find_node("chainQuitKey", node->children))) {
- key = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node->children, "chainQuitKey"))) {
+ key = obt_parse_node_string(n);
translate_key(key, &config_keyboard_reset_state,
&config_keyboard_reset_keycode);
g_free(key);
}
- if ((n = parse_find_node("keybind", node->children)))
+ if ((n = obt_parse_find_node(node->children, "keybind")))
while (n) {
- parse_key(i, doc, n, NULL);
- n = parse_find_node("keybind", n->next);
+ parse_key(n, NULL);
+ n = obt_parse_find_node(n->next, "keybind");
}
}
*/
-static void parse_mouse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_mouse(xmlNodePtr node, gpointer d)
{
xmlNodePtr n, nbut, nact;
gchar *buttonstr;
node = node->children;
- if ((n = parse_find_node("dragThreshold", node)))
- config_mouse_threshold = parse_int(doc, n);
- if ((n = parse_find_node("doubleClickTime", node)))
- config_mouse_dclicktime = parse_int(doc, n);
- if ((n = parse_find_node("screenEdgeWarpTime", node)))
- config_mouse_screenedgetime = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "dragThreshold")))
+ config_mouse_threshold = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "doubleClickTime")))
+ config_mouse_dclicktime = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "screenEdgeWarpTime")))
+ config_mouse_screenedgetime = obt_parse_node_int(n);
- n = parse_find_node("context", node);
+ n = obt_parse_find_node(node, "context");
while (n) {
- if (!parse_attr_string("name", n, &contextstr))
+ if (!obt_parse_attr_string(n, "name", &contextstr))
goto next_n;
- nbut = parse_find_node("mousebind", n->children);
+ nbut = obt_parse_find_node(n->children, "mousebind");
while (nbut) {
- if (!parse_attr_string("button", nbut, &buttonstr))
+ if (!obt_parse_attr_string(nbut, "button", &buttonstr))
goto next_nbut;
- if (parse_attr_contains("press", nbut, "action")) {
+ if (obt_parse_attr_contains(nbut, "action", "press")) {
mact = OB_MOUSE_ACTION_PRESS;
- } else if (parse_attr_contains("release", nbut, "action")) {
+ } else if (obt_parse_attr_contains(nbut, "action", "release")) {
mact = OB_MOUSE_ACTION_RELEASE;
- } else if (parse_attr_contains("click", nbut, "action")) {
+ } else if (obt_parse_attr_contains(nbut, "action", "click")) {
mact = OB_MOUSE_ACTION_CLICK;
- } else if (parse_attr_contains("doubleclick", nbut,"action")) {
+ } else if (obt_parse_attr_contains(nbut, "action","doubleclick")) {
mact = OB_MOUSE_ACTION_DOUBLE_CLICK;
- } else if (parse_attr_contains("drag", nbut, "action")) {
+ } else if (obt_parse_attr_contains(nbut, "action", "drag")) {
mact = OB_MOUSE_ACTION_MOTION;
} else
goto next_nbut;
- nact = parse_find_node("action", nbut->children);
+ nact = obt_parse_find_node(nbut->children, "action");
while (nact) {
ObActionsAct *action;
- if ((action = actions_parse(i, doc, nact)))
+ if ((action = actions_parse(nact)))
mouse_bind(buttonstr, contextstr, mact, action);
- nact = parse_find_node("action", nact->next);
+ nact = obt_parse_find_node(nact->next, "action");
}
g_free(buttonstr);
next_nbut:
- nbut = parse_find_node("mousebind", nbut->next);
+ nbut = obt_parse_find_node(nbut->next, "mousebind");
}
g_free(contextstr);
next_n:
- n = parse_find_node("context", n->next);
+ n = obt_parse_find_node(n->next, "context");
}
}
-static void parse_focus(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_focus(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
node = node->children;
- if ((n = parse_find_node("focusNew", node)))
- config_focus_new = parse_bool(doc, n);
- if ((n = parse_find_node("followMouse", node)))
- config_focus_follow = parse_bool(doc, n);
- if ((n = parse_find_node("focusDelay", node)))
- config_focus_delay = parse_int(doc, n);
- if ((n = parse_find_node("raiseOnFocus", node)))
- config_focus_raise = parse_bool(doc, n);
- if ((n = parse_find_node("focusLast", node)))
- config_focus_last = parse_bool(doc, n);
- if ((n = parse_find_node("underMouse", node)))
- config_focus_under_mouse = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(node, "focusNew")))
+ config_focus_new = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "followMouse")))
+ config_focus_follow = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "focusDelay")))
+ config_focus_delay = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "raiseOnFocus")))
+ config_focus_raise = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "focusLast")))
+ config_focus_last = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "underMouse")))
+ config_focus_under_mouse = obt_parse_node_bool(n);
}
-static void parse_placement(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_placement(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
node = node->children;
- if ((n = parse_find_node("policy", node)))
- if (parse_contains("UnderMouse", doc, n))
+ if ((n = obt_parse_find_node(node, "policy")))
+ if (obt_parse_node_contains(n, "UnderMouse"))
config_place_policy = OB_PLACE_POLICY_MOUSE;
- if ((n = parse_find_node("center", node)))
- config_place_center = parse_bool(doc, n);
- if ((n = parse_find_node("monitor", node))) {
- if (parse_contains("active", doc, n))
+ if ((n = obt_parse_find_node(node, "center")))
+ config_place_center = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "monitor"))) {
+ if (obt_parse_node_contains(n, "active"))
config_place_monitor = OB_PLACE_MONITOR_ACTIVE;
- else if (parse_contains("mouse", doc, n))
+ else if (obt_parse_node_contains(n, "mouse"))
config_place_monitor = OB_PLACE_MONITOR_MOUSE;
}
}
-static void parse_margins(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_margins(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
node = node->children;
- if ((n = parse_find_node("top", node)))
- config_margins.top = MAX(0, parse_int(doc, n));
- if ((n = parse_find_node("left", node)))
- config_margins.left = MAX(0, parse_int(doc, n));
- if ((n = parse_find_node("right", node)))
- config_margins.right = MAX(0, parse_int(doc, n));
- if ((n = parse_find_node("bottom", node)))
- config_margins.bottom = MAX(0, parse_int(doc, n));
+ if ((n = obt_parse_find_node(node, "top")))
+ config_margins.top = MAX(0, obt_parse_node_int(n));
+ if ((n = obt_parse_find_node(node, "left")))
+ config_margins.left = MAX(0, obt_parse_node_int(n));
+ if ((n = obt_parse_find_node(node, "right")))
+ config_margins.right = MAX(0, obt_parse_node_int(n));
+ if ((n = obt_parse_find_node(node, "bottom")))
+ config_margins.bottom = MAX(0, obt_parse_node_int(n));
}
-static void parse_theme(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_theme(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
node = node->children;
- if ((n = parse_find_node("name", node))) {
+ if ((n = obt_parse_find_node(node, "name"))) {
gchar *c;
g_free(config_theme);
- c = parse_string(doc, n);
- config_theme = parse_expand_tilde(c);
+ c = obt_parse_node_string(n);
+ config_theme = obt_paths_expand_tilde(c);
g_free(c);
}
- if ((n = parse_find_node("titleLayout", node))) {
+ if ((n = obt_parse_find_node(node, "titleLayout"))) {
gchar *c, *d;
g_free(config_title_layout);
- config_title_layout = parse_string(doc, n);
+ config_title_layout = obt_parse_node_string(n);
/* replace duplicates with spaces */
for (c = config_title_layout; *c != '\0'; ++c)
for (d = c+1; *d != '\0'; ++d)
if (*c == *d) *d = ' ';
}
- if ((n = parse_find_node("keepBorder", node)))
- config_theme_keepborder = parse_bool(doc, n);
- if ((n = parse_find_node("animateIconify", node)))
- config_animate_iconify = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(node, "keepBorder")))
+ config_theme_keepborder = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "animateIconify")))
+ config_animate_iconify = obt_parse_node_bool(n);
- n = parse_find_node("font", node);
+ n = obt_parse_find_node(node, "font");
while (n) {
xmlNodePtr fnode;
RrFont **font;
RrFontWeight weight = RrDefaultFontWeight;
RrFontSlant slant = RrDefaultFontSlant;
- if (parse_attr_contains("ActiveWindow", n, "place"))
+ if (obt_parse_attr_contains(n, "place", "ActiveWindow"))
font = &config_font_activewindow;
- else if (parse_attr_contains("InactiveWindow", n, "place"))
+ else if (obt_parse_attr_contains(n, "place", "InactiveWindow"))
font = &config_font_inactivewindow;
- else if (parse_attr_contains("MenuHeader", n, "place"))
+ else if (obt_parse_attr_contains(n, "place", "MenuHeader"))
font = &config_font_menutitle;
- else if (parse_attr_contains("MenuItem", n, "place"))
+ else if (obt_parse_attr_contains(n, "place", "MenuItem"))
font = &config_font_menuitem;
- else if (parse_attr_contains("OnScreenDisplay", n, "place"))
+ else if (obt_parse_attr_contains(n, "place", "OnScreenDisplay"))
font = &config_font_osd;
else
goto next_font;
- if ((fnode = parse_find_node("name", n->children))) {
+ if ((fnode = obt_parse_find_node(n->children, "name"))) {
g_free(name);
- name = parse_string(doc, fnode);
+ name = obt_parse_node_string(fnode);
}
- if ((fnode = parse_find_node("size", n->children))) {
- int s = parse_int(doc, fnode);
+ if ((fnode = obt_parse_find_node(n->children, "size"))) {
+ int s = obt_parse_node_int(fnode);
if (s > 0) size = s;
}
- if ((fnode = parse_find_node("weight", n->children))) {
- gchar *w = parse_string(doc, fnode);
+ if ((fnode = obt_parse_find_node(n->children, "weight"))) {
+ gchar *w = obt_parse_node_string(fnode);
if (!g_ascii_strcasecmp(w, "Bold"))
weight = RR_FONTWEIGHT_BOLD;
g_free(w);
}
- if ((fnode = parse_find_node("slant", n->children))) {
- gchar *s = parse_string(doc, fnode);
+ if ((fnode = obt_parse_find_node(n->children, "slant"))) {
+ gchar *s = obt_parse_node_string(fnode);
if (!g_ascii_strcasecmp(s, "Italic"))
slant = RR_FONTSLANT_ITALIC;
if (!g_ascii_strcasecmp(s, "Oblique"))
*font = RrFontOpen(ob_rr_inst, name, size, weight, slant);
g_free(name);
next_font:
- n = parse_find_node("font", n->next);
+ n = obt_parse_find_node(n->next, "font");
}
}
-static void parse_desktops(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_desktops(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
node = node->children;
- if ((n = parse_find_node("number", node))) {
- gint d = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "number"))) {
+ gint d = obt_parse_node_int(n);
if (d > 0)
config_desktops_num = (unsigned) d;
}
- if ((n = parse_find_node("firstdesk", node))) {
- gint d = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "firstdesk"))) {
+ gint d = obt_parse_node_int(n);
if (d > 0)
config_screen_firstdesk = (unsigned) d;
}
- if ((n = parse_find_node("names", node))) {
+ if ((n = obt_parse_find_node(node, "names"))) {
GSList *it;
xmlNodePtr nname;
g_slist_free(config_desktops_names);
config_desktops_names = NULL;
- nname = parse_find_node("name", n->children);
+ nname = obt_parse_find_node(n->children, "name");
while (nname) {
- config_desktops_names = g_slist_append(config_desktops_names,
- parse_string(doc, nname));
- nname = parse_find_node("name", nname->next);
+ config_desktops_names =
+ g_slist_append(config_desktops_names,
+ obt_parse_node_string(nname));
+ nname = obt_parse_find_node(nname->next, "name");
}
}
- if ((n = parse_find_node("popupTime", node)))
- config_desktop_popup_time = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "popupTime")))
+ config_desktop_popup_time = obt_parse_node_int(n);
}
-static void parse_resize(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_resize(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
node = node->children;
- if ((n = parse_find_node("drawContents", node)))
- config_resize_redraw = parse_bool(doc, n);
- if ((n = parse_find_node("popupShow", node))) {
- config_resize_popup_show = parse_int(doc, n);
- if (parse_contains("Always", doc, n))
+ if ((n = obt_parse_find_node(node, "drawContents")))
+ config_resize_redraw = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "popupShow"))) {
+ config_resize_popup_show = obt_parse_node_int(n);
+ if (obt_parse_node_contains(n, "Always"))
config_resize_popup_show = 2;
- else if (parse_contains("Never", doc, n))
+ else if (obt_parse_node_contains(n, "Never"))
config_resize_popup_show = 0;
- else if (parse_contains("Nonpixel", doc, n))
+ else if (obt_parse_node_contains(n, "Nonpixel"))
config_resize_popup_show = 1;
}
- if ((n = parse_find_node("popupPosition", node))) {
- if (parse_contains("Top", doc, n))
+ if ((n = obt_parse_find_node(node, "popupPosition"))) {
+ if (obt_parse_node_contains(n, "Top"))
config_resize_popup_pos = OB_RESIZE_POS_TOP;
- else if (parse_contains("Center", doc, n))
+ else if (obt_parse_node_contains(n, "Center"))
config_resize_popup_pos = OB_RESIZE_POS_CENTER;
- else if (parse_contains("Fixed", doc, n)) {
+ else if (obt_parse_node_contains(n, "Fixed")) {
config_resize_popup_pos = OB_RESIZE_POS_FIXED;
- if ((n = parse_find_node("popupFixedPosition", node))) {
+ if ((n = obt_parse_find_node(node, "popupFixedPosition"))) {
xmlNodePtr n2;
- if ((n2 = parse_find_node("x", n->children)))
- config_parse_gravity_coord(doc, n2,
+ if ((n2 = obt_parse_find_node(n->children, "x")))
+ config_parse_gravity_coord(n2,
&config_resize_popup_fixed.x);
- if ((n2 = parse_find_node("y", n->children)))
- config_parse_gravity_coord(doc, n2,
+ if ((n2 = obt_parse_find_node(n->children, "y")))
+ config_parse_gravity_coord(n2,
&config_resize_popup_fixed.y);
config_resize_popup_fixed.x.pos =
}
}
-static void parse_dock(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_dock(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
node = node->children;
- if ((n = parse_find_node("position", node))) {
- if (parse_contains("TopLeft", doc, n))
+ if ((n = obt_parse_find_node(node, "position"))) {
+ if (obt_parse_node_contains(n, "TopLeft"))
config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_NORTHWEST;
- else if (parse_contains("Top", doc, n))
+ else if (obt_parse_node_contains(n, "Top"))
config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_NORTH;
- else if (parse_contains("TopRight", doc, n))
+ else if (obt_parse_node_contains(n, "TopRight"))
config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_NORTHEAST;
- else if (parse_contains("Right", doc, n))
+ else if (obt_parse_node_contains(n, "Right"))
config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_EAST;
- else if (parse_contains("BottomRight", doc, n))
+ else if (obt_parse_node_contains(n, "BottomRight"))
config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_SOUTHEAST;
- else if (parse_contains("Bottom", doc, n))
+ else if (obt_parse_node_contains(n, "Bottom"))
config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_SOUTH;
- else if (parse_contains("BottomLeft", doc, n))
+ else if (obt_parse_node_contains(n, "BottomLeft"))
config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_SOUTHWEST;
- else if (parse_contains("Left", doc, n))
+ else if (obt_parse_node_contains(n, "Left"))
config_dock_floating = FALSE,
config_dock_pos = OB_DIRECTION_WEST;
- else if (parse_contains("Floating", doc, n))
+ else if (obt_parse_node_contains(n, "Floating"))
config_dock_floating = TRUE;
}
if (config_dock_floating) {
- if ((n = parse_find_node("floatingX", node)))
- config_dock_x = parse_int(doc, n);
- if ((n = parse_find_node("floatingY", node)))
- config_dock_y = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "floatingX")))
+ config_dock_x = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "floatingY")))
+ config_dock_y = obt_parse_node_int(n);
} else {
- if ((n = parse_find_node("noStrut", node)))
- config_dock_nostrut = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(node, "noStrut")))
+ config_dock_nostrut = obt_parse_node_bool(n);
}
- if ((n = parse_find_node("stacking", node))) {
- if (parse_contains("above", doc, n))
- config_dock_layer = OB_STACKING_LAYER_ABOVE;
- else if (parse_contains("normal", doc, n))
+ if ((n = obt_parse_find_node(node, "stacking"))) {
+ if (obt_parse_node_contains(n, "normal"))
config_dock_layer = OB_STACKING_LAYER_NORMAL;
- else if (parse_contains("below", doc, n))
+ else if (obt_parse_node_contains(n, "below"))
config_dock_layer = OB_STACKING_LAYER_BELOW;
+ else if (obt_parse_node_contains(n, "above"))
+ config_dock_layer = OB_STACKING_LAYER_ABOVE;
}
- if ((n = parse_find_node("direction", node))) {
- if (parse_contains("horizontal", doc, n))
+ if ((n = obt_parse_find_node(node, "direction"))) {
+ if (obt_parse_node_contains(n, "horizontal"))
config_dock_orient = OB_ORIENTATION_HORZ;
- else if (parse_contains("vertical", doc, n))
+ else if (obt_parse_node_contains(n, "vertical"))
config_dock_orient = OB_ORIENTATION_VERT;
}
- if ((n = parse_find_node("autoHide", node)))
- config_dock_hide = parse_bool(doc, n);
- if ((n = parse_find_node("hideDelay", node)))
- config_dock_hide_delay = parse_int(doc, n);
- if ((n = parse_find_node("showDelay", node)))
- config_dock_show_delay = parse_int(doc, n);
- if ((n = parse_find_node("moveButton", node))) {
- gchar *str = parse_string(doc, n);
+ if ((n = obt_parse_find_node(node, "autoHide")))
+ config_dock_hide = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "hideDelay")))
+ config_dock_hide_delay = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "showDelay")))
+ config_dock_show_delay = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "moveButton"))) {
+ gchar *str = obt_parse_node_string(n);
guint b, s;
if (translate_button(str, &s, &b)) {
config_dock_app_move_button = b;
}
}
-static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_menu(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
for (node = node->children; node; node = node->next) {
if (!xmlStrcasecmp(node->name, (const xmlChar*) "file")) {
gchar *c;
- c = parse_string(doc, node);
+ c = obt_parse_node_string(node);
config_menu_files = g_slist_append(config_menu_files,
- parse_expand_tilde(c));
+ obt_paths_expand_tilde(c));
g_free(c);
}
- if ((n = parse_find_node("hideDelay", node)))
- config_menu_hide_delay = parse_int(doc, n);
- if ((n = parse_find_node("middle", node)))
- config_menu_middle = parse_bool(doc, n);
- if ((n = parse_find_node("submenuShowDelay", node)))
- config_submenu_show_delay = parse_int(doc, n);
- if ((n = parse_find_node("applicationIcons", node)))
- config_menu_client_list_icons = parse_bool(doc, n);
- if ((n = parse_find_node("manageDesktops", node)))
- config_menu_manage_desktops = parse_bool(doc, n);
+ if ((n = obt_parse_find_node(node, "hideDelay")))
+ config_menu_hide_delay = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "middle")))
+ config_menu_middle = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "submenuShowDelay")))
+ config_submenu_show_delay = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "applicationIcons")))
+ config_menu_client_list_icons = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "manageDesktops")))
+ config_menu_manage_desktops = obt_parse_node_bool(n);
}
}
-static void parse_resistance(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_resistance(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
node = node->children;
- if ((n = parse_find_node("strength", node)))
- config_resist_win = parse_int(doc, n);
- if ((n = parse_find_node("screen_edge_strength", node)))
- config_resist_edge = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "strength")))
+ config_resist_win = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "screen_edge_strength")))
+ config_resist_edge = obt_parse_node_int(n);
}
typedef struct
actions_parse_string(it->actname));
}
-void config_startup(ObParseInst *i)
+void config_startup(ObtParseInst *i)
{
config_focus_new = TRUE;
config_focus_follow = FALSE;
config_focus_last = TRUE;
config_focus_under_mouse = FALSE;
- parse_register(i, "focus", parse_focus, NULL);
+ obt_parse_register(i, "focus", parse_focus, NULL);
config_place_policy = OB_PLACE_POLICY_SMART;
config_place_center = TRUE;
config_place_monitor = OB_PLACE_MONITOR_ANY;
- parse_register(i, "placement", parse_placement, NULL);
+ obt_parse_register(i, "placement", parse_placement, NULL);
STRUT_PARTIAL_SET(config_margins, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- parse_register(i, "margins", parse_margins, NULL);
+ obt_parse_register(i, "margins", parse_margins, NULL);
config_theme = NULL;
config_font_menuitem = NULL;
config_font_menutitle = NULL;
- parse_register(i, "theme", parse_theme, NULL);
+ obt_parse_register(i, "theme", parse_theme, NULL);
config_desktops_num = 4;
config_screen_firstdesk = 1;
config_desktops_names = NULL;
config_desktop_popup_time = 875;
- parse_register(i, "desktops", parse_desktops, NULL);
+ obt_parse_register(i, "desktops", parse_desktops, NULL);
config_resize_redraw = TRUE;
config_resize_popup_show = 1; /* nonpixel increments */
GRAVITY_COORD_SET(config_resize_popup_fixed.x, 0, FALSE, FALSE);
GRAVITY_COORD_SET(config_resize_popup_fixed.y, 0, FALSE, FALSE);
- parse_register(i, "resize", parse_resize, NULL);
+ obt_parse_register(i, "resize", parse_resize, NULL);
config_dock_layer = OB_STACKING_LAYER_ABOVE;
config_dock_pos = OB_DIRECTION_NORTHEAST;
config_dock_app_move_button = 2; /* middle */
config_dock_app_move_modifiers = 0;
- parse_register(i, "dock", parse_dock, NULL);
+ obt_parse_register(i, "dock", parse_dock, NULL);
translate_key("C-g", &config_keyboard_reset_state,
&config_keyboard_reset_keycode);
bind_default_keyboard();
- parse_register(i, "keyboard", parse_keyboard, NULL);
+ obt_parse_register(i, "keyboard", parse_keyboard, NULL);
config_mouse_threshold = 8;
config_mouse_dclicktime = 200;
bind_default_mouse();
- parse_register(i, "mouse", parse_mouse, NULL);
+ obt_parse_register(i, "mouse", parse_mouse, NULL);
config_resist_win = 10;
config_resist_edge = 20;
- parse_register(i, "resistance", parse_resistance, NULL);
+ obt_parse_register(i, "resistance", parse_resistance, NULL);
config_menu_hide_delay = 250;
config_menu_middle = FALSE;
config_menu_manage_desktops = TRUE;
config_menu_files = NULL;
- parse_register(i, "menu", parse_menu, NULL);
+ obt_parse_register(i, "menu", parse_menu, NULL);
config_per_app_settings = NULL;
- parse_register(i, "applications", parse_per_app_settings, NULL);
+ obt_parse_register(i, "applications", parse_per_app_settings, NULL);
}
void config_shutdown(void)
#include "geom.h"
#include "moveresize.h"
#include "render/render.h"
+#include "obt/parse.h"
#include <glib.h>
-struct _ObParseInst;
-
typedef struct _ObAppSettings ObAppSettings;
struct _ObAppSettings
/*! Per app settings */
extern GSList *config_per_app_settings;
-void config_startup(struct _ObParseInst *i);
+void config_startup(ObtParseInst *i);
void config_shutdown();
/*! Create an ObAppSettings structure with the default values */
*/
#include "debug.h"
+#include "gettext.h"
+#include "obt/paths.h"
#include <glib.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
+#include <errno.h>
-static gboolean show;
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
-void ob_debug_show_output(gboolean enable)
+static gboolean enabled_types[OB_DEBUG_TYPE_NUM] = {FALSE};
+static FILE *log_file = NULL;
+static guint rr_handler_id = 0;
+static guint obt_handler_id = 0;
+static guint ob_handler_id = 0;
+
+static void log_handler(const gchar *log_domain, GLogLevelFlags log_level,
+ const gchar *message, gpointer user_data);
+
+void ob_debug_startup(void)
{
- show = enable;
+ ObtPaths *p = obt_paths_new();
+ gchar *dir = g_build_filename(obt_paths_cache_home(p),
+ "openbox", NULL);
+
+ /* log messages to a log file! fancy, no? */
+ if (!obt_paths_mkdir_path(dir, 0777))
+ g_message(_("Unable to make directory '%s': %s"),
+ dir, g_strerror(errno));
+ else {
+ gchar *name = g_build_filename(obt_paths_cache_home(p),
+ "openbox", "openbox.log", NULL);
+ /* unlink it before opening to remove competition */
+ unlink(name);
+ log_file = fopen(name, "w");
+ g_free(name);
+ }
+
+ rr_handler_id =
+ g_log_set_handler("ObRender", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL |
+ G_LOG_FLAG_RECURSION, log_handler, NULL);
+ obt_handler_id =
+ g_log_set_handler("Obt", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL |
+ G_LOG_FLAG_RECURSION, log_handler, NULL);
+ ob_handler_id =
+ g_log_set_handler("Openbox", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL |
+ G_LOG_FLAG_RECURSION, log_handler, NULL);
+
+ obt_paths_unref(p);
+ g_free(dir);
}
-void ob_debug(const gchar *a, ...)
+void ob_debug_shutdown(void)
{
- va_list vl;
+ g_log_remove_handler("ObRender", rr_handler_id);
+ g_log_remove_handler("Obt", obt_handler_id);
+ g_log_remove_handler("Openbox", ob_handler_id);
- if (show) {
- fprintf(stderr, "DEBUG: ");
- va_start(vl, a);
- vfprintf(stderr, a, vl);
- va_end(vl);
+ if (log_file) {
+ fclose(log_file);
+ log_file = NULL;
}
}
-static gboolean enabled_types[OB_DEBUG_TYPE_NUM] = {FALSE};
-
void ob_debug_enable(ObDebugType type, gboolean enable)
{
g_assert(type < OB_DEBUG_TYPE_NUM);
enabled_types[type] = enable;
}
-void ob_debug_type(ObDebugType type, const gchar *a, ...)
+static inline void log_print(FILE *out, const gchar* log_domain,
+ const gchar *level, const gchar *message)
{
- va_list vl;
+ fprintf(out, log_domain);
+ fprintf(out, "-");
+ fprintf(out, level);
+ fprintf(out, ": ");
+ fprintf(out, message);
+ fprintf(out, "\n");
+ fflush(out);
+}
+
+static void log_handler(const gchar *log_domain, GLogLevelFlags log_level,
+ const gchar *message, gpointer data)
+{
+ FILE *out;
+ const gchar *level;
+
+ switch (log_level & G_LOG_LEVEL_MASK) {
+ case G_LOG_LEVEL_DEBUG: level = "Debug"; out = stdout; break;
+ case G_LOG_LEVEL_INFO: level = "Info"; out = stdout; break;
+ case G_LOG_LEVEL_MESSAGE: level = "Message"; out = stdout; break;
+ case G_LOG_LEVEL_WARNING: level = "Warning"; out = stderr; break;
+ case G_LOG_LEVEL_CRITICAL: level = "Critical"; out = stderr; break;
+ case G_LOG_LEVEL_ERROR: level = "Error"; out = stderr; break;
+ default: g_assert_not_reached(); /* invalid level.. */
+ }
+
+ log_print(out, log_domain, level, message);
+ if (log_file) log_print(log_file, log_domain, level, message);
+}
+
+static inline void log_argv(ObDebugType type,
+ const gchar *format, va_list args)
+{
+ const gchar *prefix;
+ gchar *message;
g_assert(type < OB_DEBUG_TYPE_NUM);
+ if (!enabled_types[type]) return;
+
+ switch (type) {
+ case OB_DEBUG_FOCUS: prefix = "(FOCUS) "; break;
+ case OB_DEBUG_APP_BUGS: prefix = "(APPLICATION BUG) "; break;
+ case OB_DEBUG_SM: prefix = "(SESSION) "; break;
+ default: prefix = NULL; break;
+ }
- if (show && enabled_types[type]) {
- switch (type) {
- case OB_DEBUG_FOCUS:
- fprintf(stderr, "FOCUS: ");
- break;
- case OB_DEBUG_APP_BUGS:
- fprintf(stderr, "APPLICATION BUG: ");
- break;
- case OB_DEBUG_SM:
- fprintf(stderr, "SESSION: ");
- break;
- default:
- g_assert_not_reached();
- }
-
- va_start(vl, a);
- vfprintf(stderr, a, vl);
- va_end(vl);
+ message = g_strdup_vprintf(format, args);
+ if (prefix) {
+ gchar *a = message;
+ message = g_strconcat(prefix, message, NULL);
+ g_free(a);
}
+
+ g_debug(message);
+ g_free(message);
+}
+
+void ob_debug(const gchar *a, ...)
+{
+ va_list vl;
+
+ va_start(vl, a);
+ log_argv(OB_DEBUG_NORMAL, a, vl);
+ va_end(vl);
+}
+
+void ob_debug_type(ObDebugType type, const gchar *a, ...)
+{
+ va_list vl;
+
+ va_start(vl, a);
+ log_argv(type, a, vl);
+ va_end(vl);
}
#include <glib.h>
-void ob_debug_show_output(gboolean enable);
+void ob_debug_startup();
+void ob_debug_shutdown();
void ob_debug(const gchar *a, ...);
typedef enum {
+ OB_DEBUG_NORMAL,
OB_DEBUG_FOCUS,
OB_DEBUG_APP_BUGS,
OB_DEBUG_SM,
#include "debug.h"
#include "dock.h"
-#include "mainloop.h"
#include "screen.h"
-#include "prop.h"
#include "config.h"
#include "grab.h"
#include "openbox.h"
#include "render/theme.h"
+#include "obt/prop.h"
#define DOCK_EVENT_MASK (ButtonPressMask | ButtonReleaseMask | \
EnterWindowMask | LeaveWindowMask)
}
}
+static guint window_hash(Window *w) { return *w; }
+static gboolean window_comp(Window *w1, Window *w2) { return *w1 == *w2; }
+
void dock_startup(gboolean reconfig)
{
XSetWindowAttributes attrib;
if (reconfig) {
GList *it;
- XSetWindowBorder(ob_display, dock->frame,
+ XSetWindowBorder(obt_display, dock->frame,
RrColorPixel(ob_rr_theme->osd_border_color));
- XSetWindowBorderWidth(ob_display, dock->frame, ob_rr_theme->obwidth);
+ XSetWindowBorderWidth(obt_display, dock->frame, ob_rr_theme->obwidth);
RrAppearanceFree(dock->a_frame);
dock->a_frame = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg);
0, 0, 0, 0, 0, 0, 0, 0);
dock = g_new0(ObDock, 1);
- dock->obwin.type = Window_Dock;
+ dock->obwin.type = OB_WINDOW_CLASS_DOCK;
dock->hidden = TRUE;
+ dock->dock_map = g_hash_table_new((GHashFunc)window_hash,
+ (GEqualFunc)window_comp);
+
attrib.event_mask = DOCK_EVENT_MASK;
attrib.override_redirect = True;
attrib.do_not_propagate_mask = DOCK_NOPROPAGATEMASK;
- dock->frame = XCreateWindow(ob_display, RootWindow(ob_display, ob_screen),
+ dock->frame = XCreateWindow(obt_display, obt_root(ob_screen),
0, 0, 1, 1, 0,
RrDepth(ob_rr_inst), InputOutput,
RrVisual(ob_rr_inst),
CWDontPropagate,
&attrib);
dock->a_frame = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg);
- XSetWindowBorder(ob_display, dock->frame,
+ XSetWindowBorder(obt_display, dock->frame,
RrColorPixel(ob_rr_theme->osd_border_color));
- XSetWindowBorderWidth(ob_display, dock->frame, ob_rr_theme->obwidth);
+ XSetWindowBorderWidth(obt_display, dock->frame, ob_rr_theme->obwidth);
/* Setting the window type so xcompmgr can tell what it is */
- PROP_SET32(dock->frame, net_wm_window_type, atom,
- prop_atoms.net_wm_window_type_dock);
+ OBT_PROP_SET32(dock->frame, NET_WM_WINDOW_TYPE, ATOM,
+ OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DOCK));
- g_hash_table_insert(window_map, &dock->frame, dock);
+ window_add(&dock->frame, DOCK_AS_WINDOW(dock));
stacking_add(DOCK_AS_WINDOW(dock));
}
return;
}
- XDestroyWindow(ob_display, dock->frame);
+ g_hash_table_destroy(dock->dock_map);
+
+ XDestroyWindow(obt_display, dock->frame);
RrAppearanceFree(dock->a_frame);
- g_hash_table_remove(window_map, &dock->frame);
+ window_remove(dock->frame);
stacking_remove(dock);
}
-void dock_add(Window win, XWMHints *wmhints)
+void dock_manage(Window icon_win, Window name_win)
{
ObDockApp *app;
XWindowAttributes attrib;
gchar **data;
app = g_new0(ObDockApp, 1);
- app->obwin.type = Window_DockApp;
- app->win = win;
- app->icon_win = (wmhints->flags & IconWindowHint) ?
- wmhints->icon_window : win;
+ app->name_win = name_win;
+ app->icon_win = icon_win;
- if (PROP_GETSS(app->win, wm_class, locale, &data)) {
+ if (OBT_PROP_GETSS(app->name_win, WM_CLASS, locale, &data)) {
if (data[0]) {
app->name = g_strdup(data[0]);
if (data[1])
if (app->name == NULL) app->name = g_strdup("");
if (app->class == NULL) app->class = g_strdup("");
- if (XGetWindowAttributes(ob_display, app->icon_win, &attrib)) {
+ if (XGetWindowAttributes(obt_display, app->icon_win, &attrib)) {
app->w = attrib.width;
app->h = attrib.height;
} else {
}
dock->dock_apps = g_list_append(dock->dock_apps, app);
+ g_hash_table_insert(dock->dock_map, &app->icon_win, app);
dock_configure();
- XReparentWindow(ob_display, app->icon_win, dock->frame, app->x, app->y);
+ XReparentWindow(obt_display, app->icon_win, dock->frame, app->x, app->y);
/*
This is the same case as in frame.c for client windows. When Openbox is
starting, the window is already mapped so we see unmap events occur for
*/
if (ob_state() == OB_STATE_STARTING)
app->ignore_unmaps += 2;
+ XChangeSaveSet(obt_display, app->icon_win, SetModeInsert);
+ XMapWindow(obt_display, app->icon_win);
- if (app->win != app->icon_win) {
- /* have to map it so that it can be re-managed on a restart */
- XMoveWindow(ob_display, app->win, -1000, -1000);
- XMapWindow(ob_display, app->win);
+ if (app->name_win != app->icon_win) {
+ XReparentWindow(obt_display, app->name_win, dock->frame, -1000, -1000);
+ XChangeSaveSet(obt_display, app->name_win, SetModeInsert);
+ XMapWindow(obt_display, app->name_win);
}
- XMapWindow(ob_display, app->icon_win);
- XSync(ob_display, False);
- /* specify that if we exit, the window should not be destroyed and should
- be reparented back to root automatically */
- XChangeSaveSet(ob_display, app->icon_win, SetModeInsert);
- XSelectInput(ob_display, app->icon_win, DOCKAPP_EVENT_MASK);
+ XSync(obt_display, False);
+
+ XSelectInput(obt_display, app->icon_win, DOCKAPP_EVENT_MASK);
dock_app_grab_button(app, TRUE);
- g_hash_table_insert(window_map, &app->icon_win, app);
+ ob_debug("Managed Dock App: 0x%lx 0x%lx (%s)",
+ app->icon_win, app->name_win, app->class);
- ob_debug("Managed Dock App: 0x%lx (%s)\n", app->icon_win, app->class);
+ grab_server(FALSE);
}
-void dock_remove_all(void)
+void dock_unmanage_all(void)
{
while (dock->dock_apps)
- dock_remove(dock->dock_apps->data, TRUE);
+ dock_unmanage(dock->dock_apps->data, TRUE);
}
-void dock_remove(ObDockApp *app, gboolean reparent)
+void dock_unmanage(ObDockApp *app, gboolean reparent)
{
dock_app_grab_button(app, FALSE);
- XSelectInput(ob_display, app->icon_win, NoEventMask);
+ XSelectInput(obt_display, app->icon_win, NoEventMask);
/* remove the window from our save set */
- XChangeSaveSet(ob_display, app->icon_win, SetModeDelete);
- XSync(ob_display, False);
-
- g_hash_table_remove(window_map, &app->icon_win);
-
- if (reparent)
- XReparentWindow(ob_display, app->icon_win,
- RootWindow(ob_display, ob_screen), app->x, app->y);
+ XChangeSaveSet(obt_display, app->icon_win, SetModeDelete);
+ XSync(obt_display, False);
+
+ if (reparent) {
+ XReparentWindow(obt_display, app->icon_win, obt_root(ob_screen), 0, 0);
+ if (app->name_win != app->icon_win)
+ XReparentWindow(obt_display, app->name_win,
+ obt_root(ob_screen), 0, 0);
+ }
dock->dock_apps = g_list_remove(dock->dock_apps, app);
+ g_hash_table_remove(dock->dock_map, &app->icon_win);
dock_configure();
- ob_debug("Unmanaged Dock App: 0x%lx (%s)\n", app->icon_win, app->class);
+ ob_debug("Unmanaged Dock App: 0x%lx (%s)", app->icon_win, app->class);
g_free(app->name);
g_free(app->class);
break;
}
- XMoveWindow(ob_display, app->icon_win, app->x, app->y);
+ XMoveWindow(obt_display, app->icon_win, app->x, app->y);
}
/* used for calculating offsets */
g_assert(dock->area.width > 0);
g_assert(dock->area.height > 0);
- XMoveResizeWindow(ob_display, dock->frame, dock->area.x, dock->area.y,
+ XMoveResizeWindow(obt_display, dock->frame, dock->area.x, dock->area.y,
dock->area.width, dock->area.height);
RrPaint(dock->a_frame, dock->frame, dock->area.width,
dock->area.height);
- XMapWindow(ob_display, dock->frame);
+ XMapWindow(obt_display, dock->frame);
} else
- XUnmapWindow(ob_display, dock->frame);
+ XUnmapWindow(obt_display, dock->frame);
/* but they are useful outside of this function! but don't add it if the
dock is actually not visible */
{
if (!hide) {
if (dock->hidden && config_dock_hide) {
- ob_main_loop_timeout_add(ob_main_loop,
- config_dock_show_delay * 1000,
- show_timeout, NULL, g_direct_equal, NULL);
+ obt_main_loop_timeout_add(ob_main_loop,
+ config_dock_show_delay * 1000,
+ show_timeout, NULL,
+ g_direct_equal, NULL);
} else if (!dock->hidden && config_dock_hide) {
- ob_main_loop_timeout_remove(ob_main_loop, hide_timeout);
+ obt_main_loop_timeout_remove(ob_main_loop, hide_timeout);
}
} else {
if (!dock->hidden && config_dock_hide) {
- ob_main_loop_timeout_add(ob_main_loop,
- config_dock_hide_delay * 1000,
- hide_timeout, NULL, g_direct_equal, NULL);
+ obt_main_loop_timeout_add(ob_main_loop,
+ config_dock_hide_delay * 1000,
+ hide_timeout, NULL,
+ g_direct_equal, NULL);
} else if (dock->hidden && config_dock_hide) {
- ob_main_loop_timeout_remove(ob_main_loop, show_timeout);
+ obt_main_loop_timeout_remove(ob_main_loop, show_timeout);
}
}
}
RECT_SET(*a, dock->area.x, dock->area.y,
dock->area.width, dock->area.height);
}
+
+ObDockApp* dock_find_dockapp(Window xwin)
+{
+ return g_hash_table_lookup(dock->dock_map, &xwin);
+}
gboolean hidden;
GList *dock_apps;
+ GHashTable *dock_map;
};
struct _ObDockApp {
- ObWindow obwin;
-
gint ignore_unmaps;
Window icon_win;
- Window win;
+ Window name_win;
gchar *name;
gchar *class;
void dock_configure();
void dock_hide(gboolean hide);
-void dock_add(Window win, XWMHints *wmhints);
+void dock_manage(Window icon_win, Window name_win);
-void dock_remove_all();
-void dock_remove(ObDockApp *app, gboolean reparent);
+void dock_unmanage_all();
+void dock_unmanage(ObDockApp *app, gboolean reparent);
void dock_app_drag(ObDockApp *app, XMotionEvent *e);
void dock_app_configure(ObDockApp *app, gint w, gint h);
void dock_get_area(Rect *a);
+ObDockApp* dock_find_dockapp(Window xwin);
+
#endif
#include "dock.h"
#include "actions.h"
#include "client.h"
-#include "xerror.h"
-#include "prop.h"
#include "config.h"
#include "screen.h"
#include "frame.h"
#include "prompt.h"
#include "menuframe.h"
#include "keyboard.h"
-#include "modkeys.h"
#include "mouse.h"
-#include "mainloop.h"
#include "focus.h"
#include "focus_cycle.h"
#include "moveresize.h"
#include "group.h"
#include "stacking.h"
-#include "extensions.h"
-#include "translate.h"
#include "ping.h"
+#include "obt/display.h"
+#include "obt/prop.h"
+#include "obt/keyboard.h"
#include <X11/Xlib.h>
#include <X11/Xatom.h>
static void event_process(const XEvent *e, gpointer data);
static void event_handle_root(XEvent *e);
-static gboolean event_handle_menu_keyboard(XEvent *e);
-static gboolean event_handle_menu(XEvent *e);
+static gboolean event_handle_menu_input(XEvent *e);
+static void event_handle_menu(ObMenuFrame *frame, XEvent *e);
static gboolean event_handle_prompt(ObPrompt *p, XEvent *e);
static void event_handle_dock(ObDock *s, XEvent *e);
static void event_handle_dockapp(ObDockApp *app, XEvent *e);
if (opening) {
fd = IceConnectionNumber(conn);
- ob_main_loop_fd_add(ob_main_loop, fd, ice_handler, conn, NULL);
+ obt_main_loop_fd_add(ob_main_loop, fd, ice_handler, conn, NULL);
} else {
- ob_main_loop_fd_remove(ob_main_loop, fd);
+ obt_main_loop_fd_remove(ob_main_loop, fd);
fd = -1;
}
}
{
if (reconfig) return;
- ob_main_loop_x_add(ob_main_loop, event_process, NULL, NULL);
+ obt_main_loop_x_add(ob_main_loop, event_process, NULL, NULL);
#ifdef USE_SM
IceAddConnectionWatch(ice_watch, NULL);
/* pick a window */
switch (e->type) {
case SelectionClear:
- window = RootWindow(ob_display, ob_screen);
+ window = obt_root(ob_screen);
+ break;
+ case CreateNotify:
+ window = e->xcreatewindow.window;
break;
case MapRequest:
+ window = e->xmaprequest.window;
+ break;
+ case MapNotify:
window = e->xmap.window;
break;
case UnmapNotify:
break;
default:
#ifdef XKB
- if (extensions_xkb && e->type == extensions_xkb_event_basep) {
+ if (obt_display_extension_xkb &&
+ e->type == obt_display_extension_xkb_basep)
+ {
switch (((XkbAnyEvent*)e)->xkb_type) {
case XkbBellNotify:
window = ((XkbBellNotifyEvent*)e)->window;
} else
#endif
#ifdef SYNC
- if (extensions_sync &&
- e->type == extensions_sync_event_basep + XSyncAlarmNotify)
+ if (obt_display_extension_sync &&
+ e->type == obt_display_extension_sync_basep + XSyncAlarmNotify)
{
window = None;
} else
break;
default:
#ifdef SYNC
- if (extensions_sync &&
- e->type == extensions_sync_event_basep + XSyncAlarmNotify)
+ if (obt_display_extension_sync &&
+ e->type == obt_display_extension_sync_basep + XSyncAlarmNotify)
{
t = ((XSyncAlarmNotifyEvent*)e)->time;
}
switch (e->type) {
case ButtonPress:
case ButtonRelease:
- e->xbutton.state = modkeys_only_modifier_masks(e->xbutton.state);
+ e->xbutton.state = obt_keyboard_only_modmasks(e->xbutton.state);
break;
case KeyPress:
- e->xkey.state = modkeys_only_modifier_masks(e->xkey.state);
+ e->xkey.state = obt_keyboard_only_modmasks(e->xkey.state);
break;
case KeyRelease:
#ifdef XKB
/* If XKB is present, then the modifiers are all strange from its
magic. Our X core protocol stuff won't work, so we use this to
find what the modifier state is instead. */
- if (XkbGetState(ob_display, XkbUseCoreKbd, &xkb_state) == Success)
+ if (XkbGetState(obt_display, XkbUseCoreKbd, &xkb_state) == Success)
e->xkey.state =
- modkeys_only_modifier_masks(xkb_state.compat_state);
+ obt_keyboard_only_modmasks(xkb_state.compat_state);
else
#endif
{
- e->xkey.state = modkeys_only_modifier_masks(e->xkey.state);
+ e->xkey.state = obt_keyboard_only_modmasks(e->xkey.state);
/* remove from the state the mask of the modifier key being
released, if it is a modifier key being released that is */
- e->xkey.state &= ~modkeys_keycode_to_mask(e->xkey.keycode);
+ e->xkey.state &= ~obt_keyboard_keycode_to_modmask(e->xkey.keycode);
}
break;
case MotionNotify:
- e->xmotion.state = modkeys_only_modifier_masks(e->xmotion.state);
+ e->xmotion.state = obt_keyboard_only_modmasks(e->xmotion.state);
/* compress events */
{
XEvent ce;
- while (XCheckTypedWindowEvent(ob_display, e->xmotion.window,
+ while (XCheckTypedWindowEvent(obt_display, e->xmotion.window,
e->type, &ce)) {
e->xmotion.x = ce.xmotion.x;
e->xmotion.y = ce.xmotion.y;
/* These are the ones we want.. */
- if (win == RootWindow(ob_display, ob_screen)) {
+ if (win == obt_root(ob_screen)) {
/* If looking for a focus in on a client, then always return
FALSE for focus in's to the root window */
if (in_client_only)
but has disappeared.
*/
if (in_client_only) {
- ObWindow *w = g_hash_table_lookup(window_map, &e->xfocus.window);
+ ObWindow *w = window_find(e->xfocus.window);
if (!w || !WINDOW_IS_CLIENT(w))
return FALSE;
}
return FALSE;
/* Focus left the root window revertedto state */
- if (win == RootWindow(ob_display, ob_screen))
+ if (win == obt_root(ob_screen))
return FALSE;
/* These are the ones we want.. */
g_assert(modestr);
g_assert(detailstr);
- ob_debug_type(OB_DEBUG_FOCUS, "Focus%s 0x%x mode=%s detail=%s\n",
+ ob_debug_type(OB_DEBUG_FOCUS, "Focus%s 0x%x mode=%s detail=%s",
(e->xfocus.type == FocusIn ? "In" : "Out"),
win,
modestr, detailstr);
static void event_process(const XEvent *ec, gpointer data)
{
+ XEvent ee, *e;
+ ObEventData *ed = data;
+
Window window;
ObClient *client = NULL;
ObDock *dock = NULL;
ObDockApp *dockapp = NULL;
ObWindow *obwin = NULL;
- XEvent ee, *e;
- ObEventData *ed = data;
+ ObMenuFrame *menu = NULL;
ObPrompt *prompt = NULL;
/* make a copy we can mangle */
e = ⅇ
window = event_get_window(e);
- if ((obwin = g_hash_table_lookup(window_map, &window))) {
+ if (window == obt_root(ob_screen))
+ /* don't do any lookups, waste of cpu */;
+ else if ((obwin = window_find(window))) {
switch (obwin->type) {
- case Window_Dock:
+ case OB_WINDOW_CLASS_DOCK:
dock = WINDOW_AS_DOCK(obwin);
break;
- case Window_DockApp:
- dockapp = WINDOW_AS_DOCKAPP(obwin);
- break;
- case Window_Client:
+ case OB_WINDOW_CLASS_CLIENT:
client = WINDOW_AS_CLIENT(obwin);
/* events on clients can be events on prompt windows too */
prompt = client->prompt;
break;
- case Window_Menu:
- /* not to be used for events */
- g_assert_not_reached();
+ case OB_WINDOW_CLASS_MENUFRAME:
+ menu = WINDOW_AS_MENUFRAME(obwin);
break;
- case Window_Internal:
+ case OB_WINDOW_CLASS_INTERNAL:
/* we don't do anything with events directly on these windows */
break;
- case Window_Prompt:
+ case OB_WINDOW_CLASS_PROMPT:
prompt = WINDOW_AS_PROMPT(obwin);
break;
}
}
+ else
+ dockapp = dock_find_dockapp(window);
event_set_curtime(e);
event_curserial = e->xany.serial;
/* deal with it in the kernel */
- if (menu_frame_visible &&
- (e->type == EnterNotify || e->type == LeaveNotify))
- {
- /* crossing events for menu */
- event_handle_menu(e);
- } else if (e->type == FocusIn) {
+ if (e->type == FocusIn) {
if (client &&
e->xfocus.detail == NotifyInferior)
{
XEvent ce;
ob_debug_type(OB_DEBUG_FOCUS,
- "Focus went to root or pointer root/none\n");
+ "Focus went to root or pointer root/none");
if (e->xfocus.detail == NotifyInferior ||
e->xfocus.detail == NotifyNonlinear)
But if the other focus in is something like PointerRoot then we
still want to fall back.
*/
- if (XCheckIfEvent(ob_display, &ce, event_look_for_focusin_client,
+ if (XCheckIfEvent(obt_display, &ce, event_look_for_focusin_client,
NULL))
{
- XPutBackEvent(ob_display, &ce);
+ XPutBackEvent(obt_display, &ce);
ob_debug_type(OB_DEBUG_FOCUS,
- " but another FocusIn is coming\n");
+ " but another FocusIn is coming");
} else {
/* Focus has been reverted.
else if (!client)
{
ob_debug_type(OB_DEBUG_FOCUS,
- "Focus went to a window that is already gone\n");
+ "Focus went to a window that is already gone");
/* If you send focus to a window and then it disappears, you can
get the FocusIn for it, after it is unmanaged.
XEvent ce;
/* Look for the followup FocusIn */
- if (!XCheckIfEvent(ob_display, &ce, event_look_for_focusin, NULL)) {
+ if (!XCheckIfEvent(obt_display, &ce, event_look_for_focusin, NULL)) {
/* There is no FocusIn, this means focus went to a window that
is not being managed, or a window on another screen. */
Window win, root;
gint i;
guint u;
- xerror_set_ignore(TRUE);
- if (XGetInputFocus(ob_display, &win, &i) != 0 &&
- XGetGeometry(ob_display, win, &root, &i,&i,&u,&u,&u,&u) != 0 &&
- root != RootWindow(ob_display, ob_screen))
+ obt_display_ignore_errors(TRUE);
+ if (XGetInputFocus(obt_display, &win, &i) &&
+ XGetGeometry(obt_display, win, &root, &i,&i,&u,&u,&u,&u) &&
+ root != obt_root(ob_screen))
{
ob_debug_type(OB_DEBUG_FOCUS,
- "Focus went to another screen !\n");
+ "Focus went to another screen !");
focus_left_screen = TRUE;
}
else
ob_debug_type(OB_DEBUG_FOCUS,
- "Focus went to a black hole !\n");
- xerror_set_ignore(FALSE);
+ "Focus went to a black hole !");
+ obt_display_ignore_errors(FALSE);
/* nothing is focused */
focus_set_client(NULL);
} else {
/* The FocusIn was ignored, this means it was on a window
that isn't a client. */
ob_debug_type(OB_DEBUG_FOCUS,
- "Focus went to an unmanaged window 0x%x !\n",
+ "Focus went to an unmanaged window 0x%x !",
ce.xfocus.window);
focus_fallback(TRUE, config_focus_under_mouse, TRUE, TRUE);
}
event_handle_dockapp(dockapp, e);
else if (dock)
event_handle_dock(dock, e);
- else if (window == RootWindow(ob_display, ob_screen))
+ else if (menu)
+ event_handle_menu(menu, e);
+ else if (window == obt_root(ob_screen))
event_handle_root(e);
else if (e->type == MapRequest)
- client_manage(window, NULL);
+ window_manage(window);
else if (e->type == MappingNotify) {
/* keyboard layout changes for modifier mapping changes. reload the
modifier map, and rebind all the key bindings as appropriate */
- ob_debug("Kepboard map changed. Reloading keyboard bindings.\n");
- modkeys_shutdown(TRUE);
- modkeys_startup(TRUE);
+ ob_debug("Kepboard map changed. Reloading keyboard bindings.");
+ obt_keyboard_reload();
keyboard_rebind();
}
else if (e->type == ClientMessage) {
/* This is for _NET_WM_REQUEST_FRAME_EXTENTS messages. They come for
windows that are not managed yet. */
- if (e->xclient.message_type == prop_atoms.net_request_frame_extents) {
+ if (e->xclient.message_type ==
+ OBT_PROP_ATOM(NET_REQUEST_FRAME_EXTENTS))
+ {
/* Pretend to manage the client, getting information used to
determine its decorations */
ObClient *c = client_fake_manage(e->xclient.window);
vals[1] = c->frame->size.right;
vals[2] = c->frame->size.top;
vals[3] = c->frame->size.bottom;
- PROP_SETA32(e->xclient.window, net_frame_extents,
- cardinal, vals, 4);
+ OBT_PROP_SETA32(e->xclient.window, NET_FRAME_EXTENTS,
+ CARDINAL, vals, 4);
/* Free the pretend client */
client_fake_unmanage(c);
/* we are not to be held responsible if someone sends us an
invalid request! */
- xerror_set_ignore(TRUE);
- XConfigureWindow(ob_display, window,
+ obt_display_ignore_errors(TRUE);
+ XConfigureWindow(obt_display, window,
e->xconfigurerequest.value_mask, &xwc);
- xerror_set_ignore(FALSE);
+ obt_display_ignore_errors(FALSE);
}
#ifdef SYNC
- else if (extensions_sync &&
- e->type == extensions_sync_event_basep + XSyncAlarmNotify)
+ else if (obt_display_extension_sync &&
+ e->type == obt_display_extension_sync_basep + XSyncAlarmNotify)
{
XSyncAlarmNotifyEvent *se = (XSyncAlarmNotifyEvent*)e;
if (se->alarm == moveresize_alarm && moveresize_in_progress)
else if (e->type == ButtonPress || e->type == ButtonRelease) {
/* If the button press was on some non-root window, or was physically
on the root window, then process it */
- if (window != RootWindow(ob_display, ob_screen) ||
+ if (window != obt_root(ob_screen) ||
e->xbutton.subwindow == None)
{
event_handle_user_input(client, e);
else {
ObWindow *w;
- if ((w = g_hash_table_lookup(window_map, &e->xbutton.subwindow)) &&
+ if ((w = window_find(e->xbutton.subwindow)) &&
WINDOW_IS_INTERNAL(w))
{
event_handle_user_input(client, e);
switch(e->type) {
case SelectionClear:
- ob_debug("Another WM has requested to replace us. Exiting.\n");
+ ob_debug("Another WM has requested to replace us. Exiting.");
ob_exit_replace();
break;
if (e->xclient.format != 32) break;
msgtype = e->xclient.message_type;
- if (msgtype == prop_atoms.net_current_desktop) {
+ if (msgtype == OBT_PROP_ATOM(NET_CURRENT_DESKTOP)) {
guint d = e->xclient.data.l[0];
if (d < screen_num_desktops) {
event_curtime = e->xclient.data.l[1];
if (event_curtime == 0)
ob_debug_type(OB_DEBUG_APP_BUGS,
"_NET_CURRENT_DESKTOP message is missing "
- "a timestamp\n");
+ "a timestamp");
screen_set_desktop(d, TRUE);
}
- } else if (msgtype == prop_atoms.net_number_of_desktops) {
+ } else if (msgtype == OBT_PROP_ATOM(NET_NUMBER_OF_DESKTOPS)) {
guint d = e->xclient.data.l[0];
if (d > 0 && d <= 1000)
screen_set_num_desktops(d);
- } else if (msgtype == prop_atoms.net_showing_desktop) {
+ } else if (msgtype == OBT_PROP_ATOM(NET_SHOWING_DESKTOP)) {
screen_show_desktop(e->xclient.data.l[0] != 0, NULL);
- } else if (msgtype == prop_atoms.ob_control) {
- ob_debug("OB_CONTROL: %d\n", e->xclient.data.l[0]);
+ } else if (msgtype == OBT_PROP_ATOM(OB_CONTROL)) {
+ ob_debug("OB_CONTROL: %d", e->xclient.data.l[0]);
if (e->xclient.data.l[0] == 1)
ob_reconfigure();
else if (e->xclient.data.l[0] == 2)
ob_restart();
else if (e->xclient.data.l[0] == 3)
ob_exit(0);
- } else if (msgtype == prop_atoms.wm_protocols) {
- if ((Atom)e->xclient.data.l[0] == prop_atoms.net_wm_ping)
+ } else if (msgtype == OBT_PROP_ATOM(WM_PROTOCOLS)) {
+ if ((Atom)e->xclient.data.l[0] == OBT_PROP_ATOM(NET_WM_PING))
ping_got_pong(e->xclient.data.l[1]);
}
break;
case PropertyNotify:
- if (e->xproperty.atom == prop_atoms.net_desktop_names) {
- ob_debug("UPDATE DESKTOP NAMES\n");
+ if (e->xproperty.atom == OBT_PROP_ATOM(NET_DESKTOP_NAMES)) {
+ ob_debug("UPDATE DESKTOP NAMES");
screen_update_desktop_names();
}
- else if (e->xproperty.atom == prop_atoms.net_desktop_layout)
+ else if (e->xproperty.atom == OBT_PROP_ATOM(NET_DESKTOP_LAYOUT))
screen_update_layout();
break;
case ConfigureNotify:
if (config_focus_delay) {
ObFocusDelayData *data;
- ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
+ obt_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
data = g_new(ObFocusDelayData, 1);
data->client = client;
data->time = event_curtime;
data->serial = event_curserial;
- ob_main_loop_timeout_add(ob_main_loop,
- config_focus_delay * 1000,
- focus_delay_func,
- data, focus_delay_cmp, focus_delay_dest);
+ obt_main_loop_timeout_add(ob_main_loop,
+ config_focus_delay * 1000,
+ focus_delay_func,
+ data, focus_delay_cmp, focus_delay_dest);
} else {
ObFocusDelayData data;
data.client = client;
event_end_ignore_all_enters(event_start_ignore_all_enters());
ob_debug_type(OB_DEBUG_FOCUS,
- "%sNotify mode %d detail %d on %lx\n",
+ "%sNotify mode %d detail %d on %lx",
(e->type == EnterNotify ? "Enter" : "Leave"),
e->xcrossing.mode,
e->xcrossing.detail, (client?client->window:0));
delay is up */
e->xcrossing.detail != NotifyInferior)
{
- ob_main_loop_timeout_remove_data(ob_main_loop,
- focus_delay_func,
- client, FALSE);
+ obt_main_loop_timeout_remove_data(ob_main_loop,
+ focus_delay_func,
+ client, FALSE);
}
break;
default:
{
ob_debug_type(OB_DEBUG_FOCUS,
"%sNotify mode %d detail %d serial %lu on %lx "
- "IGNORED\n",
+ "IGNORED",
(e->type == EnterNotify ? "Enter" : "Leave"),
e->xcrossing.mode,
e->xcrossing.detail,
else {
ob_debug_type(OB_DEBUG_FOCUS,
"%sNotify mode %d detail %d serial %lu on %lx, "
- "focusing window\n",
+ "focusing window",
(e->type == EnterNotify ? "Enter" : "Leave"),
e->xcrossing.mode,
e->xcrossing.detail,
RECT_TO_DIMS(client->area, x, y, w, h);
ob_debug("ConfigureRequest for \"%s\" desktop %d wmstate %d "
- "visibile %d\n"
- " x %d y %d w %d h %d b %d\n",
+ "visibile %d",
client->title,
- screen_desktop, client->wmstate, client->frame->visible,
+ screen_desktop, client->wmstate, client->frame->visible);
+ ob_debug(" x %d y %d w %d h %d b %d",
x, y, w, h, client->border_width);
if (e->xconfigurerequest.value_mask & CWBorderWidth)
/* get the sibling */
if (e->xconfigurerequest.value_mask & CWSibling) {
ObWindow *win;
- win = g_hash_table_lookup(window_map,
- &e->xconfigurerequest.above);
+ win = window_find(e->xconfigurerequest.above);
if (win && WINDOW_IS_CLIENT(win) &&
WINDOW_AS_CLIENT(win) != client)
{
}
ob_debug("ConfigureRequest x(%d) %d y(%d) %d w(%d) %d h(%d) %d "
- "move %d resize %d\n",
+ "move %d resize %d",
e->xconfigurerequest.value_mask & CWX, x,
e->xconfigurerequest.value_mask & CWY, y,
e->xconfigurerequest.value_mask & CWWidth, w,
ob_debug_type(OB_DEBUG_APP_BUGS,
"Application %s is trying to move via "
"ConfigureRequest to it's root window position "
- "but it is not using StaticGravity\n",
+ "but it is not using StaticGravity",
client->title);
/* don't move it */
x = client->area.x;
client_find_onscreen(client, &x, &y, w, h, FALSE);
- ob_debug("Granting ConfigureRequest x %d y %d w %d h %d\n",
+ ob_debug("Granting ConfigureRequest x %d y %d w %d h %d",
x, y, w, h);
client_configure(client, x, y, w, h, FALSE, TRUE, TRUE);
}
break;
}
case UnmapNotify:
+ ob_debug("UnmapNotify for window 0x%x eventwin 0x%x sendevent %d "
+ "ignores left %d",
+ client->window, e->xunmap.event, e->xunmap.from_configure,
+ client->ignore_unmaps);
if (client->ignore_unmaps) {
client->ignore_unmaps--;
break;
}
- ob_debug("UnmapNotify for window 0x%x eventwin 0x%x sendevent %d "
- "ignores left %d\n",
- client->window, e->xunmap.event, e->xunmap.from_configure,
- client->ignore_unmaps);
client_unmanage(client);
break;
case DestroyNotify:
- ob_debug("DestroyNotify for window 0x%x\n", client->window);
+ ob_debug("DestroyNotify for window 0x%x", client->window);
client_unmanage(client);
break;
case ReparentNotify:
/* we don't want the reparent event, put it back on the stack for the
X server to deal with after we unmanage the window */
- XPutBackEvent(ob_display, e);
+ XPutBackEvent(obt_display, e);
- ob_debug("ReparentNotify for window 0x%x\n", client->window);
+ ob_debug("ReparentNotify for window 0x%x", client->window);
client_unmanage(client);
break;
case MapRequest:
- ob_debug("MapRequest for 0x%lx\n", client->window);
+ ob_debug("MapRequest for 0x%lx", client->window);
if (!client->iconic) break; /* this normally doesn't happen, but if it
does, we don't want it!
it can happen now when the window is on
if (e->xclient.format != 32) return;
msgtype = e->xclient.message_type;
- if (msgtype == prop_atoms.wm_change_state) {
+ if (msgtype == OBT_PROP_ATOM(WM_CHANGE_STATE)) {
/* compress changes into a single change */
- while (XCheckTypedWindowEvent(ob_display, client->window,
+ while (XCheckTypedWindowEvent(obt_display, client->window,
e->type, &ce)) {
/* XXX: it would be nice to compress ALL messages of a
type, not just messages in a row without other
message types between. */
if (ce.xclient.message_type != msgtype) {
- XPutBackEvent(ob_display, &ce);
+ XPutBackEvent(obt_display, &ce);
break;
}
e->xclient = ce.xclient;
}
client_set_wm_state(client, e->xclient.data.l[0]);
- } else if (msgtype == prop_atoms.net_wm_desktop) {
+ } else if (msgtype == OBT_PROP_ATOM(NET_WM_DESKTOP)) {
/* compress changes into a single change */
- while (XCheckTypedWindowEvent(ob_display, client->window,
+ while (XCheckTypedWindowEvent(obt_display, client->window,
e->type, &ce)) {
/* XXX: it would be nice to compress ALL messages of a
type, not just messages in a row without other
message types between. */
if (ce.xclient.message_type != msgtype) {
- XPutBackEvent(ob_display, &ce);
+ XPutBackEvent(obt_display, &ce);
break;
}
e->xclient = ce.xclient;
(unsigned)e->xclient.data.l[0] == DESKTOP_ALL)
client_set_desktop(client, (unsigned)e->xclient.data.l[0],
FALSE, FALSE);
- } else if (msgtype == prop_atoms.net_wm_state) {
+ } else if (msgtype == OBT_PROP_ATOM(NET_WM_STATE)) {
gulong ignore_start;
/* can't compress these */
- ob_debug("net_wm_state %s %ld %ld for 0x%lx\n",
+ ob_debug("net_wm_state %s %ld %ld for 0x%lx",
(e->xclient.data.l[0] == 0 ? "Remove" :
e->xclient.data.l[0] == 1 ? "Add" :
e->xclient.data.l[0] == 2 ? "Toggle" : "INVALID"),
e->xclient.data.l[1], e->xclient.data.l[2]);
if (!config_focus_under_mouse)
event_end_ignore_all_enters(ignore_start);
- } else if (msgtype == prop_atoms.net_close_window) {
- ob_debug("net_close_window for 0x%lx\n", client->window);
+ } else if (msgtype == OBT_PROP_ATOM(NET_CLOSE_WINDOW)) {
+ ob_debug("net_close_window for 0x%lx", client->window);
client_close(client);
- } else if (msgtype == prop_atoms.net_active_window) {
- ob_debug("net_active_window for 0x%lx source=%s\n",
+ } else if (msgtype == OBT_PROP_ATOM(NET_ACTIVE_WINDOW)) {
+ ob_debug("net_active_window for 0x%lx source=%s",
client->window,
(e->xclient.data.l[0] == 0 ? "unknown" :
(e->xclient.data.l[0] == 1 ? "application" :
if (e->xclient.data.l[1] == 0)
ob_debug_type(OB_DEBUG_APP_BUGS,
"_NET_ACTIVE_WINDOW message for window %s is"
- " missing a timestamp\n", client->title);
+ " missing a timestamp", client->title);
} else
ob_debug_type(OB_DEBUG_APP_BUGS,
"_NET_ACTIVE_WINDOW message for window %s is "
- "missing source indication\n");
+ "missing source indication");
client_activate(client, TRUE, TRUE, TRUE,
(e->xclient.data.l[0] == 0 ||
e->xclient.data.l[0] == 2));
- } else if (msgtype == prop_atoms.net_wm_moveresize) {
- ob_debug("net_wm_moveresize for 0x%lx direction %d\n",
+ } else if (msgtype == OBT_PROP_ATOM(NET_WM_MOVERESIZE)) {
+ ob_debug("net_wm_moveresize for 0x%lx direction %d",
client->window, e->xclient.data.l[2]);
if ((Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_topleft ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_top ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_topright ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_right ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_right ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_bottomright ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_bottom ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOM) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_bottomleft ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_left ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_move ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_keyboard ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_KEYBOARD) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_move_keyboard) {
-
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE_KEYBOARD))
+ {
moveresize_start(client, e->xclient.data.l[0],
e->xclient.data.l[1], e->xclient.data.l[3],
e->xclient.data.l[2]);
}
else if ((Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_cancel)
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_CANCEL))
moveresize_end(TRUE);
- } else if (msgtype == prop_atoms.net_moveresize_window) {
+ } else if (msgtype == OBT_PROP_ATOM(NET_MOVERESIZE_WINDOW)) {
gint ograv, x, y, w, h;
ograv = client->gravity;
else
h = client->area.height;
- ob_debug("MOVERESIZE x %d %d y %d %d (gravity %d)\n",
+ ob_debug("MOVERESIZE x %d %d y %d %d (gravity %d)",
e->xclient.data.l[0] & 1 << 8, x,
e->xclient.data.l[0] & 1 << 9, y,
client->gravity);
client_configure(client, x, y, w, h, FALSE, TRUE, FALSE);
client->gravity = ograv;
- } else if (msgtype == prop_atoms.net_restack_window) {
+ } else if (msgtype == OBT_PROP_ATOM(NET_RESTACK_WINDOW)) {
if (e->xclient.data.l[0] != 2) {
ob_debug_type(OB_DEBUG_APP_BUGS,
"_NET_RESTACK_WINDOW sent for window %s with "
- "invalid source indication %ld\n",
+ "invalid source indication %ld",
client->title, e->xclient.data.l[0]);
} else {
ObClient *sibling = NULL;
if (e->xclient.data.l[1]) {
- ObWindow *win = g_hash_table_lookup
- (window_map, &e->xclient.data.l[1]);
+ ObWindow *win = window_find(e->xclient.data.l[1]);
if (WINDOW_IS_CLIENT(win) &&
WINDOW_AS_CLIENT(win) != client)
{
if (sibling == NULL)
ob_debug_type(OB_DEBUG_APP_BUGS,
"_NET_RESTACK_WINDOW sent for window %s "
- "with invalid sibling 0x%x\n",
+ "with invalid sibling 0x%x",
client->title, e->xclient.data.l[1]);
}
if (e->xclient.data.l[2] == Below ||
} else
ob_debug_type(OB_DEBUG_APP_BUGS,
"_NET_RESTACK_WINDOW sent for window %s "
- "with invalid detail %d\n",
+ "with invalid detail %d",
client->title, e->xclient.data.l[2]);
}
}
if (!client_validate(client)) break;
/* compress changes to a single property into a single change */
- while (XCheckTypedWindowEvent(ob_display, client->window,
+ while (XCheckTypedWindowEvent(obt_display, client->window,
e->type, &ce)) {
Atom a, b;
if (a == b)
continue;
- if ((a == prop_atoms.net_wm_name ||
- a == prop_atoms.wm_name ||
- a == prop_atoms.net_wm_icon_name ||
- a == prop_atoms.wm_icon_name)
+ if ((a == OBT_PROP_ATOM(NET_WM_NAME) ||
+ a == OBT_PROP_ATOM(WM_NAME) ||
+ a == OBT_PROP_ATOM(NET_WM_ICON_NAME) ||
+ a == OBT_PROP_ATOM(WM_ICON_NAME))
&&
- (b == prop_atoms.net_wm_name ||
- b == prop_atoms.wm_name ||
- b == prop_atoms.net_wm_icon_name ||
- b == prop_atoms.wm_icon_name)) {
+ (b == OBT_PROP_ATOM(NET_WM_NAME) ||
+ b == OBT_PROP_ATOM(WM_NAME) ||
+ b == OBT_PROP_ATOM(NET_WM_ICON_NAME) ||
+ b == OBT_PROP_ATOM(WM_ICON_NAME))) {
continue;
}
- if (a == prop_atoms.net_wm_icon &&
- b == prop_atoms.net_wm_icon)
+ if (a == OBT_PROP_ATOM(NET_WM_ICON) &&
+ b == OBT_PROP_ATOM(NET_WM_ICON))
continue;
- XPutBackEvent(ob_display, &ce);
+ XPutBackEvent(obt_display, &ce);
break;
}
msgtype = e->xproperty.atom;
if (msgtype == XA_WM_NORMAL_HINTS) {
- ob_debug("Update NORMAL hints\n");
+ ob_debug("Update NORMAL hints");
client_update_normal_hints(client);
/* normal hints can make a window non-resizable */
client_setup_decor_and_functions(client, FALSE);
/* type may have changed, so update the layer */
client_calc_layer(client);
client_setup_decor_and_functions(client, TRUE);
- } else if (msgtype == prop_atoms.net_wm_name ||
- msgtype == prop_atoms.wm_name ||
- msgtype == prop_atoms.net_wm_icon_name ||
- msgtype == prop_atoms.wm_icon_name) {
+ } else if (msgtype == OBT_PROP_ATOM(NET_WM_NAME) ||
+ msgtype == OBT_PROP_ATOM(WM_NAME) ||
+ msgtype == OBT_PROP_ATOM(NET_WM_ICON_NAME) ||
+ msgtype == OBT_PROP_ATOM(WM_ICON_NAME)) {
client_update_title(client);
- } else if (msgtype == prop_atoms.wm_protocols) {
+ } else if (msgtype == OBT_PROP_ATOM(WM_PROTOCOLS)) {
client_update_protocols(client);
client_setup_decor_and_functions(client, TRUE);
}
- else if (msgtype == prop_atoms.net_wm_strut) {
+ else if (msgtype == OBT_PROP_ATOM(NET_WM_STRUT)) {
client_update_strut(client);
}
- else if (msgtype == prop_atoms.net_wm_strut_partial) {
+ else if (msgtype == OBT_PROP_ATOM(NET_WM_STRUT_PARTIAL)) {
client_update_strut(client);
}
- else if (msgtype == prop_atoms.net_wm_icon) {
+ else if (msgtype == OBT_PROP_ATOM(NET_WM_ICON)) {
client_update_icons(client);
}
- else if (msgtype == prop_atoms.net_wm_icon_geometry) {
+ else if (msgtype == OBT_PROP_ATOM(NET_WM_ICON_GEOMETRY)) {
client_update_icon_geometry(client);
}
- else if (msgtype == prop_atoms.net_wm_user_time) {
+ else if (msgtype == OBT_PROP_ATOM(NET_WM_USER_TIME)) {
guint32 t;
if (client == focus_client &&
- PROP_GET32(client->window, net_wm_user_time, cardinal, &t) &&
- t && !event_time_after(t, e->xproperty.time) &&
+ OBT_PROP_GET32(client->window, NET_WM_USER_TIME, CARDINAL, &t)
+ && t && !event_time_after(t, e->xproperty.time) &&
(!event_last_user_time ||
event_time_after(t, event_last_user_time)))
{
}
}
#ifdef SYNC
- else if (msgtype == prop_atoms.net_wm_sync_request_counter) {
+ else if (msgtype == OBT_PROP_ATOM(NET_WM_SYNC_REQUEST_COUNTER)) {
client_update_sync_request_counter(client);
}
#endif
default:
;
#ifdef SHAPE
- if (extensions_shape && e->type == extensions_shape_event_basep) {
+ if (obt_display_extension_shape &&
+ e->type == obt_display_extension_shape_basep)
+ {
client->shaped = ((XShapeEvent*)e)->shaped;
frame_adjust_shape(client->frame);
}
app->ignore_unmaps--;
break;
}
- dock_remove(app, TRUE);
+ dock_unmanage(app, TRUE);
break;
case DestroyNotify:
- dock_remove(app, FALSE);
+ dock_unmanage(app, FALSE);
break;
case ReparentNotify:
- dock_remove(app, FALSE);
+ dock_unmanage(app, FALSE);
break;
case ConfigureNotify:
dock_app_configure(app, e->xconfigure.width, e->xconfigure.height);
return FALSE;
}
-static gboolean event_handle_menu_keyboard(XEvent *ev)
+static gboolean event_handle_menu_input(XEvent *ev)
{
- guint keycode, state;
- gunichar unikey;
- ObMenuFrame *frame;
gboolean ret = FALSE;
- keycode = ev->xkey.keycode;
- state = ev->xkey.state;
- unikey = translate_unichar(keycode);
+ if (ev->type == ButtonRelease || ev->type == ButtonPress) {
+ ObMenuEntryFrame *e;
- frame = find_active_or_last_menu();
- if (frame == NULL)
- g_assert_not_reached(); /* there is no active menu */
+ if (menu_hide_delay_reached() &&
+ (ev->xbutton.button < 4 || ev->xbutton.button > 5))
+ {
+ if ((e = menu_entry_frame_under(ev->xbutton.x_root,
+ ev->xbutton.y_root)))
+ {
+ if (ev->type == ButtonPress && e->frame->child)
+ menu_frame_select(e->frame->child, NULL, TRUE);
+ menu_frame_select(e->frame, e, TRUE);
+ if (ev->type == ButtonRelease)
+ menu_entry_frame_execute(e, ev->xbutton.state);
+ }
+ else if (ev->type == ButtonRelease)
+ menu_frame_hide_all();
+ }
+ ret = TRUE;
+ }
+ else if (ev->type == MotionNotify) {
+ ObMenuFrame *f;
+ ObMenuEntryFrame *e;
- /* Allow control while going thru the menu */
- else if (ev->type == KeyPress && (state & ~ControlMask) == 0) {
- frame->got_press = TRUE;
+ if ((e = menu_entry_frame_under(ev->xmotion.x_root,
+ ev->xmotion.y_root)))
+ if (!(f = find_active_menu()) ||
+ f == e->frame ||
+ f->parent == e->frame ||
+ f->child == e->frame)
+ menu_frame_select(e->frame, e, FALSE);
+ }
+ else if (ev->type == KeyPress || ev->type == KeyRelease) {
+ guint keycode, state;
+ gunichar unikey;
+ ObMenuFrame *frame;
- if (keycode == ob_keycode(OB_KEY_ESCAPE)) {
- menu_frame_hide_all();
- ret = TRUE;
- }
+ keycode = ev->xkey.keycode;
+ state = ev->xkey.state;
+ unikey = obt_keyboard_keycode_to_unichar(keycode);
- else if (keycode == ob_keycode(OB_KEY_LEFT)) {
- /* Left goes to the parent menu */
- menu_frame_select(frame, NULL, TRUE);
- ret = TRUE;
- }
+ frame = find_active_or_last_menu();
+ if (frame == NULL)
+ g_assert_not_reached(); /* there is no active menu */
- else if (keycode == ob_keycode(OB_KEY_RIGHT)) {
- /* Right goes to the selected submenu */
- if (frame->child) menu_frame_select_next(frame->child);
- ret = TRUE;
- }
+ /* Allow control while going thru the menu */
+ else if (ev->type == KeyPress && (state & ~ControlMask) == 0) {
+ frame->got_press = TRUE;
- else if (keycode == ob_keycode(OB_KEY_UP)) {
- menu_frame_select_previous(frame);
- ret = TRUE;
- }
+ if (keycode == ob_keycode(OB_KEY_ESCAPE)) {
+ menu_frame_hide_all();
+ ret = TRUE;
+ }
- else if (keycode == ob_keycode(OB_KEY_DOWN)) {
- menu_frame_select_next(frame);
- ret = TRUE;
- }
- }
+ else if (keycode == ob_keycode(OB_KEY_LEFT)) {
+ /* Left goes to the parent menu */
+ menu_frame_select(frame, NULL, TRUE);
+ ret = TRUE;
+ }
- /* Use KeyRelease events for running things so that the key release doesn't
- get sent to the focused application.
+ else if (keycode == ob_keycode(OB_KEY_RIGHT)) {
+ /* Right goes to the selected submenu */
+ if (frame->child) menu_frame_select_next(frame->child);
+ ret = TRUE;
+ }
- Allow ControlMask only, and don't bother if the menu is empty */
- else if (ev->type == KeyRelease && (state & ~ControlMask) == 0 &&
- frame->entries && frame->got_press)
- {
- if (keycode == ob_keycode(OB_KEY_RETURN)) {
- /* Enter runs the active item or goes into the submenu.
- Control-Enter runs it without closing the menu. */
- if (frame->child)
- menu_frame_select_next(frame->child);
- else if (frame->selected)
- menu_entry_frame_execute(frame->selected, state);
-
- ret = TRUE;
- }
+ else if (keycode == ob_keycode(OB_KEY_UP)) {
+ menu_frame_select_previous(frame);
+ ret = TRUE;
+ }
- /* keyboard accelerator shortcuts. (if it was a valid key) */
- else if (unikey != 0) {
- GList *start;
- GList *it;
- ObMenuEntryFrame *found = NULL;
- guint num_found = 0;
-
- /* start after the selected one */
- start = frame->entries;
- if (frame->selected) {
- for (it = start; frame->selected != it->data;
- it = g_list_next(it))
- g_assert(it != NULL); /* nothing was selected? */
- /* next with wraparound */
- start = g_list_next(it);
- if (start == NULL) start = frame->entries;
+ else if (keycode == ob_keycode(OB_KEY_DOWN)) {
+ menu_frame_select_next(frame);
+ ret = TRUE;
}
+ }
- it = start;
- do {
- ObMenuEntryFrame *e = it->data;
- gunichar entrykey = 0;
+ /* Use KeyRelease events for running things so that the key release
+ doesn't get sent to the focused application.
- if (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL)
- entrykey = e->entry->data.normal.shortcut;
- else if (e->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)
- entrykey = e->entry->data.submenu.submenu->shortcut;
+ Allow ControlMask only, and don't bother if the menu is empty */
+ else if (ev->type == KeyRelease && (state & ~ControlMask) == 0 &&
+ frame->entries && frame->got_press)
+ {
+ if (keycode == ob_keycode(OB_KEY_RETURN)) {
+ /* Enter runs the active item or goes into the submenu.
+ Control-Enter runs it without closing the menu. */
+ if (frame->child)
+ menu_frame_select_next(frame->child);
+ else if (frame->selected)
+ menu_entry_frame_execute(frame->selected, state);
- if (unikey == entrykey) {
- if (found == NULL) found = e;
- ++num_found;
+ ret = TRUE;
+ }
+
+ /* keyboard accelerator shortcuts. (if it was a valid key) */
+ else if (unikey != 0) {
+ GList *start;
+ GList *it;
+ ObMenuEntryFrame *found = NULL;
+ guint num_found = 0;
+
+ /* start after the selected one */
+ start = frame->entries;
+ if (frame->selected) {
+ for (it = start; frame->selected != it->data;
+ it = g_list_next(it))
+ g_assert(it != NULL); /* nothing was selected? */
+ /* next with wraparound */
+ start = g_list_next(it);
+ if (start == NULL) start = frame->entries;
}
- /* next with wraparound */
- it = g_list_next(it);
- if (it == NULL) it = frame->entries;
- } while (it != start);
+ it = start;
+ do {
+ ObMenuEntryFrame *e = it->data;
+ gunichar entrykey = 0;
- if (found) {
- if (found->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
- num_found == 1)
- {
- menu_frame_select(frame, found, TRUE);
- usleep(50000); /* highlight the item for a short bit so the
- user can see what happened */
- menu_entry_frame_execute(found, state);
- } else {
- menu_frame_select(frame, found, TRUE);
- if (num_found == 1)
- menu_frame_select_next(frame->child);
- }
+ if (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL)
+ entrykey = e->entry->data.normal.shortcut;
+ else if (e->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)
+ entrykey = e->entry->data.submenu.submenu->shortcut;
- ret = TRUE;
+ if (unikey == entrykey) {
+ if (found == NULL) found = e;
+ ++num_found;
+ }
+
+ /* next with wraparound */
+ it = g_list_next(it);
+ if (it == NULL) it = frame->entries;
+ } while (it != start);
+
+ if (found) {
+ if (found->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
+ num_found == 1)
+ {
+ menu_frame_select(frame, found, TRUE);
+ usleep(50000); /* highlight the item for a short bit so
+ the user can see what happened */
+ menu_entry_frame_execute(found, state);
+ } else {
+ menu_frame_select(frame, found, TRUE);
+ if (num_found == 1)
+ menu_frame_select_next(frame->child);
+ }
+
+ ret = TRUE;
+ }
}
}
}
return ret;
}
-static gboolean event_handle_menu(XEvent *ev)
+static void event_handle_menu(ObMenuFrame *frame, XEvent *ev)
{
ObMenuFrame *f;
ObMenuEntryFrame *e;
- gboolean ret = TRUE;
switch (ev->type) {
- case ButtonRelease:
- if (menu_hide_delay_reached() &&
- (ev->xbutton.button < 4 || ev->xbutton.button > 5))
- {
- if ((e = menu_entry_frame_under(ev->xbutton.x_root,
- ev->xbutton.y_root)))
- {
- menu_frame_select(e->frame, e, TRUE);
- menu_entry_frame_execute(e, ev->xbutton.state);
- }
- else
- menu_frame_hide_all();
- }
- break;
case EnterNotify:
if ((e = g_hash_table_lookup(menu_frame_map, &ev->xcrossing.window))) {
if (e->ignore_enters)
menu_frame_select(e->frame, NULL, FALSE);
}
break;
- case MotionNotify:
- if ((e = menu_entry_frame_under(ev->xmotion.x_root,
- ev->xmotion.y_root)))
- if (!(f = find_active_menu()) ||
- f == e->frame ||
- f->parent == e->frame ||
- f->child == e->frame)
- menu_frame_select(e->frame, e, FALSE);
- break;
- case KeyPress:
- case KeyRelease:
- ret = event_handle_menu_keyboard(ev);
- break;
}
- return ret;
}
static void event_handle_user_input(ObClient *client, XEvent *e)
e->type == KeyRelease);
if (menu_frame_visible) {
- if (event_handle_menu(e))
+ if (event_handle_menu_input(e))
/* don't use the event if the menu used it, but if the menu
didn't use it and it's a keypress that is bound, it will
close the menu and be used */
static void focus_delay_client_dest(ObClient *client, gpointer data)
{
- ob_main_loop_timeout_remove_data(ob_main_loop, focus_delay_func,
- client, FALSE);
+ obt_main_loop_timeout_remove_data(ob_main_loop, focus_delay_func,
+ client, FALSE);
}
void event_halt_focus_delay(void)
{
/* ignore all enter events up till the event which caused this to occur */
if (event_curserial) event_ignore_enter_range(1, event_curserial);
- ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
+ obt_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
}
gulong event_start_ignore_all_enters(void)
{
- return NextRequest(ob_display);
+ return NextRequest(obt_display);
}
static void event_ignore_enter_range(gulong start, gulong end)
r->end = end;
ignore_serials = g_slist_prepend(ignore_serials, r);
- ob_debug_type(OB_DEBUG_FOCUS, "ignoring enters from %lu until %lu\n",
+ ob_debug_type(OB_DEBUG_FOCUS, "ignoring enters from %lu until %lu",
r->start, r->end);
/* increment the serial so we don't ignore events we weren't meant to */
- PROP_ERASE(screen_support_win, motif_wm_hints);
+ OBT_PROP_ERASE(screen_support_win, MOTIF_WM_HINTS);
}
void event_end_ignore_all_enters(gulong start)
movement will be ignored until we create some further network traffic.
Instead ignore up to NextRequest-1, then when we increment the serial,
we will be *past* the range of ignored serials */
- event_ignore_enter_range(start, NextRequest(ob_display)-1);
+ event_ignore_enter_range(start, NextRequest(obt_display)-1);
}
static gboolean is_enter_focus_event_ignored(gulong serial)
{
if (actions_interactive_act_running()) {
actions_interactive_cancel_act();
- ob_debug("KILLED interactive action\n");
+ ob_debug("KILLED interactive action");
}
else if (menu_frame_visible) {
menu_frame_hide_all();
- ob_debug("KILLED open menus\n");
+ ob_debug("KILLED open menus");
}
else if (moveresize_in_progress) {
moveresize_end(TRUE);
- ob_debug("KILLED interactive moveresize\n");
+ ob_debug("KILLED interactive moveresize");
}
else if (grab_on_keyboard()) {
ungrab_keyboard();
- ob_debug("KILLED active grab on keyboard\n");
+ ob_debug("KILLED active grab on keyboard");
}
else
ungrab_passive_key();
- XSync(ob_display, FALSE);
+ XSync(obt_display, FALSE);
}
gboolean event_time_after(Time t1, Time t2)
/* Generate a timestamp */
XEvent event;
- XChangeProperty(ob_display, screen_support_win,
- prop_atoms.wm_class, prop_atoms.string,
+ XChangeProperty(obt_display, screen_support_win,
+ OBT_PROP_ATOM(WM_CLASS), OBT_PROP_ATOM(STRING),
8, PropModeAppend, NULL, 0);
- XWindowEvent(ob_display, screen_support_win, PropertyChangeMask, &event);
+ XWindowEvent(obt_display, screen_support_win, PropertyChangeMask, &event);
return event.xproperty.time;
}
/*! The last user-interaction time, as given by the clients */
extern Time event_last_user_time;
-/*! The value of the mask for the NumLock modifier */
-extern guint NumLockMask;
-/*! The value of the mask for the ScrollLock modifier */
-extern guint ScrollLockMask;
-
void event_startup(gboolean reconfig);
void event_shutdown(gboolean reconfig);
+++ /dev/null
-/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
-
- extensions.c for the Openbox window manager
- Copyright (c) 2006 Mikael Magnusson
- Copyright (c) 2003-2007 Dana Jansens
-
- 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.
-
- See the COPYING file for a copy of the GNU General Public License.
-*/
-
-#include "openbox.h"
-#include "geom.h"
-#include "extensions.h"
-#include "screen.h"
-#include "debug.h"
-
-gboolean extensions_xkb = FALSE;
-gint extensions_xkb_event_basep;
-gboolean extensions_shape = FALSE;
-gint extensions_shape_event_basep;
-gboolean extensions_xinerama = FALSE;
-gint extensions_xinerama_event_basep;
-gboolean extensions_randr = FALSE;
-gint extensions_randr_event_basep;
-gboolean extensions_sync = FALSE;
-gint extensions_sync_event_basep;
-
-void extensions_query_all(void)
-{
- gint junk;
- (void)junk;
-
-#ifdef XKB
- extensions_xkb =
- XkbQueryExtension(ob_display, &junk, &extensions_xkb_event_basep,
- &junk, NULL, NULL);
- if (!extensions_xkb)
- ob_debug("XKB extension is not present on the server\n");
-#endif
-
-#ifdef SHAPE
- extensions_shape =
- XShapeQueryExtension(ob_display, &extensions_shape_event_basep,
- &junk);
- if (!extensions_shape)
- ob_debug("X Shape extension is not present on the server\n");
-#endif
-
-#ifdef XINERAMA
- extensions_xinerama =
- XineramaQueryExtension(ob_display, &extensions_xinerama_event_basep,
- &junk) && XineramaIsActive(ob_display);
- if (!extensions_xinerama)
- ob_debug("Xinerama extension is not present on the server\n");
-#endif
-
-#ifdef XRANDR
- extensions_randr =
- XRRQueryExtension(ob_display, &extensions_randr_event_basep,
- &junk);
- if (!extensions_randr)
- ob_debug("XRandR extension is not present on the server\n");
-#endif
-
-#ifdef SYNC
- extensions_sync =
- XSyncQueryExtension(ob_display, &extensions_sync_event_basep,
- &junk) &&
- XSyncInitialize(ob_display, &junk, &junk);
- if (!extensions_sync)
- ob_debug("X Sync extension is not present on the server or is an "
- "incompatible version\n");
-#endif
-}
-
-void extensions_xinerama_screens(Rect **xin_areas, guint *nxin)
-{
- guint i;
- gint l, r, t, b;
- if (ob_debug_xinerama) {
- gint w = WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen));
- gint h = HeightOfScreen(ScreenOfDisplay(ob_display, ob_screen));
- *nxin = 2;
- *xin_areas = g_new(Rect, *nxin + 1);
- RECT_SET((*xin_areas)[0], 0, 0, w/2, h);
- RECT_SET((*xin_areas)[1], w/2, 0, w-(w/2), h);
- }
- else
-#ifdef XINERAMA
- if (extensions_xinerama) {
- guint i;
- gint n;
- XineramaScreenInfo *info = XineramaQueryScreens(ob_display, &n);
- *nxin = n;
- *xin_areas = g_new(Rect, *nxin + 1);
- for (i = 0; i < *nxin; ++i)
- RECT_SET((*xin_areas)[i], info[i].x_org, info[i].y_org,
- info[i].width, info[i].height);
- XFree(info);
- }
- else
-#endif
- {
- *nxin = 1;
- *xin_areas = g_new(Rect, *nxin + 1);
- RECT_SET((*xin_areas)[0], 0, 0,
- WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen)),
- HeightOfScreen(ScreenOfDisplay(ob_display, ob_screen)));
- }
-
- /* returns one extra with the total area in it */
- l = (*xin_areas)[0].x;
- t = (*xin_areas)[0].y;
- r = (*xin_areas)[0].x + (*xin_areas)[0].width - 1;
- b = (*xin_areas)[0].y + (*xin_areas)[0].height - 1;
- for (i = 1; i < *nxin; ++i) {
- l = MIN(l, (*xin_areas)[i].x);
- t = MIN(l, (*xin_areas)[i].y);
- r = MAX(r, (*xin_areas)[i].x + (*xin_areas)[i].width - 1);
- b = MAX(b, (*xin_areas)[i].y + (*xin_areas)[i].height - 1);
- }
- RECT_SET((*xin_areas)[*nxin], l, t, r - l + 1, b - t + 1);
-}
+++ /dev/null
-/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
-
- extensions.h for the Openbox window manager
- Copyright (c) 2006 Mikael Magnusson
- Copyright (c) 2003-2007 Dana Jansens
-
- 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.
-
- See the COPYING file for a copy of the GNU General Public License.
-*/
-
-#ifndef __extensions_h
-#define __extensions_h
-
-#include "geom.h"
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h> /* shape.h uses Region which is in here */
-#ifdef XKB
-#include <X11/XKBlib.h>
-#endif
-#ifdef SHAPE
-#include <X11/extensions/shape.h>
-#endif
-#ifdef XINERAMA
-#include <X11/extensions/Xinerama.h>
-#endif
-#ifdef XRANDR
-#include <X11/extensions/Xrandr.h>
-#endif
-#ifdef SYNC
-#include <X11/extensions/sync.h>
-#endif
-
-#include <glib.h>
-
-/*! Does the display have the XKB extension? */
-extern gboolean extensions_xkb;
-/*! Base for events for the XKB extension */
-extern gint extensions_xkb_event_basep;
-
-/*! Does the display have the Shape extension? */
-extern gboolean extensions_shape;
-/*! Base for events for the Shape extension */
-extern gint extensions_shape_event_basep;
-
-/*! Does the display have the Xinerama extension? */
-extern gboolean extensions_xinerama;
-/*! Base for events for the Xinerama extension */
-extern gint extensions_xinerama_event_basep;
-
-/*! Does the display have the RandR extension? */
-extern gboolean extensions_randr;
-/*! Base for events for the Randr extension */
-extern gint extensions_randr_event_basep;
-
-/*! Does the display have the Sync extension? */
-extern gboolean extensions_sync;
-/*! Base for events for the Sync extension */
-extern gint extensions_sync_event_basep;
-
-void extensions_query_all();
-
-void extensions_xinerama_screens(Rect **areas, guint *nxin);
-
-#endif
#include "group.h"
#include "focus_cycle.h"
#include "screen.h"
-#include "prop.h"
#include "keyboard.h"
#include "focus.h"
#include "stacking.h"
+#include "obt/prop.h"
#include <X11/Xlib.h>
#include <glib.h>
if (reconfig) return;
/* reset focus to root */
- XSetInputFocus(ob_display, PointerRoot, RevertToNone, CurrentTime);
+ XSetInputFocus(obt_display, PointerRoot, RevertToNone, CurrentTime);
}
static void push_to_top(ObClient *client)
Window active;
ob_debug_type(OB_DEBUG_FOCUS,
- "focus_set_client 0x%lx\n", client ? client->window : 0);
+ "focus_set_client 0x%lx", client ? client->window : 0);
if (focus_client == client)
return;
/* set the NET_ACTIVE_WINDOW hint, but preserve it on shutdown */
if (ob_state() != OB_STATE_EXITING) {
active = client ? client->window : None;
- PROP_SET32(RootWindow(ob_display, ob_screen),
- net_active_window, window, active);
+ OBT_PROP_SET32(obt_root(ob_screen), NET_ACTIVE_WINDOW, WINDOW, active);
}
}
GList *it;
ObClient *c;
- ob_debug_type(OB_DEBUG_FOCUS, "trying pointer stuff\n");
+ ob_debug_type(OB_DEBUG_FOCUS, "trying pointer stuff");
if (allow_pointer && config_focus_follow)
if ((c = client_under_pointer()) &&
(allow_refocus || client_focus_target(c) != old) &&
(client_normal(c) &&
client_focus(c)))
{
- ob_debug_type(OB_DEBUG_FOCUS, "found in pointer stuff\n");
+ ob_debug_type(OB_DEBUG_FOCUS, "found in pointer stuff");
return c;
}
- ob_debug_type(OB_DEBUG_FOCUS, "trying the focus order\n");
+ ob_debug_type(OB_DEBUG_FOCUS, "trying the focus order");
for (it = focus_order; it; it = g_list_next(it)) {
c = it->data;
/* fallback focus to a window if:
(allow_refocus || client_focus_target(c) != old) &&
client_focus(c))
{
- ob_debug_type(OB_DEBUG_FOCUS, "found in focus order\n");
+ ob_debug_type(OB_DEBUG_FOCUS, "found in focus order");
return c;
}
}
- ob_debug_type(OB_DEBUG_FOCUS, "trying a desktop window\n");
+ ob_debug_type(OB_DEBUG_FOCUS, "trying a desktop window");
for (it = focus_order; it; it = g_list_next(it)) {
c = it->data;
/* fallback focus to a window if:
(allow_refocus || client_focus_target(c) != old) &&
client_focus(c))
{
- ob_debug_type(OB_DEBUG_FOCUS, "found a desktop window\n");
+ ob_debug_type(OB_DEBUG_FOCUS, "found a desktop window");
return c;
}
}
event_cancel_all_key_grabs();
/* when nothing will be focused, send focus to the backup target */
- XSetInputFocus(ob_display, screen_support_win, RevertToPointerRoot,
+ XSetInputFocus(obt_display, screen_support_win, RevertToPointerRoot,
event_curtime);
}
#include "focus_cycle.h"
#include "focus_cycle_indicator.h"
-#include "focus_cycle_popup.h"
#include "client.h"
#include "frame.h"
#include "focus.h"
ObClient* focus_cycle(gboolean forward, gboolean all_desktops,
gboolean dock_windows, gboolean desktop_windows,
gboolean linear, gboolean interactive,
- gboolean showbar, gboolean dialog,
+ gboolean showbar, ObFocusCyclePopupMode mode,
gboolean done, gboolean cancel)
{
static ObClient *t = NULL;
focus_cycle_target = ft;
focus_cycle_draw_indicator(showbar ? ft : NULL);
}
- if (dialog)
- /* same arguments as focus_target_valid */
- focus_cycle_popup_show(ft,
- focus_cycle_iconic_windows,
- focus_cycle_all_desktops,
- focus_cycle_dock_windows,
- focus_cycle_desktop_windows);
+ /* same arguments as focus_target_valid */
+ focus_cycle_popup_show(ft,
+ focus_cycle_iconic_windows,
+ focus_cycle_all_desktops,
+ focus_cycle_dock_windows,
+ focus_cycle_desktop_windows,
+ mode);
return focus_cycle_target;
} else if (ft != focus_cycle_target) {
focus_cycle_target = ft;
#define __focus_cycle_h
#include "misc.h"
+#include "focus_cycle_popup.h"
#include <X11/Xlib.h>
#include <glib.h>
struct _ObClient* focus_cycle(gboolean forward, gboolean all_desktops,
gboolean dock_windows, gboolean desktop_windows,
gboolean linear, gboolean interactive,
- gboolean showbar, gboolean dialog,
+ gboolean showbar, ObFocusCyclePopupMode mode,
gboolean done, gboolean cancel);
struct _ObClient* focus_directional_cycle(ObDirection dir,
gboolean dock_windows,
static struct
{
- InternalWindow top;
- InternalWindow left;
- InternalWindow right;
- InternalWindow bottom;
+ ObInternalWindow top;
+ ObInternalWindow left;
+ ObInternalWindow right;
+ ObInternalWindow bottom;
} focus_indicator;
static RrAppearance *a_focus_indicator;
static Window create_window(Window parent, gulong mask,
XSetWindowAttributes *attrib)
{
- return XCreateWindow(ob_display, parent, 0, 0, 1, 1, 0,
+ return XCreateWindow(obt_display, parent, 0, 0, 1, 1, 0,
RrDepth(ob_rr_inst), InputOutput,
RrVisual(ob_rr_inst), mask, attrib);
if (reconfig) return;
- focus_indicator.top.type = Window_Internal;
- focus_indicator.left.type = Window_Internal;
- focus_indicator.right.type = Window_Internal;
- focus_indicator.bottom.type = Window_Internal;
+ focus_indicator.top.type = OB_WINDOW_CLASS_INTERNAL;
+ focus_indicator.left.type = OB_WINDOW_CLASS_INTERNAL;
+ focus_indicator.right.type = OB_WINDOW_CLASS_INTERNAL;
+ focus_indicator.bottom.type = OB_WINDOW_CLASS_INTERNAL;
attr.override_redirect = True;
- attr.background_pixel = BlackPixel(ob_display, ob_screen);
+ attr.background_pixel = BlackPixel(obt_display, ob_screen);
focus_indicator.top.window =
- create_window(RootWindow(ob_display, ob_screen),
+ create_window(obt_root(ob_screen),
CWOverrideRedirect | CWBackPixel, &attr);
focus_indicator.left.window =
- create_window(RootWindow(ob_display, ob_screen),
+ create_window(obt_root(ob_screen),
CWOverrideRedirect | CWBackPixel, &attr);
focus_indicator.right.window =
- create_window(RootWindow(ob_display, ob_screen),
+ create_window(obt_root(ob_screen),
CWOverrideRedirect | CWBackPixel, &attr);
focus_indicator.bottom.window =
- create_window(RootWindow(ob_display, ob_screen),
+ create_window(obt_root(ob_screen),
CWOverrideRedirect | CWBackPixel, &attr);
stacking_add(INTERNAL_AS_WINDOW(&focus_indicator.top));
stacking_add(INTERNAL_AS_WINDOW(&focus_indicator.left));
stacking_add(INTERNAL_AS_WINDOW(&focus_indicator.right));
stacking_add(INTERNAL_AS_WINDOW(&focus_indicator.bottom));
- g_hash_table_insert(window_map, &focus_indicator.top.window,
- &focus_indicator.top);
- g_hash_table_insert(window_map, &focus_indicator.left.window,
- &focus_indicator.left);
- g_hash_table_insert(window_map, &focus_indicator.right.window,
- &focus_indicator.right);
- g_hash_table_insert(window_map, &focus_indicator.bottom.window,
- &focus_indicator.bottom);
+ window_add(&focus_indicator.top.window,
+ INTERNAL_AS_WINDOW(&focus_indicator.top));
+ window_add(&focus_indicator.left.window,
+ INTERNAL_AS_WINDOW(&focus_indicator.left));
+ window_add(&focus_indicator.right.window,
+ INTERNAL_AS_WINDOW(&focus_indicator.right));
+ window_add(&focus_indicator.bottom.window,
+ INTERNAL_AS_WINDOW(&focus_indicator.bottom));
color_white = RrColorNew(ob_rr_inst, 0xff, 0xff, 0xff);
RrAppearanceFree(a_focus_indicator);
- g_hash_table_remove(window_map, &focus_indicator.top.window);
- g_hash_table_remove(window_map, &focus_indicator.left.window);
- g_hash_table_remove(window_map, &focus_indicator.right.window);
- g_hash_table_remove(window_map, &focus_indicator.bottom.window);
+ window_remove(focus_indicator.top.window);
+ window_remove(focus_indicator.left.window);
+ window_remove(focus_indicator.right.window);
+ window_remove(focus_indicator.bottom.window);
stacking_remove(INTERNAL_AS_WINDOW(&focus_indicator.top));
stacking_remove(INTERNAL_AS_WINDOW(&focus_indicator.left));
stacking_remove(INTERNAL_AS_WINDOW(&focus_indicator.right));
stacking_remove(INTERNAL_AS_WINDOW(&focus_indicator.bottom));
- XDestroyWindow(ob_display, focus_indicator.top.window);
- XDestroyWindow(ob_display, focus_indicator.left.window);
- XDestroyWindow(ob_display, focus_indicator.right.window);
- XDestroyWindow(ob_display, focus_indicator.bottom.window);
+ XDestroyWindow(obt_display, focus_indicator.top.window);
+ XDestroyWindow(obt_display, focus_indicator.left.window);
+ XDestroyWindow(obt_display, focus_indicator.right.window);
+ XDestroyWindow(obt_display, focus_indicator.bottom.window);
}
void focus_cycle_draw_indicator(ObClient *c)
/* kill enter events cause by this unmapping */
ignore_start = event_start_ignore_all_enters();
- XUnmapWindow(ob_display, focus_indicator.top.window);
- XUnmapWindow(ob_display, focus_indicator.left.window);
- XUnmapWindow(ob_display, focus_indicator.right.window);
- XUnmapWindow(ob_display, focus_indicator.bottom.window);
+ XUnmapWindow(obt_display, focus_indicator.top.window);
+ XUnmapWindow(obt_display, focus_indicator.left.window);
+ XUnmapWindow(obt_display, focus_indicator.right.window);
+ XUnmapWindow(obt_display, focus_indicator.bottom.window);
event_end_ignore_all_enters(ignore_start);
/* kill enter events cause by this moving */
ignore_start = event_start_ignore_all_enters();
- XMoveResizeWindow(ob_display, focus_indicator.top.window,
+ XMoveResizeWindow(obt_display, focus_indicator.top.window,
x, y, w, h);
a_focus_indicator->texture[0].data.lineart.x1 = 0;
a_focus_indicator->texture[0].data.lineart.y1 = h-1;
w = wl;
h = c->frame->area.height;
- XMoveResizeWindow(ob_display, focus_indicator.left.window,
+ XMoveResizeWindow(obt_display, focus_indicator.left.window,
x, y, w, h);
a_focus_indicator->texture[0].data.lineart.x1 = w-1;
a_focus_indicator->texture[0].data.lineart.y1 = 0;
w = wr;
h = c->frame->area.height ;
- XMoveResizeWindow(ob_display, focus_indicator.right.window,
+ XMoveResizeWindow(obt_display, focus_indicator.right.window,
x, y, w, h);
a_focus_indicator->texture[0].data.lineart.x1 = 0;
a_focus_indicator->texture[0].data.lineart.y1 = 0;
w = c->frame->area.width;
h = wb;
- XMoveResizeWindow(ob_display, focus_indicator.bottom.window,
+ XMoveResizeWindow(obt_display, focus_indicator.bottom.window,
x, y, w, h);
a_focus_indicator->texture[0].data.lineart.x1 = 0;
a_focus_indicator->texture[0].data.lineart.y1 = 0;
RrPaint(a_focus_indicator, focus_indicator.bottom.window,
w, h);
- XMapWindow(ob_display, focus_indicator.top.window);
- XMapWindow(ob_display, focus_indicator.left.window);
- XMapWindow(ob_display, focus_indicator.right.window);
- XMapWindow(ob_display, focus_indicator.bottom.window);
+ XMapWindow(obt_display, focus_indicator.top.window);
+ XMapWindow(obt_display, focus_indicator.left.window);
+ XMapWindow(obt_display, focus_indicator.right.window);
+ XMapWindow(obt_display, focus_indicator.bottom.window);
event_end_ignore_all_enters(ignore_start);
#include <X11/Xlib.h>
#include <glib.h>
-#define ICON_SIZE 40
-#define ICON_HILITE_WIDTH 2
-#define ICON_HILITE_MARGIN 1
+/* Size of the hilite box around a window's icon */
+#define HILITE_SIZE 40
+/* Width of the outer ring around the hilite box */
+#define HILITE_WIDTH 2
+/* Space between the outer ring around the hilite box and the icon inside it */
+#define HILITE_MARGIN 1
+/* Total distance from the edge of the hilite box to the icon inside it */
+#define HILITE_OFFSET (HILITE_WIDTH + HILITE_MARGIN)
+/* Size of the icons, which can appear inside or outside of a hilite box */
+#define ICON_SIZE (HILITE_SIZE - 2*HILITE_OFFSET)
+/* Margin area around the outside of the dialog */
#define OUTSIDE_BORDER 3
+/* Margin area around the text */
#define TEXT_BORDER 2
+/* Scroll the list-mode list when the cursor gets within this many rows of the
+ top or bottom */
+#define SCROLL_MARGIN 4
typedef struct _ObFocusCyclePopup ObFocusCyclePopup;
typedef struct _ObFocusCyclePopupTarget ObFocusCyclePopupTarget;
struct _ObFocusCyclePopupTarget
{
ObClient *client;
+ RrImage *icon;
gchar *text;
- Window win;
+ Window iconwin;
+ /* This is used when the popup is in list mode */
+ Window textwin;
};
struct _ObFocusCyclePopup
ObWindow obwin;
Window bg;
- Window text;
+ /* This is used when the popup is in icon mode */
+ Window icon_mode_text;
+
+ Window list_mode_up;
+ Window list_mode_down;
GList *targets;
gint n_targets;
gint maxtextw;
+ /* How are the list is scrolled, in scroll mode */
+ gint scroll;
+
RrAppearance *a_bg;
RrAppearance *a_text;
+ RrAppearance *a_hilite_text;
RrAppearance *a_icon;
-
- RrPixel32 *hilite_rgba;
+ RrAppearance *a_arrow;
gboolean mapped;
+ ObFocusCyclePopupMode mode;
};
/*! This popup shows all possible windows */
static Window create_window(Window parent, guint bwidth, gulong mask,
XSetWindowAttributes *attr)
{
- return XCreateWindow(ob_display, parent, 0, 0, 1, 1, bwidth,
+ return XCreateWindow(obt_display, parent, 0, 0, 1, 1, bwidth,
RrDepth(ob_rr_inst), InputOutput,
RrVisual(ob_rr_inst), mask, attr);
}
void focus_cycle_popup_startup(gboolean reconfig)
{
XSetWindowAttributes attrib;
+ RrPixel32 *p;
single_popup = icon_popup_new();
- popup.obwin.type = Window_Internal;
+ popup.obwin.type = OB_WINDOW_CLASS_INTERNAL;
popup.a_bg = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg);
- popup.a_text = RrAppearanceCopy(ob_rr_theme->osd_hilite_label);
- popup.a_icon = RrAppearanceCopy(ob_rr_theme->a_clear_tex);
+ popup.a_hilite_text = RrAppearanceCopy(ob_rr_theme->osd_hilite_label);
+ popup.a_text = RrAppearanceCopy(ob_rr_theme->a_unfocused_label);
+ popup.a_icon = RrAppearanceCopy(ob_rr_theme->a_clear);
+ popup.a_arrow = RrAppearanceCopy(ob_rr_theme->a_clear_tex);
+ popup.a_hilite_text->surface.parent = popup.a_bg;
popup.a_text->surface.parent = popup.a_bg;
popup.a_icon->surface.parent = popup.a_bg;
- popup.a_icon->texture[0].type = RR_TEXTURE_RGBA;
+ popup.a_text->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
+ popup.a_hilite_text->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
+
+ /* 2 textures. texture[0] is the icon. texture[1] is the hilight, and
+ may or may not be used */
+ RrAppearanceAddTextures(popup.a_icon, 2);
- RrAppearanceAddTextures(popup.a_bg, 1);
- popup.a_bg->texture[0].type = RR_TEXTURE_RGBA;
+ RrAppearanceClearTextures(popup.a_icon);
+ popup.a_icon->texture[0].type = RR_TEXTURE_IMAGE;
+
+ RrAppearanceClearTextures(popup.a_arrow);
+ popup.a_arrow->texture[0].type = RR_TEXTURE_MASK;
+ popup.a_arrow->texture[0].data.mask.color =
+ ob_rr_theme->osd_color;
attrib.override_redirect = True;
attrib.border_pixel=RrColorPixel(ob_rr_theme->osd_border_color);
- popup.bg = create_window(RootWindow(ob_display, ob_screen),
- ob_rr_theme->obwidth,
+ popup.bg = create_window(obt_root(ob_screen), ob_rr_theme->obwidth,
CWOverrideRedirect | CWBorderPixel, &attrib);
- popup.text = create_window(popup.bg, 0, 0, NULL);
+ /* create the text window used for the icon-mode popup */
+ popup.icon_mode_text = create_window(popup.bg, 0, 0, NULL);
+
+ /* create the windows for the up and down arrows */
+ popup.list_mode_up = create_window(popup.bg, 0, 0, NULL);
+ popup.list_mode_down = create_window(popup.bg, 0, 0, NULL);
popup.targets = NULL;
popup.n_targets = 0;
popup.last_target = NULL;
- popup.hilite_rgba = NULL;
+ /* set up the hilite texture for the icon */
+ popup.a_icon->texture[1].data.rgba.width = HILITE_SIZE;
+ popup.a_icon->texture[1].data.rgba.height = HILITE_SIZE;
+ popup.a_icon->texture[1].data.rgba.alpha = 0xff;
+ p = g_new(RrPixel32, HILITE_SIZE * HILITE_SIZE);
+ popup.a_icon->texture[1].data.rgba.data = p;
- XMapWindow(ob_display, popup.text);
+ /* create the hilite under the target icon */
+ {
+ RrPixel32 color;
+ gint x, y, o;
+
+ color = ((ob_rr_theme->osd_color->r & 0xff) << RrDefaultRedOffset) +
+ ((ob_rr_theme->osd_color->g & 0xff) << RrDefaultGreenOffset) +
+ ((ob_rr_theme->osd_color->b & 0xff) << RrDefaultBlueOffset);
+
+ o = 0;
+ for (x = 0; x < HILITE_SIZE; x++)
+ for (y = 0; y < HILITE_SIZE; y++) {
+ guchar a;
+
+ if (x < HILITE_WIDTH ||
+ x >= HILITE_SIZE - HILITE_WIDTH ||
+ y < HILITE_WIDTH ||
+ y >= HILITE_SIZE - HILITE_WIDTH)
+ {
+ /* the border of the target */
+ a = 0x88;
+ } else {
+ /* the background of the target */
+ a = 0x22;
+ }
+
+ p[o++] = color + (a << RrDefaultAlphaOffset);
+ }
+ }
stacking_add(INTERNAL_AS_WINDOW(&popup));
- g_hash_table_insert(window_map, &popup.bg, &popup);
+ window_add(&popup.bg, INTERNAL_AS_WINDOW(&popup));
}
void focus_cycle_popup_shutdown(gboolean reconfig)
{
icon_popup_free(single_popup);
- g_hash_table_remove(window_map, &popup.bg);
+ window_remove(popup.bg);
stacking_remove(INTERNAL_AS_WINDOW(&popup));
while(popup.targets) {
ObFocusCyclePopupTarget *t = popup.targets->data;
+ RrImageUnref(t->icon);
g_free(t->text);
- XDestroyWindow(ob_display, t->win);
+ XDestroyWindow(obt_display, t->iconwin);
+ XDestroyWindow(obt_display, t->textwin);
+ g_free(t);
popup.targets = g_list_delete_link(popup.targets, popup.targets);
}
- g_free(popup.hilite_rgba);
- popup.hilite_rgba = NULL;
+ g_free(popup.a_icon->texture[1].data.rgba.data);
+ popup.a_icon->texture[1].data.rgba.data = NULL;
- XDestroyWindow(ob_display, popup.text);
- XDestroyWindow(ob_display, popup.bg);
+ XDestroyWindow(obt_display, popup.list_mode_up);
+ XDestroyWindow(obt_display, popup.list_mode_down);
+ XDestroyWindow(obt_display, popup.icon_mode_text);
+ XDestroyWindow(obt_display, popup.bg);
+ RrAppearanceFree(popup.a_arrow);
RrAppearanceFree(popup.a_icon);
+ RrAppearanceFree(popup.a_hilite_text);
RrAppearanceFree(popup.a_text);
RrAppearanceFree(popup.a_bg);
}
p->a_text->texture[0].data.text.string = text;
maxwidth = MAX(maxwidth, RrMinWidth(p->a_text));
- if (!create_targets)
+ if (!create_targets) {
g_free(text);
- else {
+ } else {
ObFocusCyclePopupTarget *t = g_new(ObFocusCyclePopupTarget, 1);
t->client = ft;
t->text = text;
- t->win = create_window(p->bg, 0, 0, NULL);
-
- XMapWindow(ob_display, t->win);
+ t->icon = client_icon(t->client);
+ RrImageRef(t->icon); /* own the icon so it won't go away */
+ t->iconwin = create_window(p->bg, 0, 0, NULL);
+ t->textwin = create_window(p->bg, 0, 0, NULL);
p->targets = g_list_prepend(p->targets, t);
++n;
gint l, t, r, b;
gint x, y, w, h;
Rect *screen_area = NULL;
- gint icons_per_row;
- gint icon_rows;
- gint textx, texty, textw, texth;
gint rgbax, rgbay, rgbaw, rgbah;
- gint icons_center_x;
- gint innerw, innerh;
gint i;
GList *it;
const ObFocusCyclePopupTarget *newtarget;
- gint newtargetx, newtargety;
+ gint icons_per_row;
+ gint icon_rows;
+ gint textw, texth;
+ gint selected_pos;
+ gint last_scroll;
+
+ /* vars for icon mode */
+ gint icon_mode_textx;
+ gint icon_mode_texty;
+ gint icons_center_x;
+
+ /* vars for list mode */
+ gint list_mode_icon_column_w = HILITE_SIZE + OUTSIDE_BORDER;
+ gint up_arrow_x, down_arrow_x;
+ gint up_arrow_y, down_arrow_y;
+ gboolean showing_arrows = FALSE;
+
+ g_assert(p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ||
+ p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST);
screen_area = screen_physical_area_active();
t = mt + OUTSIDE_BORDER;
b = mb + OUTSIDE_BORDER;
- /* get the icon pictures' sizes */
- innerw = ICON_SIZE - (ICON_HILITE_WIDTH + ICON_HILITE_MARGIN) * 2;
- innerh = ICON_SIZE - (ICON_HILITE_WIDTH + ICON_HILITE_MARGIN) * 2;
-
/* get the width from the text and keep it within limits */
w = l + r + p->maxtextw;
+ if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST)
+ /* when in list mode, there are icons down the side */
+ w += list_mode_icon_column_w;
w = MIN(w, MAX(screen_area->width/3, POPUP_WIDTH)); /* max width */
w = MAX(w, POPUP_WIDTH); /* min width */
- /* how many icons will fit in that row? make the width fit that */
- w -= l + r;
- icons_per_row = (w + ICON_SIZE - 1) / ICON_SIZE;
- w = icons_per_row * ICON_SIZE + l + r;
-
- /* how many rows do we need? */
- icon_rows = (p->n_targets-1) / icons_per_row + 1;
+ /* get the text height */
+ texth = RrMinHeight(p->a_hilite_text);
+ if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST)
+ texth = MAX(MAX(texth, RrMinHeight(p->a_text)), HILITE_SIZE);
+ else
+ texth += TEXT_BORDER * 2;
+
+ if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) {
+ /* how many icons will fit in that row? make the width fit that */
+ w -= l + r;
+ icons_per_row = (w + HILITE_SIZE - 1) / HILITE_SIZE;
+ w = icons_per_row * HILITE_SIZE + l + r;
+
+ /* how many rows do we need? */
+ icon_rows = (p->n_targets-1) / icons_per_row + 1;
+ } else {
+ /* in list mode, there is one column of icons.. */
+ icons_per_row = 1;
+ /* maximum is 80% of the screen height */
+ icon_rows = MIN(p->n_targets,
+ (4*screen_area->height/5) /* 80% of the screen */
+ /
+ MAX(HILITE_SIZE, texth)); /* height of each row */
+ /* but make sure there is always one */
+ icon_rows = MAX(icon_rows, 1);
+ }
- /* get the text dimensions */
+ /* get the text width */
textw = w - l - r;
- texth = RrMinHeight(p->a_text) + TEXT_BORDER * 2;
-
- /* find the height of the dialog */
- h = t + b + (icon_rows * ICON_SIZE) + (OUTSIDE_BORDER + texth);
-
- /* get the position of the text */
- textx = l;
- texty = h - texth - b;
+ if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST)
+ /* leave space on the side for the icons */
+ textw -= list_mode_icon_column_w;
- /* find the position for the popup (include the outer borders) */
- x = screen_area->x + (screen_area->width -
- (w + ob_rr_theme->obwidth * 2)) / 2;
- y = screen_area->y + (screen_area->height -
- (h + ob_rr_theme->obwidth * 2)) / 2;
-
- /* get the dimensions of the target hilite texture */
- rgbax = ml;
- rgbay = mt;
- rgbaw = w - ml - mr;
- rgbah = h - mt - mb;
-
- /* center the icons if there is less than one row */
- if (icon_rows == 1)
- icons_center_x = (w - p->n_targets * ICON_SIZE) / 2;
- else
- icons_center_x = 0;
+ if (!p->mapped)
+ /* reset the scrolling when the dialog is first shown */
+ p->scroll = 0;
- if (!p->mapped) {
- /* position the background but don't draw it*/
- XMoveResizeWindow(ob_display, p->bg, x, y, w, h);
-
- /* set up the hilite texture for the background */
- p->a_bg->texture[0].data.rgba.width = rgbaw;
- p->a_bg->texture[0].data.rgba.height = rgbah;
- p->a_bg->texture[0].data.rgba.alpha = 0xff;
- p->hilite_rgba = g_new(RrPixel32, rgbaw * rgbah);
- p->a_bg->texture[0].data.rgba.data = p->hilite_rgba;
-
- /* position the text, but don't draw it */
- XMoveResizeWindow(ob_display, p->text, textx, texty, textw, texth);
- p->a_text->surface.parentx = textx;
- p->a_text->surface.parenty = texty;
- }
+ /* find the height of the dialog */
+ h = t + b + (icon_rows * MAX(HILITE_SIZE, texth));
+ if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS)
+ /* in icon mode the text sits below the icons, so make some space */
+ h += OUTSIDE_BORDER + texth;
/* find the focused target */
+ newtarget = NULL;
for (i = 0, it = p->targets; it; ++i, it = g_list_next(it)) {
const ObFocusCyclePopupTarget *target = it->data;
- const gint row = i / icons_per_row; /* starting from 0 */
- const gint col = i % icons_per_row; /* starting from 0 */
-
if (target->client == c) {
/* save the target */
newtarget = target;
- newtargetx = icons_center_x + l + (col * ICON_SIZE);
- newtargety = t + (row * ICON_SIZE);
+ break;
+ }
+ }
+ selected_pos = i;
+ g_assert(newtarget != NULL);
- if (!p->mapped)
- break; /* if we're not dimensioning, then we're done */
+ /* scroll the list if needed */
+ last_scroll = p->scroll;
+ if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) {
+ const gint top = p->scroll + SCROLL_MARGIN;
+ const gint bottom = p->scroll + icon_rows - SCROLL_MARGIN;
+ const gint min_scroll = 0;
+ const gint max_scroll = p->n_targets - icon_rows;
+
+ if (top - selected_pos >= 0) {
+ p->scroll -= top - selected_pos + 1;
+ p->scroll = MAX(p->scroll, min_scroll);
+ } else if (selected_pos - bottom >= 0) {
+ p->scroll += selected_pos - bottom + 1;
+ p->scroll = MIN(p->scroll, max_scroll);
}
}
- g_assert(newtarget != NULL);
+ /* show the scroll arrows when appropriate */
+ if (p->scroll && p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) {
+ XMapWindow(obt_display, p->list_mode_up);
+ showing_arrows = TRUE;
+ } else
+ XUnmapWindow(obt_display, p->list_mode_up);
- /* create the hilite under the target icon */
+ if (p->scroll < p->n_targets - icon_rows &&
+ p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST)
{
- RrPixel32 color;
- gint i, j, o;
+ XMapWindow(obt_display, p->list_mode_down);
+ showing_arrows = TRUE;
+ } else
+ XUnmapWindow(obt_display, p->list_mode_down);
- color = ((ob_rr_theme->osd_color->r & 0xff) << RrDefaultRedOffset) +
- ((ob_rr_theme->osd_color->g & 0xff) << RrDefaultGreenOffset) +
- ((ob_rr_theme->osd_color->b & 0xff) << RrDefaultBlueOffset);
+ /* make space for the arrows */
+ if (showing_arrows)
+ h += ob_rr_theme->up_arrow_mask->height + OUTSIDE_BORDER
+ + ob_rr_theme->down_arrow_mask->height + OUTSIDE_BORDER;
- o = 0;
- for (i = 0; i < rgbah; ++i)
- for (j = 0; j < rgbaw; ++j) {
- guchar a;
- const gint x = j + rgbax - newtargetx;
- const gint y = i + rgbay - newtargety;
+ /* center the icons if there is less than one row */
+ if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS && icon_rows == 1)
+ icons_center_x = (w - p->n_targets * HILITE_SIZE) / 2;
+ else
+ icons_center_x = 0;
- if (x < 0 || x >= ICON_SIZE ||
- y < 0 || y >= ICON_SIZE)
- {
- /* outside the target */
- a = 0x00;
- }
- else if (x < ICON_HILITE_WIDTH ||
- x >= ICON_SIZE - ICON_HILITE_WIDTH ||
- y < ICON_HILITE_WIDTH ||
- y >= ICON_SIZE - ICON_HILITE_WIDTH)
- {
- /* the border of the target */
- a = 0x88;
- }
- else {
- /* the background of the target */
- a = 0x22;
- }
+ if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) {
+ /* get the position of the text */
+ icon_mode_textx = l;
+ icon_mode_texty = h - texth - b;
+ }
- p->hilite_rgba[o++] =
- color + (a << RrDefaultAlphaOffset);
- }
+ /* find the position for the popup (include the outer borders) */
+ x = screen_area->x + (screen_area->width -
+ (w + ob_rr_theme->obwidth * 2)) / 2;
+ y = screen_area->y + (screen_area->height -
+ (h + ob_rr_theme->obwidth * 2)) / 2;
+
+ /* get the dimensions of the target hilite texture */
+ rgbax = ml;
+ rgbay = mt;
+ rgbaw = w - ml - mr;
+ rgbah = h - mt - mb;
+
+ if (!p->mapped) {
+ /* position the background but don't draw it */
+ XMoveResizeWindow(obt_display, p->bg, x, y, w, h);
+
+ if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) {
+ /* position the text */
+ XMoveResizeWindow(obt_display, p->icon_mode_text,
+ icon_mode_textx, icon_mode_texty, textw, texth);
+ XMapWindow(obt_display, popup.icon_mode_text);
+ } else {
+ XUnmapWindow(obt_display, popup.icon_mode_text);
+
+ up_arrow_x = (w - ob_rr_theme->up_arrow_mask->width) / 2;
+ up_arrow_y = t;
+
+ down_arrow_x = (w - ob_rr_theme->down_arrow_mask->width) / 2;
+ down_arrow_y = h - b - ob_rr_theme->down_arrow_mask->height;
+
+ /* position the arrows */
+ XMoveResizeWindow(obt_display, p->list_mode_up,
+ up_arrow_x, up_arrow_y,
+ ob_rr_theme->up_arrow_mask->width,
+ ob_rr_theme->up_arrow_mask->height);
+ XMoveResizeWindow(obt_display, p->list_mode_down,
+ down_arrow_x, down_arrow_y,
+ ob_rr_theme->down_arrow_mask->width,
+ ob_rr_theme->down_arrow_mask->height);
+ }
}
/* * * draw everything * * */
/* draw the background */
- RrPaint(p->a_bg, p->bg, w, h);
+ if (!p->mapped)
+ RrPaint(p->a_bg, p->bg, w, h);
+
+ /* draw the scroll arrows */
+ if (!p->mapped && p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) {
+ p->a_arrow->texture[0].data.mask.mask =
+ ob_rr_theme->up_arrow_mask;
+ p->a_arrow->surface.parent = p->a_bg;
+ p->a_arrow->surface.parentx = up_arrow_x;
+ p->a_arrow->surface.parenty = up_arrow_y;
+ RrPaint(p->a_arrow, p->list_mode_up,
+ ob_rr_theme->up_arrow_mask->width,
+ ob_rr_theme->up_arrow_mask->height);
+
+ p->a_arrow->texture[0].data.mask.mask =
+ ob_rr_theme->down_arrow_mask;
+ p->a_arrow->surface.parent = p->a_bg;
+ p->a_arrow->surface.parentx = down_arrow_x;
+ p->a_arrow->surface.parenty = down_arrow_y;
+ RrPaint(p->a_arrow, p->list_mode_down,
+ ob_rr_theme->down_arrow_mask->width,
+ ob_rr_theme->down_arrow_mask->height);
+ }
- /* draw the icons */
+ /* draw the icons and text */
for (i = 0, it = p->targets; it; ++i, it = g_list_next(it)) {
const ObFocusCyclePopupTarget *target = it->data;
- /* have to redraw the targetted icon and last targetted icon,
- they can pick up the hilite changes in the backgroud */
- if (!p->mapped || newtarget == target || p->last_target == target) {
- const ObClientIcon *icon;
- const gint row = i / icons_per_row; /* starting from 0 */
- const gint col = i % icons_per_row; /* starting from 0 */
- gint innerx, innery;
-
- /* find the dimensions of the icon inside it */
- innerx = icons_center_x + l + (col * ICON_SIZE);
- innerx += ICON_HILITE_WIDTH + ICON_HILITE_MARGIN;
- innery = t + (row * ICON_SIZE);
- innery += ICON_HILITE_WIDTH + ICON_HILITE_MARGIN;
-
- /* move the icon */
- XMoveResizeWindow(ob_display, target->win,
- innerx, innery, innerw, innerh);
+ /* have to redraw the targetted icon and last targetted icon
+ * to update the hilite */
+ if (!p->mapped || newtarget == target || p->last_target == target ||
+ last_scroll != p->scroll)
+ {
+ /* row and column start from 0 */
+ const gint row = i / icons_per_row - p->scroll;
+ const gint col = i % icons_per_row;
+ gint iconx, icony;
+ gint list_mode_textx, list_mode_texty;
+ RrAppearance *text;
+
+ /* find the coordinates for the icon */
+ iconx = icons_center_x + l + (col * HILITE_SIZE);
+ icony = t + (showing_arrows ? ob_rr_theme->up_arrow_mask->height
+ + OUTSIDE_BORDER
+ : 0)
+ + (row * MAX(texth, HILITE_SIZE))
+ + MAX(texth - HILITE_SIZE, 0) / 2;
+
+ /* find the dimensions of the text box */
+ list_mode_textx = iconx + HILITE_SIZE + TEXT_BORDER;
+ list_mode_texty = icony;
+
+ /* position the icon */
+ XMoveResizeWindow(obt_display, target->iconwin,
+ iconx, icony, HILITE_SIZE, HILITE_SIZE);
+
+ /* position the text */
+ if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST)
+ XMoveResizeWindow(obt_display, target->textwin,
+ list_mode_textx, list_mode_texty,
+ textw, texth);
+
+ /* show/hide the right windows */
+ if (row >= 0 && row < icon_rows) {
+ XMapWindow(obt_display, target->iconwin);
+ if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST)
+ XMapWindow(obt_display, target->textwin);
+ else
+ XUnmapWindow(obt_display, target->textwin);
+ } else {
+ XUnmapWindow(obt_display, target->textwin);
+ if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST)
+ XUnmapWindow(obt_display, target->iconwin);
+ else
+ XMapWindow(obt_display, target->iconwin);
+ }
/* get the icon from the client */
- icon = client_icon(target->client, innerw, innerh);
- p->a_icon->texture[0].data.rgba.width = icon->width;
- p->a_icon->texture[0].data.rgba.height = icon->height;
- p->a_icon->texture[0].data.rgba.alpha =
+ p->a_icon->texture[0].data.image.twidth = ICON_SIZE;
+ p->a_icon->texture[0].data.image.theight = ICON_SIZE;
+ p->a_icon->texture[0].data.image.tx = HILITE_OFFSET;
+ p->a_icon->texture[0].data.image.ty = HILITE_OFFSET;
+ p->a_icon->texture[0].data.image.alpha =
target->client->iconic ? OB_ICONIC_ALPHA : 0xff;
- p->a_icon->texture[0].data.rgba.data = icon->data;
+ p->a_icon->texture[0].data.image.image = target->icon;
+
+ /* Draw the hilite? */
+ p->a_icon->texture[1].type = (target == newtarget) ?
+ RR_TEXTURE_RGBA : RR_TEXTURE_NONE;
/* draw the icon */
- p->a_icon->surface.parentx = innerx;
- p->a_icon->surface.parenty = innery;
- RrPaint(p->a_icon, target->win, innerw, innerh);
+ p->a_icon->surface.parentx = iconx;
+ p->a_icon->surface.parenty = icony;
+ RrPaint(p->a_icon, target->iconwin, HILITE_SIZE, HILITE_SIZE);
+
+ /* draw the text */
+ if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST ||
+ target == newtarget)
+ {
+ text = (target == newtarget) ? p->a_hilite_text : p->a_text;
+ text->texture[0].data.text.string = target->text;
+ text->surface.parentx =
+ p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ?
+ icon_mode_textx : list_mode_textx;
+ text->surface.parenty =
+ p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ?
+ icon_mode_texty : list_mode_texty;
+ RrPaint(text,
+ (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ?
+ p->icon_mode_text : target->textwin),
+ textw, texth);
+ }
}
}
- /* draw the text */
- p->a_text->texture[0].data.text.string = newtarget->text;
- p->a_text->surface.parentx = textx;
- p->a_text->surface.parenty = texty;
- RrPaint(p->a_text, p->text, textw, texth);
-
p->last_target = newtarget;
g_free(screen_area);
+
+ XFlush(obt_display);
}
void focus_cycle_popup_show(ObClient *c, gboolean iconic_windows,
gboolean all_desktops, gboolean dock_windows,
- gboolean desktop_windows)
+ gboolean desktop_windows,
+ ObFocusCyclePopupMode mode)
{
g_assert(c != NULL);
+ if (mode == OB_FOCUS_CYCLE_POPUP_MODE_NONE) {
+ focus_cycle_popup_hide();
+ return;
+ }
+
/* do this stuff only when the dialog is first showing */
- if (!popup.mapped)
- popup_setup(&popup, TRUE, iconic_windows, all_desktops,
+ if (!popup.mapped) {
+ popup_setup(&popup, TRUE, iconic_windows, all_desktops,
dock_windows, desktop_windows);
+ /* this is fixed once the dialog is shown */
+ popup.mode = mode;
+ }
g_assert(popup.targets != NULL);
popup_render(&popup, c);
if (!popup.mapped) {
/* show the dialog */
- XMapWindow(ob_display, popup.bg);
- XFlush(ob_display);
+ XMapWindow(obt_display, popup.bg);
+ XFlush(obt_display);
popup.mapped = TRUE;
screen_hide_desktop_popup();
}
ignore_start = event_start_ignore_all_enters();
- XUnmapWindow(ob_display, popup.bg);
- XFlush(ob_display);
+ XUnmapWindow(obt_display, popup.bg);
+ XFlush(obt_display);
event_end_ignore_all_enters(ignore_start);
while(popup.targets) {
ObFocusCyclePopupTarget *t = popup.targets->data;
+ RrImageUnref(t->icon);
g_free(t->text);
- XDestroyWindow(ob_display, t->win);
+ XDestroyWindow(obt_display, t->iconwin);
+ XDestroyWindow(obt_display, t->textwin);
g_free(t);
popup.targets = g_list_delete_link(popup.targets, popup.targets);
}
popup.n_targets = 0;
popup.last_target = NULL;
-
- g_free(popup.hilite_rgba);
- popup.hilite_rgba = NULL;
}
void focus_cycle_popup_single_show(struct _ObClient *c,
}
text = popup_get_name(c);
- icon_popup_show(single_popup, text, client_icon(c, ICON_SIZE, ICON_SIZE));
+ icon_popup_show(single_popup, text, client_icon(c));
g_free(text);
screen_hide_desktop_popup();
}
#include <glib.h>
+typedef enum {
+ OB_FOCUS_CYCLE_POPUP_MODE_NONE,
+ OB_FOCUS_CYCLE_POPUP_MODE_ICONS,
+ OB_FOCUS_CYCLE_POPUP_MODE_LIST
+} ObFocusCyclePopupMode;
+
void focus_cycle_popup_startup(gboolean reconfig);
void focus_cycle_popup_shutdown(gboolean reconfig);
void focus_cycle_popup_show(struct _ObClient *c, gboolean iconic_windows,
gboolean all_desktops, gboolean dock_windows,
- gboolean desktop_windows);
+ gboolean desktop_windows,
+ ObFocusCyclePopupMode mode);
void focus_cycle_popup_hide();
void focus_cycle_popup_single_show(struct _ObClient *c,
#include "frame.h"
#include "client.h"
#include "openbox.h"
-#include "extensions.h"
-#include "prop.h"
#include "grab.h"
#include "config.h"
#include "framerender.h"
-#include "mainloop.h"
#include "focus_cycle.h"
#include "focus_cycle_indicator.h"
#include "moveresize.h"
#include "screen.h"
#include "render/theme.h"
+#include "obt/display.h"
+#include "obt/prop.h"
#define FRAME_EVENTMASK (EnterWindowMask | LeaveWindowMask | \
ButtonPressMask | ButtonReleaseMask | \
static Window createWindow(Window parent, Visual *visual,
gulong mask, XSetWindowAttributes *attrib)
{
- return XCreateWindow(ob_display, parent, 0, 0, 1, 1, 0,
+ return XCreateWindow(obt_display, parent, 0, 0, 1, 1, 0,
(visual ? 32 : RrDepth(ob_rr_inst)), InputOutput,
(visual ? visual : RrVisual(ob_rr_inst)),
mask, attrib);
if (RrDepth(ob_rr_inst) == 32)
return NULL;
- ret = XGetWindowAttributes(ob_display, c->window, &wattrib);
+ ret = XGetWindowAttributes(obt_display, c->window, &wattrib);
g_assert(ret != BadDrawable);
g_assert(ret != BadWindow);
mask |= CWColormap | CWBackPixel | CWBorderPixel;
/* create a colormap with the visual */
self->colormap = attrib.colormap =
- XCreateColormap(ob_display,
- RootWindow(ob_display, ob_screen),
+ XCreateColormap(obt_display, obt_root(ob_screen),
visual, AllocNone);
- attrib.background_pixel = BlackPixel(ob_display, ob_screen);
- attrib.border_pixel = BlackPixel(ob_display, ob_screen);
+ attrib.background_pixel = BlackPixel(obt_display, ob_screen);
+ attrib.border_pixel = BlackPixel(obt_display, ob_screen);
}
- self->window = createWindow(RootWindow(ob_display, ob_screen), visual,
+ self->window = createWindow(obt_root(ob_screen), visual,
mask, &attrib);
/* create the visible decor windows */
self->focused = FALSE;
/* the other stuff is shown based on decor settings */
- XMapWindow(ob_display, self->label);
- XMapWindow(ob_display, self->backback);
- XMapWindow(ob_display, self->backfront);
+ XMapWindow(obt_display, self->label);
+ XMapWindow(obt_display, self->backback);
+ XMapWindow(obt_display, self->backfront);
self->max_press = self->close_press = self->desk_press =
self->iconify_press = self->shade_press = FALSE;
static void set_theme_statics(ObFrame *self)
{
/* set colors/appearance/sizes for stuff that doesn't change */
- XResizeWindow(ob_display, self->max,
+ XResizeWindow(obt_display, self->max,
ob_rr_theme->button_size, ob_rr_theme->button_size);
- XResizeWindow(ob_display, self->iconify,
+ XResizeWindow(obt_display, self->iconify,
ob_rr_theme->button_size, ob_rr_theme->button_size);
- XResizeWindow(ob_display, self->icon,
+ XResizeWindow(obt_display, self->icon,
ob_rr_theme->button_size + 2, ob_rr_theme->button_size + 2);
- XResizeWindow(ob_display, self->close,
+ XResizeWindow(obt_display, self->close,
ob_rr_theme->button_size, ob_rr_theme->button_size);
- XResizeWindow(ob_display, self->desk,
+ XResizeWindow(obt_display, self->desk,
ob_rr_theme->button_size, ob_rr_theme->button_size);
- XResizeWindow(ob_display, self->shade,
+ XResizeWindow(obt_display, self->shade,
ob_rr_theme->button_size, ob_rr_theme->button_size);
- XResizeWindow(ob_display, self->tltresize,
+ XResizeWindow(obt_display, self->tltresize,
ob_rr_theme->grip_width, ob_rr_theme->paddingy + 1);
- XResizeWindow(ob_display, self->trtresize,
+ XResizeWindow(obt_display, self->trtresize,
ob_rr_theme->grip_width, ob_rr_theme->paddingy + 1);
- XResizeWindow(ob_display, self->tllresize,
+ XResizeWindow(obt_display, self->tllresize,
ob_rr_theme->paddingx + 1, ob_rr_theme->title_height);
- XResizeWindow(ob_display, self->trrresize,
+ XResizeWindow(obt_display, self->trrresize,
ob_rr_theme->paddingx + 1, ob_rr_theme->title_height);
}
{
free_theme_statics(self);
- XDestroyWindow(ob_display, self->window);
+ XDestroyWindow(obt_display, self->window);
if (self->colormap)
- XFreeColormap(ob_display, self->colormap);
+ XFreeColormap(obt_display, self->colormap);
g_free(self);
}
the client gets its MapNotify, i.e. to make sure the client is
_visible_ when it gets MapNotify. */
grab_server(TRUE);
- XMapWindow(ob_display, self->client->window);
- XMapWindow(ob_display, self->window);
+ XMapWindow(obt_display, self->client->window);
+ XMapWindow(obt_display, self->window);
grab_server(FALSE);
}
}
if (self->visible) {
self->visible = FALSE;
if (!frame_iconify_animating(self))
- XUnmapWindow(ob_display, self->window);
+ XUnmapWindow(obt_display, self->window);
/* we unmap the client itself so that we can get MapRequest
events, and because the ICCCM tells us to! */
- XUnmapWindow(ob_display, self->client->window);
+ XUnmapWindow(obt_display, self->client->window);
self->client->ignore_unmaps += 1;
}
}
if (!self->client->shaped) {
/* clear the shape on the frame window */
- XShapeCombineMask(ob_display, self->window, ShapeBounding,
+ XShapeCombineMask(obt_display, self->window, ShapeBounding,
self->size.left,
self->size.top,
None, ShapeSet);
} else {
/* make the frame's shape match the clients */
- XShapeCombineShape(ob_display, self->window, ShapeBounding,
+ XShapeCombineShape(obt_display, self->window, ShapeBounding,
self->size.left,
self->size.top,
self->client->window,
++num;
}
- XShapeCombineRectangles(ob_display, self->window,
+ XShapeCombineRectangles(obt_display, self->window,
ShapeBounding, 0, 0, xrect, num,
ShapeUnion, Unsorted);
}
ob_rr_theme->grip_width - self->size.bottom;
if (self->cbwidth_l) {
- XMoveResizeWindow(ob_display, self->innerleft,
+ XMoveResizeWindow(obt_display, self->innerleft,
self->size.left - self->cbwidth_l,
self->size.top,
self->cbwidth_l, self->client->area.height);
- XMapWindow(ob_display, self->innerleft);
+ XMapWindow(obt_display, self->innerleft);
} else
- XUnmapWindow(ob_display, self->innerleft);
+ XUnmapWindow(obt_display, self->innerleft);
if (self->cbwidth_l && innercornerheight > 0) {
- XMoveResizeWindow(ob_display, self->innerbll,
+ XMoveResizeWindow(obt_display, self->innerbll,
0,
self->client->area.height -
(ob_rr_theme->grip_width -
self->cbwidth_l,
ob_rr_theme->grip_width - self->size.bottom);
- XMapWindow(ob_display, self->innerbll);
+ XMapWindow(obt_display, self->innerbll);
} else
- XUnmapWindow(ob_display, self->innerbll);
+ XUnmapWindow(obt_display, self->innerbll);
if (self->cbwidth_r) {
- XMoveResizeWindow(ob_display, self->innerright,
+ XMoveResizeWindow(obt_display, self->innerright,
self->size.left + self->client->area.width,
self->size.top,
self->cbwidth_r, self->client->area.height);
- XMapWindow(ob_display, self->innerright);
+ XMapWindow(obt_display, self->innerright);
} else
- XUnmapWindow(ob_display, self->innerright);
+ XUnmapWindow(obt_display, self->innerright);
if (self->cbwidth_r && innercornerheight > 0) {
- XMoveResizeWindow(ob_display, self->innerbrr,
+ XMoveResizeWindow(obt_display, self->innerbrr,
0,
self->client->area.height -
(ob_rr_theme->grip_width -
self->cbwidth_r,
ob_rr_theme->grip_width - self->size.bottom);
- XMapWindow(ob_display, self->innerbrr);
+ XMapWindow(obt_display, self->innerbrr);
} else
- XUnmapWindow(ob_display, self->innerbrr);
+ XUnmapWindow(obt_display, self->innerbrr);
if (self->cbwidth_t) {
- XMoveResizeWindow(ob_display, self->innertop,
+ XMoveResizeWindow(obt_display, self->innertop,
self->size.left - self->cbwidth_l,
self->size.top - self->cbwidth_t,
self->client->area.width +
self->cbwidth_l + self->cbwidth_r,
self->cbwidth_t);
- XMapWindow(ob_display, self->innertop);
+ XMapWindow(obt_display, self->innertop);
} else
- XUnmapWindow(ob_display, self->innertop);
+ XUnmapWindow(obt_display, self->innertop);
if (self->cbwidth_b) {
- XMoveResizeWindow(ob_display, self->innerbottom,
+ XMoveResizeWindow(obt_display, self->innerbottom,
self->size.left - self->cbwidth_l,
self->size.top + self->client->area.height,
self->client->area.width +
self->cbwidth_l + self->cbwidth_r,
self->cbwidth_b);
- XMoveResizeWindow(ob_display, self->innerblb,
+ XMoveResizeWindow(obt_display, self->innerblb,
0, 0,
ob_rr_theme->grip_width + self->bwidth,
self->cbwidth_b);
- XMoveResizeWindow(ob_display, self->innerbrb,
+ XMoveResizeWindow(obt_display, self->innerbrb,
self->client->area.width +
self->cbwidth_l + self->cbwidth_r -
(ob_rr_theme->grip_width + self->bwidth),
ob_rr_theme->grip_width + self->bwidth,
self->cbwidth_b);
- XMapWindow(ob_display, self->innerbottom);
- XMapWindow(ob_display, self->innerblb);
- XMapWindow(ob_display, self->innerbrb);
+ XMapWindow(obt_display, self->innerbottom);
+ XMapWindow(obt_display, self->innerblb);
+ XMapWindow(obt_display, self->innerbrb);
} else {
- XUnmapWindow(ob_display, self->innerbottom);
- XUnmapWindow(ob_display, self->innerblb);
- XUnmapWindow(ob_display, self->innerbrb);
+ XUnmapWindow(obt_display, self->innerbottom);
+ XUnmapWindow(obt_display, self->innerblb);
+ XUnmapWindow(obt_display, self->innerbrb);
}
if (self->bwidth) {
/* height of titleleft and titleright */
titlesides = (!self->max_horz ? ob_rr_theme->grip_width : 0);
- XMoveResizeWindow(ob_display, self->titletop,
+ XMoveResizeWindow(obt_display, self->titletop,
ob_rr_theme->grip_width + self->bwidth, 0,
/* width + bwidth*2 - bwidth*2 - grips*2 */
self->width - ob_rr_theme->grip_width * 2,
self->bwidth);
- XMoveResizeWindow(ob_display, self->titletopleft,
+ XMoveResizeWindow(obt_display, self->titletopleft,
0, 0,
ob_rr_theme->grip_width + self->bwidth,
self->bwidth);
- XMoveResizeWindow(ob_display, self->titletopright,
+ XMoveResizeWindow(obt_display, self->titletopright,
self->client->area.width +
self->size.left + self->size.right -
ob_rr_theme->grip_width - self->bwidth,
self->bwidth);
if (titlesides > 0) {
- XMoveResizeWindow(ob_display, self->titleleft,
+ XMoveResizeWindow(obt_display, self->titleleft,
0, self->bwidth,
self->bwidth,
titlesides);
- XMoveResizeWindow(ob_display, self->titleright,
+ XMoveResizeWindow(obt_display, self->titleright,
self->client->area.width +
self->size.left + self->size.right -
self->bwidth,
self->bwidth,
titlesides);
- XMapWindow(ob_display, self->titleleft);
- XMapWindow(ob_display, self->titleright);
+ XMapWindow(obt_display, self->titleleft);
+ XMapWindow(obt_display, self->titleright);
} else {
- XUnmapWindow(ob_display, self->titleleft);
- XUnmapWindow(ob_display, self->titleright);
+ XUnmapWindow(obt_display, self->titleleft);
+ XUnmapWindow(obt_display, self->titleright);
}
- XMapWindow(ob_display, self->titletop);
- XMapWindow(ob_display, self->titletopleft);
- XMapWindow(ob_display, self->titletopright);
+ XMapWindow(obt_display, self->titletop);
+ XMapWindow(obt_display, self->titletopleft);
+ XMapWindow(obt_display, self->titletopright);
if (self->decorations & OB_FRAME_DECOR_TITLEBAR) {
- XMoveResizeWindow(ob_display, self->titlebottom,
+ XMoveResizeWindow(obt_display, self->titlebottom,
(self->max_horz ? 0 : self->bwidth),
ob_rr_theme->title_height + self->bwidth,
self->width,
self->bwidth);
- XMapWindow(ob_display, self->titlebottom);
+ XMapWindow(obt_display, self->titlebottom);
} else
- XUnmapWindow(ob_display, self->titlebottom);
+ XUnmapWindow(obt_display, self->titlebottom);
} else {
- XUnmapWindow(ob_display, self->titlebottom);
+ XUnmapWindow(obt_display, self->titlebottom);
- XUnmapWindow(ob_display, self->titletop);
- XUnmapWindow(ob_display, self->titletopleft);
- XUnmapWindow(ob_display, self->titletopright);
- XUnmapWindow(ob_display, self->titleleft);
- XUnmapWindow(ob_display, self->titleright);
+ XUnmapWindow(obt_display, self->titletop);
+ XUnmapWindow(obt_display, self->titletopleft);
+ XUnmapWindow(obt_display, self->titletopright);
+ XUnmapWindow(obt_display, self->titleleft);
+ XUnmapWindow(obt_display, self->titleright);
}
if (self->decorations & OB_FRAME_DECOR_TITLEBAR) {
- XMoveResizeWindow(ob_display, self->title,
+ XMoveResizeWindow(obt_display, self->title,
(self->max_horz ? 0 : self->bwidth),
self->bwidth,
self->width, ob_rr_theme->title_height);
- XMapWindow(ob_display, self->title);
+ XMapWindow(obt_display, self->title);
if (self->decorations & OB_FRAME_DECOR_GRIPS) {
- XMoveResizeWindow(ob_display, self->topresize,
+ XMoveResizeWindow(obt_display, self->topresize,
ob_rr_theme->grip_width,
0,
self->width - ob_rr_theme->grip_width *2,
ob_rr_theme->paddingy + 1);
- XMoveWindow(ob_display, self->tltresize, 0, 0);
- XMoveWindow(ob_display, self->tllresize, 0, 0);
- XMoveWindow(ob_display, self->trtresize,
+ XMoveWindow(obt_display, self->tltresize, 0, 0);
+ XMoveWindow(obt_display, self->tllresize, 0, 0);
+ XMoveWindow(obt_display, self->trtresize,
self->width - ob_rr_theme->grip_width, 0);
- XMoveWindow(ob_display, self->trrresize,
+ XMoveWindow(obt_display, self->trrresize,
self->width - ob_rr_theme->paddingx - 1, 0);
- XMapWindow(ob_display, self->topresize);
- XMapWindow(ob_display, self->tltresize);
- XMapWindow(ob_display, self->tllresize);
- XMapWindow(ob_display, self->trtresize);
- XMapWindow(ob_display, self->trrresize);
+ XMapWindow(obt_display, self->topresize);
+ XMapWindow(obt_display, self->tltresize);
+ XMapWindow(obt_display, self->tllresize);
+ XMapWindow(obt_display, self->trtresize);
+ XMapWindow(obt_display, self->trrresize);
} else {
- XUnmapWindow(ob_display, self->topresize);
- XUnmapWindow(ob_display, self->tltresize);
- XUnmapWindow(ob_display, self->tllresize);
- XUnmapWindow(ob_display, self->trtresize);
- XUnmapWindow(ob_display, self->trrresize);
+ XUnmapWindow(obt_display, self->topresize);
+ XUnmapWindow(obt_display, self->tltresize);
+ XUnmapWindow(obt_display, self->tllresize);
+ XUnmapWindow(obt_display, self->trtresize);
+ XUnmapWindow(obt_display, self->trrresize);
}
} else
- XUnmapWindow(ob_display, self->title);
+ XUnmapWindow(obt_display, self->title);
}
if ((self->decorations & OB_FRAME_DECOR_TITLEBAR))
gint sidebwidth = self->max_horz ? 0 : self->bwidth;
if (self->bwidth && self->size.bottom) {
- XMoveResizeWindow(ob_display, self->handlebottom,
+ XMoveResizeWindow(obt_display, self->handlebottom,
ob_rr_theme->grip_width +
self->bwidth + sidebwidth,
self->size.top + self->client->area.height +
if (sidebwidth) {
- XMoveResizeWindow(ob_display, self->lgripleft,
+ XMoveResizeWindow(obt_display, self->lgripleft,
0,
self->size.top +
self->client->area.height +
(!self->max_horz ?
ob_rr_theme->grip_width :
self->size.bottom - self->cbwidth_b));
- XMoveResizeWindow(ob_display, self->rgripright,
+ XMoveResizeWindow(obt_display, self->rgripright,
self->size.left +
self->client->area.width +
self->size.right - self->bwidth,
ob_rr_theme->grip_width :
self->size.bottom - self->cbwidth_b));
- XMapWindow(ob_display, self->lgripleft);
- XMapWindow(ob_display, self->rgripright);
+ XMapWindow(obt_display, self->lgripleft);
+ XMapWindow(obt_display, self->rgripright);
} else {
- XUnmapWindow(ob_display, self->lgripleft);
- XUnmapWindow(ob_display, self->rgripright);
+ XUnmapWindow(obt_display, self->lgripleft);
+ XUnmapWindow(obt_display, self->rgripright);
}
- XMoveResizeWindow(ob_display, self->lgripbottom,
+ XMoveResizeWindow(obt_display, self->lgripbottom,
sidebwidth,
self->size.top + self->client->area.height +
self->size.bottom - self->bwidth,
ob_rr_theme->grip_width + self->bwidth,
self->bwidth);
- XMoveResizeWindow(ob_display, self->rgripbottom,
+ XMoveResizeWindow(obt_display, self->rgripbottom,
self->size.left + self->client->area.width +
self->size.right - self->bwidth - sidebwidth-
ob_rr_theme->grip_width,
ob_rr_theme->grip_width + self->bwidth,
self->bwidth);
- XMapWindow(ob_display, self->handlebottom);
- XMapWindow(ob_display, self->lgripbottom);
- XMapWindow(ob_display, self->rgripbottom);
+ XMapWindow(obt_display, self->handlebottom);
+ XMapWindow(obt_display, self->lgripbottom);
+ XMapWindow(obt_display, self->rgripbottom);
if (self->decorations & OB_FRAME_DECOR_HANDLE &&
ob_rr_theme->handle_height > 0)
{
- XMoveResizeWindow(ob_display, self->handletop,
+ XMoveResizeWindow(obt_display, self->handletop,
ob_rr_theme->grip_width +
self->bwidth + sidebwidth,
FRAME_HANDLE_Y(self),
self->width - (ob_rr_theme->grip_width +
sidebwidth) * 2,
self->bwidth);
- XMapWindow(ob_display, self->handletop);
+ XMapWindow(obt_display, self->handletop);
if (self->decorations & OB_FRAME_DECOR_GRIPS) {
- XMoveResizeWindow(ob_display, self->handleleft,
+ XMoveResizeWindow(obt_display, self->handleleft,
ob_rr_theme->grip_width,
0,
self->bwidth,
ob_rr_theme->handle_height);
- XMoveResizeWindow(ob_display, self->handleright,
+ XMoveResizeWindow(obt_display, self->handleright,
self->width -
ob_rr_theme->grip_width -
self->bwidth,
self->bwidth,
ob_rr_theme->handle_height);
- XMoveResizeWindow(ob_display, self->lgriptop,
+ XMoveResizeWindow(obt_display, self->lgriptop,
sidebwidth,
FRAME_HANDLE_Y(self),
ob_rr_theme->grip_width +
self->bwidth,
self->bwidth);
- XMoveResizeWindow(ob_display, self->rgriptop,
+ XMoveResizeWindow(obt_display, self->rgriptop,
self->size.left +
self->client->area.width +
self->size.right - self->bwidth -
self->bwidth,
self->bwidth);
- XMapWindow(ob_display, self->handleleft);
- XMapWindow(ob_display, self->handleright);
- XMapWindow(ob_display, self->lgriptop);
- XMapWindow(ob_display, self->rgriptop);
+ XMapWindow(obt_display, self->handleleft);
+ XMapWindow(obt_display, self->handleright);
+ XMapWindow(obt_display, self->lgriptop);
+ XMapWindow(obt_display, self->rgriptop);
} else {
- XUnmapWindow(ob_display, self->handleleft);
- XUnmapWindow(ob_display, self->handleright);
- XUnmapWindow(ob_display, self->lgriptop);
- XUnmapWindow(ob_display, self->rgriptop);
+ XUnmapWindow(obt_display, self->handleleft);
+ XUnmapWindow(obt_display, self->handleright);
+ XUnmapWindow(obt_display, self->lgriptop);
+ XUnmapWindow(obt_display, self->rgriptop);
}
} else {
- XUnmapWindow(ob_display, self->handleleft);
- XUnmapWindow(ob_display, self->handleright);
- XUnmapWindow(ob_display, self->lgriptop);
- XUnmapWindow(ob_display, self->rgriptop);
+ XUnmapWindow(obt_display, self->handleleft);
+ XUnmapWindow(obt_display, self->handleright);
+ XUnmapWindow(obt_display, self->lgriptop);
+ XUnmapWindow(obt_display, self->rgriptop);
- XUnmapWindow(ob_display, self->handletop);
+ XUnmapWindow(obt_display, self->handletop);
}
} else {
- XUnmapWindow(ob_display, self->handleleft);
- XUnmapWindow(ob_display, self->handleright);
- XUnmapWindow(ob_display, self->lgriptop);
- XUnmapWindow(ob_display, self->rgriptop);
-
- XUnmapWindow(ob_display, self->handletop);
-
- XUnmapWindow(ob_display, self->handlebottom);
- XUnmapWindow(ob_display, self->lgripleft);
- XUnmapWindow(ob_display, self->rgripright);
- XUnmapWindow(ob_display, self->lgripbottom);
- XUnmapWindow(ob_display, self->rgripbottom);
+ XUnmapWindow(obt_display, self->handleleft);
+ XUnmapWindow(obt_display, self->handleright);
+ XUnmapWindow(obt_display, self->lgriptop);
+ XUnmapWindow(obt_display, self->rgriptop);
+
+ XUnmapWindow(obt_display, self->handletop);
+
+ XUnmapWindow(obt_display, self->handlebottom);
+ XUnmapWindow(obt_display, self->lgripleft);
+ XUnmapWindow(obt_display, self->rgripright);
+ XUnmapWindow(obt_display, self->lgripbottom);
+ XUnmapWindow(obt_display, self->rgripbottom);
}
if (self->decorations & OB_FRAME_DECOR_HANDLE &&
ob_rr_theme->handle_height > 0)
{
- XMoveResizeWindow(ob_display, self->handle,
+ XMoveResizeWindow(obt_display, self->handle,
sidebwidth,
FRAME_HANDLE_Y(self) + self->bwidth,
self->width, ob_rr_theme->handle_height);
- XMapWindow(ob_display, self->handle);
+ XMapWindow(obt_display, self->handle);
if (self->decorations & OB_FRAME_DECOR_GRIPS) {
- XMoveResizeWindow(ob_display, self->lgrip,
+ XMoveResizeWindow(obt_display, self->lgrip,
0, 0,
ob_rr_theme->grip_width,
ob_rr_theme->handle_height);
- XMoveResizeWindow(ob_display, self->rgrip,
+ XMoveResizeWindow(obt_display, self->rgrip,
self->width - ob_rr_theme->grip_width,
0,
ob_rr_theme->grip_width,
ob_rr_theme->handle_height);
- XMapWindow(ob_display, self->lgrip);
- XMapWindow(ob_display, self->rgrip);
+ XMapWindow(obt_display, self->lgrip);
+ XMapWindow(obt_display, self->rgrip);
} else {
- XUnmapWindow(ob_display, self->lgrip);
- XUnmapWindow(ob_display, self->rgrip);
+ XUnmapWindow(obt_display, self->lgrip);
+ XUnmapWindow(obt_display, self->rgrip);
}
} else {
- XUnmapWindow(ob_display, self->lgrip);
- XUnmapWindow(ob_display, self->rgrip);
+ XUnmapWindow(obt_display, self->lgrip);
+ XUnmapWindow(obt_display, self->rgrip);
- XUnmapWindow(ob_display, self->handle);
+ XUnmapWindow(obt_display, self->handle);
}
if (self->bwidth && !self->max_horz &&
(self->client->area.height + self->size.top +
self->size.bottom) > ob_rr_theme->grip_width * 2)
{
- XMoveResizeWindow(ob_display, self->left,
+ XMoveResizeWindow(obt_display, self->left,
0,
self->bwidth + ob_rr_theme->grip_width,
self->bwidth,
self->size.top + self->size.bottom -
ob_rr_theme->grip_width * 2);
- XMapWindow(ob_display, self->left);
+ XMapWindow(obt_display, self->left);
} else
- XUnmapWindow(ob_display, self->left);
+ XUnmapWindow(obt_display, self->left);
if (self->bwidth && !self->max_horz &&
(self->client->area.height + self->size.top +
self->size.bottom) > ob_rr_theme->grip_width * 2)
{
- XMoveResizeWindow(ob_display, self->right,
+ XMoveResizeWindow(obt_display, self->right,
self->client->area.width + self->cbwidth_l +
self->cbwidth_r + self->bwidth,
self->bwidth + ob_rr_theme->grip_width,
self->size.top + self->size.bottom -
ob_rr_theme->grip_width * 2);
- XMapWindow(ob_display, self->right);
+ XMapWindow(obt_display, self->right);
} else
- XUnmapWindow(ob_display, self->right);
+ XUnmapWindow(obt_display, self->right);
- XMoveResizeWindow(ob_display, self->backback,
+ XMoveResizeWindow(obt_display, self->backback,
self->size.left, self->size.top,
self->client->area.width,
self->client->area.height);
but don't do this during an iconify animation. it will be
reflected afterwards.
*/
- XMoveResizeWindow(ob_display, self->window,
+ XMoveResizeWindow(obt_display, self->window,
self->area.x,
self->area.y,
self->area.width,
also this correctly positions the client when it maps.
this also needs to be run when the frame's decorations sizes change!
*/
- XMoveWindow(ob_display, self->client->window,
+ XMoveWindow(obt_display, self->client->window,
self->size.left, self->size.top);
if (resized) {
vals[1] = self->size.right;
vals[2] = self->size.top;
vals[3] = self->size.bottom;
- PROP_SETA32(self->client->window, net_frame_extents,
- cardinal, vals, 4);
- PROP_SETA32(self->client->window, kde_net_wm_frame_strut,
- cardinal, vals, 4);
+ OBT_PROP_SETA32(self->client->window, NET_FRAME_EXTENTS,
+ CARDINAL, vals, 4);
+ OBT_PROP_SETA32(self->client->window, KDE_NET_WM_FRAME_STRUT,
+ CARDINAL, vals, 4);
}
/* if this occurs while we are focus cycling, the indicator needs to
focus_cycle_draw_indicator(self->client);
}
if (resized && (self->decorations & OB_FRAME_DECOR_TITLEBAR))
- XResizeWindow(ob_display, self->label, self->label_width,
+ XResizeWindow(obt_display, self->label, self->label_width,
ob_rr_theme->label_height);
}
/* these ones turn off when max vert, and some when shaded */
a.cursor = ob_cursor(r && topbot && !sh ?
OB_CURSOR_NORTH : OB_CURSOR_NONE);
- XChangeWindowAttributes(ob_display, self->topresize, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->titletop, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->topresize, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->titletop, CWCursor, &a);
a.cursor = ob_cursor(r && topbot ? OB_CURSOR_SOUTH : OB_CURSOR_NONE);
- XChangeWindowAttributes(ob_display, self->handle, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->handletop, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->handlebottom, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->innerbottom, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->handle, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->handletop, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->handlebottom, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->innerbottom, CWCursor, &a);
/* these ones change when shaded */
a.cursor = ob_cursor(r ? (sh ? OB_CURSOR_WEST : OB_CURSOR_NORTHWEST) :
OB_CURSOR_NONE);
- XChangeWindowAttributes(ob_display, self->titleleft, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->tltresize, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->tllresize, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->titletopleft, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->titleleft, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->tltresize, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->tllresize, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->titletopleft, CWCursor, &a);
a.cursor = ob_cursor(r ? (sh ? OB_CURSOR_EAST : OB_CURSOR_NORTHEAST) :
OB_CURSOR_NONE);
- XChangeWindowAttributes(ob_display, self->titleright, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->trtresize, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->trrresize, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->titletopright, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->titleright, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->trtresize, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->trrresize, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->titletopright, CWCursor,&a);
/* these ones are pretty static */
a.cursor = ob_cursor(r ? OB_CURSOR_WEST : OB_CURSOR_NONE);
- XChangeWindowAttributes(ob_display, self->left, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->innerleft, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->left, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->innerleft, CWCursor, &a);
a.cursor = ob_cursor(r ? OB_CURSOR_EAST : OB_CURSOR_NONE);
- XChangeWindowAttributes(ob_display, self->right, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->innerright, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->right, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->innerright, CWCursor, &a);
a.cursor = ob_cursor(r ? OB_CURSOR_SOUTHWEST : OB_CURSOR_NONE);
- XChangeWindowAttributes(ob_display, self->lgrip, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->handleleft, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->lgripleft, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->lgriptop, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->lgripbottom, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->innerbll, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->innerblb, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->lgrip, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->handleleft, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->lgripleft, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->lgriptop, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->lgripbottom, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->innerbll, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->innerblb, CWCursor, &a);
a.cursor = ob_cursor(r ? OB_CURSOR_SOUTHEAST : OB_CURSOR_NONE);
- XChangeWindowAttributes(ob_display, self->rgrip, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->handleright, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->rgripright, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->rgriptop, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->rgripbottom, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->innerbrr, CWCursor, &a);
- XChangeWindowAttributes(ob_display, self->innerbrb, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->rgrip, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->handleright, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->rgripright, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->rgriptop, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->rgripbottom, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->innerbrr, CWCursor, &a);
+ XChangeWindowAttributes(obt_display, self->innerbrb, CWCursor, &a);
}
}
void frame_adjust_client_area(ObFrame *self)
{
/* adjust the window which is there to prevent flashing on unmap */
- XMoveResizeWindow(ob_display, self->backfront, 0, 0,
+ XMoveResizeWindow(obt_display, self->backfront, 0, 0,
self->client->area.width,
self->client->area.height);
}
self->focused = hilite;
self->need_render = TRUE;
framerender_frame(self);
- XFlush(ob_display);
+ XFlush(obt_display);
}
void frame_adjust_title(ObFrame *self)
*/
/* reparent the client to the frame */
- XReparentWindow(ob_display, self->client->window, self->window, 0, 0);
+ XReparentWindow(obt_display, self->client->window, self->window, 0, 0);
/*
When reparenting the client window, it is usually not mapped yet, since
/* select the event mask on the client's parent (to receive config/map
req's) the ButtonPress is to catch clicks on the client border */
- XSelectInput(ob_display, self->window, FRAME_EVENTMASK);
+ XSelectInput(obt_display, self->window, FRAME_EVENTMASK);
/* set all the windows for the frame in the window_map */
- g_hash_table_insert(window_map, &self->window, self->client);
- g_hash_table_insert(window_map, &self->backback, self->client);
- g_hash_table_insert(window_map, &self->backfront, self->client);
- g_hash_table_insert(window_map, &self->innerleft, self->client);
- g_hash_table_insert(window_map, &self->innertop, self->client);
- g_hash_table_insert(window_map, &self->innerright, self->client);
- g_hash_table_insert(window_map, &self->innerbottom, self->client);
- g_hash_table_insert(window_map, &self->innerblb, self->client);
- g_hash_table_insert(window_map, &self->innerbll, self->client);
- g_hash_table_insert(window_map, &self->innerbrb, self->client);
- g_hash_table_insert(window_map, &self->innerbrr, self->client);
- g_hash_table_insert(window_map, &self->title, self->client);
- g_hash_table_insert(window_map, &self->label, self->client);
- g_hash_table_insert(window_map, &self->max, self->client);
- g_hash_table_insert(window_map, &self->close, self->client);
- g_hash_table_insert(window_map, &self->desk, self->client);
- g_hash_table_insert(window_map, &self->shade, self->client);
- g_hash_table_insert(window_map, &self->icon, self->client);
- g_hash_table_insert(window_map, &self->iconify, self->client);
- g_hash_table_insert(window_map, &self->handle, self->client);
- g_hash_table_insert(window_map, &self->lgrip, self->client);
- g_hash_table_insert(window_map, &self->rgrip, self->client);
- g_hash_table_insert(window_map, &self->topresize, self->client);
- g_hash_table_insert(window_map, &self->tltresize, self->client);
- g_hash_table_insert(window_map, &self->tllresize, self->client);
- g_hash_table_insert(window_map, &self->trtresize, self->client);
- g_hash_table_insert(window_map, &self->trrresize, self->client);
- g_hash_table_insert(window_map, &self->left, self->client);
- g_hash_table_insert(window_map, &self->right, self->client);
- g_hash_table_insert(window_map, &self->titleleft, self->client);
- g_hash_table_insert(window_map, &self->titletop, self->client);
- g_hash_table_insert(window_map, &self->titletopleft, self->client);
- g_hash_table_insert(window_map, &self->titletopright, self->client);
- g_hash_table_insert(window_map, &self->titleright, self->client);
- g_hash_table_insert(window_map, &self->titlebottom, self->client);
- g_hash_table_insert(window_map, &self->handleleft, self->client);
- g_hash_table_insert(window_map, &self->handletop, self->client);
- g_hash_table_insert(window_map, &self->handleright, self->client);
- g_hash_table_insert(window_map, &self->handlebottom, self->client);
- g_hash_table_insert(window_map, &self->lgripleft, self->client);
- g_hash_table_insert(window_map, &self->lgriptop, self->client);
- g_hash_table_insert(window_map, &self->lgripbottom, self->client);
- g_hash_table_insert(window_map, &self->rgripright, self->client);
- g_hash_table_insert(window_map, &self->rgriptop, self->client);
- g_hash_table_insert(window_map, &self->rgripbottom, self->client);
+ window_add(&self->window, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->backback, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->backfront, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->innerleft, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->innertop, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->innerright, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->innerbottom, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->innerblb, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->innerbll, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->innerbrb, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->innerbrr, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->title, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->label, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->max, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->close, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->desk, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->shade, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->icon, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->iconify, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->handle, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->lgrip, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->rgrip, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->topresize, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->tltresize, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->tllresize, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->trtresize, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->trrresize, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->left, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->right, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->titleleft, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->titletop, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->titletopleft, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->titletopright, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->titleright, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->titlebottom, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->handleleft, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->handletop, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->handleright, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->handlebottom, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->lgripleft, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->lgriptop, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->lgripbottom, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->rgripright, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->rgriptop, CLIENT_AS_WINDOW(self->client));
+ window_add(&self->rgripbottom, CLIENT_AS_WINDOW(self->client));
}
void frame_release_client(ObFrame *self)
gboolean reparent = TRUE;
/* if there was any animation going on, kill it */
- ob_main_loop_timeout_remove_data(ob_main_loop, frame_animate_iconify,
- self, FALSE);
+ obt_main_loop_timeout_remove_data(ob_main_loop, frame_animate_iconify,
+ self, FALSE);
/* check if the app has already reparented its window away */
- while (XCheckTypedWindowEvent(ob_display, self->client->window,
+ while (XCheckTypedWindowEvent(obt_display, self->client->window,
ReparentNotify, &ev))
{
/* This check makes sure we don't catch our own reparent action to
*/
if (ev.xreparent.parent != self->window) {
reparent = FALSE;
- XPutBackEvent(ob_display, &ev);
+ XPutBackEvent(obt_display, &ev);
break;
}
}
if (reparent) {
/* according to the ICCCM - if the client doesn't reparent itself,
then we will reparent the window to root for them */
- XReparentWindow(ob_display, self->client->window,
- RootWindow(ob_display, ob_screen),
- self->client->area.x,
- self->client->area.y);
+ XReparentWindow(obt_display, self->client->window, obt_root(ob_screen),
+ self->client->area.x, self->client->area.y);
}
/* remove all the windows for the frame from the window_map */
- g_hash_table_remove(window_map, &self->window);
- g_hash_table_remove(window_map, &self->backback);
- g_hash_table_remove(window_map, &self->backfront);
- g_hash_table_remove(window_map, &self->innerleft);
- g_hash_table_remove(window_map, &self->innertop);
- g_hash_table_remove(window_map, &self->innerright);
- g_hash_table_remove(window_map, &self->innerbottom);
- g_hash_table_remove(window_map, &self->innerblb);
- g_hash_table_remove(window_map, &self->innerbll);
- g_hash_table_remove(window_map, &self->innerbrb);
- g_hash_table_remove(window_map, &self->innerbrr);
- g_hash_table_remove(window_map, &self->title);
- g_hash_table_remove(window_map, &self->label);
- g_hash_table_remove(window_map, &self->max);
- g_hash_table_remove(window_map, &self->close);
- g_hash_table_remove(window_map, &self->desk);
- g_hash_table_remove(window_map, &self->shade);
- g_hash_table_remove(window_map, &self->icon);
- g_hash_table_remove(window_map, &self->iconify);
- g_hash_table_remove(window_map, &self->handle);
- g_hash_table_remove(window_map, &self->lgrip);
- g_hash_table_remove(window_map, &self->rgrip);
- g_hash_table_remove(window_map, &self->topresize);
- g_hash_table_remove(window_map, &self->tltresize);
- g_hash_table_remove(window_map, &self->tllresize);
- g_hash_table_remove(window_map, &self->trtresize);
- g_hash_table_remove(window_map, &self->trrresize);
- g_hash_table_remove(window_map, &self->left);
- g_hash_table_remove(window_map, &self->right);
- g_hash_table_remove(window_map, &self->titleleft);
- g_hash_table_remove(window_map, &self->titletop);
- g_hash_table_remove(window_map, &self->titletopleft);
- g_hash_table_remove(window_map, &self->titletopright);
- g_hash_table_remove(window_map, &self->titleright);
- g_hash_table_remove(window_map, &self->titlebottom);
- g_hash_table_remove(window_map, &self->handleleft);
- g_hash_table_remove(window_map, &self->handletop);
- g_hash_table_remove(window_map, &self->handleright);
- g_hash_table_remove(window_map, &self->handlebottom);
- g_hash_table_remove(window_map, &self->lgripleft);
- g_hash_table_remove(window_map, &self->lgriptop);
- g_hash_table_remove(window_map, &self->lgripbottom);
- g_hash_table_remove(window_map, &self->rgripright);
- g_hash_table_remove(window_map, &self->rgriptop);
- g_hash_table_remove(window_map, &self->rgripbottom);
-
- ob_main_loop_timeout_remove_data(ob_main_loop, flash_timeout, self, TRUE);
+ window_remove(self->window);
+ window_remove(self->backback);
+ window_remove(self->backfront);
+ window_remove(self->innerleft);
+ window_remove(self->innertop);
+ window_remove(self->innerright);
+ window_remove(self->innerbottom);
+ window_remove(self->innerblb);
+ window_remove(self->innerbll);
+ window_remove(self->innerbrb);
+ window_remove(self->innerbrr);
+ window_remove(self->title);
+ window_remove(self->label);
+ window_remove(self->max);
+ window_remove(self->close);
+ window_remove(self->desk);
+ window_remove(self->shade);
+ window_remove(self->icon);
+ window_remove(self->iconify);
+ window_remove(self->handle);
+ window_remove(self->lgrip);
+ window_remove(self->rgrip);
+ window_remove(self->topresize);
+ window_remove(self->tltresize);
+ window_remove(self->tllresize);
+ window_remove(self->trtresize);
+ window_remove(self->trrresize);
+ window_remove(self->left);
+ window_remove(self->right);
+ window_remove(self->titleleft);
+ window_remove(self->titletop);
+ window_remove(self->titletopleft);
+ window_remove(self->titletopright);
+ window_remove(self->titleright);
+ window_remove(self->titlebottom);
+ window_remove(self->handleleft);
+ window_remove(self->handletop);
+ window_remove(self->handleright);
+ window_remove(self->handlebottom);
+ window_remove(self->lgripleft);
+ window_remove(self->lgriptop);
+ window_remove(self->lgripbottom);
+ window_remove(self->rgripright);
+ window_remove(self->rgriptop);
+ window_remove(self->rgripbottom);
+
+ obt_main_loop_timeout_remove_data(ob_main_loop, flash_timeout, self, TRUE);
}
/* is there anything present between us and the label? */
/* position and map the elements */
if (self->icon_on) {
- XMapWindow(ob_display, self->icon);
- XMoveWindow(ob_display, self->icon, self->icon_x,
+ XMapWindow(obt_display, self->icon);
+ XMoveWindow(obt_display, self->icon, self->icon_x,
ob_rr_theme->paddingy);
} else
- XUnmapWindow(ob_display, self->icon);
+ XUnmapWindow(obt_display, self->icon);
if (self->desk_on) {
- XMapWindow(ob_display, self->desk);
- XMoveWindow(ob_display, self->desk, self->desk_x,
+ XMapWindow(obt_display, self->desk);
+ XMoveWindow(obt_display, self->desk, self->desk_x,
ob_rr_theme->paddingy + 1);
} else
- XUnmapWindow(ob_display, self->desk);
+ XUnmapWindow(obt_display, self->desk);
if (self->shade_on) {
- XMapWindow(ob_display, self->shade);
- XMoveWindow(ob_display, self->shade, self->shade_x,
+ XMapWindow(obt_display, self->shade);
+ XMoveWindow(obt_display, self->shade, self->shade_x,
ob_rr_theme->paddingy + 1);
} else
- XUnmapWindow(ob_display, self->shade);
+ XUnmapWindow(obt_display, self->shade);
if (self->iconify_on) {
- XMapWindow(ob_display, self->iconify);
- XMoveWindow(ob_display, self->iconify, self->iconify_x,
+ XMapWindow(obt_display, self->iconify);
+ XMoveWindow(obt_display, self->iconify, self->iconify_x,
ob_rr_theme->paddingy + 1);
} else
- XUnmapWindow(ob_display, self->iconify);
+ XUnmapWindow(obt_display, self->iconify);
if (self->max_on) {
- XMapWindow(ob_display, self->max);
- XMoveWindow(ob_display, self->max, self->max_x,
+ XMapWindow(obt_display, self->max);
+ XMoveWindow(obt_display, self->max, self->max_x,
ob_rr_theme->paddingy + 1);
} else
- XUnmapWindow(ob_display, self->max);
+ XUnmapWindow(obt_display, self->max);
if (self->close_on) {
- XMapWindow(ob_display, self->close);
- XMoveWindow(ob_display, self->close, self->close_x,
+ XMapWindow(obt_display, self->close);
+ XMoveWindow(obt_display, self->close, self->close_x,
ob_rr_theme->paddingy + 1);
} else
- XUnmapWindow(ob_display, self->close);
+ XUnmapWindow(obt_display, self->close);
if (self->label_on) {
self->label_width = MAX(1, self->label_width); /* no lower than 1 */
- XMapWindow(ob_display, self->label);
- XMoveWindow(ob_display, self->label, self->label_x,
+ XMapWindow(obt_display, self->label);
+ XMoveWindow(obt_display, self->label, self->label_x,
ob_rr_theme->paddingy);
} else
- XUnmapWindow(ob_display, self->label);
+ XUnmapWindow(obt_display, self->label);
}
ObFrameContext frame_context_from_string(const gchar *name)
if (moveresize_in_progress)
return OB_FRAME_CONTEXT_MOVE_RESIZE;
- if (win == RootWindow(ob_display, ob_screen))
+ if (win == obt_root(ob_screen))
return OB_FRAME_CONTEXT_ROOT ;
if (client == NULL) return OB_FRAME_CONTEXT_NONE;
if (win == client->window) {
self->flash_on = self->focused;
if (!self->flashing)
- ob_main_loop_timeout_add(ob_main_loop,
- G_USEC_PER_SEC * 0.6,
- flash_timeout,
- self,
- g_direct_equal,
- flash_done);
+ obt_main_loop_timeout_add(ob_main_loop,
+ G_USEC_PER_SEC * 0.6,
+ flash_timeout,
+ self,
+ g_direct_equal,
+ flash_done);
g_get_current_time(&self->flash_end);
g_time_val_add(&self->flash_end, G_USEC_PER_SEC * 5);
if (time == 0)
frame_end_iconify_animation(self);
else {
- XMoveResizeWindow(ob_display, self->window, x, y, w, h);
- XFlush(ob_display);
+ XMoveResizeWindow(obt_display, self->window, x, y, w, h);
+ XFlush(obt_display);
}
return time > 0; /* repeat until we're out of time */
if (self->iconify_animation_going == 0) return;
if (!self->visible)
- XUnmapWindow(ob_display, self->window);
+ XUnmapWindow(obt_display, self->window);
else {
/* Send a ConfigureNotify when the animation is done, this fixes
KDE's pager showing the window in the wrong place. since the
/* we're not animating any more ! */
self->iconify_animation_going = 0;
- XMoveResizeWindow(ob_display, self->window,
+ XMoveResizeWindow(obt_display, self->window,
self->area.x, self->area.y,
self->area.width, self->area.height);
/* we delay re-rendering until after we're done animating */
framerender_frame(self);
- XFlush(ob_display);
+ XFlush(obt_display);
}
void frame_begin_iconify_animation(ObFrame *self, gboolean iconifying)
}
if (new_anim) {
- ob_main_loop_timeout_remove_data(ob_main_loop, frame_animate_iconify,
- self, FALSE);
- ob_main_loop_timeout_add(ob_main_loop,
- FRAME_ANIMATE_ICONIFY_STEP_TIME,
- frame_animate_iconify, self,
- g_direct_equal, NULL);
+ obt_main_loop_timeout_remove_data(ob_main_loop, frame_animate_iconify,
+ self, FALSE);
+ obt_main_loop_timeout_add(ob_main_loop,
+ FRAME_ANIMATE_ICONIFY_STEP_TIME,
+ frame_animate_iconify, self,
+ g_direct_equal, NULL);
/* do the first step */
frame_animate_iconify(self);
/* show it during the animation even if it is not "visible" */
if (!self->visible)
- XMapWindow(ob_display, self->window);
+ XMapWindow(obt_display, self->window);
}
}
RrColorPixel(ob_rr_theme->cb_focused_color) :
RrColorPixel(ob_rr_theme->cb_unfocused_color));
- XSetWindowBackground(ob_display, self->backback, px);
- XClearWindow(ob_display, self->backback);
- XSetWindowBackground(ob_display, self->innerleft, px);
- XClearWindow(ob_display, self->innerleft);
- XSetWindowBackground(ob_display, self->innertop, px);
- XClearWindow(ob_display, self->innertop);
- XSetWindowBackground(ob_display, self->innerright, px);
- XClearWindow(ob_display, self->innerright);
- XSetWindowBackground(ob_display, self->innerbottom, px);
- XClearWindow(ob_display, self->innerbottom);
- XSetWindowBackground(ob_display, self->innerbll, px);
- XClearWindow(ob_display, self->innerbll);
- XSetWindowBackground(ob_display, self->innerbrr, px);
- XClearWindow(ob_display, self->innerbrr);
- XSetWindowBackground(ob_display, self->innerblb, px);
- XClearWindow(ob_display, self->innerblb);
- XSetWindowBackground(ob_display, self->innerbrb, px);
- XClearWindow(ob_display, self->innerbrb);
+ XSetWindowBackground(obt_display, self->backback, px);
+ XClearWindow(obt_display, self->backback);
+ XSetWindowBackground(obt_display, self->innerleft, px);
+ XClearWindow(obt_display, self->innerleft);
+ XSetWindowBackground(obt_display, self->innertop, px);
+ XClearWindow(obt_display, self->innertop);
+ XSetWindowBackground(obt_display, self->innerright, px);
+ XClearWindow(obt_display, self->innerright);
+ XSetWindowBackground(obt_display, self->innerbottom, px);
+ XClearWindow(obt_display, self->innerbottom);
+ XSetWindowBackground(obt_display, self->innerbll, px);
+ XClearWindow(obt_display, self->innerbll);
+ XSetWindowBackground(obt_display, self->innerbrr, px);
+ XClearWindow(obt_display, self->innerbrr);
+ XSetWindowBackground(obt_display, self->innerblb, px);
+ XClearWindow(obt_display, self->innerblb);
+ XSetWindowBackground(obt_display, self->innerbrb, px);
+ XClearWindow(obt_display, self->innerbrb);
px = (self->focused ?
RrColorPixel(ob_rr_theme->frame_focused_border_color) :
RrColorPixel(ob_rr_theme->frame_unfocused_border_color));
- XSetWindowBackground(ob_display, self->left, px);
- XClearWindow(ob_display, self->left);
- XSetWindowBackground(ob_display, self->right, px);
- XClearWindow(ob_display, self->right);
-
- XSetWindowBackground(ob_display, self->titleleft, px);
- XClearWindow(ob_display, self->titleleft);
- XSetWindowBackground(ob_display, self->titletop, px);
- XClearWindow(ob_display, self->titletop);
- XSetWindowBackground(ob_display, self->titletopleft, px);
- XClearWindow(ob_display, self->titletopleft);
- XSetWindowBackground(ob_display, self->titletopright, px);
- XClearWindow(ob_display, self->titletopright);
- XSetWindowBackground(ob_display, self->titleright, px);
- XClearWindow(ob_display, self->titleright);
-
- XSetWindowBackground(ob_display, self->handleleft, px);
- XClearWindow(ob_display, self->handleleft);
- XSetWindowBackground(ob_display, self->handletop, px);
- XClearWindow(ob_display, self->handletop);
- XSetWindowBackground(ob_display, self->handleright, px);
- XClearWindow(ob_display, self->handleright);
- XSetWindowBackground(ob_display, self->handlebottom, px);
- XClearWindow(ob_display, self->handlebottom);
-
- XSetWindowBackground(ob_display, self->lgripleft, px);
- XClearWindow(ob_display, self->lgripleft);
- XSetWindowBackground(ob_display, self->lgriptop, px);
- XClearWindow(ob_display, self->lgriptop);
- XSetWindowBackground(ob_display, self->lgripbottom, px);
- XClearWindow(ob_display, self->lgripbottom);
-
- XSetWindowBackground(ob_display, self->rgripright, px);
- XClearWindow(ob_display, self->rgripright);
- XSetWindowBackground(ob_display, self->rgriptop, px);
- XClearWindow(ob_display, self->rgriptop);
- XSetWindowBackground(ob_display, self->rgripbottom, px);
- XClearWindow(ob_display, self->rgripbottom);
+ XSetWindowBackground(obt_display, self->left, px);
+ XClearWindow(obt_display, self->left);
+ XSetWindowBackground(obt_display, self->right, px);
+ XClearWindow(obt_display, self->right);
+
+ XSetWindowBackground(obt_display, self->titleleft, px);
+ XClearWindow(obt_display, self->titleleft);
+ XSetWindowBackground(obt_display, self->titletop, px);
+ XClearWindow(obt_display, self->titletop);
+ XSetWindowBackground(obt_display, self->titletopleft, px);
+ XClearWindow(obt_display, self->titletopleft);
+ XSetWindowBackground(obt_display, self->titletopright, px);
+ XClearWindow(obt_display, self->titletopright);
+ XSetWindowBackground(obt_display, self->titleright, px);
+ XClearWindow(obt_display, self->titleright);
+
+ XSetWindowBackground(obt_display, self->handleleft, px);
+ XClearWindow(obt_display, self->handleleft);
+ XSetWindowBackground(obt_display, self->handletop, px);
+ XClearWindow(obt_display, self->handletop);
+ XSetWindowBackground(obt_display, self->handleright, px);
+ XClearWindow(obt_display, self->handleright);
+ XSetWindowBackground(obt_display, self->handlebottom, px);
+ XClearWindow(obt_display, self->handlebottom);
+
+ XSetWindowBackground(obt_display, self->lgripleft, px);
+ XClearWindow(obt_display, self->lgripleft);
+ XSetWindowBackground(obt_display, self->lgriptop, px);
+ XClearWindow(obt_display, self->lgriptop);
+ XSetWindowBackground(obt_display, self->lgripbottom, px);
+ XClearWindow(obt_display, self->lgripbottom);
+
+ XSetWindowBackground(obt_display, self->rgripright, px);
+ XClearWindow(obt_display, self->rgripright);
+ XSetWindowBackground(obt_display, self->rgriptop, px);
+ XClearWindow(obt_display, self->rgriptop);
+ XSetWindowBackground(obt_display, self->rgripbottom, px);
+ XClearWindow(obt_display, self->rgripbottom);
/* don't use the separator color for shaded windows */
if (!self->client->shaded)
RrColorPixel(ob_rr_theme->title_separator_focused_color) :
RrColorPixel(ob_rr_theme->title_separator_unfocused_color));
- XSetWindowBackground(ob_display, self->titlebottom, px);
- XClearWindow(ob_display, self->titlebottom);
+ XSetWindowBackground(obt_display, self->titlebottom, px);
+ XClearWindow(obt_display, self->titlebottom);
}
if (self->decorations & OB_FRAME_DECOR_TITLEBAR) {
}
}
- XFlush(ob_display);
+ XFlush(obt_display);
}
static void framerender_label(ObFrame *self, RrAppearance *a)
static void framerender_icon(ObFrame *self, RrAppearance *a)
{
- const ObClientIcon *icon;
+ RrImage *icon;
if (!self->icon_on) return;
- icon = client_icon(self->client,
- ob_rr_theme->button_size + 2,
- ob_rr_theme->button_size + 2);
+ icon = client_icon(self->client);
+
if (icon) {
- a->texture[0].type = RR_TEXTURE_RGBA;
- a->texture[0].data.rgba.width = icon->width;
- a->texture[0].data.rgba.height = icon->height;
- a->texture[0].data.rgba.alpha = 0xff;
- a->texture[0].data.rgba.data = icon->data;
- } else
+ RrAppearanceClearTextures(a);
+ a->texture[0].type = RR_TEXTURE_IMAGE;
+ a->texture[0].data.image.alpha = 0xff;
+ a->texture[0].data.image.image = icon;
+ } else {
+ RrAppearanceClearTextures(a);
a->texture[0].type = RR_TEXTURE_NONE;
+ }
RrPaint(a, self->icon,
ob_rr_theme->button_size + 2, ob_rr_theme->button_size + 2);
*/
#include "grab.h"
-#include "modkeys.h"
#include "openbox.h"
#include "event.h"
-#include "xerror.h"
#include "screen.h"
#include "debug.h"
+#include "obt/display.h"
+#include "obt/keyboard.h"
#include <glib.h>
#include <X11/Xlib.h>
if (grab) {
if (kgrabs++ == 0) {
- ret = XGrabKeyboard(ob_display, RootWindow(ob_display, ob_screen),
+ ret = XGrabKeyboard(obt_display, obt_root(ob_screen),
False, GrabModeAsync, GrabModeAsync,
event_curtime) == Success;
if (!ret)
ret = TRUE;
} else if (kgrabs > 0) {
if (--kgrabs == 0) {
- XUngrabKeyboard(ob_display, ungrab_time());
+ XUngrabKeyboard(obt_display, ungrab_time());
}
ret = TRUE;
}
if (grab) {
if (pgrabs++ == 0) {
- ret = XGrabPointer(ob_display, screen_support_win, owner_events,
+ ret = XGrabPointer(obt_display, screen_support_win, owner_events,
GRAB_PTR_MASK,
GrabModeAsync, GrabModeAsync,
- (confine ? RootWindow(ob_display, ob_screen) :
- None),
+ (confine ? obt_root(ob_screen) : None),
ob_cursor(cur), event_curtime) == Success;
if (!ret)
--pgrabs;
ret = TRUE;
} else if (pgrabs > 0) {
if (--pgrabs == 0) {
- XUngrabPointer(ob_display, ungrab_time());
+ XUngrabPointer(obt_display, ungrab_time());
}
ret = TRUE;
}
static guint sgrabs = 0;
if (grab) {
if (sgrabs++ == 0) {
- XGrabServer(ob_display);
- XSync(ob_display, FALSE);
+ XGrabServer(obt_display);
+ XSync(obt_display, FALSE);
}
} else if (sgrabs > 0) {
if (--sgrabs == 0) {
- XUngrabServer(ob_display);
- XFlush(ob_display);
+ XUngrabServer(obt_display);
+ XFlush(obt_display);
}
}
return sgrabs;
guint i = 0;
guint num, caps, scroll;
- num = modkeys_key_to_mask(OB_MODKEY_KEY_NUMLOCK);
- caps = modkeys_key_to_mask(OB_MODKEY_KEY_CAPSLOCK);
- scroll = modkeys_key_to_mask(OB_MODKEY_KEY_SCROLLLOCK);
+ num = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_NUMLOCK);
+ caps = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CAPSLOCK);
+ scroll = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SCROLLLOCK);
mask_list[i++] = 0;
mask_list[i++] = num;
{
guint i;
- xerror_set_ignore(TRUE); /* can get BadAccess from these */
- xerror_occured = FALSE;
+ /* can get BadAccess from these */
+ obt_display_ignore_errors(TRUE);
for (i = 0; i < MASK_LIST_SIZE; ++i)
- XGrabButton(ob_display, button, state | mask_list[i], win, False, mask,
- pointer_mode, GrabModeAsync, None, ob_cursor(cur));
- xerror_set_ignore(FALSE);
- if (xerror_occured)
+ XGrabButton(obt_display, button, state | mask_list[i], win, False,
+ mask, pointer_mode, GrabModeAsync, None, ob_cursor(cur));
+ obt_display_ignore_errors(FALSE);
+ if (obt_display_error_occured)
ob_debug("Failed to grab button %d modifiers %d", button, state);
}
guint i;
for (i = 0; i < MASK_LIST_SIZE; ++i)
- XUngrabButton(ob_display, button, state | mask_list[i], win);
+ XUngrabButton(obt_display, button, state | mask_list[i], win);
}
void grab_key(guint keycode, guint state, Window win, gint keyboard_mode)
{
guint i;
- xerror_set_ignore(TRUE); /* can get BadAccess' from these */
- xerror_occured = FALSE;
+ /* can get BadAccess' from these */
+ obt_display_ignore_errors(TRUE);
for (i = 0; i < MASK_LIST_SIZE; ++i)
- XGrabKey(ob_display, keycode, state | mask_list[i], win, FALSE,
+ XGrabKey(obt_display, keycode, state | mask_list[i], win, FALSE,
GrabModeAsync, keyboard_mode);
- xerror_set_ignore(FALSE);
- if (xerror_occured)
+ obt_display_ignore_errors(FALSE);
+ if (obt_display_error_occured)
ob_debug("Failed to grab keycode %d modifiers %d", keycode, state);
}
void ungrab_all_keys(Window win)
{
- XUngrabKey(ob_display, AnyKey, AnyModifier, win);
+ XUngrabKey(obt_display, AnyKey, AnyModifier, win);
}
void grab_key_passive_count(int change)
/*ob_debug("ungrabbing %d passive grabs\n", passive_count);*/
if (passive_count) {
/* kill out passive grab */
- XUngrabKeyboard(ob_display, event_curtime);
+ XUngrabKeyboard(obt_display, event_curtime);
passive_count = 0;
}
}
See the COPYING file for a copy of the GNU General Public License.
*/
-#include "mainloop.h"
#include "focus.h"
#include "screen.h"
#include "frame.h"
#include "grab.h"
#include "client.h"
#include "actions.h"
-#include "prop.h"
#include "menuframe.h"
#include "config.h"
#include "keytree.h"
{
KeyBindingTree *p;
- ungrab_all_keys(RootWindow(ob_display, ob_screen));
+ ungrab_all_keys(obt_root(ob_screen));
if (grab) {
p = curpos ? curpos->first_child : keyboard_firstnode;
while (p) {
if (p->key)
- grab_key(p->key, p->state, RootWindow(ob_display, ob_screen),
+ grab_key(p->key, p->state, obt_root(ob_screen),
GrabModeAsync);
p = p->next_sibling;
}
if (curpos)
grab_key(config_keyboard_reset_keycode,
config_keyboard_reset_state,
- RootWindow(ob_display, ob_screen), GrabModeAsync);
+ obt_root(ob_screen), GrabModeAsync);
}
}
if (e->xkey.keycode == config_keyboard_reset_keycode &&
e->xkey.state == config_keyboard_reset_state)
{
- ob_main_loop_timeout_remove(ob_main_loop, chain_timeout);
+ obt_main_loop_timeout_remove(ob_main_loop, chain_timeout);
keyboard_reset_chains(-1);
return;
}
menu_frame_hide_all();
if (p->first_child != NULL) { /* part of a chain */
- ob_main_loop_timeout_remove(ob_main_loop, chain_timeout);
+ obt_main_loop_timeout_remove(ob_main_loop, chain_timeout);
/* 3 second timeout for chains */
- ob_main_loop_timeout_add(ob_main_loop, 3 * G_USEC_PER_SEC,
- chain_timeout, NULL,
- g_direct_equal, NULL);
+ obt_main_loop_timeout_add(ob_main_loop, 3 * G_USEC_PER_SEC,
+ chain_timeout, NULL,
+ g_direct_equal, NULL);
set_curpos(p);
} else if (p->chroot) /* an empty chroot */
set_curpos(p);
void keyboard_shutdown(gboolean reconfig)
{
- ob_main_loop_timeout_remove(ob_main_loop, chain_timeout);
+ obt_main_loop_timeout_remove(ob_main_loop, chain_timeout);
keyboard_unbind_all();
set_curpos(NULL);
+++ /dev/null
-/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
-
- mainloop.h for the Openbox window manager
- Copyright (c) 2006 Mikael Magnusson
- Copyright (c) 2003-2007 Dana Jansens
-
- 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.
-
- See the COPYING file for a copy of the GNU General Public License.
-*/
-
-#ifndef __ob__mainloop_h
-#define __ob__mainloop_h
-
-#include <X11/Xlib.h>
-#include <glib.h>
-
-typedef struct _ObMainLoop ObMainLoop;
-
-ObMainLoop *ob_main_loop_new(Display *display);
-void ob_main_loop_destroy(ObMainLoop *loop);
-
-typedef void (*ObMainLoopXHandler) (const XEvent *e, gpointer data);
-
-void ob_main_loop_x_add(ObMainLoop *loop,
- ObMainLoopXHandler handler,
- gpointer data,
- GDestroyNotify notify);
-void ob_main_loop_x_remove(ObMainLoop *loop,
- ObMainLoopXHandler handler);
-
-typedef void (*ObMainLoopFdHandler) (gint fd, gpointer data);
-
-void ob_main_loop_fd_add(ObMainLoop *loop,
- gint fd,
- ObMainLoopFdHandler handler,
- gpointer data,
- GDestroyNotify notify);
-void ob_main_loop_fd_remove(ObMainLoop *loop,
- gint fd);
-
-typedef void (*ObMainLoopSignalHandler) (gint signal, gpointer data);
-
-void ob_main_loop_signal_add(ObMainLoop *loop,
- gint signal,
- ObMainLoopSignalHandler handler,
- gpointer data,
- GDestroyNotify notify);
-void ob_main_loop_signal_remove(ObMainLoop *loop,
- ObMainLoopSignalHandler handler);
-
-void ob_main_loop_timeout_add(ObMainLoop *loop,
- gulong microseconds,
- GSourceFunc handler,
- gpointer data,
- GEqualFunc cmp,
- GDestroyNotify notify);
-void ob_main_loop_timeout_remove(ObMainLoop *loop,
- GSourceFunc handler);
-void ob_main_loop_timeout_remove_data(ObMainLoop *loop,
- GSourceFunc handler,
- gpointer data,
- gboolean cancel_dest);
-
-void ob_main_loop_run(ObMainLoop *loop);
-void ob_main_loop_exit(ObMainLoop *loop);
-
-#endif
#include "debug.h"
#include "menu.h"
#include "openbox.h"
-#include "mainloop.h"
#include "stacking.h"
#include "grab.h"
#include "client.h"
#include "client_list_menu.h"
#include "client_list_combined_menu.h"
#include "gettext.h"
-#include "parser/parse.h"
+#include "obt/parse.h"
+#include "obt/paths.h"
typedef struct _ObMenuParseState ObMenuParseState;
};
static GHashTable *menu_hash = NULL;
-static ObParseInst *menu_parse_inst;
+static ObtParseInst *menu_parse_inst;
static ObMenuParseState menu_parse_state;
static gboolean menu_can_hide = FALSE;
static void menu_destroy_hash_value(ObMenu *self);
-static void parse_menu_item(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data);
-static void parse_menu_separator(ObParseInst *i,
- xmlDocPtr doc, xmlNodePtr node,
- gpointer data);
-static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data);
+static void parse_menu_item(xmlNodePtr node, gpointer data);
+static void parse_menu_separator(xmlNodePtr node, gpointer data);
+static void parse_menu(xmlNodePtr node, gpointer data);
static gunichar parse_shortcut(const gchar *label, gboolean allow_shortcut,
gchar **strippedlabel, guint *position,
gboolean *always_show);
void menu_startup(gboolean reconfig)
{
- xmlDocPtr doc;
- xmlNodePtr node;
gboolean loaded = FALSE;
GSList *it;
client_list_combined_menu_startup(reconfig);
client_menu_startup();
- menu_parse_inst = parse_startup();
+ menu_parse_inst = obt_parse_instance_new();
menu_parse_state.parent = NULL;
menu_parse_state.pipe_creator = NULL;
- parse_register(menu_parse_inst, "menu", parse_menu, &menu_parse_state);
- parse_register(menu_parse_inst, "item", parse_menu_item,
- &menu_parse_state);
- parse_register(menu_parse_inst, "separator",
- parse_menu_separator, &menu_parse_state);
+ obt_parse_register(menu_parse_inst, "menu", parse_menu, &menu_parse_state);
+ obt_parse_register(menu_parse_inst, "item", parse_menu_item,
+ &menu_parse_state);
+ obt_parse_register(menu_parse_inst, "separator",
+ parse_menu_separator, &menu_parse_state);
for (it = config_menu_files; it; it = g_slist_next(it)) {
- if (parse_load_menu(it->data, &doc, &node)) {
+ if (obt_parse_load_config_file(menu_parse_inst,
+ "openbox",
+ it->data,
+ "openbox_menu"))
+ {
loaded = TRUE;
- parse_tree(menu_parse_inst, doc, node->children);
- xmlFreeDoc(doc);
+ obt_parse_tree_from_root(menu_parse_inst);
+ obt_parse_close(menu_parse_inst);
} else
g_message(_("Unable to find a valid menu file '%s'"),
(const gchar*)it->data);
}
if (!loaded) {
- if (parse_load_menu("menu.xml", &doc, &node)) {
- parse_tree(menu_parse_inst, doc, node->children);
- xmlFreeDoc(doc);
+ if (obt_parse_load_config_file(menu_parse_inst,
+ "openbox",
+ "menu.xml",
+ "openbox_menu"))
+ {
+ obt_parse_tree_from_root(menu_parse_inst);
+ obt_parse_close(menu_parse_inst);
} else
g_message(_("Unable to find a valid menu file '%s'"),
"menu.xml");
if (!reconfig)
client_remove_destroy_notify(client_dest);
- parse_shutdown(menu_parse_inst);
+ obt_parse_instance_unref(menu_parse_inst);
menu_parse_inst = NULL;
client_list_menu_shutdown(reconfig);
void menu_pipe_execute(ObMenu *self)
{
- xmlDocPtr doc;
- xmlNodePtr node;
gchar *output;
GError *err = NULL;
return;
}
- if (parse_load_mem(output, strlen(output),
- "openbox_pipe_menu", &doc, &node))
+ if (obt_parse_load_mem(menu_parse_inst, output, strlen(output),
+ "openbox_pipe_menu"))
{
menu_parse_state.pipe_creator = self;
menu_parse_state.parent = self;
- parse_tree(menu_parse_inst, doc, node->children);
- xmlFreeDoc(doc);
+ obt_parse_tree_from_root(menu_parse_inst);
+ obt_parse_close(menu_parse_inst);
} else {
g_message(_("Invalid output from pipe-menu '%s'"), self->execute);
}
return shortcut;
}
-static void parse_menu_item(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_menu_item(xmlNodePtr node, gpointer data)
{
ObMenuParseState *state = data;
gchar *label;
if (state->parent) {
- if (parse_attr_string("label", node, &label)) {
+ if (obt_parse_attr_string(node, "label", &label)) {
GSList *acts = NULL;
for (node = node->children; node; node = node->next)
if (!xmlStrcasecmp(node->name, (const xmlChar*) "action")) {
- ObActionsAct *a = actions_parse(i, doc, node);
+ ObActionsAct *a = actions_parse(node);
if (a)
acts = g_slist_append(acts, a);
}
}
}
-static void parse_menu_separator(ObParseInst *i,
- xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_menu_separator(xmlNodePtr node, gpointer data)
{
ObMenuParseState *state = data;
if (state->parent) {
gchar *label;
- if (!parse_attr_string("label", node, &label))
+ if (!obt_parse_attr_string(node, "label", &label))
label = NULL;
menu_add_separator(state->parent, -1, label);
}
}
-static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_menu(xmlNodePtr node, gpointer data)
{
ObMenuParseState *state = data;
gchar *name = NULL, *title = NULL, *script = NULL;
ObMenu *menu;
- if (!parse_attr_string("id", node, &name))
+ if (!obt_parse_attr_string(node, "id", &name))
goto parse_menu_fail;
if (!g_hash_table_lookup(menu_hash, name)) {
- if (!parse_attr_string("label", node, &title))
+ if (!obt_parse_attr_string(node, "label", &title))
goto parse_menu_fail;
if ((menu = menu_new(name, title, TRUE, NULL))) {
menu->pipe_creator = state->pipe_creator;
- if (parse_attr_string("execute", node, &script)) {
- menu->execute = parse_expand_tilde(script);
+ if (obt_parse_attr_string(node, "execute", &script)) {
+ menu->execute = obt_paths_expand_tilde(script);
} else {
ObMenu *old;
old = state->parent;
state->parent = menu;
- parse_tree(i, doc, node->children);
+ obt_parse_tree(menu_parse_inst, node->children);
state->parent = old;
}
}
menu_can_hide = TRUE;
else {
menu_can_hide = FALSE;
- ob_main_loop_timeout_add(ob_main_loop,
- config_menu_hide_delay * 1000,
- menu_hide_delay_func,
- NULL, g_direct_equal, NULL);
+ obt_main_loop_timeout_add(ob_main_loop,
+ config_menu_hide_delay * 1000,
+ menu_hide_delay_func,
+ NULL, g_direct_equal, NULL);
}
}
}
if (self && --self->ref == 0) {
switch (self->type) {
case OB_MENU_ENTRY_TYPE_NORMAL:
+ RrImageUnref(self->data.normal.icon);
g_free(self->data.normal.label);
while (self->data.normal.actions) {
actions_act_unref(self->data.normal.actions->data);
#include "window.h"
#include "geom.h"
#include "render/render.h"
-#include "parser/parse.h"
#include <glib.h>
/* List of ObActions */
GSList *actions;
- /* Icon shit */
- gint icon_width;
- gint icon_height;
- gint icon_alpha;
- RrPixel32 *icon_data;
+ /* Icon stuff. If you set this, make sure you RrImageRef() it too. */
+ RrImage *icon;
+ gint icon_alpha;
/* Mask icon */
RrPixmapMask *mask;
#include "actions.h"
#include "grab.h"
#include "openbox.h"
-#include "mainloop.h"
#include "config.h"
#include "render/theme.h"
static Window createWindow(Window parent, gulong mask,
XSetWindowAttributes *attrib)
{
- return XCreateWindow(ob_display, parent, 0, 0, 1, 1, 0,
+ return XCreateWindow(obt_display, parent, 0, 0, 1, 1, 0,
RrDepth(ob_rr_inst), InputOutput,
RrVisual(ob_rr_inst), mask, attrib);
}
XSetWindowAttributes attr;
self = g_new0(ObMenuFrame, 1);
- self->type = Window_Menu;
+ self->obwin.type = OB_WINDOW_CLASS_MENUFRAME;
self->menu = menu;
self->selected = NULL;
self->client = client;
self->show_from = show_from;
attr.event_mask = FRAME_EVENTMASK;
- self->window = createWindow(RootWindow(ob_display, ob_screen),
+ self->window = createWindow(obt_root(ob_screen),
CWEventMask, &attr);
- XSetWindowBorderWidth(ob_display, self->window, ob_rr_theme->mbwidth);
- XSetWindowBorder(ob_display, self->window,
+ XSetWindowBorderWidth(obt_display, self->window, ob_rr_theme->mbwidth);
+ XSetWindowBorder(obt_display, self->window,
RrColorPixel(ob_rr_theme->menu_border_color));
self->a_items = RrAppearanceCopy(ob_rr_theme->a_menu);
- stacking_add(MENU_AS_WINDOW(self));
+ window_add(&self->window, MENUFRAME_AS_WINDOW(self));
+ stacking_add(MENUFRAME_AS_WINDOW(self));
return self;
}
self->entries = g_list_delete_link(self->entries, self->entries);
}
- stacking_remove(MENU_AS_WINDOW(self));
+ stacking_remove(MENUFRAME_AS_WINDOW(self));
+ window_remove(self->window);
RrAppearanceFree(self->a_items);
- XDestroyWindow(ob_display, self->window);
+ XDestroyWindow(obt_display, self->window);
g_free(self);
}
g_hash_table_insert(menu_frame_map, &self->bullet, self);
}
- XMapWindow(ob_display, self->window);
- XMapWindow(ob_display, self->text);
+ XMapWindow(obt_display, self->window);
+ XMapWindow(obt_display, self->text);
+
+ window_add(&self->window, MENUFRAME_AS_WINDOW(self->frame));
return self;
}
if (self) {
menu_entry_unref(self->entry);
- XDestroyWindow(ob_display, self->text);
- XDestroyWindow(ob_display, self->window);
+ window_remove(self->window);
+
+ XDestroyWindow(obt_display, self->text);
+ XDestroyWindow(obt_display, self->window);
g_hash_table_remove(menu_frame_map, &self->text);
g_hash_table_remove(menu_frame_map, &self->window);
if (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL) {
- XDestroyWindow(ob_display, self->icon);
+ XDestroyWindow(obt_display, self->icon);
g_hash_table_remove(menu_frame_map, &self->icon);
}
if (self->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) {
- XDestroyWindow(ob_display, self->bullet);
+ XDestroyWindow(obt_display, self->bullet);
g_hash_table_remove(menu_frame_map, &self->bullet);
}
void menu_frame_move(ObMenuFrame *self, gint x, gint y)
{
RECT_SET_POINT(self->area, x, y);
- XMoveWindow(ob_display, self->window, self->area.x, self->area.y);
+ XMoveWindow(obt_display, self->window, self->area.x, self->area.y);
}
static void menu_frame_place_topmenu(ObMenuFrame *self, gint *x, gint *y)
default:
g_assert_not_reached();
}
+
RECT_SET_SIZE(self->area, self->frame->inner_w, th);
- XResizeWindow(ob_display, self->window,
+ XResizeWindow(obt_display, self->window,
self->area.width, self->area.height);
item_a->surface.parent = self->frame->a_items;
item_a->surface.parentx = self->area.x;
switch (self->entry->type) {
case OB_MENU_ENTRY_TYPE_NORMAL:
- XMoveResizeWindow(ob_display, self->text,
+ XMoveResizeWindow(obt_display, self->text,
self->frame->text_x, PADDING,
self->frame->text_w,
ITEM_HEIGHT - 2*PADDING);
ITEM_HEIGHT - 2*PADDING);
break;
case OB_MENU_ENTRY_TYPE_SUBMENU:
- XMoveResizeWindow(ob_display, self->text,
+ XMoveResizeWindow(obt_display, self->text,
self->frame->text_x, PADDING,
self->frame->text_w - ITEM_HEIGHT,
ITEM_HEIGHT - 2*PADDING);
case OB_MENU_ENTRY_TYPE_SEPARATOR:
if (self->entry->data.separator.label != NULL) {
/* labeled separator */
- XMoveResizeWindow(ob_display, self->text,
+ XMoveResizeWindow(obt_display, self->text,
ob_rr_theme->paddingx, ob_rr_theme->paddingy,
self->area.width - 2*ob_rr_theme->paddingx,
ob_rr_theme->menu_title_height -
RrAppearance *clear;
/* unlabeled separaator */
- XMoveResizeWindow(ob_display, self->text, PADDING, PADDING,
+ XMoveResizeWindow(obt_display, self->text, PADDING, PADDING,
self->area.width - 2*PADDING, SEPARATOR_HEIGHT);
clear = ob_rr_theme->a_clear_tex;
+ RrAppearanceClearTextures(clear);
clear->texture[0].type = RR_TEXTURE_LINE_ART;
clear->surface.parent = item_a;
clear->surface.parentx = PADDING;
}
if (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
- self->entry->data.normal.icon_data)
+ self->entry->data.normal.icon)
{
RrAppearance *clear;
- XMoveResizeWindow(ob_display, self->icon,
+ XMoveResizeWindow(obt_display, self->icon,
PADDING, frame->item_margin.top,
ITEM_HEIGHT - frame->item_margin.top
- frame->item_margin.bottom,
- frame->item_margin.bottom);
clear = ob_rr_theme->a_clear_tex;
- clear->texture[0].type = RR_TEXTURE_RGBA;
- clear->texture[0].data.rgba.width =
- self->entry->data.normal.icon_width;
- clear->texture[0].data.rgba.height =
- self->entry->data.normal.icon_height;
- clear->texture[0].data.rgba.alpha =
+ RrAppearanceClearTextures(clear);
+ clear->texture[0].type = RR_TEXTURE_IMAGE;
+ clear->texture[0].data.image.image =
+ self->entry->data.normal.icon;
+ clear->texture[0].data.image.alpha =
self->entry->data.normal.icon_alpha;
- clear->texture[0].data.rgba.data =
- self->entry->data.normal.icon_data;
clear->surface.parent = item_a;
clear->surface.parentx = PADDING;
clear->surface.parenty = frame->item_margin.top;
- frame->item_margin.bottom,
ITEM_HEIGHT - frame->item_margin.top
- frame->item_margin.bottom);
- XMapWindow(ob_display, self->icon);
+ XMapWindow(obt_display, self->icon);
} else if (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
self->entry->data.normal.mask)
{
RrColor *c;
RrAppearance *clear;
- XMoveResizeWindow(ob_display, self->icon,
+ XMoveResizeWindow(obt_display, self->icon,
PADDING, frame->item_margin.top,
ITEM_HEIGHT - frame->item_margin.top
- frame->item_margin.bottom,
- frame->item_margin.bottom);
clear = ob_rr_theme->a_clear_tex;
+ RrAppearanceClearTextures(clear);
clear->texture[0].type = RR_TEXTURE_MASK;
clear->texture[0].data.mask.mask =
self->entry->data.normal.mask;
- frame->item_margin.bottom,
ITEM_HEIGHT - frame->item_margin.top
- frame->item_margin.bottom);
- XMapWindow(ob_display, self->icon);
+ XMapWindow(obt_display, self->icon);
} else
- XUnmapWindow(ob_display, self->icon);
+ XUnmapWindow(obt_display, self->icon);
if (self->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) {
RrAppearance *bullet_a;
- XMoveResizeWindow(ob_display, self->bullet,
+ XMoveResizeWindow(obt_display, self->bullet,
self->frame->text_x + self->frame->text_w -
ITEM_HEIGHT + PADDING, PADDING,
ITEM_HEIGHT - 2*PADDING,
RrPaint(bullet_a, self->bullet,
ITEM_HEIGHT - 2*PADDING,
ITEM_HEIGHT - 2*PADDING);
- XMapWindow(ob_display, self->bullet);
+ XMapWindow(obt_display, self->bullet);
} else
- XUnmapWindow(ob_display, self->bullet);
+ XUnmapWindow(obt_display, self->bullet);
- XFlush(ob_display);
+ XFlush(obt_display);
}
/*! this code is taken from the menu_frame_render. if that changes, this won't
}
RECT_SET_POINT(e->area, 0, h+e->border);
- XMoveWindow(ob_display, e->window,
+ XMoveWindow(obt_display, e->window,
e->area.x-e->border, e->area.y-e->border);
- XSetWindowBorderWidth(ob_display, e->window, e->border);
- XSetWindowBorder(ob_display, e->window,
+ XSetWindowBorderWidth(obt_display, e->window, e->border);
+ XSetWindowBorder(obt_display, e->window,
RrColorPixel(ob_rr_theme->menu_border_color));
tw = MIN(tw, MAX_MENU_WIDTH);
th = ob_rr_theme->menu_font_height;
- if (e->entry->data.normal.icon_data ||
+ if (e->entry->data.normal.icon ||
e->entry->data.normal.mask)
has_icon = TRUE;
break;
tw = MIN(tw, MAX_MENU_WIDTH);
th = ob_rr_theme->menu_font_height;
- if (e->entry->data.normal.icon_data ||
+ if (e->entry->data.normal.icon ||
e->entry->data.normal.mask)
has_icon = TRUE;
if (!w) w = 10;
if (!h) h = 3;
- XResizeWindow(ob_display, self->window, w, h);
+ XResizeWindow(obt_display, self->window, w, h);
self->inner_w = w;
RECT_SET_SIZE(self->area, w, h);
- XFlush(ob_display);
+ XFlush(obt_display);
}
static void menu_frame_update(ObMenuFrame *self)
menu_frame_move(self, x, y);
- XMapWindow(ob_display, self->window);
+ XMapWindow(obt_display, self->window);
if (screen_pointer_pos(&px, &py)) {
ObMenuEntryFrame *e = menu_entry_frame_under(px, py);
}
menu_frame_move(self, x + dx, y + dy);
- XMapWindow(ob_display, self->window);
+ XMapWindow(obt_display, self->window);
if (screen_pointer_pos(&px, &py)) {
ObMenuEntryFrame *e = menu_entry_frame_under(px, py);
ungrab_keyboard();
}
- XUnmapWindow(ob_display, self->window);
+ XUnmapWindow(obt_display, self->window);
menu_frame_free(self);
}
if (config_submenu_show_delay) {
/* remove any submenu open requests */
- ob_main_loop_timeout_remove(ob_main_loop,
- menu_entry_frame_submenu_timeout);
+ obt_main_loop_timeout_remove(ob_main_loop,
+ menu_entry_frame_submenu_timeout);
}
if ((it = g_list_last(menu_frame_visible)))
menu_frame_hide(it->data);
if (f->client == client) {
if (config_submenu_show_delay) {
/* remove any submenu open requests */
- ob_main_loop_timeout_remove(ob_main_loop,
- menu_entry_frame_submenu_timeout);
+ obt_main_loop_timeout_remove(ob_main_loop,
+ menu_entry_frame_submenu_timeout);
}
menu_frame_hide(f);
}
if (config_submenu_show_delay) {
/* remove any submenu open requests */
- ob_main_loop_timeout_remove(ob_main_loop,
- menu_entry_frame_submenu_timeout);
+ obt_main_loop_timeout_remove(ob_main_loop,
+ menu_entry_frame_submenu_timeout);
}
self->selected = entry;
if (self->selected->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) {
if (config_submenu_show_delay && !immediate) {
/* initiate a new submenu open request */
- ob_main_loop_timeout_add(ob_main_loop,
- config_submenu_show_delay * 1000,
- menu_entry_frame_submenu_timeout,
- self->selected, g_direct_equal,
- NULL);
+ obt_main_loop_timeout_add(ob_main_loop,
+ config_submenu_show_delay * 1000,
+ menu_entry_frame_submenu_timeout,
+ self->selected, g_direct_equal,
+ NULL);
} else {
menu_entry_frame_show_submenu(self->selected);
}
struct _ObMenuFrame
{
/* stuff to be an ObWindow */
- Window_InternalType type;
+ ObWindow obwin;
Window window;
struct _ObMenu *menu;
#include "openbox.h"
#include "config.h"
-#include "xerror.h"
#include "actions.h"
#include "event.h"
#include "client.h"
-#include "prop.h"
#include "grab.h"
#include "frame.h"
#include "translate.h"
#include "mouse.h"
#include "gettext.h"
+#include "obt/display.h"
#include <glib.h>
{
if (replay_pointer_needed) {
/* replay the pointer event before any windows move */
- XAllowEvents(ob_display, ReplayPointer, event_curtime);
+ XAllowEvents(obt_display, ReplayPointer, event_curtime);
replay_pointer_needed = FALSE;
}
}
Window wjunk;
guint ujunk, b, w, h;
/* this can cause errors to occur when the window closes */
- xerror_set_ignore(TRUE);
- junk1 = XGetGeometry(ob_display, e->xbutton.window,
+ obt_display_ignore_errors(TRUE);
+ junk1 = XGetGeometry(obt_display, e->xbutton.window,
&wjunk, &junk1, &junk2, &w, &h, &b, &ujunk);
- xerror_set_ignore(FALSE);
+ obt_display_ignore_errors(FALSE);
if (junk1) {
if (e->xbutton.x >= (signed)-b &&
e->xbutton.y >= (signed)-b &&
#include "grab.h"
#include "framerender.h"
#include "screen.h"
-#include "prop.h"
#include "client.h"
#include "frame.h"
#include "openbox.h"
#include "resist.h"
-#include "mainloop.h"
-#include "modkeys.h"
#include "popup.h"
#include "moveresize.h"
#include "config.h"
#include "event.h"
#include "debug.h"
-#include "extensions.h"
#include "render/render.h"
#include "render/theme.h"
+#include "obt/display.h"
+#include "obt/prop.h"
+#include "obt/keyboard.h"
#include <X11/Xlib.h>
#include <glib.h>
void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr)
{
ObCursor cur;
- gboolean mv = (cnr == prop_atoms.net_wm_moveresize_move ||
- cnr == prop_atoms.net_wm_moveresize_move_keyboard);
+ gboolean mv = (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE) ||
+ cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE_KEYBOARD));
gint up = 1;
gint left = 1;
(c->functions & OB_CLIENT_FUNC_RESIZE)))
return;
- if (cnr == prop_atoms.net_wm_moveresize_size_topleft) {
+ if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT)) {
cur = OB_CURSOR_NORTHWEST;
up = left = -1;
- } else if (cnr == prop_atoms.net_wm_moveresize_size_top) {
+ }
+ else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP)) {
cur = OB_CURSOR_NORTH;
up = -1;
- } else if (cnr == prop_atoms.net_wm_moveresize_size_topright) {
+ }
+ else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT)) {
cur = OB_CURSOR_NORTHEAST;
up = -1;
- } else if (cnr == prop_atoms.net_wm_moveresize_size_right)
+ }
+ else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT))
cur = OB_CURSOR_EAST;
- else if (cnr == prop_atoms.net_wm_moveresize_size_bottomright)
+ else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT))
cur = OB_CURSOR_SOUTHEAST;
- else if (cnr == prop_atoms.net_wm_moveresize_size_bottom)
+ else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOM))
cur = OB_CURSOR_SOUTH;
- else if (cnr == prop_atoms.net_wm_moveresize_size_bottomleft) {
+ else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT)) {
cur = OB_CURSOR_SOUTHWEST;
left = -1;
- } else if (cnr == prop_atoms.net_wm_moveresize_size_left) {
+ }
+ else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT)) {
cur = OB_CURSOR_WEST;
left = -1;
- } else if (cnr == prop_atoms.net_wm_moveresize_size_keyboard)
+ }
+ else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_KEYBOARD))
cur = OB_CURSOR_SOUTHEAST;
- else if (cnr == prop_atoms.net_wm_moveresize_move)
+ else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE))
cur = OB_CURSOR_MOVE;
- else if (cnr == prop_atoms.net_wm_moveresize_move_keyboard)
+ else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE_KEYBOARD))
cur = OB_CURSOR_MOVE;
else
g_assert_not_reached();
moveresize_in_progress = TRUE;
#ifdef SYNC
- if (config_resize_redraw && !moving && extensions_sync &&
+ if (config_resize_redraw && !moving && obt_display_extension_sync &&
moveresize_client->sync_request && moveresize_client->sync_counter &&
!moveresize_client->not_responding)
{
/* set the counter to an initial value */
XSyncIntToValue(&val, 0);
- XSyncSetCounter(ob_display, moveresize_client->sync_counter, val);
+ XSyncSetCounter(obt_display, moveresize_client->sync_counter, val);
/* this will be incremented when we tell the client what we're
looking for */
aa.trigger.test_type = XSyncPositiveTransition;
aa.events = True;
XSyncIntToValue(&aa.delta, 1);
- moveresize_alarm = XSyncCreateAlarm(ob_display,
+ moveresize_alarm = XSyncCreateAlarm(obt_display,
XSyncCACounter |
XSyncCAValue |
XSyncCAValueType |
#ifdef SYNC
/* turn off the alarm */
if (moveresize_alarm != None) {
- XSyncDestroyAlarm(ob_display, moveresize_alarm);
+ XSyncDestroyAlarm(obt_display, moveresize_alarm);
moveresize_alarm = None;
}
- ob_main_loop_timeout_remove(ob_main_loop, sync_timeout_func);
+ obt_main_loop_timeout_remove(ob_main_loop, sync_timeout_func);
#endif
client_configure(moveresize_client,
}
#ifdef SYNC
- if (config_resize_redraw && extensions_sync &&
+ if (config_resize_redraw && obt_display_extension_sync &&
moveresize_client->sync_request && moveresize_client->sync_counter &&
!moveresize_client->not_responding)
{
/* tell the client what we're waiting for */
ce.xclient.type = ClientMessage;
- ce.xclient.message_type = prop_atoms.wm_protocols;
- ce.xclient.display = ob_display;
+ ce.xclient.message_type = OBT_PROP_ATOM(WM_PROTOCOLS);
+ ce.xclient.display = obt_display;
ce.xclient.window = moveresize_client->window;
ce.xclient.format = 32;
- ce.xclient.data.l[0] = prop_atoms.net_wm_sync_request;
+ ce.xclient.data.l[0] = OBT_PROP_ATOM(NET_WM_SYNC_REQUEST);
ce.xclient.data.l[1] = event_curtime;
ce.xclient.data.l[2] = XSyncValueLow32(val);
ce.xclient.data.l[3] = XSyncValueHigh32(val);
ce.xclient.data.l[4] = 0l;
- XSendEvent(ob_display, moveresize_client->window, FALSE,
+ XSendEvent(obt_display, moveresize_client->window, FALSE,
NoEventMask, &ce);
waiting_for_sync = TRUE;
- ob_main_loop_timeout_remove(ob_main_loop, sync_timeout_func);
- ob_main_loop_timeout_add(ob_main_loop, G_USEC_PER_SEC * 2,
- sync_timeout_func,
- NULL, NULL, NULL);
+ obt_main_loop_timeout_remove(ob_main_loop, sync_timeout_func);
+ obt_main_loop_timeout_add(ob_main_loop, G_USEC_PER_SEC * 2,
+ sync_timeout_func,
+ NULL, NULL, NULL);
}
#endif
cancel_edge_warp();
if (dir != (ObDirection)-1) {
edge_warp_odd = TRUE; /* switch on the first timeout */
- ob_main_loop_timeout_add(ob_main_loop,
- config_mouse_screenedgetime * 1000,
- edge_warp_delay_func,
- NULL, NULL, NULL);
+ obt_main_loop_timeout_add(ob_main_loop,
+ config_mouse_screenedgetime * 1000,
+ edge_warp_delay_func,
+ NULL, NULL, NULL);
}
edge_warp_dir = dir;
}
static void cancel_edge_warp(void)
{
- ob_main_loop_timeout_remove(ob_main_loop, edge_warp_delay_func);
+ obt_main_loop_timeout_remove(ob_main_loop, edge_warp_delay_func);
}
static void move_with_keys(gint keycode, gint state)
gint dist = 0;
/* shift means jump to edge */
- if (state & modkeys_key_to_mask(OB_MODKEY_KEY_SHIFT)) {
+ if (state & obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SHIFT)) {
gint x, y;
ObDirection dir;
dy = y - moveresize_client->area.y;
} else {
/* control means fine grained */
- if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL))
+ if (state &
+ obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CONTROL))
+ {
dist = 1;
+ }
else
dist = KEY_DIST;
}
screen_pointer_pos(&opx, &opy);
- XWarpPointer(ob_display, None, None, 0, 0, 0, 0, dx, dy);
+ XWarpPointer(obt_display, None, None, 0, 0, 0, 0, dx, dy);
/* steal the motion events this causes */
- XSync(ob_display, FALSE);
+ XSync(obt_display, FALSE);
{
XEvent ce;
- while (XCheckTypedEvent(ob_display, MotionNotify, &ce));
+ while (XCheckTypedEvent(obt_display, MotionNotify, &ce));
}
screen_pointer_pos(&px, &py);
}
/* shift means jump to edge */
- if (state & modkeys_key_to_mask(OB_MODKEY_KEY_SHIFT)) {
+ if (state & obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SHIFT)) {
gint x, y, w, h;
if (keycode == ob_keycode(OB_KEY_RIGHT))
distw = moveresize_client->size_inc.width;
resist = 1;
}
- else if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL)) {
+ else if (state &
+ obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CONTROL))
+ {
distw = 1;
resist = 1;
}
disth = moveresize_client->size_inc.height;
resist = 1;
}
- else if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL)) {
+ else if (state &
+ obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CONTROL))
+ {
disth = 1;
resist = 1;
}
pdy = dh;
screen_pointer_pos(&opx, &opy);
- XWarpPointer(ob_display, None, None, 0, 0, 0, 0, pdx, pdy);
+ XWarpPointer(obt_display, None, None, 0, 0, 0, 0, pdx, pdy);
/* steal the motion events this causes */
- XSync(ob_display, FALSE);
+ XSync(obt_display, FALSE);
{
XEvent ce;
- while (XCheckTypedEvent(ob_display, MotionNotify, &ce));
+ while (XCheckTypedEvent(obt_display, MotionNotify, &ce));
}
screen_pointer_pos(&px, &py);
gint dw, dh;
ObDirection dir;
- if (corner == prop_atoms.net_wm_moveresize_size_topleft) {
+ if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT)) {
dw = -(e->xmotion.x_root - start_x);
dh = -(e->xmotion.y_root - start_y);
dir = OB_DIRECTION_NORTHWEST;
- } else if (corner == prop_atoms.net_wm_moveresize_size_top) {
+ } else if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP)) {
dw = 0;
dh = -(e->xmotion.y_root - start_y);
dir = OB_DIRECTION_NORTH;
- } else if (corner == prop_atoms.net_wm_moveresize_size_topright) {
+ } else if (corner ==
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT)) {
dw = (e->xmotion.x_root - start_x);
dh = -(e->xmotion.y_root - start_y);
dir = OB_DIRECTION_NORTHEAST;
- } else if (corner == prop_atoms.net_wm_moveresize_size_right) {
+ } else if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT)) {
dw = (e->xmotion.x_root - start_x);
dh = 0;
dir = OB_DIRECTION_EAST;
} else if (corner ==
- prop_atoms.net_wm_moveresize_size_bottomright) {
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT)) {
dw = (e->xmotion.x_root - start_x);
dh = (e->xmotion.y_root - start_y);
dir = OB_DIRECTION_SOUTHEAST;
- } else if (corner == prop_atoms.net_wm_moveresize_size_bottom) {
+ } else if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOM))
+ {
dw = 0;
dh = (e->xmotion.y_root - start_y);
dir = OB_DIRECTION_SOUTH;
} else if (corner ==
- prop_atoms.net_wm_moveresize_size_bottomleft) {
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT)) {
dw = -(e->xmotion.x_root - start_x);
dh = (e->xmotion.y_root - start_y);
dir = OB_DIRECTION_SOUTHWEST;
- } else if (corner == prop_atoms.net_wm_moveresize_size_left) {
+ } else if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT)) {
dw = -(e->xmotion.x_root - start_x);
dh = 0;
dir = OB_DIRECTION_WEST;
- } else if (corner == prop_atoms.net_wm_moveresize_size_keyboard) {
+ } else if (corner ==
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_KEYBOARD)) {
dw = (e->xmotion.x_root - start_x);
dh = (e->xmotion.y_root - start_y);
dir = OB_DIRECTION_SOUTHEAST;
cur_w += dw;
cur_h += dh;
- if (corner == prop_atoms.net_wm_moveresize_size_topleft ||
- corner == prop_atoms.net_wm_moveresize_size_left ||
- corner == prop_atoms.net_wm_moveresize_size_bottomleft)
+ if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT) ||
+ corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT) ||
+ corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT))
{
cur_x -= dw;
}
- if (corner == prop_atoms.net_wm_moveresize_size_topleft ||
- corner == prop_atoms.net_wm_moveresize_size_top ||
- corner == prop_atoms.net_wm_moveresize_size_topright)
+ if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT) ||
+ corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP) ||
+ corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT))
{
cur_y -= dh;
}
e->xkey.keycode == ob_keycode(OB_KEY_DOWN) ||
e->xkey.keycode == ob_keycode(OB_KEY_UP))
{
- if (corner == prop_atoms.net_wm_moveresize_size_keyboard) {
+ if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_KEYBOARD)) {
resize_with_keys(e->xkey.keycode, e->xkey.state);
used = TRUE;
- } else if (corner == prop_atoms.net_wm_moveresize_move_keyboard) {
+ } else if (corner ==
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE_KEYBOARD))
+ {
move_with_keys(e->xkey.keycode, e->xkey.state);
used = TRUE;
}
}
}
#ifdef SYNC
- else if (e->type == extensions_sync_event_basep + XSyncAlarmNotify)
+ else if (e->type == obt_display_extension_sync_basep + XSyncAlarmNotify)
{
waiting_for_sync = FALSE; /* we got our sync... */
do_resize(); /* ...so try resize if there is more change pending */
#include "openbox.h"
#include "session.h"
#include "dock.h"
-#include "modkeys.h"
#include "event.h"
#include "menu.h"
#include "client.h"
-#include "xerror.h"
-#include "prop.h"
#include "screen.h"
#include "actions.h"
#include "startupnotify.h"
#include "framerender.h"
#include "keyboard.h"
#include "mouse.h"
-#include "extensions.h"
#include "menuframe.h"
#include "grab.h"
#include "group.h"
#include "config.h"
#include "ping.h"
-#include "mainloop.h"
#include "prompt.h"
#include "gettext.h"
-#include "parser/parse.h"
#include "render/render.h"
#include "render/theme.h"
+#include "obt/display.h"
+#include "obt/prop.h"
+#include "obt/keyboard.h"
+#include "obt/parse.h"
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
-
-RrInstance *ob_rr_inst;
-RrTheme *ob_rr_theme;
-ObMainLoop *ob_main_loop;
-Display *ob_display;
-gint ob_screen;
-gboolean ob_replace_wm = FALSE;
-gboolean ob_sm_use = TRUE;
-gchar *ob_sm_id = NULL;
-gchar *ob_sm_save_file = NULL;
-gboolean ob_sm_restore = TRUE;
-gboolean ob_debug_xinerama = FALSE;
+RrInstance *ob_rr_inst;
+RrImageCache *ob_rr_icons;
+RrTheme *ob_rr_theme;
+ObtMainLoop *ob_main_loop;
+gint ob_screen;
+gboolean ob_replace_wm = FALSE;
+gboolean ob_sm_use = TRUE;
+gchar *ob_sm_id = NULL;
+gchar *ob_sm_save_file = NULL;
+gboolean ob_sm_restore = TRUE;
+gboolean ob_debug_xinerama = FALSE;
static ObState state;
static gboolean xsync = FALSE;
state = OB_STATE_STARTING;
+ ob_debug_startup();
+
/* initialize the locale */
if (!setlocale(LC_ALL, ""))
g_message("Couldn't set locale from environment.");
bind_textdomain_codeset(PACKAGE_NAME, "UTF-8");
textdomain(PACKAGE_NAME);
- if (chdir(g_get_home_dir()) == -1)
- g_message(_("Unable to change to home directory '%s': %s"),
- g_get_home_dir(), g_strerror(errno));
-
/* parse the command line args, which can change the argv[0] */
parse_args(&argc, argv);
/* parse the environment variables */
program_name = g_path_get_basename(argv[0]);
g_set_prgname(program_name);
- if (!remote_control) {
- parse_paths_startup();
-
+ if (!remote_control)
session_startup(argc, argv);
- }
-
- ob_display = XOpenDisplay(NULL);
- if (ob_display == NULL)
+ if (!obt_display_open(NULL))
ob_exit_with_error(_("Failed to open the display from the DISPLAY environment variable."));
- if (fcntl(ConnectionNumber(ob_display), F_SETFD, 1) == -1)
- ob_exit_with_error("Failed to set display as close-on-exec");
if (remote_control) {
- prop_startup();
-
/* Send client message telling the OB process to:
* remote_control = 1 -> reconfigure
* remote_control = 2 -> restart */
- PROP_MSG(RootWindow(ob_display, ob_screen),
- ob_control, remote_control, 0, 0, 0);
- XCloseDisplay(ob_display);
+ OBT_PROP_MSG(ob_screen, obt_root(ob_screen),
+ OB_CONTROL, remote_control, 0, 0, 0, 0);
+ obt_display_close(obt_display);
exit(EXIT_SUCCESS);
}
- ob_main_loop = ob_main_loop_new(ob_display);
+ ob_main_loop = obt_main_loop_new();
/* set up signal handler */
- ob_main_loop_signal_add(ob_main_loop, SIGUSR1, signal_handler, NULL, NULL);
- ob_main_loop_signal_add(ob_main_loop, SIGUSR2, signal_handler, NULL, NULL);
- ob_main_loop_signal_add(ob_main_loop, SIGTERM, signal_handler, NULL, NULL);
- ob_main_loop_signal_add(ob_main_loop, SIGINT, signal_handler, NULL, NULL);
- ob_main_loop_signal_add(ob_main_loop, SIGHUP, signal_handler, NULL, NULL);
- ob_main_loop_signal_add(ob_main_loop, SIGPIPE, signal_handler, NULL, NULL);
- ob_main_loop_signal_add(ob_main_loop, SIGCHLD, signal_handler, NULL, NULL);
+ obt_main_loop_signal_add(ob_main_loop, SIGUSR1, signal_handler, NULL,NULL);
+ obt_main_loop_signal_add(ob_main_loop, SIGUSR2, signal_handler, NULL,NULL);
+ obt_main_loop_signal_add(ob_main_loop, SIGTERM, signal_handler, NULL,NULL);
+ obt_main_loop_signal_add(ob_main_loop, SIGINT, signal_handler, NULL,NULL);
+ obt_main_loop_signal_add(ob_main_loop, SIGHUP, signal_handler, NULL,NULL);
+ obt_main_loop_signal_add(ob_main_loop, SIGPIPE, signal_handler, NULL,NULL);
+ obt_main_loop_signal_add(ob_main_loop, SIGCHLD, signal_handler, NULL,NULL);
- ob_screen = DefaultScreen(ob_display);
+ ob_screen = DefaultScreen(obt_display);
- ob_rr_inst = RrInstanceNew(ob_display, ob_screen);
+ ob_rr_inst = RrInstanceNew(obt_display, ob_screen);
if (ob_rr_inst == NULL)
ob_exit_with_error(_("Failed to initialize the obrender library."));
+ /* Saving 3 resizes of an RrImage makes a lot of sense for icons, as there
+ are generally 3 icon sizes needed: the titlebar icon, the menu icon,
+ and the alt-tab icon
+ */
+ ob_rr_icons = RrImageCacheNew(3);
- XSynchronize(ob_display, xsync);
+ XSynchronize(obt_display, xsync);
/* check for locale support */
if (!XSupportsLocale())
if (!XSetLocaleModifiers(""))
g_message(_("Cannot set locale modifiers for the X server."));
- /* set our error handler */
- XSetErrorHandler(xerror_handler);
-
/* set the DISPLAY environment variable for any lauched children, to the
display we're using, so they open in the right place. */
- setenv("DISPLAY", DisplayString(ob_display), TRUE);
+ setenv("DISPLAY", DisplayString(obt_display), TRUE);
/* create available cursors */
cursors[OB_CURSOR_NONE] = None;
cursors[OB_CURSOR_NORTHWEST] = load_cursor("top_left_corner",
XC_top_left_corner);
-
- prop_startup(); /* get atoms values for the display */
- extensions_query_all(); /* find which extensions are present */
-
if (screen_annex()) { /* it will be ours! */
do {
- modkeys_startup(reconfigure);
+ if (reconfigure) obt_keyboard_reload();
/* get the keycodes for keys we use */
- keys[OB_KEY_RETURN] = modkeys_sym_to_code(XK_Return);
- keys[OB_KEY_ESCAPE] = modkeys_sym_to_code(XK_Escape);
- keys[OB_KEY_LEFT] = modkeys_sym_to_code(XK_Left);
- keys[OB_KEY_RIGHT] = modkeys_sym_to_code(XK_Right);
- keys[OB_KEY_UP] = modkeys_sym_to_code(XK_Up);
- keys[OB_KEY_DOWN] = modkeys_sym_to_code(XK_Down);
- keys[OB_KEY_TAB] = modkeys_sym_to_code(XK_Tab);
- keys[OB_KEY_SPACE] = modkeys_sym_to_code(XK_space);
+ keys[OB_KEY_RETURN] = obt_keyboard_keysym_to_keycode(XK_Return);
+ keys[OB_KEY_ESCAPE] = obt_keyboard_keysym_to_keycode(XK_Escape);
+ keys[OB_KEY_LEFT] = obt_keyboard_keysym_to_keycode(XK_Left);
+ keys[OB_KEY_RIGHT] = obt_keyboard_keysym_to_keycode(XK_Right);
+ keys[OB_KEY_UP] = obt_keyboard_keysym_to_keycode(XK_Up);
+ keys[OB_KEY_DOWN] = obt_keyboard_keysym_to_keycode(XK_Down);
+ keys[OB_KEY_TAB] = obt_keyboard_keysym_to_keycode(XK_Tab);
+ keys[OB_KEY_SPACE] = obt_keyboard_keysym_to_keycode(XK_space);
{
- ObParseInst *i;
- xmlDocPtr doc;
- xmlNodePtr node;
+ ObtParseInst *i;
/* startup the parsing so everything can register sections
of the rc */
- i = parse_startup();
+ i = obt_parse_instance_new();
/* register all the available actions */
actions_startup(reconfigure);
config_startup(i);
/* parse/load user options */
- if (parse_load_rc(config_file, &doc, &node)) {
- parse_tree(i, doc, node->xmlChildrenNode);
- parse_close(doc);
+ if ((config_file &&
+ obt_parse_load_file(i, config_file, "openbox_config")) ||
+ obt_parse_load_config_file(i, "openbox", "rc.xml",
+ "openbox_config"))
+ {
+ obt_parse_tree_from_root(i);
+ obt_parse_close(i);
}
else {
g_message(_("Unable to find a valid config file, using some simple defaults"));
gchar *p = g_filename_to_utf8(config_file, -1,
NULL, NULL, NULL);
if (p)
- PROP_SETS(RootWindow(ob_display, ob_screen),
- ob_config_file, p);
+ OBT_PROP_SETS(obt_root(ob_screen), OB_CONFIG_FILE,
+ utf8, p);
g_free(p);
}
else
- PROP_ERASE(RootWindow(ob_display, ob_screen),
- ob_config_file);
+ OBT_PROP_ERASE(obt_root(ob_screen), OB_CONFIG_FILE);
/* we're done with parsing now, kill it */
- parse_shutdown(i);
+ obt_parse_instance_unref(i);
}
/* load the theme specified in the rc file */
if (ob_rr_theme == NULL)
ob_exit_with_error(_("Unable to load a theme."));
- PROP_SETS(RootWindow(ob_display, ob_screen),
- ob_theme, ob_rr_theme->name);
+ OBT_PROP_SETS(obt_root(ob_screen),
+ OB_THEME, utf8, ob_rr_theme->name);
}
if (reconfigure) {
ObWindow *w;
/* get all the existing windows */
- client_manage_all();
+ window_manage_all();
focus_nothing();
/* focus what was focused if a wm was already running */
- if (PROP_GET32(RootWindow(ob_display, ob_screen),
- net_active_window, window, &xid) &&
- (w = g_hash_table_lookup(window_map, &xid)) &&
- WINDOW_IS_CLIENT(w))
+ if (OBT_PROP_GET32(obt_root(ob_screen),
+ NET_ACTIVE_WINDOW, WINDOW, &xid) &&
+ (w = window_find(xid)) && WINDOW_IS_CLIENT(w))
{
client_focus(WINDOW_AS_CLIENT(w));
}
reconfigure = FALSE;
state = OB_STATE_RUNNING;
- ob_main_loop_run(ob_main_loop);
+ obt_main_loop_run(ob_main_loop);
state = OB_STATE_EXITING;
- if (!reconfigure) {
- dock_remove_all();
- client_unmanage_all();
- }
+ if (!reconfigure)
+ window_unmanage_all();
menu_shutdown(reconfigure);
menu_frame_shutdown(reconfigure);
event_shutdown(reconfigure);
config_shutdown();
actions_shutdown(reconfigure);
- modkeys_shutdown(reconfigure);
} while (reconfigure);
}
- XSync(ob_display, FALSE);
+ XSync(obt_display, FALSE);
RrThemeFree(ob_rr_theme);
+ RrImageCacheUnref(ob_rr_icons);
RrInstanceFree(ob_rr_inst);
session_shutdown(being_replaced);
- XCloseDisplay(ob_display);
-
- parse_paths_shutdown();
+ obt_display_close(obt_display);
if (restart) {
if (restart_path != NULL) {
g_free(ob_sm_id);
g_free(program_name);
+ ob_debug_shutdown();
+
return exitcode;
}
{
switch (signal) {
case SIGUSR1:
- ob_debug("Caught signal %d. Restarting.\n", signal);
+ ob_debug("Caught signal %d. Restarting.", signal);
ob_restart();
break;
case SIGUSR2:
- ob_debug("Caught signal %d. Reconfiguring.\n", signal);
+ ob_debug("Caught signal %d. Reconfiguring.", signal);
ob_reconfigure();
break;
case SIGCHLD:
while (waitpid(-1, NULL, WNOHANG) > 0);
break;
default:
- ob_debug("Caught signal %d. Exiting.\n", signal);
+ ob_debug("Caught signal %d. Exiting.", signal);
/* TERM and INT return a 0 code */
ob_exit(!(signal == SIGTERM || signal == SIGINT));
}
g_print(_(" --sync Run in synchronous mode\n"));
g_print(_(" --debug Display debugging output\n"));
g_print(_(" --debug-focus Display debugging output for focus handling\n"));
+ g_print(_(" --debug-session Display debugging output for session managment\n"));
g_print(_(" --debug-xinerama Split the display into fake xinerama screens\n"));
g_print(_("\nPlease report bugs at %s\n"), PACKAGE_BUGREPORT);
}
xsync = TRUE;
}
else if (!strcmp(argv[i], "--debug")) {
- ob_debug_show_output(TRUE);
- ob_debug_enable(OB_DEBUG_SM, TRUE);
+ ob_debug_enable(OB_DEBUG_NORMAL, TRUE);
ob_debug_enable(OB_DEBUG_APP_BUGS, TRUE);
}
else if (!strcmp(argv[i], "--debug-focus")) {
- ob_debug_show_output(TRUE);
- ob_debug_enable(OB_DEBUG_SM, TRUE);
+ ob_debug_enable(OB_DEBUG_NORMAL, TRUE);
ob_debug_enable(OB_DEBUG_APP_BUGS, TRUE);
ob_debug_enable(OB_DEBUG_FOCUS, TRUE);
}
+ else if (!strcmp(argv[i], "--debug-session")) {
+ ob_debug_enable(OB_DEBUG_NORMAL, TRUE);
+ ob_debug_enable(OB_DEBUG_APP_BUGS, TRUE);
+ ob_debug_enable(OB_DEBUG_SM, TRUE);
+ }
else if (!strcmp(argv[i], "--debug-xinerama")) {
ob_debug_xinerama = TRUE;
}
ob_sm_save_file = g_strdup(argv[i+1]);
remove_args(argc, argv, i, 2);
--i; /* this arg was removed so go back */
- ob_debug_type(OB_DEBUG_SM, "--sm-save-file %s\n",
+ ob_debug_type(OB_DEBUG_SM, "--sm-save-file %s",
ob_sm_save_file);
}
}
ob_sm_id = g_strdup(argv[i+1]);
remove_args(argc, argv, i, 2);
--i; /* this arg was removed so go back */
- ob_debug_type(OB_DEBUG_SM, "--sm-client-id %s\n", ob_sm_id);
+ ob_debug_type(OB_DEBUG_SM, "--sm-client-id %s", ob_sm_id);
}
}
else if (!strcmp(argv[i], "--sm-disable")) {
Cursor c = None;
#if USE_XCURSOR
- c = XcursorLibraryLoadCursor(ob_display, name);
+ c = XcursorLibraryLoadCursor(obt_display, name);
#endif
if (c == None)
- c = XCreateFontCursor(ob_display, fontval);
+ c = XCreateFontCursor(obt_display, fontval);
return c;
}
void ob_exit(gint code)
{
exitcode = code;
- ob_main_loop_exit(ob_main_loop);
+ obt_main_loop_exit(ob_main_loop);
}
void ob_exit_replace()
{
exitcode = 0;
being_replaced = TRUE;
- ob_main_loop_exit(ob_main_loop);
+ obt_main_loop_exit(ob_main_loop);
}
Cursor ob_cursor(ObCursor cursor)
#include "render/render.h"
#include "render/theme.h"
+#include "obt/mainloop.h"
+#include "obt/display.h"
#include <glib.h>
#include <X11/Xlib.h>
-struct _ObMainLoop;
-
extern RrInstance *ob_rr_inst;
+extern RrImageCache *ob_rr_icons;
extern RrTheme *ob_rr_theme;
-extern struct _ObMainLoop *ob_main_loop;
-
-/*! The X display */
-extern Display *ob_display;
+extern ObtMainLoop *ob_main_loop;
/*! The number of the screen on which we're running */
extern gint ob_screen;
#include "ping.h"
#include "client.h"
-#include "prop.h"
#include "event.h"
#include "debug.h"
-#include "mainloop.h"
#include "openbox.h"
+#include "obt/mainloop.h"
+#include "obt/prop.h"
typedef struct _ObPingTarget
{
t->client = client;
t->h = h;
- ob_main_loop_timeout_add(ob_main_loop, PING_TIMEOUT, ping_timeout,
- t, g_direct_equal, NULL);
+ obt_main_loop_timeout_add(ob_main_loop, PING_TIMEOUT, ping_timeout,
+ t, g_direct_equal, NULL);
/* act like we just timed out immediately, to start the pinging process
now instead of after the first delay. this makes sure the client
ends up in the ping_ids hash table now. */
ObPingTarget *t;
if ((t = g_hash_table_lookup(ping_ids, &id))) {
- /*ob_debug("-PONG: '%s' (id %u)\n", t->client->title, t->id);*/
+ /*ob_debug("-PONG: '%s' (id %u)", t->client->title, t->id);*/
if (t->waiting > PING_TIMEOUT_WARN) {
/* we had notified that they weren't responding, so now we
need to notify that they are again */
ping_end(t->client, NULL);
}
else
- ob_debug("Got PONG with id %u but not waiting for one\n", id);
+ ob_debug("Got PONG with id %u but not waiting for one", id);
}
static gboolean find_client(gpointer key, gpointer value, gpointer client)
g_hash_table_insert(ping_ids, &t->id, t);
}
- /*ob_debug("+PING: '%s' (id %u)\n", t->client->title, t->id);*/
- PROP_MSG_TO(t->client->window, t->client->window, wm_protocols,
- prop_atoms.net_wm_ping, t->id, t->client->window, 0, 0,
- NoEventMask);
+ /*ob_debug("+PING: '%s' (id %u)", t->client->title, t->id);*/
+ OBT_PROP_MSG_TO(t->client->window, t->client->window, WM_PROTOCOLS,
+ OBT_PROP_ATOM(NET_WM_PING), t->id, t->client->window, 0, 0,
+ NoEventMask);
}
static gboolean ping_timeout(gpointer data)
if ((t = g_hash_table_find(ping_ids, find_client, client))) {
g_hash_table_remove(ping_ids, &t->id);
- ob_main_loop_timeout_remove_data(ob_main_loop, ping_timeout, t, FALSE);
+ obt_main_loop_timeout_remove_data(ob_main_loop, ping_timeout,
+ t, FALSE);
g_free(t);
}
/* try direct parent first */
if ((p = client_direct_parent(c))) {
add_choice(choice, client_monitor(p));
- ob_debug("placement adding choice %d for parent\n",
+ ob_debug("placement adding choice %d for parent",
client_monitor(p));
}
itc->desktop == DESKTOP_ALL || c->desktop == DESKTOP_ALL))
{
add_choice(choice, client_monitor(it->data));
- ob_debug("placement adding choice %d for group sibling\n",
+ ob_debug("placement adding choice %d for group sibling",
client_monitor(it->data));
}
}
if (itc != c) {
add_choice(choice, client_monitor(it->data));
ob_debug("placement adding choice %d for group sibling on "
- "another desktop\n", client_monitor(it->data));
+ "another desktop", client_monitor(it->data));
}
}
}
config_place_monitor != OB_PLACE_MONITOR_MOUSE)
{
add_choice(choice, client_monitor(focus_client));
- ob_debug("placement adding choice %d for normal focused window\n",
+ ob_debug("placement adding choice %d for normal focused window",
client_monitor(focus_client));
}
g_free(monitor);
if (contain) {
add_choice(choice, i);
- ob_debug("placement adding choice %d for mouse pointer\n", i);
+ ob_debug("placement adding choice %d for mouse pointer", i);
break;
}
}
#include "stacking.h"
#include "event.h"
#include "screen.h"
-#include "mainloop.h"
#include "render/render.h"
#include "render/theme.h"
XSetWindowAttributes attrib;
ObPopup *self = g_new0(ObPopup, 1);
- self->obwin.type = Window_Internal;
+ self->obwin.type = OB_WINDOW_CLASS_INTERNAL;
self->gravity = NorthWestGravity;
self->x = self->y = self->textw = self->h = 0;
self->a_bg = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg);
self->iconwm = self->iconhm = 1;
attrib.override_redirect = True;
- self->bg = XCreateWindow(ob_display, RootWindow(ob_display, ob_screen),
+ self->bg = XCreateWindow(obt_display, obt_root(ob_screen),
0, 0, 1, 1, 0, RrDepth(ob_rr_inst),
InputOutput, RrVisual(ob_rr_inst),
CWOverrideRedirect, &attrib);
- self->text = XCreateWindow(ob_display, self->bg,
+ self->text = XCreateWindow(obt_display, self->bg,
0, 0, 1, 1, 0, RrDepth(ob_rr_inst),
InputOutput, RrVisual(ob_rr_inst), 0, NULL);
- XSetWindowBorderWidth(ob_display, self->bg, ob_rr_theme->obwidth);
- XSetWindowBorder(ob_display, self->bg,
+ XSetWindowBorderWidth(obt_display, self->bg, ob_rr_theme->obwidth);
+ XSetWindowBorder(obt_display, self->bg,
RrColorPixel(ob_rr_theme->osd_border_color));
- XMapWindow(ob_display, self->text);
+ XMapWindow(obt_display, self->text);
stacking_add(INTERNAL_AS_WINDOW(self));
- g_hash_table_insert(window_map, &self->bg, self);
+ window_add(&self->bg, INTERNAL_AS_WINDOW(self));
return self;
}
void popup_free(ObPopup *self)
{
if (self) {
- XDestroyWindow(ob_display, self->bg);
- XDestroyWindow(ob_display, self->text);
+ XDestroyWindow(obt_display, self->bg);
+ XDestroyWindow(obt_display, self->text);
RrAppearanceFree(self->a_bg);
RrAppearanceFree(self->a_text);
- g_hash_table_remove(window_map, &self->bg);
+ window_remove(self->bg);
stacking_remove(self);
g_free(self);
}
{
ObPopup *self = data;
- XMapWindow(ob_display, self->bg);
+ XMapWindow(obt_display, self->bg);
stacking_raise(INTERNAL_AS_WINDOW(self));
self->mapped = TRUE;
self->delay_mapped = FALSE;
}
/* set the windows/appearances up */
- XMoveResizeWindow(ob_display, self->bg, x, y, w, h);
+ XMoveResizeWindow(obt_display, self->bg, x, y, w, h);
/* when there is no icon and the text is not parent relative, then
fill the whole dialog with the text appearance, don't use the bg at all
*/
self->a_text->surface.parent = self->a_bg;
self->a_text->surface.parentx = textx;
self->a_text->surface.parenty = texty;
- XMoveResizeWindow(ob_display, self->text, textx, texty, textw, texth);
+ XMoveResizeWindow(obt_display, self->text, textx, texty, textw, texth);
RrPaint(self->a_text, self->text, textw, texth);
}
if (usec) {
/* don't kill previous show timers */
if (!self->delay_mapped) {
- ob_main_loop_timeout_add(ob_main_loop, usec,
- popup_show_timeout, self,
- g_direct_equal, NULL);
+ obt_main_loop_timeout_add(ob_main_loop, usec,
+ popup_show_timeout, self,
+ g_direct_equal, NULL);
self->delay_mapped = TRUE;
}
} else {
/* kill enter events cause by this unmapping */
ignore_start = event_start_ignore_all_enters();
- XUnmapWindow(ob_display, self->bg);
+ XUnmapWindow(obt_display, self->bg);
self->mapped = FALSE;
event_end_ignore_all_enters(ignore_start);
} else if (self->delay_mapped) {
- ob_main_loop_timeout_remove(ob_main_loop, popup_show_timeout);
+ obt_main_loop_timeout_remove(ob_main_loop, popup_show_timeout);
self->delay_mapped = FALSE;
}
}
self->a_icon->surface.parent = self->popup->a_bg;
self->a_icon->surface.parentx = x;
self->a_icon->surface.parenty = y;
- XMoveResizeWindow(ob_display, self->icon, x, y, w, h);
+ XMoveResizeWindow(obt_display, self->icon, x, y, w, h);
RrPaint(self->a_icon, self->icon, w, h);
}
self = g_new0(ObIconPopup, 1);
self->popup = popup_new();
self->a_icon = RrAppearanceCopy(ob_rr_theme->a_clear_tex);
- self->icon = XCreateWindow(ob_display, self->popup->bg,
+ self->icon = XCreateWindow(obt_display, self->popup->bg,
0, 0, 1, 1, 0,
RrDepth(ob_rr_inst), InputOutput,
RrVisual(ob_rr_inst), 0, NULL);
- XMapWindow(ob_display, self->icon);
+ XMapWindow(obt_display, self->icon);
self->popup->hasicon = TRUE;
self->popup->draw_icon = icon_popup_draw_icon;
void icon_popup_free(ObIconPopup *self)
{
if (self) {
- XDestroyWindow(ob_display, self->icon);
+ XDestroyWindow(obt_display, self->icon);
RrAppearanceFree(self->a_icon);
popup_free(self->popup);
g_free(self);
}
void icon_popup_delay_show(ObIconPopup *self, gulong usec,
- gchar *text, const ObClientIcon *icon)
+ gchar *text, RrImage *icon)
{
if (icon) {
- self->a_icon->texture[0].type = RR_TEXTURE_RGBA;
- self->a_icon->texture[0].data.rgba.width = icon->width;
- self->a_icon->texture[0].data.rgba.height = icon->height;
- self->a_icon->texture[0].data.rgba.alpha = 0xff;
- self->a_icon->texture[0].data.rgba.data = icon->data;
- } else
+ RrAppearanceClearTextures(self->a_icon);
+ self->a_icon->texture[0].type = RR_TEXTURE_IMAGE;
+ self->a_icon->texture[0].data.image.alpha = 0xff;
+ self->a_icon->texture[0].data.image.image = icon;
+ } else {
+ RrAppearanceClearTextures(self->a_icon);
self->a_icon->texture[0].type = RR_TEXTURE_NONE;
+ }
popup_delay_show(self->popup, usec, text);
}
a->surface.parent = self->popup->a_bg;
a->surface.parentx = x + px;
a->surface.parenty = y + py;
- XMoveResizeWindow(ob_display, self->wins[n],
+ XMoveResizeWindow(obt_display, self->wins[n],
x + px, y + py, eachw, eachh);
RrPaint(a, self->wins[n], eachw, eachh);
}
guint i;
for (i = 0; i < self->desks; ++i)
- XDestroyWindow(ob_display, self->wins[i]);
+ XDestroyWindow(obt_display, self->wins[i]);
g_free(self->wins);
RrAppearanceFree(self->hilight);
RrAppearanceFree(self->unhilight);
if (screen_num_desktops < self->desks)
for (i = screen_num_desktops; i < self->desks; ++i)
- XDestroyWindow(ob_display, self->wins[i]);
+ XDestroyWindow(obt_display, self->wins[i]);
if (screen_num_desktops != self->desks)
self->wins = g_renew(Window, self->wins, screen_num_desktops);
attr.border_pixel =
RrColorPixel(ob_rr_theme->osd_border_color);
- self->wins[i] = XCreateWindow(ob_display, self->popup->bg,
+ self->wins[i] = XCreateWindow(obt_display, self->popup->bg,
0, 0, 1, 1, ob_rr_theme->obwidth,
RrDepth(ob_rr_inst), InputOutput,
RrVisual(ob_rr_inst), CWBorderPixel,
&attr);
- XMapWindow(ob_display, self->wins[i]);
+ XMapWindow(obt_display, self->wins[i]);
}
self->desks = screen_num_desktops;
#define icon_popup_show(s, t, i) icon_popup_delay_show((s),0,(t),(i))
void icon_popup_delay_show(ObIconPopup *self, gulong usec,
- gchar *text, const struct _ObClientIcon *icon);
+ gchar *text, RrImage *icon);
#define icon_popup_hide(p) popup_hide((p)->popup)
#define icon_popup_position(p, g, x, y) popup_position((p)->popup,(g),(x),(y))
#define icon_popup_text_width(p, w) popup_text_width((p)->popup,(w))
#include "prompt.h"
#include "openbox.h"
#include "screen.h"
-#include "openbox.h"
#include "client.h"
-#include "prop.h"
-#include "modkeys.h"
#include "event.h"
+#include "obt/display.h"
+#include "obt/keyboard.h"
+#include "obt/prop.h"
#include "gettext.h"
static GList *prompt_list = NULL;
self->data = data;
self->default_result = default_result;
self->cancel_result = cancel_result;
- self->super.type = Window_Prompt;
- self->super.window = XCreateWindow(ob_display,
- RootWindow(ob_display, ob_screen),
+ self->super.type = OB_WINDOW_CLASS_PROMPT;
+ self->super.window = XCreateWindow(obt_display, obt_root(ob_screen),
0, 0, 1, 1, 0,
CopyFromParent, InputOutput,
CopyFromParent,
&attrib);
/* make it a dialog type window */
- PROP_SET32(self->super.window, net_wm_window_type, atom,
- prop_atoms.net_wm_window_type_dialog);
+ OBT_PROP_SET32(self->super.window, NET_WM_WINDOW_TYPE, ATOM,
+ OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DIALOG));
/* listen for key presses on the window */
self->event_mask = KeyPressMask;
/* set up the text message widow */
self->msg.text = g_strdup(msg);
- self->msg.window = XCreateWindow(ob_display, self->super.window,
+ self->msg.window = XCreateWindow(obt_display, self->super.window,
0, 0, 1, 1, 0,
CopyFromParent, InputOutput,
CopyFromParent, 0, NULL);
- XMapWindow(ob_display, self->msg.window);
+ XMapWindow(obt_display, self->msg.window);
/* set up the buttons from the answers */
}
for (i = 0; i < self->n_buttons; ++i) {
- self->button[i].window = XCreateWindow(ob_display, self->super.window,
+ self->button[i].window = XCreateWindow(obt_display, self->super.window,
0, 0, 1, 1, 0,
CopyFromParent, InputOutput,
CopyFromParent, 0, NULL);
- XMapWindow(ob_display, self->button[i].window);
- g_hash_table_insert(window_map, &self->button[i].window,
- PROMPT_AS_WINDOW(self));
+ XMapWindow(obt_display, self->button[i].window);
+ window_add(&self->button[i].window, PROMPT_AS_WINDOW(self));
/* listen for button presses on the buttons */
- XSelectInput(ob_display, self->button[i].window,
+ XSelectInput(obt_display, self->button[i].window,
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask);
}
prompt_list = g_list_remove(prompt_list, self);
for (i = 0; i < self->n_buttons; ++i) {
- g_hash_table_remove(window_map, &self->button[i].window);
- XDestroyWindow(ob_display, self->button[i].window);
+ window_remove(self->button[i].window);
+ XDestroyWindow(obt_display, self->button[i].window);
}
- XDestroyWindow(ob_display, self->msg.window);
- XDestroyWindow(ob_display, self->super.window);
+ XDestroyWindow(obt_display, self->msg.window);
+ XDestroyWindow(obt_display, self->super.window);
g_free(self);
}
}
prompt_resize(self, w + l + r, h + t + b);
/* move and resize the internal windows */
- XMoveResizeWindow(ob_display, self->msg.window,
+ XMoveResizeWindow(obt_display, self->msg.window,
self->msg.x, self->msg.y,
self->msg.width, self->msg.height);
for (i = 0; i < self->n_buttons; ++i)
- XMoveResizeWindow(ob_display, self->button[i].window,
+ XMoveResizeWindow(obt_display, self->button[i].window,
self->button[i].x, self->button[i].y,
self->button[i].width, self->button[i].height);
}
hints.flags = PMinSize | PMaxSize;
hints.min_width = hints.max_width = w;
hints.min_height = hints.max_height = h;
- XSetWMNormalHints(ob_display, self->super.window, &hints);
+ XSetWMNormalHints(obt_display, self->super.window, &hints);
if (self->mapped) {
/* send a configure request like a normal client would */
req.type = ConfigureRequest;
- req.display = ob_display;
- req.parent = RootWindow(ob_display, ob_screen);
+ req.display = obt_display;
+ req.parent = obt_root(ob_screen);
req.window = self->super.window;
req.width = w;
req.height = h;
(XEvent*)&req);
}
else
- XResizeWindow(ob_display, self->super.window, w, h);
+ XResizeWindow(obt_display, self->super.window, w, h);
}
static void setup_button_focus_tex(ObPromptElement *e, RrAppearance *a,
if (self->mapped) {
/* activate the prompt */
- PROP_MSG(self->super.window, net_active_window,
- 1, /* from an application.. */
- event_curtime,
- 0,
- 0);
+ OBT_PROP_MSG(ob_screen, self->super.window, NET_ACTIVE_WINDOW,
+ 1, /* from an application.. */
+ event_curtime,
+ 0,
+ 0, 0);
return;
}
break;
}
- XSetTransientForHint(ob_display, self->super.window,
+ XSetTransientForHint(obt_display, self->super.window,
(parent ? parent->window : 0));
/* set up the dialog and render it */
void prompt_hide(ObPrompt *self)
{
- XUnmapWindow(ob_display, self->super.window);
+ XUnmapWindow(obt_display, self->super.window);
self->mapped = FALSE;
}
if (e->type != KeyPress) return FALSE;
- g_print("key 0x%x 0x%x\n", e->xkey.keycode, ob_keycode(OB_KEY_TAB));
-
- shift_mask = modkeys_key_to_mask(OB_MODKEY_KEY_SHIFT);
+ shift_mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SHIFT);
shift = !!(e->xkey.state & shift_mask);
/* only accept shift */
struct _ObPrompt
{
- InternalWindow super;
+ ObInternalWindow super;
gint ref;
guint event_mask;
See the COPYING file for a copy of the GNU General Public License.
*/
+#include "resist.h"
#include "client.h"
#include "frame.h"
#include "stacking.h"
#include "screen.h"
#include "dock.h"
#include "config.h"
-#include "resist.h"
-#include "parser/parse.h"
#include <glib.h>
#ifndef ob__resist_h
#define ob__resist_h
-struct _ObClient;
+#include "misc.h"
#include <glib.h>
+struct _ObClient;
+
/*! @x The client's x destination (in the client's coordinates, not the frame's
@y The client's y destination (in the client's coordinates, not the frame's
*/
#include "debug.h"
#include "openbox.h"
#include "dock.h"
-#include "xerror.h"
-#include "prop.h"
#include "grab.h"
#include "startupnotify.h"
#include "moveresize.h"
#include "config.h"
-#include "mainloop.h"
#include "screen.h"
#include "client.h"
#include "session.h"
#include "event.h"
#include "focus.h"
#include "popup.h"
-#include "extensions.h"
#include "render/render.h"
#include "gettext.h"
+#include "obt/display.h"
+#include "obt/prop.h"
+#include "obt/mainloop.h"
#include <X11/Xlib.h>
#ifdef HAVE_UNISTD_H
Time timestamp;
wm_sn = g_strdup_printf("WM_S%d", ob_screen);
- wm_sn_atom = XInternAtom(ob_display, wm_sn, FALSE);
+ wm_sn_atom = XInternAtom(obt_display, wm_sn, FALSE);
g_free(wm_sn);
- current_wm_sn_owner = XGetSelectionOwner(ob_display, wm_sn_atom);
+ current_wm_sn_owner = XGetSelectionOwner(obt_display, wm_sn_atom);
if (current_wm_sn_owner == screen_support_win)
current_wm_sn_owner = None;
if (current_wm_sn_owner) {
ob_screen);
return FALSE;
}
- xerror_set_ignore(TRUE);
- xerror_occured = FALSE;
+ obt_display_ignore_errors(TRUE);
/* We want to find out when the current selection owner dies */
- XSelectInput(ob_display, current_wm_sn_owner, StructureNotifyMask);
- XSync(ob_display, FALSE);
+ XSelectInput(obt_display, current_wm_sn_owner, StructureNotifyMask);
+ XSync(obt_display, FALSE);
- xerror_set_ignore(FALSE);
- if (xerror_occured)
+ obt_display_ignore_errors(FALSE);
+ if (obt_display_error_occured)
current_wm_sn_owner = None;
}
timestamp = event_get_server_time();
- XSetSelectionOwner(ob_display, wm_sn_atom, screen_support_win,
+ XSetSelectionOwner(obt_display, wm_sn_atom, screen_support_win,
timestamp);
- if (XGetSelectionOwner(ob_display, wm_sn_atom) != screen_support_win) {
+ if (XGetSelectionOwner(obt_display, wm_sn_atom) != screen_support_win) {
g_message(_("Could not acquire window manager selection on screen %d"),
ob_screen);
return FALSE;
const gulong timeout = G_USEC_PER_SEC * 15; /* wait for 15s max */
while (wait < timeout) {
- if (XCheckWindowEvent(ob_display, current_wm_sn_owner,
+ if (XCheckWindowEvent(obt_display, current_wm_sn_owner,
StructureNotifyMask, &event) &&
event.type == DestroyNotify)
break;
}
/* Send client message indicating that we are now the WM */
- prop_message(RootWindow(ob_display, ob_screen), prop_atoms.manager,
- timestamp, wm_sn_atom, screen_support_win, 0,
- SubstructureNotifyMask);
+ obt_prop_message(ob_screen, obt_root(ob_screen), OBT_PROP_ATOM(MANAGER),
+ timestamp, wm_sn_atom, screen_support_win, 0, 0,
+ SubstructureNotifyMask);
return TRUE;
}
XSetWindowAttributes attrib;
pid_t pid;
gint i, num_support;
- Atom *prop_atoms_start, *wm_supported_pos;
gulong *supported;
/* create the netwm support window */
attrib.override_redirect = TRUE;
attrib.event_mask = PropertyChangeMask;
- screen_support_win = XCreateWindow(ob_display,
- RootWindow(ob_display, ob_screen),
+ screen_support_win = XCreateWindow(obt_display, obt_root(ob_screen),
-100, -100, 1, 1, 0,
CopyFromParent, InputOutput,
CopyFromParent,
CWEventMask | CWOverrideRedirect,
&attrib);
- XMapWindow(ob_display, screen_support_win);
- XLowerWindow(ob_display, screen_support_win);
+ XMapWindow(obt_display, screen_support_win);
+ XLowerWindow(obt_display, screen_support_win);
if (!replace_wm()) {
- XDestroyWindow(ob_display, screen_support_win);
+ XDestroyWindow(obt_display, screen_support_win);
return FALSE;
}
- xerror_set_ignore(TRUE);
- xerror_occured = FALSE;
- XSelectInput(ob_display, RootWindow(ob_display, ob_screen),
- ROOT_EVENTMASK);
- xerror_set_ignore(FALSE);
- if (xerror_occured) {
+ obt_display_ignore_errors(TRUE);
+ XSelectInput(obt_display, obt_root(ob_screen), ROOT_EVENTMASK);
+ obt_display_ignore_errors(FALSE);
+ if (obt_display_error_occured) {
g_message(_("A window manager is already running on screen %d"),
ob_screen);
- XDestroyWindow(ob_display, screen_support_win);
+ XDestroyWindow(obt_display, screen_support_win);
return FALSE;
}
/* set the OPENBOX_PID hint */
pid = getpid();
- PROP_SET32(RootWindow(ob_display, ob_screen),
- openbox_pid, cardinal, pid);
+ OBT_PROP_SET32(obt_root(ob_screen), OPENBOX_PID, CARDINAL, pid);
/* set supporting window */
- PROP_SET32(RootWindow(ob_display, ob_screen),
- net_supporting_wm_check, window, screen_support_win);
+ OBT_PROP_SET32(obt_root(ob_screen),
+ NET_SUPPORTING_WM_CHECK, WINDOW, screen_support_win);
/* set properties on the supporting window */
- PROP_SETS(screen_support_win, net_wm_name, "Openbox");
- PROP_SET32(screen_support_win, net_supporting_wm_check,
- window, screen_support_win);
+ OBT_PROP_SETS(screen_support_win, NET_WM_NAME, utf8, "Openbox");
+ OBT_PROP_SET32(screen_support_win, NET_SUPPORTING_WM_CHECK,
+ WINDOW, screen_support_win);
/* set the _NET_SUPPORTED_ATOMS hint */
- /* this is all the atoms after net_supported in the prop_atoms struct */
- prop_atoms_start = (Atom*)&prop_atoms;
- wm_supported_pos = (Atom*)&(prop_atoms.net_supported);
- num_support = sizeof(prop_atoms) / sizeof(Atom) -
- (wm_supported_pos - prop_atoms_start) - 1;
+ /* this is all the atoms after NET_SUPPORTED in the ObtPropAtoms enum */
+ num_support = OBT_PROP_NUM_ATOMS - OBT_PROP_NET_SUPPORTED - 1;
i = 0;
supported = g_new(gulong, num_support);
- supported[i++] = prop_atoms.net_supporting_wm_check;
- supported[i++] = prop_atoms.net_wm_full_placement;
- supported[i++] = prop_atoms.net_current_desktop;
- supported[i++] = prop_atoms.net_number_of_desktops;
- supported[i++] = prop_atoms.net_desktop_geometry;
- supported[i++] = prop_atoms.net_desktop_viewport;
- supported[i++] = prop_atoms.net_active_window;
- supported[i++] = prop_atoms.net_workarea;
- supported[i++] = prop_atoms.net_client_list;
- supported[i++] = prop_atoms.net_client_list_stacking;
- supported[i++] = prop_atoms.net_desktop_names;
- supported[i++] = prop_atoms.net_close_window;
- supported[i++] = prop_atoms.net_desktop_layout;
- supported[i++] = prop_atoms.net_showing_desktop;
- supported[i++] = prop_atoms.net_wm_name;
- supported[i++] = prop_atoms.net_wm_visible_name;
- supported[i++] = prop_atoms.net_wm_icon_name;
- supported[i++] = prop_atoms.net_wm_visible_icon_name;
- supported[i++] = prop_atoms.net_wm_desktop;
- supported[i++] = prop_atoms.net_wm_strut;
- supported[i++] = prop_atoms.net_wm_strut_partial;
- supported[i++] = prop_atoms.net_wm_icon;
- supported[i++] = prop_atoms.net_wm_icon_geometry;
- supported[i++] = prop_atoms.net_wm_window_type;
- supported[i++] = prop_atoms.net_wm_window_type_desktop;
- supported[i++] = prop_atoms.net_wm_window_type_dock;
- supported[i++] = prop_atoms.net_wm_window_type_toolbar;
- supported[i++] = prop_atoms.net_wm_window_type_menu;
- supported[i++] = prop_atoms.net_wm_window_type_utility;
- supported[i++] = prop_atoms.net_wm_window_type_splash;
- supported[i++] = prop_atoms.net_wm_window_type_dialog;
- supported[i++] = prop_atoms.net_wm_window_type_normal;
- supported[i++] = prop_atoms.net_wm_allowed_actions;
- supported[i++] = prop_atoms.net_wm_action_move;
- supported[i++] = prop_atoms.net_wm_action_resize;
- supported[i++] = prop_atoms.net_wm_action_minimize;
- supported[i++] = prop_atoms.net_wm_action_shade;
- supported[i++] = prop_atoms.net_wm_action_maximize_horz;
- supported[i++] = prop_atoms.net_wm_action_maximize_vert;
- supported[i++] = prop_atoms.net_wm_action_fullscreen;
- supported[i++] = prop_atoms.net_wm_action_change_desktop;
- supported[i++] = prop_atoms.net_wm_action_close;
- supported[i++] = prop_atoms.net_wm_action_above;
- supported[i++] = prop_atoms.net_wm_action_below;
- supported[i++] = prop_atoms.net_wm_state;
- supported[i++] = prop_atoms.net_wm_state_modal;
- supported[i++] = prop_atoms.net_wm_state_maximized_vert;
- supported[i++] = prop_atoms.net_wm_state_maximized_horz;
- supported[i++] = prop_atoms.net_wm_state_shaded;
- supported[i++] = prop_atoms.net_wm_state_skip_taskbar;
- supported[i++] = prop_atoms.net_wm_state_skip_pager;
- supported[i++] = prop_atoms.net_wm_state_hidden;
- supported[i++] = prop_atoms.net_wm_state_fullscreen;
- supported[i++] = prop_atoms.net_wm_state_above;
- supported[i++] = prop_atoms.net_wm_state_below;
- supported[i++] = prop_atoms.net_wm_state_demands_attention;
- supported[i++] = prop_atoms.net_moveresize_window;
- supported[i++] = prop_atoms.net_wm_moveresize;
- supported[i++] = prop_atoms.net_wm_user_time;
+ supported[i++] = OBT_PROP_ATOM(NET_SUPPORTING_WM_CHECK);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_FULL_PLACEMENT);
+ supported[i++] = OBT_PROP_ATOM(NET_CURRENT_DESKTOP);
+ supported[i++] = OBT_PROP_ATOM(NET_NUMBER_OF_DESKTOPS);
+ supported[i++] = OBT_PROP_ATOM(NET_DESKTOP_GEOMETRY);
+ supported[i++] = OBT_PROP_ATOM(NET_DESKTOP_VIEWPORT);
+ supported[i++] = OBT_PROP_ATOM(NET_ACTIVE_WINDOW);
+ supported[i++] = OBT_PROP_ATOM(NET_WORKAREA);
+ supported[i++] = OBT_PROP_ATOM(NET_CLIENT_LIST);
+ supported[i++] = OBT_PROP_ATOM(NET_CLIENT_LIST_STACKING);
+ supported[i++] = OBT_PROP_ATOM(NET_DESKTOP_NAMES);
+ supported[i++] = OBT_PROP_ATOM(NET_CLOSE_WINDOW);
+ supported[i++] = OBT_PROP_ATOM(NET_DESKTOP_LAYOUT);
+ supported[i++] = OBT_PROP_ATOM(NET_SHOWING_DESKTOP);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_NAME);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_VISIBLE_NAME);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ICON_NAME);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_VISIBLE_ICON_NAME);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_DESKTOP);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STRUT);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STRUT_PARTIAL);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ICON);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ICON_GEOMETRY);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DESKTOP);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DOCK);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_TOOLBAR);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_MENU);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_UTILITY);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_SPLASH);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DIALOG);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_NORMAL);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ALLOWED_ACTIONS);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_MOVE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_RESIZE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_MINIMIZE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_SHADE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_MAXIMIZE_HORZ);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_MAXIMIZE_VERT);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_FULLSCREEN);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_CHANGE_DESKTOP);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_CLOSE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_ABOVE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_BELOW);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_MODAL);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_SHADED);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_HIDDEN);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_ABOVE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_BELOW);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION);
+ supported[i++] = OBT_PROP_ATOM(NET_MOVERESIZE_WINDOW);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_MOVERESIZE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_USER_TIME);
/*
- supported[i++] = prop_atoms.net_wm_user_time_window;
+ supported[i++] = OBT_PROP_ATOM(NET_WM_USER_TIME_WINDOW);
*/
- supported[i++] = prop_atoms.net_frame_extents;
- supported[i++] = prop_atoms.net_request_frame_extents;
- supported[i++] = prop_atoms.net_restack_window;
- supported[i++] = prop_atoms.net_startup_id;
+ supported[i++] = OBT_PROP_ATOM(NET_FRAME_EXTENTS);
+ supported[i++] = OBT_PROP_ATOM(NET_REQUEST_FRAME_EXTENTS);
+ supported[i++] = OBT_PROP_ATOM(NET_RESTACK_WINDOW);
+ supported[i++] = OBT_PROP_ATOM(NET_STARTUP_ID);
#ifdef SYNC
- supported[i++] = prop_atoms.net_wm_sync_request;
- supported[i++] = prop_atoms.net_wm_sync_request_counter;
+ supported[i++] = OBT_PROP_ATOM(NET_WM_SYNC_REQUEST);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_SYNC_REQUEST_COUNTER);
#endif
- supported[i++] = prop_atoms.net_wm_pid;
- supported[i++] = prop_atoms.net_wm_ping;
-
- supported[i++] = prop_atoms.kde_wm_change_state;
- supported[i++] = prop_atoms.kde_net_wm_frame_strut;
- supported[i++] = prop_atoms.kde_net_wm_window_type_override;
-
- supported[i++] = prop_atoms.ob_wm_action_undecorate;
- supported[i++] = prop_atoms.ob_wm_state_undecorated;
- supported[i++] = prop_atoms.openbox_pid;
- supported[i++] = prop_atoms.ob_theme;
- supported[i++] = prop_atoms.ob_config_file;
- supported[i++] = prop_atoms.ob_control;
+ supported[i++] = OBT_PROP_ATOM(NET_WM_PID);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_PING);
+
+ supported[i++] = OBT_PROP_ATOM(KDE_WM_CHANGE_STATE);
+ supported[i++] = OBT_PROP_ATOM(KDE_NET_WM_FRAME_STRUT);
+ supported[i++] = OBT_PROP_ATOM(KDE_NET_WM_WINDOW_TYPE_OVERRIDE);
+
+ supported[i++] = OBT_PROP_ATOM(OB_WM_ACTION_UNDECORATE);
+ supported[i++] = OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED);
+ supported[i++] = OBT_PROP_ATOM(OPENBOX_PID);
+ supported[i++] = OBT_PROP_ATOM(OB_THEME);
+ supported[i++] = OBT_PROP_ATOM(OB_CONFIG_FILE);
+ supported[i++] = OBT_PROP_ATOM(OB_CONTROL);
g_assert(i == num_support);
- PROP_SETA32(RootWindow(ob_display, ob_screen),
- net_supported, atom, supported, num_support);
+ OBT_PROP_SETA32(obt_root(ob_screen),
+ NET_SUPPORTED, ATOM, supported, num_support);
g_free(supported);
screen_tell_ksplash();
hear it anyways. perhaps it is for old ksplash. or new ksplash. or
something. oh well. */
e.xclient.type = ClientMessage;
- e.xclient.display = ob_display;
- e.xclient.window = RootWindow(ob_display, ob_screen);
+ e.xclient.display = obt_display;
+ e.xclient.window = obt_root(ob_screen);
e.xclient.message_type =
- XInternAtom(ob_display, "_KDE_SPLASH_PROGRESS", False );
+ XInternAtom(obt_display, "_KDE_SPLASH_PROGRESS", False );
e.xclient.format = 8;
strcpy(e.xclient.data.b, "wm started");
- XSendEvent(ob_display, RootWindow(ob_display, ob_screen),
- False, SubstructureNotifyMask, &e );
+ XSendEvent(obt_display, obt_root(ob_screen),
+ False, SubstructureNotifyMask, &e);
}
void screen_startup(gboolean reconfig)
screen_resize();
/* have names already been set for the desktops? */
- if (PROP_GETSS(RootWindow(ob_display, ob_screen),
- net_desktop_names, utf8, &names))
- {
+ if (OBT_PROP_GETSS(obt_root(ob_screen), NET_DESKTOP_NAMES, utf8, &names)) {
g_strfreev(names);
namesexist = TRUE;
}
names[i] = g_strdup(it->data);
/* set the root window property */
- PROP_SETSS(RootWindow(ob_display, ob_screen), net_desktop_names,names);
+ OBT_PROP_SETSS(obt_root(ob_screen),
+ NET_DESKTOP_NAMES, utf8, (const gchar**)names);
g_strfreev(names);
}
this will also set the default names from the config file up for
desktops that don't have names yet */
screen_num_desktops = 0;
- if (PROP_GET32(RootWindow(ob_display, ob_screen),
- net_number_of_desktops, cardinal, &d))
+ if (OBT_PROP_GET32(obt_root(ob_screen),
+ NET_NUMBER_OF_DESKTOPS, CARDINAL, &d))
{
if (d != config_desktops_num) {
g_warning(_("Openbox is configured for %d desktops, but the current session has %d. Overriding the Openbox configuration."),
screen_desktop = screen_num_desktops; /* something invalid */
/* start on the current desktop when a wm was already running */
- if (PROP_GET32(RootWindow(ob_display, ob_screen),
- net_current_desktop, cardinal, &d) &&
+ if (OBT_PROP_GET32(obt_root(ob_screen),
+ NET_CURRENT_DESKTOP, CARDINAL, &d) &&
d < screen_num_desktops)
{
screen_set_desktop(d, FALSE);
/* don't start in showing-desktop mode */
screen_showing_desktop = FALSE;
- PROP_SET32(RootWindow(ob_display, ob_screen),
- net_showing_desktop, cardinal, screen_showing_desktop);
+ OBT_PROP_SET32(obt_root(ob_screen),
+ NET_SHOWING_DESKTOP, CARDINAL, screen_showing_desktop);
if (session_desktop_layout_present &&
screen_validate_layout(&session_desktop_layout))
if (reconfig)
return;
- XSelectInput(ob_display, RootWindow(ob_display, ob_screen),
- NoEventMask);
+ XSelectInput(obt_display, obt_root(ob_screen), NoEventMask);
/* we're not running here no more! */
- PROP_ERASE(RootWindow(ob_display, ob_screen), openbox_pid);
+ OBT_PROP_ERASE(obt_root(ob_screen), OPENBOX_PID);
/* not without us */
- PROP_ERASE(RootWindow(ob_display, ob_screen), net_supported);
+ OBT_PROP_ERASE(obt_root(ob_screen), NET_SUPPORTED);
/* don't keep this mode */
- PROP_ERASE(RootWindow(ob_display, ob_screen), net_showing_desktop);
+ OBT_PROP_ERASE(obt_root(ob_screen), NET_SHOWING_DESKTOP);
- XDestroyWindow(ob_display, screen_support_win);
+ XDestroyWindow(obt_display, screen_support_win);
g_strfreev(screen_desktop_names);
screen_desktop_names = NULL;
GList *it;
gulong geometry[2];
- w = WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen));
- h = HeightOfScreen(ScreenOfDisplay(ob_display, ob_screen));
+ w = WidthOfScreen(ScreenOfDisplay(obt_display, ob_screen));
+ h = HeightOfScreen(ScreenOfDisplay(obt_display, ob_screen));
if (w == oldw && h == oldh) return;
/* Set the _NET_DESKTOP_GEOMETRY hint */
screen_physical_size.width = geometry[0] = w;
screen_physical_size.height = geometry[1] = h;
- PROP_SETA32(RootWindow(ob_display, ob_screen),
- net_desktop_geometry, cardinal, geometry, 2);
+ OBT_PROP_SETA32(obt_root(ob_screen),
+ NET_DESKTOP_GEOMETRY, CARDINAL, geometry, 2);
if (ob_state() == OB_STATE_STARTING)
return;
old = screen_num_desktops;
screen_num_desktops = num;
- PROP_SET32(RootWindow(ob_display, ob_screen),
- net_number_of_desktops, cardinal, num);
+ OBT_PROP_SET32(obt_root(ob_screen), NET_NUMBER_OF_DESKTOPS, CARDINAL, num);
/* set the viewport hint */
viewport = g_new0(gulong, num * 2);
- PROP_SETA32(RootWindow(ob_display, ob_screen),
- net_desktop_viewport, cardinal, viewport, num * 2);
+ OBT_PROP_SETA32(obt_root(ob_screen),
+ NET_DESKTOP_VIEWPORT, CARDINAL, viewport, num * 2);
g_free(viewport);
/* the number of rows/columns will differ */
if (previous == num) return;
- PROP_SET32(RootWindow(ob_display, ob_screen),
- net_current_desktop, cardinal, num);
+ OBT_PROP_SET32(obt_root(ob_screen), NET_CURRENT_DESKTOP, CARDINAL, num);
/* This whole thing decides when/how to save the screen_last_desktop so
that it can be restored later if you want */
}
}
screen_desktop_timeout = FALSE;
- ob_main_loop_timeout_remove(ob_main_loop, last_desktop_func);
- ob_main_loop_timeout_add(ob_main_loop, REMEMBER_LAST_DESKTOP_TIME,
- last_desktop_func, NULL, NULL, NULL);
+ obt_main_loop_timeout_remove(ob_main_loop, last_desktop_func);
+ obt_main_loop_timeout_add(ob_main_loop, REMEMBER_LAST_DESKTOP_TIME,
+ last_desktop_func, NULL, NULL, NULL);
- ob_debug("Moving to desktop %d\n", num+1);
+ ob_debug("Moving to desktop %d", num+1);
/* ignore enter events caused by the move */
ignore_start = event_start_ignore_all_enters();
parent - which will have to be on the same desktop */
!client_direct_parent(c))
{
- ob_debug("moving window %s\n", c->title);
+ ob_debug("moving window %s", c->title);
client_set_desktop(c, c->desktop+1, FALSE, TRUE);
}
}
parent - which will have to be on the same desktop */
!client_direct_parent(c))
{
- ob_debug("moving window %s\n", c->title);
+ ob_debug("moving window %s", c->title);
client_set_desktop(c, c->desktop - 1, TRUE, TRUE);
}
/* raise all the windows that are on the current desktop which
(d == DESKTOP_ALL || d == screen_desktop))
{
stacking_raise(CLIENT_AS_WINDOW(c));
- ob_debug("raising window %s\n", c->title);
+ ob_debug("raising window %s", c->title);
}
}
}
/* fallback focus like we're changing desktops */
if (screen_desktop < screen_num_desktops - 1) {
screen_fallback_focus();
- ob_debug("fake desktop change\n");
+ ob_debug("fake desktop change");
}
screen_set_num_desktops(screen_num_desktops-1);
MAX(a->width/3, POPUP_WIDTH));
pager_popup_show(desktop_popup, screen_desktop_names[d], d);
- ob_main_loop_timeout_remove(ob_main_loop, hide_desktop_popup_func);
- ob_main_loop_timeout_add(ob_main_loop, config_desktop_popup_time * 1000,
- hide_desktop_popup_func, NULL, NULL, NULL);
+ obt_main_loop_timeout_remove(ob_main_loop, hide_desktop_popup_func);
+ obt_main_loop_timeout_add(ob_main_loop, config_desktop_popup_time * 1000,
+ hide_desktop_popup_func, NULL, NULL, NULL);
g_free(a);
}
void screen_hide_desktop_popup(void)
{
- ob_main_loop_timeout_remove(ob_main_loop, hide_desktop_popup_func);
+ obt_main_loop_timeout_remove(ob_main_loop, hide_desktop_popup_func);
pager_popup_hide(desktop_popup);
}
screen_desktop_layout.rows = 1;
screen_desktop_layout.columns = screen_num_desktops;
- if (PROP_GETA32(RootWindow(ob_display, ob_screen),
- net_desktop_layout, cardinal, &data, &num)) {
+ if (OBT_PROP_GETA32(obt_root(ob_screen),
+ NET_DESKTOP_LAYOUT, CARDINAL, &data, &num)) {
if (num == 3 || num == 4) {
- if (data[0] == prop_atoms.net_wm_orientation_vert)
+ if (data[0] == OBT_PROP_ATOM(NET_WM_ORIENTATION_VERT))
l.orientation = OB_ORIENTATION_VERT;
- else if (data[0] == prop_atoms.net_wm_orientation_horz)
+ else if (data[0] == OBT_PROP_ATOM(NET_WM_ORIENTATION_HORZ))
l.orientation = OB_ORIENTATION_HORZ;
else
return;
if (num < 4)
l.start_corner = OB_CORNER_TOPLEFT;
else {
- if (data[3] == prop_atoms.net_wm_topleft)
+ if (data[3] == OBT_PROP_ATOM(NET_WM_TOPLEFT))
l.start_corner = OB_CORNER_TOPLEFT;
- else if (data[3] == prop_atoms.net_wm_topright)
+ else if (data[3] == OBT_PROP_ATOM(NET_WM_TOPRIGHT))
l.start_corner = OB_CORNER_TOPRIGHT;
- else if (data[3] == prop_atoms.net_wm_bottomright)
+ else if (data[3] == OBT_PROP_ATOM(NET_WM_BOTTOMRIGHT))
l.start_corner = OB_CORNER_BOTTOMRIGHT;
- else if (data[3] == prop_atoms.net_wm_bottomleft)
+ else if (data[3] == OBT_PROP_ATOM(NET_WM_BOTTOMLEFT))
l.start_corner = OB_CORNER_BOTTOMLEFT;
else
return;
g_strfreev(screen_desktop_names);
screen_desktop_names = NULL;
- if (PROP_GETSS(RootWindow(ob_display, ob_screen),
- net_desktop_names, utf8, &screen_desktop_names))
+ if (OBT_PROP_GETSS(obt_root(ob_screen),
+ NET_DESKTOP_NAMES, utf8, &screen_desktop_names))
for (i = 0; screen_desktop_names[i] && i < screen_num_desktops; ++i);
else
i = 0;
/* if we changed any names, then set the root property so we can
all agree on the names */
- PROP_SETSS(RootWindow(ob_display, ob_screen), net_desktop_names,
- screen_desktop_names);
+ OBT_PROP_SETSS(obt_root(ob_screen), NET_DESKTOP_NAMES,
+ utf8, (const gchar**)screen_desktop_names);
}
/* resize the pager for these names */
}
show = !!show; /* make it boolean */
- PROP_SET32(RootWindow(ob_display, ob_screen),
- net_showing_desktop, cardinal, show);
+ OBT_PROP_SET32(obt_root(ob_screen), NET_SHOWING_DESKTOP, CARDINAL, show);
}
void screen_install_colormap(ObClient *client, gboolean install)
{
if (client == NULL || client->colormap == None) {
if (install)
- XInstallColormap(RrDisplay(ob_rr_inst), RrColormap(ob_rr_inst));
+ XInstallColormap(obt_display, RrColormap(ob_rr_inst));
else
- XUninstallColormap(RrDisplay(ob_rr_inst), RrColormap(ob_rr_inst));
+ XUninstallColormap(obt_display, RrColormap(ob_rr_inst));
} else {
- xerror_set_ignore(TRUE);
+ obt_display_ignore_errors(TRUE);
if (install)
- XInstallColormap(RrDisplay(ob_rr_inst), client->colormap);
+ XInstallColormap(obt_display, client->colormap);
else
- XUninstallColormap(RrDisplay(ob_rr_inst), client->colormap);
- xerror_set_ignore(FALSE);
+ XUninstallColormap(obt_display, client->colormap);
+ obt_display_ignore_errors(FALSE);
}
}
} \
}
+static void get_xinerama_screens(Rect **xin_areas, guint *nxin)
+{
+ guint i;
+ gint l, r, t, b;
+
+ if (ob_debug_xinerama) {
+ gint w = WidthOfScreen(ScreenOfDisplay(obt_display, ob_screen));
+ gint h = HeightOfScreen(ScreenOfDisplay(obt_display, ob_screen));
+ *nxin = 2;
+ *xin_areas = g_new(Rect, *nxin + 1);
+ RECT_SET((*xin_areas)[0], 0, 0, w/2, h);
+ RECT_SET((*xin_areas)[1], w/2, 0, w-(w/2), h);
+ }
+#ifdef XINERAMA
+ else if (obt_display_extension_xinerama) {
+ guint i;
+ gint n;
+ XineramaScreenInfo *info = XineramaQueryScreens(obt_display, &n);
+ *nxin = n;
+ *xin_areas = g_new(Rect, *nxin + 1);
+ for (i = 0; i < *nxin; ++i)
+ RECT_SET((*xin_areas)[i], info[i].x_org, info[i].y_org,
+ info[i].width, info[i].height);
+ XFree(info);
+ }
+#endif
+ else {
+ *nxin = 1;
+ *xin_areas = g_new(Rect, *nxin + 1);
+ RECT_SET((*xin_areas)[0], 0, 0,
+ WidthOfScreen(ScreenOfDisplay(obt_display, ob_screen)),
+ HeightOfScreen(ScreenOfDisplay(obt_display, ob_screen)));
+ }
+
+ /* returns one extra with the total area in it */
+ l = (*xin_areas)[0].x;
+ t = (*xin_areas)[0].y;
+ r = (*xin_areas)[0].x + (*xin_areas)[0].width - 1;
+ b = (*xin_areas)[0].y + (*xin_areas)[0].height - 1;
+ for (i = 1; i < *nxin; ++i) {
+ l = MIN(l, (*xin_areas)[i].x);
+ t = MIN(l, (*xin_areas)[i].y);
+ r = MAX(r, (*xin_areas)[i].x + (*xin_areas)[i].width - 1);
+ b = MAX(b, (*xin_areas)[i].y + (*xin_areas)[i].height - 1);
+ }
+ RECT_SET((*xin_areas)[*nxin], l, t, r - l + 1, b - t + 1);
+}
+
void screen_update_areas(void)
{
guint i, j;
GSList *sit;
g_free(monitor_area);
- extensions_xinerama_screens(&monitor_area, &screen_num_monitors);
+ get_xinerama_screens(&monitor_area, &screen_num_monitors);
/* set up the user-specified margins */
config_margins.top_start = RECT_LEFT(monitor_area[screen_num_monitors]);
/* all the work areas are not used here, only the ones for the first
monitor are */
- PROP_SETA32(RootWindow(ob_display, ob_screen), net_workarea, cardinal,
- dims, 4 * screen_num_desktops);
+ OBT_PROP_SETA32(obt_root(ob_screen), NET_WORKAREA, CARDINAL,
+ dims, 4 * screen_num_desktops);
/* the area has changed, adjust all the windows if they need it */
for (it = client_list; it; it = g_list_next(it))
void screen_set_root_cursor(void)
{
if (sn_app_starting())
- XDefineCursor(ob_display, RootWindow(ob_display, ob_screen),
+ XDefineCursor(obt_display, obt_root(ob_screen),
ob_cursor(OB_CURSOR_BUSYPOINTER));
else
- XDefineCursor(ob_display, RootWindow(ob_display, ob_screen),
+ XDefineCursor(obt_display, obt_root(ob_screen),
ob_cursor(OB_CURSOR_POINTER));
}
guint u;
gboolean ret;
- ret = !!XQueryPointer(ob_display, RootWindow(ob_display, ob_screen),
+ ret = !!XQueryPointer(obt_display, obt_root(ob_screen),
&w, &w, x, y, &i, &i, &u);
if (!ret) {
- for (i = 0; i < ScreenCount(ob_display); ++i)
+ for (i = 0; i < ScreenCount(obt_display); ++i)
if (i != ob_screen)
- if (XQueryPointer(ob_display, RootWindow(ob_display, i),
+ if (XQueryPointer(obt_display, obt_root(i),
&w, &w, x, y, &i, &i, &u))
break;
}
#include "debug.h"
#include "openbox.h"
#include "client.h"
-#include "prop.h"
#include "focus.h"
#include "gettext.h"
-#include "parser/parse.h"
+#include "obt/parse.h"
+#include "obt/paths.h"
#include <time.h>
#include <errno.h>
void session_startup(gint argc, gchar **argv)
{
gchar *dir;
+ ObtPaths *p;
if (!ob_sm_use) return;
sm_argc = argc;
sm_argv = argv;
- dir = g_build_filename(parse_xdg_data_home_path(),
+ p = obt_paths_new();
+ dir = g_build_filename(obt_paths_cache_home(p),
"openbox", "sessions", NULL);
- if (!parse_mkdir_path(dir, 0700)) {
+ obt_paths_unref(p), p = NULL;
+
+ if (!obt_paths_mkdir_path(dir, 0700)) {
g_message(_("Unable to make directory '%s': %s"),
dir, g_strerror(errno));
}
if (ob_sm_save_file != NULL) {
if (ob_sm_restore) {
- ob_debug_type(OB_DEBUG_SM, "Loading from session file %s\n",
+ ob_debug_type(OB_DEBUG_SM, "Loading from session file %s",
ob_sm_save_file);
session_load_file(ob_sm_save_file);
}
/* connect to the server */
oldid = ob_sm_id;
- ob_debug_type(OB_DEBUG_SM, "Connecting to SM with id: %s\n",
+ ob_debug_type(OB_DEBUG_SM, "Connecting to SM with id: %s",
oldid ? oldid : "(null)");
sm_conn = SmcOpenConnection(NULL, NULL, 1, 0,
SmcSaveYourselfProcMask |
&cb, oldid, &ob_sm_id,
SM_ERR_LEN-1, sm_err);
g_free(oldid);
- ob_debug_type(OB_DEBUG_SM, "Connected to SM with id: %s\n", ob_sm_id);
+ ob_debug_type(OB_DEBUG_SM, "Connected to SM with id: %s", ob_sm_id);
if (sm_conn == NULL)
- ob_debug("Failed to connect to session manager: %s\n", sm_err);
+ ob_debug("Failed to connect to session manager: %s", sm_err);
return sm_conn != NULL;
}
.vals = &vals
};
SmProp *list = ∝
- ob_debug_type(OB_DEBUG_SM, "Setting program: %s\n", sm_argv[0]);
+ ob_debug_type(OB_DEBUG_SM, "Setting program: %s", sm_argv[0]);
SmcSetProperties(sm_conn, 1, &list);
g_free(prop.name);
g_free(prop.type);
.vals = &vals
};
SmProp *list = ∝
- ob_debug_type(OB_DEBUG_SM, "Setting user: %s\n", user);
+ ob_debug_type(OB_DEBUG_SM, "Setting user: %s", user);
SmcSetProperties(sm_conn, 1, &list);
g_free(prop.name);
g_free(prop.type);
.vals = &vals
};
SmProp *list = ∝
- ob_debug_type(OB_DEBUG_SM, "Setting restart: %d\n", restart);
+ ob_debug_type(OB_DEBUG_SM, "Setting restart: %d", restart);
SmcSetProperties(sm_conn, 1, &list);
g_free(prop.name);
g_free(prop.type);
.vals = &vals
};
SmProp *list = ∝
- ob_debug_type(OB_DEBUG_SM, "Setting pid: %s\n", pid);
+ ob_debug_type(OB_DEBUG_SM, "Setting pid: %s", pid);
SmcSetProperties(sm_conn, 1, &list);
g_free(prop.name);
g_free(prop.type);
.vals = &vals
};
SmProp *list = ∝
- ob_debug_type(OB_DEBUG_SM, "Setting priority: %d\n", priority);
+ ob_debug_type(OB_DEBUG_SM, "Setting priority: %d", priority);
SmcSetProperties(sm_conn, 1, &list);
g_free(prop.name);
g_free(prop.type);
};
SmProp *list = ∝
- ob_debug_type(OB_DEBUG_SM, "Setting clone command: (%d)\n", sm_argc);
+ ob_debug_type(OB_DEBUG_SM, "Setting clone command: (%d)", sm_argc);
for (i = 0; i < sm_argc; ++i) {
vals[i].value = sm_argv[i];
vals[i].length = strlen(sm_argv[i]) + 1;
- ob_debug_type(OB_DEBUG_SM, " %s\n", vals[i].value);
+ ob_debug_type(OB_DEBUG_SM, " %s", vals[i].value);
}
SmcSetProperties(sm_conn, 1, &list);
};
SmProp *list = ∝
- ob_debug_type(OB_DEBUG_SM, "Setting restart command: (%d)\n", sm_argc+4);
+ ob_debug_type(OB_DEBUG_SM, "Setting restart command: (%d)", sm_argc+4);
for (i = 0; i < sm_argc; ++i) {
vals[i].value = sm_argv[i];
vals[i].length = strlen(sm_argv[i]) + 1;
- ob_debug_type(OB_DEBUG_SM, " %s\n", vals[i].value);
+ ob_debug_type(OB_DEBUG_SM, " %s", vals[i].value);
}
vals[i].value = g_strdup("--sm-client-id");
vals[i].length = strlen("--sm-client-id") + 1;
vals[i+1].value = ob_sm_id;
vals[i+1].length = strlen(ob_sm_id) + 1;
- ob_debug_type(OB_DEBUG_SM, " %s\n", vals[i].value);
- ob_debug_type(OB_DEBUG_SM, " %s\n", vals[i+1].value);
+ ob_debug_type(OB_DEBUG_SM, " %s", vals[i].value);
+ ob_debug_type(OB_DEBUG_SM, " %s", vals[i+1].value);
vals[i+2].value = g_strdup("--sm-save-file");
vals[i+2].length = strlen("--sm-save-file") + 1;
vals[i+3].value = ob_sm_save_file;
vals[i+3].length = strlen(ob_sm_save_file) + 1;
- ob_debug_type(OB_DEBUG_SM, " %s\n", vals[i+2].value);
- ob_debug_type(OB_DEBUG_SM, " %s\n", vals[i+3].value);
+ ob_debug_type(OB_DEBUG_SM, " %s", vals[i+2].value);
+ ob_debug_type(OB_DEBUG_SM, " %s", vals[i+3].value);
SmcSetProperties(sm_conn, 1, &list);
g_free(prop.name);
ObSMSaveData *savedata = data;
/* save the current state */
- ob_debug_type(OB_DEBUG_SM, "Session save phase 2 requested\n");
+ ob_debug_type(OB_DEBUG_SM, "Session save phase 2 requested");
ob_debug_type(OB_DEBUG_SM,
- " Saving session to file '%s'\n", ob_sm_save_file);
+ " Saving session to file '%s'", ob_sm_save_file);
if (savedata == NULL)
savedata = sm_save_get_data();
success = session_save_to_file(savedata);
/* tell the session manager how to restore this state */
if (success) session_setup_restart_command();
- ob_debug_type(OB_DEBUG_SM, "Saving is done (success = %d)\n", success);
+ ob_debug_type(OB_DEBUG_SM, "Saving is done (success = %d)", success);
SmcSaveYourselfDone(conn, success);
}
ObSMSaveData *savedata = NULL;
gchar *vendor;
- ob_debug_type(OB_DEBUG_SM, "Session save requested\n");
+ ob_debug_type(OB_DEBUG_SM, "Session save requested");
vendor = SmcVendor(sm_conn);
- ob_debug_type(OB_DEBUG_SM, "Session manager's vendor: %s\n", vendor);
+ ob_debug_type(OB_DEBUG_SM, "Session manager's vendor: %s", vendor);
if (!strcmp(vendor, "KDE")) {
/* ksmserver guarantees that phase 1 will complete before allowing any
free(vendor);
if (!SmcRequestSaveYourselfPhase2(conn, sm_save_yourself_2, savedata)) {
- ob_debug_type(OB_DEBUG_SM, "Requst for phase 2 failed\n");
+ ob_debug_type(OB_DEBUG_SM, "Requst for phase 2 failed");
g_free(savedata);
SmcSaveYourselfDone(conn, FALSE);
}
static void sm_die(SmcConn conn, SmPointer data)
{
- ob_debug_type(OB_DEBUG_SM, "Die requested\n");
+ ob_debug_type(OB_DEBUG_SM, "Die requested");
ob_exit(0);
}
static void sm_save_complete(SmcConn conn, SmPointer data)
{
- ob_debug_type(OB_DEBUG_SM, "Save complete\n");
+ ob_debug_type(OB_DEBUG_SM, "Save complete");
}
static void sm_shutdown_cancelled(SmcConn conn, SmPointer data)
{
- ob_debug_type(OB_DEBUG_SM, "Shutdown cancelled\n");
+ ob_debug_type(OB_DEBUG_SM, "Shutdown cancelled");
}
static gboolean session_save_to_file(const ObSMSaveData *savedata)
if (!c->sm_client_id) {
ob_debug_type(OB_DEBUG_SM, "Client %s does not have a "
- "session id set\n",
+ "session id set",
c->title);
if (!c->wm_command) {
ob_debug_type(OB_DEBUG_SM, "Client %s does not have an "
"oldskool wm_command set either. We won't "
- "be saving its data\n",
+ "be saving its data",
c->title);
continue;
}
}
- ob_debug_type(OB_DEBUG_SM, "Saving state for client %s\n",
+ ob_debug_type(OB_DEBUG_SM, "Saving state for client %s",
c->title);
prex = c->area.x;
static gboolean session_state_cmp(ObSessionState *s, ObClient *c)
{
- ob_debug_type(OB_DEBUG_SM, "Comparing client against saved state: \n");
- ob_debug_type(OB_DEBUG_SM, " client id: %s \n", c->sm_client_id);
- ob_debug_type(OB_DEBUG_SM, " client name: %s \n", c->name);
- ob_debug_type(OB_DEBUG_SM, " client class: %s \n", c->class);
- ob_debug_type(OB_DEBUG_SM, " client role: %s \n", c->role);
- ob_debug_type(OB_DEBUG_SM, " client type: %d \n", c->type);
- ob_debug_type(OB_DEBUG_SM, " client command: %s \n",
+ ob_debug_type(OB_DEBUG_SM, "Comparing client against saved state: ");
+ ob_debug_type(OB_DEBUG_SM, " client id: %s ", c->sm_client_id);
+ ob_debug_type(OB_DEBUG_SM, " client name: %s ", c->name);
+ ob_debug_type(OB_DEBUG_SM, " client class: %s ", c->class);
+ ob_debug_type(OB_DEBUG_SM, " client role: %s ", c->role);
+ ob_debug_type(OB_DEBUG_SM, " client type: %d ", c->type);
+ ob_debug_type(OB_DEBUG_SM, " client command: %s ",
c->wm_command ? c->wm_command : "(null)");
- ob_debug_type(OB_DEBUG_SM, " state id: %s \n", s->id);
- ob_debug_type(OB_DEBUG_SM, " state name: %s \n", s->name);
- ob_debug_type(OB_DEBUG_SM, " state class: %s \n", s->class);
- ob_debug_type(OB_DEBUG_SM, " state role: %s \n", s->role);
- ob_debug_type(OB_DEBUG_SM, " state type: %d \n", s->type);
- ob_debug_type(OB_DEBUG_SM, " state command: %s \n",
+ ob_debug_type(OB_DEBUG_SM, " state id: %s ", s->id);
+ ob_debug_type(OB_DEBUG_SM, " state name: %s ", s->name);
+ ob_debug_type(OB_DEBUG_SM, " state class: %s ", s->class);
+ ob_debug_type(OB_DEBUG_SM, " state role: %s ", s->role);
+ ob_debug_type(OB_DEBUG_SM, " state type: %d ", s->type);
+ ob_debug_type(OB_DEBUG_SM, " state command: %s ",
s->command ? s->command : "(null)");
if ((c->sm_client_id && s->id && !strcmp(c->sm_client_id, s->id)) ||
static void session_load_file(const gchar *path)
{
- xmlDocPtr doc;
+ ObtParseInst *i;
xmlNodePtr node, n, m;
GList *it, *inext;
- if (!parse_load(path, "openbox_session", &doc, &node))
+ i = obt_parse_instance_new();
+
+ if (!obt_parse_load_file(i, path, "openbox_session")) {
+ obt_parse_instance_unref(i);
return;
+ }
+ node = obt_parse_root(i);
- if ((n = parse_find_node("desktop", node->children)))
- session_desktop = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node->children, "desktop")))
+ session_desktop = obt_parse_node_int(n);
- if ((n = parse_find_node("numdesktops", node->children)))
- session_num_desktops = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node->children, "numdesktops")))
+ session_num_desktops = obt_parse_node_int(n);
- if ((n = parse_find_node("desktoplayout", node->children))) {
+ if ((n = obt_parse_find_node(node->children, "desktoplayout"))) {
/* make sure they are all there for it to be valid */
- if ((m = parse_find_node("orientation", n->children)))
- session_desktop_layout.orientation = parse_int(doc, m);
- if (m && (m = parse_find_node("startcorner", n->children)))
- session_desktop_layout.start_corner = parse_int(doc, m);
- if (m && (m = parse_find_node("columns", n->children)))
- session_desktop_layout.columns = parse_int(doc, m);
- if (m && (m = parse_find_node("rows", n->children)))
- session_desktop_layout.rows = parse_int(doc, m);
+ if ((m = obt_parse_find_node(n->children, "orientation")))
+ session_desktop_layout.orientation = obt_parse_node_int(m);
+ if (m && (m = obt_parse_find_node(n->children, "startcorner")))
+ session_desktop_layout.start_corner = obt_parse_node_int(m);
+ if (m && (m = obt_parse_find_node(n->children, "columns")))
+ session_desktop_layout.columns = obt_parse_node_int(m);
+ if (m && (m = obt_parse_find_node(n->children, "rows")))
+ session_desktop_layout.rows = obt_parse_node_int(m);
session_desktop_layout_present = m != NULL;
}
- if ((n = parse_find_node("desktopnames", node->children))) {
- for (m = parse_find_node("name", n->children); m;
- m = parse_find_node("name", m->next))
+ if ((n = obt_parse_find_node(node->children, "desktopnames"))) {
+ for (m = obt_parse_find_node(n->children, "name"); m;
+ m = obt_parse_find_node(m->next, "name"))
{
session_desktop_names = g_slist_append(session_desktop_names,
- parse_string(doc, m));
+ obt_parse_node_string(m));
}
}
- for (node = parse_find_node("window", node->children); node != NULL;
- node = parse_find_node("window", node->next))
+ for (node = obt_parse_find_node(node->children, "window"); node != NULL;
+ node = obt_parse_find_node(node->next, "window"))
{
ObSessionState *state;
state = g_new0(ObSessionState, 1);
- if (!parse_attr_string("id", node, &state->id))
- if (!parse_attr_string("command", node, &state->command))
+ if (!obt_parse_attr_string(node, "id", &state->id))
+ if (!obt_parse_attr_string(node, "command", &state->command))
goto session_load_bail;
- if (!(n = parse_find_node("name", node->children)))
+ if (!(n = obt_parse_find_node(node->children, "name")))
goto session_load_bail;
- state->name = parse_string(doc, n);
- if (!(n = parse_find_node("class", node->children)))
+ state->name = obt_parse_node_string(n);
+ if (!(n = obt_parse_find_node(node->children, "class")))
goto session_load_bail;
- state->class = parse_string(doc, n);
- if (!(n = parse_find_node("role", node->children)))
+ state->class = obt_parse_node_string(n);
+ if (!(n = obt_parse_find_node(node->children, "role")))
goto session_load_bail;
- state->role = parse_string(doc, n);
- if (!(n = parse_find_node("windowtype", node->children)))
+ state->role = obt_parse_node_string(n);
+ if (!(n = obt_parse_find_node(node->children, "windowtype")))
goto session_load_bail;
- state->type = parse_int(doc, n);
- if (!(n = parse_find_node("desktop", node->children)))
+ state->type = obt_parse_node_int(n);
+ if (!(n = obt_parse_find_node(node->children, "desktop")))
goto session_load_bail;
- state->desktop = parse_int(doc, n);
- if (!(n = parse_find_node("x", node->children)))
+ state->desktop = obt_parse_node_int(n);
+ if (!(n = obt_parse_find_node(node->children, "x")))
goto session_load_bail;
- state->x = parse_int(doc, n);
- if (!(n = parse_find_node("y", node->children)))
+ state->x = obt_parse_node_int(n);
+ if (!(n = obt_parse_find_node(node->children, "y")))
goto session_load_bail;
- state->y = parse_int(doc, n);
- if (!(n = parse_find_node("width", node->children)))
+ state->y = obt_parse_node_int(n);
+ if (!(n = obt_parse_find_node(node->children, "width")))
goto session_load_bail;
- state->w = parse_int(doc, n);
- if (!(n = parse_find_node("height", node->children)))
+ state->w = obt_parse_node_int(n);
+ if (!(n = obt_parse_find_node(node->children, "height")))
goto session_load_bail;
- state->h = parse_int(doc, n);
+ state->h = obt_parse_node_int(n);
state->shaded =
- parse_find_node("shaded", node->children) != NULL;
+ obt_parse_find_node(node->children, "shaded") != NULL;
state->iconic =
- parse_find_node("iconic", node->children) != NULL;
+ obt_parse_find_node(node->children, "iconic") != NULL;
state->skip_pager =
- parse_find_node("skip_pager", node->children) != NULL;
+ obt_parse_find_node(node->children, "skip_pager") != NULL;
state->skip_taskbar =
- parse_find_node("skip_taskbar", node->children) != NULL;
+ obt_parse_find_node(node->children, "skip_taskbar") != NULL;
state->fullscreen =
- parse_find_node("fullscreen", node->children) != NULL;
+ obt_parse_find_node(node->children, "fullscreen") != NULL;
state->above =
- parse_find_node("above", node->children) != NULL;
+ obt_parse_find_node(node->children, "above") != NULL;
state->below =
- parse_find_node("below", node->children) != NULL;
+ obt_parse_find_node(node->children, "below") != NULL;
state->max_horz =
- parse_find_node("max_horz", node->children) != NULL;
+ obt_parse_find_node(node->children, "max_horz") != NULL;
state->max_vert =
- parse_find_node("max_vert", node->children) != NULL;
+ obt_parse_find_node(node->children, "max_vert") != NULL;
state->undecorated =
- parse_find_node("undecorated", node->children) != NULL;
+ obt_parse_find_node(node->children, "undecorated") != NULL;
state->focused =
- parse_find_node("focused", node->children) != NULL;
+ obt_parse_find_node(node->children, "focused") != NULL;
/* save this. they are in the file in stacking order, so preserve
that order here */
}
}
- xmlFreeDoc(doc);
+ obt_parse_instance_unref(i);
}
#endif
*/
#include "openbox.h"
-#include "prop.h"
#include "screen.h"
#include "focus.h"
#include "client.h"
#include "window.h"
#include "event.h"
#include "debug.h"
+#include "obt/prop.h"
GList *stacking_list = NULL;
/*! When true, stacking changes will not be reflected on the screen. This is
}
}
- PROP_SETA32(RootWindow(ob_display, ob_screen),
- net_client_list_stacking, window, (gulong*)windows, i);
+ OBT_PROP_SETA32(obt_root(ob_screen), NET_CLIENT_LIST_STACKING, WINDOW,
+ (gulong*)windows, i);
g_free(windows);
}
#endif
if (!pause_changes)
- XRestackWindows(ob_display, win, i);
+ XRestackWindows(obt_display, win, i);
g_free(win);
stacking_set_list();
win[1] = window_top(window);
start = event_start_ignore_all_enters();
- XRestackWindows(ob_display, win, 2);
+ XRestackWindows(obt_display, win, 2);
event_end_ignore_all_enters(start);
pause_changes = TRUE;
for (i = 1, it = stacking_list; it; ++i, it = g_list_next(it))
win[i] = window_top(it->data);
start = event_start_ignore_all_enters();
- XRestackWindows(ob_display, win, i);
+ XRestackWindows(obt_display, win, i);
event_end_ignore_all_enters(start);
g_free(win);
sibling->iconic))
{
ob_debug("Setting restack sibling to NULL, they are not on the same "
- "desktop or it is iconified\n");
+ "desktop or it is iconified");
sibling = NULL;
}
switch (detail) {
case Below:
- ob_debug("Restack request Below for client %s sibling %s\n",
+ ob_debug("Restack request Below for client %s sibling %s",
client->title, sibling ? sibling->title : "(all)");
/* just lower it */
stacking_lower(CLIENT_AS_WINDOW(client));
ret = TRUE;
break;
case BottomIf:
- ob_debug("Restack request BottomIf for client %s sibling "
- "%s\n",
+ ob_debug("Restack request BottomIf for client %s sibling %s",
client->title, sibling ? sibling->title : "(all)");
/* if this client occludes sibling (or anything if NULL), then
lower it to the bottom */
}
break;
case Above:
- ob_debug("Restack request Above for client %s sibling %s\n",
+ ob_debug("Restack request Above for client %s sibling %s",
client->title, sibling ? sibling->title : "(all)");
stacking_raise(CLIENT_AS_WINDOW(client));
ret = TRUE;
break;
case TopIf:
- ob_debug("Restack request TopIf for client %s sibling %s\n",
+ ob_debug("Restack request TopIf for client %s sibling %s",
client->title, sibling ? sibling->title : "(all)");
if (stacking_occluded(client, sibling)) {
stacking_raise(CLIENT_AS_WINDOW(client));
}
break;
case Opposite:
- ob_debug("Restack request Opposite for client %s sibling "
- "%s\n",
+ ob_debug("Restack request Opposite for client %s sibling %s",
client->title, sibling ? sibling->title : "(all)");
if (stacking_occluded(client, sibling)) {
stacking_raise(CLIENT_AS_WINDOW(client));
#else
#include "openbox.h"
-#include "mainloop.h"
#include "screen.h"
#define SN_API_NOT_YET_FROZEN
{
if (reconfig) return;
- sn_display = sn_display_new(ob_display, NULL, NULL);
+ sn_display = sn_display_new(obt_display, NULL, NULL);
sn_context = sn_monitor_context_new(sn_display, ob_screen,
sn_event_func, NULL, NULL);
sn_launcher = sn_launcher_context_new(sn_display, ob_screen);
- ob_main_loop_x_add(ob_main_loop, sn_handler, NULL, NULL);
+ obt_main_loop_x_add(ob_main_loop, sn_handler, NULL, NULL);
}
void sn_shutdown(gboolean reconfig)
if (reconfig) return;
- ob_main_loop_x_remove(ob_main_loop, sn_handler);
+ obt_main_loop_x_remove(ob_main_loop, sn_handler);
for (it = sn_waits; it; it = g_slist_next(it))
sn_startup_sequence_unref((SnStartupSequence*)it->data);
sn_waits = g_slist_prepend(sn_waits, seq);
/* 20 second timeout for apps to start if the launcher doesn't
have a timeout */
- ob_main_loop_timeout_add(ob_main_loop, 20 * G_USEC_PER_SEC,
- sn_wait_timeout, seq,
- g_direct_equal,
- (GDestroyNotify)sn_startup_sequence_unref);
+ obt_main_loop_timeout_add(ob_main_loop, 20 * G_USEC_PER_SEC,
+ sn_wait_timeout, seq,
+ g_direct_equal,
+ (GDestroyNotify)sn_startup_sequence_unref);
change = TRUE;
break;
case SN_MONITOR_EVENT_CHANGED:
case SN_MONITOR_EVENT_CANCELED:
if ((seq = sequence_find(sn_startup_sequence_get_id(seq)))) {
sn_waits = g_slist_remove(sn_waits, seq);
- ob_main_loop_timeout_remove_data(ob_main_loop, sn_wait_timeout,
- seq, FALSE);
+ obt_main_loop_timeout_remove_data(ob_main_loop, sn_wait_timeout,
+ seq, FALSE);
change = TRUE;
}
break;
/* 20 second timeout for apps to start */
sn_launcher_context_ref(sn_launcher);
- ob_main_loop_timeout_add(ob_main_loop, 20 * G_USEC_PER_SEC,
- sn_launch_wait_timeout, sn_launcher,
- g_direct_equal,
- (GDestroyNotify)sn_launcher_context_unref);
+ obt_main_loop_timeout_add(ob_main_loop, 20 * G_USEC_PER_SEC,
+ sn_launch_wait_timeout, sn_launcher,
+ g_direct_equal,
+ (GDestroyNotify)sn_launcher_context_unref);
setenv("DESKTOP_STARTUP_ID", id, TRUE);
#include "openbox.h"
#include "mouse.h"
-#include "modkeys.h"
-#include "translate.h"
#include "gettext.h"
+#include "obt/keyboard.h"
+
#include <glib.h>
#include <string.h>
#include <stdlib.h>
else if (!g_ascii_strcasecmp("Control", str) ||
!g_ascii_strcasecmp("C", str))
- mask = modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL);
+ mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CONTROL);
else if (!g_ascii_strcasecmp("Alt", str) ||
!g_ascii_strcasecmp("A", str))
- mask = modkeys_key_to_mask(OB_MODKEY_KEY_ALT);
+ mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_ALT);
else if (!g_ascii_strcasecmp("Meta", str) ||
!g_ascii_strcasecmp("M", str))
- mask = modkeys_key_to_mask(OB_MODKEY_KEY_META);
+ mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_META);
/* W = windows key, is linked to the Super_L/R buttons */
else if (!g_ascii_strcasecmp("Super", str) ||
!g_ascii_strcasecmp("W", str))
- mask = modkeys_key_to_mask(OB_MODKEY_KEY_SUPER);
+ mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SUPER);
else if (!g_ascii_strcasecmp("Shift", str) ||
!g_ascii_strcasecmp("S", str))
- mask = modkeys_key_to_mask(OB_MODKEY_KEY_SHIFT);
+ mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SHIFT);
else if (!g_ascii_strcasecmp("Hyper", str) ||
!g_ascii_strcasecmp("H", str))
- mask = modkeys_key_to_mask(OB_MODKEY_KEY_HYPER);
+ mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_HYPER);
else
g_message(_("Invalid modifier key '%s' in key/mouse binding"), str);
g_message(_("Invalid key name '%s' in key binding"), l);
goto translation_fail;
}
- *keycode = XKeysymToKeycode(ob_display, sym);
+ *keycode = XKeysymToKeycode(obt_display, sym);
}
if (!*keycode) {
g_message(_("Requested key '%s' does not exist on the display"), l);
g_strfreev(parsed);
return ret;
}
-
-gchar *translate_keycode(guint keycode)
-{
- KeySym sym;
- const gchar *ret = NULL;
-
- if ((sym = XKeycodeToKeysym(ob_display, keycode, 0)) != NoSymbol)
- ret = XKeysymToString(sym);
- return g_locale_to_utf8(ret, -1, NULL, NULL, NULL);
-}
-
-gunichar translate_unichar(guint keycode)
-{
- gunichar unikey = 0;
-
- char *key;
- if ((key = translate_keycode(keycode)) != NULL &&
- /* don't accept keys that aren't a single letter, like "space" */
- key[1] == '\0')
- {
- unikey = g_utf8_get_char_validated(key, -1);
- if (unikey == (gunichar)-1 || unikey == (gunichar)-2 || unikey == 0)
- unikey = 0;
- }
- g_free(key);
- return unikey;
-}
gboolean translate_button(const gchar *str, guint *state, guint *keycode);
gboolean translate_key(const gchar *str, guint *state, guint *keycode);
-/*! Give the string form of a keycode */
-gchar *translate_keycode(guint keycode);
-
-/*! Translate a keycode to the unicode character it represents */
-gunichar translate_unichar(guint keycode);
-
#endif
#include "dock.h"
#include "client.h"
#include "frame.h"
+#include "openbox.h"
#include "prompt.h"
+#include "debug.h"
+#include "grab.h"
-GHashTable *window_map;
+static GHashTable *window_map;
static guint window_hash(Window *w) { return *w; }
static gboolean window_comp(Window *w1, Window *w2) { return *w1 == *w2; }
Window window_top(ObWindow *self)
{
switch (self->type) {
- case Window_Menu:
- return ((ObMenuFrame*)self)->window;
- case Window_Dock:
- return ((ObDock*)self)->frame;
- case Window_DockApp:
- /* not to be used for stacking */
- g_assert_not_reached();
- break;
- case Window_Client:
- return ((ObClient*)self)->frame->window;
- case Window_Internal:
- return ((InternalWindow*)self)->window;
- case Window_Prompt:
- return ((ObPrompt*)self)->super.window;
+ case OB_WINDOW_CLASS_MENUFRAME:
+ return WINDOW_AS_MENUFRAME(self)->window;
+ case OB_WINDOW_CLASS_DOCK:
+ return WINDOW_AS_DOCK(self)->frame;
+ case OB_WINDOW_CLASS_CLIENT:
+ return WINDOW_AS_CLIENT(self)->frame->window;
+ case OB_WINDOW_CLASS_INTERNAL:
+ return WINDOW_AS_INTERNAL(self)->window;
+ case OB_WINDOW_CLASS_PROMPT:
+ return WINDOW_AS_PROMPT(self)->super.window;
}
g_assert_not_reached();
return None;
ObStackingLayer window_layer(ObWindow *self)
{
switch (self->type) {
- case Window_Menu:
- return OB_STACKING_LAYER_INTERNAL;
- case Window_Dock:
+ case OB_WINDOW_CLASS_DOCK:
return config_dock_layer;
- case Window_DockApp:
- /* not to be used for stacking */
- g_assert_not_reached();
- break;
- case Window_Client:
+ case OB_WINDOW_CLASS_CLIENT:
return ((ObClient*)self)->layer;
- case Window_Internal:
+ case OB_WINDOW_CLASS_MENUFRAME:
+ case OB_WINDOW_CLASS_INTERNAL:
return OB_STACKING_LAYER_INTERNAL;
- case Window_Prompt:
+ case OB_WINDOW_CLASS_PROMPT:
/* not used directly for stacking, prompts are managed as clients */
g_assert_not_reached();
break;
g_assert_not_reached();
return None;
}
+
+ObWindow* window_find(Window xwin)
+{
+ return g_hash_table_lookup(window_map, &xwin);
+}
+
+void window_add(Window *xwin, ObWindow *win)
+{
+ g_assert(xwin != NULL);
+ g_assert(win != NULL);
+ g_hash_table_insert(window_map, xwin, win);
+}
+
+void window_remove(Window xwin)
+{
+ g_assert(xwin != None);
+ g_hash_table_remove(window_map, &xwin);
+}
+
+void window_manage_all(void)
+{
+ guint i, j, nchild;
+ Window w, *children;
+ XWMHints *wmhints;
+ XWindowAttributes attrib;
+
+ if (!XQueryTree(obt_display, RootWindow(obt_display, ob_screen),
+ &w, &w, &children, &nchild)) {
+ ob_debug("XQueryTree failed in window_manage_all");
+ nchild = 0;
+ }
+
+ /* remove all icon windows from the list */
+ for (i = 0; i < nchild; i++) {
+ if (children[i] == None) continue;
+ wmhints = XGetWMHints(obt_display, children[i]);
+ if (wmhints) {
+ if ((wmhints->flags & IconWindowHint) &&
+ (wmhints->icon_window != children[i]))
+ for (j = 0; j < nchild; j++)
+ if (children[j] == wmhints->icon_window) {
+ /* XXX watch the window though */
+ children[j] = None;
+ break;
+ }
+ XFree(wmhints);
+ }
+ }
+
+ for (i = 0; i < nchild; ++i) {
+ if (children[i] == None) continue;
+ if (window_find(children[i])) continue; /* skip our own windows */
+ if (XGetWindowAttributes(obt_display, children[i], &attrib)) {
+ if (attrib.map_state == IsUnmapped)
+ ;
+ else
+ window_manage(children[i]);
+ }
+ }
+
+ if (children) XFree(children);
+}
+
+void window_manage(Window win)
+{
+ XEvent e;
+ XWindowAttributes attrib;
+ gboolean no_manage = FALSE;
+ gboolean is_dockapp = FALSE;
+ Window icon_win = None;
+
+ grab_server(TRUE);
+
+ /* check if it has already been unmapped by the time we started
+ mapping. the grab does a sync so we don't have to here */
+ if (XCheckTypedWindowEvent(obt_display, win, DestroyNotify, &e) ||
+ XCheckTypedWindowEvent(obt_display, win, UnmapNotify, &e))
+ {
+ XPutBackEvent(obt_display, &e);
+ ob_debug("Trying to manage unmapped window. Aborting that.\n");
+ no_manage = TRUE;
+ }
+
+ if (!XGetWindowAttributes(obt_display, win, &attrib))
+ no_manage = TRUE;
+ else {
+ XWMHints *wmhints;
+
+ /* is the window a docking app */
+ is_dockapp = FALSE;
+ if ((wmhints = XGetWMHints(obt_display, win))) {
+ if ((wmhints->flags & StateHint) &&
+ wmhints->initial_state == WithdrawnState)
+ {
+ if (wmhints->flags & IconWindowHint)
+ icon_win = wmhints->icon_window;
+ is_dockapp = TRUE;
+ }
+ XFree(wmhints);
+ }
+ }
+
+ if (!no_manage) {
+ if (attrib.override_redirect) {
+ ob_debug("not managing override redirect window 0x%x\n", win);
+ grab_server(FALSE);
+ }
+ else if (is_dockapp) {
+ if (!icon_win)
+ icon_win = win;
+ dock_manage(icon_win, win);
+ }
+ else
+ client_manage(win, NULL);
+ }
+ else {
+ grab_server(FALSE);
+ ob_debug("FAILED to manage window 0x%x\n", win);
+ }
+}
+
+void window_unmanage_all(void)
+{
+ dock_unmanage_all();
+ client_unmanage_all();
+}
typedef struct _ObInternalWindow ObInternalWindow;
typedef enum {
- Window_Menu,
- Window_Dock,
- Window_DockApp, /* used for events but not stacking */
- Window_Client,
- Window_Internal,/* used for stacking but not events (except to filter
- events on the root window) */
- Window_Prompt,
-} Window_InternalType;
-
-struct _ObWindow
-{
- Window_InternalType type;
+ OB_WINDOW_CLASS_MENUFRAME,
+ OB_WINDOW_CLASS_DOCK,
+ OB_WINDOW_CLASS_CLIENT,
+ OB_WINDOW_CLASS_INTERNAL,
+ OB_WINDOW_CLASS_PROMPT
+} ObWindowClass;
+
+/* In order to be an ObWindow, you need to make this struct the top of your
+ struct */
+struct _ObWindow {
+ ObWindowClass type;
};
-/* Wrapper for internal stuff. If its struct matches this then it can be used
- as an ObWindow */
-typedef struct InternalWindow {
- Window_InternalType type;
- Window window;
-} InternalWindow;
-
-#define WINDOW_IS_MENU(win) (((ObWindow*)win)->type == Window_Menu)
-#define WINDOW_IS_DOCK(win) (((ObWindow*)win)->type == Window_Dock)
-#define WINDOW_IS_DOCKAPP(win) (((ObWindow*)win)->type == Window_DockApp)
-#define WINDOW_IS_CLIENT(win) (((ObWindow*)win)->type == Window_Client)
-#define WINDOW_IS_INTERNAL(win) (((ObWindow*)win)->type == Window_Internal)
-#define WINDOW_IS_PROMPT(win) (((ObWindow*)win)->type == Window_Prompt)
+#define WINDOW_IS_MENUFRAME(win) \
+ (((ObWindow*)win)->type == OB_WINDOW_CLASS_MENUFRAME)
+#define WINDOW_IS_DOCK(win) \
+ (((ObWindow*)win)->type == OB_WINDOW_CLASS_DOCK)
+#define WINDOW_IS_CLIENT(win) \
+ (((ObWindow*)win)->type == OB_WINDOW_CLASS_CLIENT)
+#define WINDOW_IS_INTERNAL(win) \
+ (((ObWindow*)win)->type == OB_WINDOW_CLASS_INTERNAL)
+#define WINDOW_IS_PROMPT(win) \
+ (((ObWindow*)win)->type == OB_WINDOW_CLASS_PROMPT)
struct _ObMenu;
struct _ObDock;
struct _ObClient;
struct _ObPrompt;
-#define WINDOW_AS_MENU(win) ((struct _ObMenuFrame*)win)
+#define WINDOW_AS_MENUFRAME(win) ((struct _ObMenuFrame*)win)
#define WINDOW_AS_DOCK(win) ((struct _ObDock*)win)
-#define WINDOW_AS_DOCKAPP(win) ((struct _ObDockApp*)win)
#define WINDOW_AS_CLIENT(win) ((struct _ObClient*)win)
-#define WINDOW_AS_INTERNAL(win) ((struct InternalWindow*)win)
+#define WINDOW_AS_INTERNAL(win) ((struct _ObInternalWindow*)win)
#define WINDOW_AS_PROMPT(win) ((struct _ObPrompt*)win)
-#define MENU_AS_WINDOW(menu) ((ObWindow*)menu)
+#define MENUFRAME_AS_WINDOW(menu) ((ObWindow*)menu)
#define DOCK_AS_WINDOW(dock) ((ObWindow*)dock)
-#define DOCKAPP_AS_WINDOW(dockapp) ((ObWindow*)dockapp)
#define CLIENT_AS_WINDOW(client) ((ObWindow*)client)
#define INTERNAL_AS_WINDOW(intern) ((ObWindow*)intern)
#define PROMPT_AS_WINDOW(prompt) ((ObWindow*)prompt)
-extern GHashTable *window_map;
-
-void window_startup(gboolean reconfig);
+void window_startup (gboolean reconfig);
void window_shutdown(gboolean reconfig);
-Window window_top(ObWindow *self);
+Window window_top (ObWindow *self);
ObStackingLayer window_layer(ObWindow *self);
+ObWindow* window_find (Window xwin);
+void window_add (Window *xwin, ObWindow *win);
+void window_remove(Window xwin);
+
+/* Internal openbox-owned windows like the alt-tab popup */
+struct _ObInternalWindow {
+ ObWindowClass type;
+ Window window;
+};
+
+void window_manage_all(void);
+void window_manage(Window win);
+void window_unmanage_all(void);
+
#endif
+++ /dev/null
-/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
-
- xerror.c for the Openbox window manager
- Copyright (c) 2006 Mikael Magnusson
- Copyright (c) 2003-2007 Dana Jansens
-
- 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.
-
- See the COPYING file for a copy of the GNU General Public License.
-*/
-
-#include "openbox.h"
-#include "gettext.h"
-#include "debug.h"
-#include "xerror.h"
-#include <glib.h>
-#include <X11/Xlib.h>
-
-static gboolean xerror_ignore = FALSE;
-gboolean xerror_occured = FALSE;
-
-gint xerror_handler(Display *d, XErrorEvent *e)
-{
-#ifdef DEBUG
- gchar errtxt[128];
-
- XGetErrorText(d, e->error_code, errtxt, 127);
- if (!xerror_ignore) {
- if (e->error_code == BadWindow)
- /*g_message(_("X Error: %s\n"), errtxt)*/;
- else
- g_error(_("X Error: %s"), errtxt);
- } else
- ob_debug("XError code %d '%s'\n", e->error_code, errtxt);
-#else
- (void)d; (void)e;
-#endif
-
- xerror_occured = TRUE;
- return 0;
-}
-
-void xerror_set_ignore(gboolean ignore)
-{
- XSync(ob_display, FALSE);
- xerror_ignore = ignore;
-}
+++ /dev/null
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: ObParser
-Description: Openbox config file parsing library
-Version: @VERSION@
-Requires: libxml-2.0 glib-2.0
-Libs: -L${libdir} -lobparser
-Cflags: -I${includedir}/openbox/@OB_VERSION@
+++ /dev/null
-/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
-
- parse.c for the Openbox window manager
- Copyright (c) 2003-2007 Dana Jansens
-
- 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.
-
- See the COPYING file for a copy of the GNU General Public License.
-*/
-
-#include "parse.h"
-#include <glib.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-static gboolean xdg_start;
-static gchar *xdg_config_home_path;
-static gchar *xdg_data_home_path;
-static GSList *xdg_config_dir_paths;
-static GSList *xdg_data_dir_paths;
-
-struct Callback {
- gchar *tag;
- ParseCallback func;
- gpointer data;
-};
-
-struct _ObParseInst {
- GHashTable *callbacks;
-};
-
-static void destfunc(struct Callback *c)
-{
- g_free(c->tag);
- g_free(c);
-}
-
-ObParseInst* parse_startup(void)
-{
- ObParseInst *i = g_new(ObParseInst, 1);
- i->callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
- (GDestroyNotify)destfunc);
- return i;
-}
-
-void parse_shutdown(ObParseInst *i)
-{
- if (i) {
- g_hash_table_destroy(i->callbacks);
- g_free(i);
- }
-}
-
-void parse_register(ObParseInst *i, const gchar *tag,
- ParseCallback func, gpointer data)
-{
- struct Callback *c;
-
- if ((c = g_hash_table_lookup(i->callbacks, tag))) {
- g_error("Tag '%s' already registered", tag);
- return;
- }
-
- c = g_new(struct Callback, 1);
- c->tag = g_strdup(tag);
- c->func = func;
- c->data = data;
- g_hash_table_insert(i->callbacks, c->tag, c);
-}
-
-gboolean parse_load_rc(const gchar *file, xmlDocPtr *doc, xmlNodePtr *root)
-{
- GSList *it;
- gboolean r = FALSE;
-
- if (file && parse_load(file, "openbox_config", doc, root))
- return TRUE;
-
- for (it = xdg_config_dir_paths; !r && it; it = g_slist_next(it)) {
- gchar *path;
-
- path = g_build_filename(it->data, "openbox", "rc.xml", NULL);
- r = parse_load(path, "openbox_config", doc, root);
- g_free(path);
- }
-
- return r;
-}
-
-gboolean parse_load_theme(const gchar *name, xmlDocPtr *doc, xmlNodePtr *root,
- gchar **retpath)
-{
- GSList *it;
- gchar *path;
- gboolean r = FALSE;
- gchar *eng;
-
- /* backward compatibility.. */
- path = g_build_filename(g_get_home_dir(), ".themes", name,
- "openbox-3", "themerc.xml", NULL);
- if (parse_load(path, "openbox_theme", doc, root) &&
- parse_attr_string("engine", *root, &eng))
- {
- if (!strcmp(eng, "box")) {
- *retpath = g_path_get_dirname(path);
- r = TRUE;
- }
- g_free(eng);
- }
- g_free(path);
-
- if (!r) {
- for (it = xdg_data_dir_paths; !r && it; it = g_slist_next(it)) {
- path = g_build_filename(it->data, "themes", name, "openbox-3",
- "themerc.xml", NULL);
- if (parse_load(path, "openbox_theme", doc, root) &&
- parse_attr_string("engine", *root, &eng))
- {
- if (!strcmp(eng, "box")) {
- *retpath = g_path_get_dirname(path);
- r = TRUE;
- }
- g_free(eng);
- }
- g_free(path);
- }
- }
- return r;
-}
-
-gboolean parse_load_menu(const gchar *file, xmlDocPtr *doc, xmlNodePtr *root)
-{
- GSList *it;
- gchar *path;
- gboolean r = FALSE;
-
- if (file[0] == '/') {
- r = parse_load(file, "openbox_menu", doc, root);
- } else {
- for (it = xdg_config_dir_paths; !r && it; it = g_slist_next(it)) {
- path = g_build_filename(it->data, "openbox", file, NULL);
- r = parse_load(path, "openbox_menu", doc, root);
- g_free(path);
- }
- }
- return r;
-}
-
-gboolean parse_load(const gchar *path, const gchar *rootname,
- xmlDocPtr *doc, xmlNodePtr *root)
-{
- struct stat s;
-
- if (stat(path, &s) < 0)
- return FALSE;
-
- /* XML_PARSE_BLANKS is needed apparently. When it loads a theme file,
- without this option, the tree is weird and has extra nodes in it. */
- if ((*doc = xmlReadFile(path, NULL,
- XML_PARSE_NOBLANKS | XML_PARSE_RECOVER))) {
- *root = xmlDocGetRootElement(*doc);
- if (!*root) {
- xmlFreeDoc(*doc);
- *doc = NULL;
- g_message("%s is an empty document", path);
- } else {
- if (xmlStrcmp((*root)->name, (const xmlChar*)rootname)) {
- xmlFreeDoc(*doc);
- *doc = NULL;
- g_message("XML Document %s is of wrong type. Root "
- "node is not '%s'", path, rootname);
- }
- }
- }
- if (!*doc)
- return FALSE;
- return TRUE;
-}
-
-gboolean parse_load_mem(gpointer data, guint len, const gchar *rootname,
- xmlDocPtr *doc, xmlNodePtr *root)
-{
- if ((*doc = xmlParseMemory(data, len))) {
- *root = xmlDocGetRootElement(*doc);
- if (!*root) {
- xmlFreeDoc(*doc);
- *doc = NULL;
- g_message("Given memory is an empty document");
- } else {
- if (xmlStrcmp((*root)->name, (const xmlChar*)rootname)) {
- xmlFreeDoc(*doc);
- *doc = NULL;
- g_message("XML Document in given memory is of wrong "
- "type. Root node is not '%s'\n", rootname);
- }
- }
- }
- if (!*doc)
- return FALSE;
- return TRUE;
-}
-
-void parse_close(xmlDocPtr doc)
-{
- xmlFreeDoc(doc);
-}
-
-void parse_tree(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
-{
- while (node) {
- struct Callback *c = g_hash_table_lookup(i->callbacks, node->name);
-
- if (c)
- c->func(i, doc, node, c->data);
-
- node = node->next;
- }
-}
-
-gchar *parse_string(xmlDocPtr doc, xmlNodePtr node)
-{
- xmlChar *c = xmlNodeListGetString(doc, node->children, TRUE);
- gchar *s = g_strdup(c ? (gchar*)c : "");
- xmlFree(c);
- return s;
-}
-
-gint parse_int(xmlDocPtr doc, xmlNodePtr node)
-{
- xmlChar *c = xmlNodeListGetString(doc, node->children, TRUE);
- gint i = c ? atoi((gchar*)c) : 0;
- xmlFree(c);
- return i;
-}
-
-gboolean parse_bool(xmlDocPtr doc, xmlNodePtr node)
-{
- xmlChar *c = xmlNodeListGetString(doc, node->children, TRUE);
- gboolean b = FALSE;
- if (c && !xmlStrcasecmp(c, (const xmlChar*) "true"))
- b = TRUE;
- else if (c && !xmlStrcasecmp(c, (const xmlChar*) "yes"))
- b = TRUE;
- else if (c && !xmlStrcasecmp(c, (const xmlChar*) "on"))
- b = TRUE;
- xmlFree(c);
- return b;
-}
-
-gboolean parse_contains(const gchar *val, xmlDocPtr doc, xmlNodePtr node)
-{
- xmlChar *c = xmlNodeListGetString(doc, node->children, TRUE);
- gboolean r;
- r = !xmlStrcasecmp(c, (const xmlChar*) val);
- xmlFree(c);
- return r;
-}
-
-xmlNodePtr parse_find_node(const gchar *tag, xmlNodePtr node)
-{
- while (node) {
- if (!xmlStrcmp(node->name, (const xmlChar*) tag))
- return node;
- node = node->next;
- }
- return NULL;
-}
-
-gboolean parse_attr_bool(const gchar *name, xmlNodePtr node, gboolean *value)
-{
- xmlChar *c = xmlGetProp(node, (const xmlChar*) name);
- gboolean r = FALSE;
- if (c) {
- if (!xmlStrcasecmp(c, (const xmlChar*) "true"))
- *value = TRUE, r = TRUE;
- else if (!xmlStrcasecmp(c, (const xmlChar*) "yes"))
- *value = TRUE, r = TRUE;
- else if (!xmlStrcasecmp(c, (const xmlChar*) "on"))
- *value = TRUE, r = TRUE;
- else if (!xmlStrcasecmp(c, (const xmlChar*) "false"))
- *value = FALSE, r = TRUE;
- else if (!xmlStrcasecmp(c, (const xmlChar*) "no"))
- *value = FALSE, r = TRUE;
- else if (!xmlStrcasecmp(c, (const xmlChar*) "off"))
- *value = FALSE, r = TRUE;
- }
- xmlFree(c);
- return r;
-}
-
-gboolean parse_attr_int(const gchar *name, xmlNodePtr node, gint *value)
-{
- xmlChar *c = xmlGetProp(node, (const xmlChar*) name);
- gboolean r = FALSE;
- if (c) {
- *value = atoi((gchar*)c);
- r = TRUE;
- }
- xmlFree(c);
- return r;
-}
-
-gboolean parse_attr_string(const gchar *name, xmlNodePtr node, gchar **value)
-{
- xmlChar *c = xmlGetProp(node, (const xmlChar*) name);
- gboolean r = FALSE;
- if (c) {
- *value = g_strdup((gchar*)c);
- r = TRUE;
- }
- xmlFree(c);
- return r;
-}
-
-gboolean parse_attr_contains(const gchar *val, xmlNodePtr node,
- const gchar *name)
-{
- xmlChar *c = xmlGetProp(node, (const xmlChar*) name);
- gboolean r = FALSE;
- if (c)
- r = !xmlStrcasecmp(c, (const xmlChar*) val);
- xmlFree(c);
- return r;
-}
-
-static gint slist_path_cmp(const gchar *a, const gchar *b)
-{
- return strcmp(a, b);
-}
-
-typedef GSList* (*GSListFunc) (gpointer list, gconstpointer data);
-
-static GSList* slist_path_add(GSList *list, gpointer data, GSListFunc func)
-{
- g_assert(func);
-
- if (!data)
- return list;
-
- if (!g_slist_find_custom(list, data, (GCompareFunc) slist_path_cmp))
- list = func(list, data);
- else
- g_free(data);
-
- return list;
-}
-
-static GSList* split_paths(const gchar *paths)
-{
- GSList *list = NULL;
- gchar **spl, **it;
-
- if (!paths)
- return NULL;
- spl = g_strsplit(paths, ":", -1);
- for (it = spl; *it; ++it)
- list = slist_path_add(list, *it, (GSListFunc) g_slist_append);
- g_free(spl);
- return list;
-}
-
-void parse_paths_startup(void)
-{
- const gchar *path;
-
- if (xdg_start)
- return;
- xdg_start = TRUE;
-
- path = g_getenv("XDG_CONFIG_HOME");
- if (path && path[0] != '\0') /* not unset or empty */
- xdg_config_home_path = g_build_filename(path, NULL);
- else
- xdg_config_home_path = g_build_filename(g_get_home_dir(), ".config",
- NULL);
-
- path = g_getenv("XDG_DATA_HOME");
- if (path && path[0] != '\0') /* not unset or empty */
- xdg_data_home_path = g_build_filename(path, NULL);
- else
- xdg_data_home_path = g_build_filename(g_get_home_dir(), ".local",
- "share", NULL);
-
- path = g_getenv("XDG_CONFIG_DIRS");
- if (path && path[0] != '\0') /* not unset or empty */
- xdg_config_dir_paths = split_paths(path);
- else {
- xdg_config_dir_paths = slist_path_add(xdg_config_dir_paths,
- g_strdup(CONFIGDIR),
- (GSListFunc) g_slist_append);
- xdg_config_dir_paths = slist_path_add(xdg_config_dir_paths,
- g_build_filename
- (G_DIR_SEPARATOR_S,
- "etc", "xdg", NULL),
- (GSListFunc) g_slist_append);
- }
- xdg_config_dir_paths = slist_path_add(xdg_config_dir_paths,
- g_strdup(xdg_config_home_path),
- (GSListFunc) g_slist_prepend);
-
- path = g_getenv("XDG_DATA_DIRS");
- if (path && path[0] != '\0') /* not unset or empty */
- xdg_data_dir_paths = split_paths(path);
- else {
- xdg_data_dir_paths = slist_path_add(xdg_data_dir_paths,
- g_strdup(DATADIR),
- (GSListFunc) g_slist_append);
- xdg_data_dir_paths = slist_path_add(xdg_data_dir_paths,
- g_build_filename
- (G_DIR_SEPARATOR_S,
- "usr", "local", "share", NULL),
- (GSListFunc) g_slist_append);
- xdg_data_dir_paths = slist_path_add(xdg_data_dir_paths,
- g_build_filename
- (G_DIR_SEPARATOR_S,
- "usr", "share", NULL),
- (GSListFunc) g_slist_append);
- }
- xdg_data_dir_paths = slist_path_add(xdg_data_dir_paths,
- g_strdup(xdg_data_home_path),
- (GSListFunc) g_slist_prepend);
-}
-
-void parse_paths_shutdown(void)
-{
- GSList *it;
-
- if (!xdg_start)
- return;
- xdg_start = FALSE;
-
- for (it = xdg_config_dir_paths; it; it = g_slist_next(it))
- g_free(it->data);
- g_slist_free(xdg_config_dir_paths);
- xdg_config_dir_paths = NULL;
- for (it = xdg_data_dir_paths; it; it = g_slist_next(it))
- g_free(it->data);
- g_slist_free(xdg_data_dir_paths);
- xdg_data_dir_paths = NULL;
- g_free(xdg_config_home_path);
- xdg_config_home_path = NULL;
- g_free(xdg_data_home_path);
- xdg_data_home_path = NULL;
-}
-
-gchar *parse_expand_tilde(const gchar *f)
-{
- gchar **spl;
- gchar *ret;
-
- if (!f)
- return NULL;
- spl = g_strsplit(f, "~", 0);
- ret = g_strjoinv(g_get_home_dir(), spl);
- g_strfreev(spl);
- return ret;
-}
-
-gboolean parse_mkdir(const gchar *path, gint mode)
-{
- gboolean ret = TRUE;
-
- g_return_val_if_fail(path != NULL, FALSE);
- g_return_val_if_fail(path[0] != '\0', FALSE);
-
- if (!g_file_test(path, G_FILE_TEST_IS_DIR))
- if (mkdir(path, mode) == -1)
- ret = FALSE;
-
- return ret;
-}
-
-gboolean parse_mkdir_path(const gchar *path, gint mode)
-{
- gboolean ret = TRUE;
-
- g_return_val_if_fail(path != NULL, FALSE);
- g_return_val_if_fail(path[0] == '/', FALSE);
-
- if (!g_file_test(path, G_FILE_TEST_IS_DIR)) {
- gchar *c, *e;
-
- c = g_strdup(path);
- e = c;
- while ((e = strchr(e + 1, '/'))) {
- *e = '\0';
- if (!(ret = parse_mkdir(c, mode)))
- goto parse_mkdir_path_end;
- *e = '/';
- }
- ret = parse_mkdir(c, mode);
-
- parse_mkdir_path_end:
- g_free(c);
- }
-
- return ret;
-}
-
-const gchar* parse_xdg_config_home_path(void)
-{
- return xdg_config_home_path;
-}
-
-const gchar* parse_xdg_data_home_path(void)
-{
- return xdg_data_home_path;
-}
-
-GSList* parse_xdg_config_dir_paths(void)
-{
- return xdg_config_dir_paths;
-}
-
-GSList* parse_xdg_data_dir_paths(void)
-{
- return xdg_data_dir_paths;
-}
+++ /dev/null
-/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
-
- parse.h for the Openbox window manager
- Copyright (c) 2003-2007 Dana Jansens
-
- 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.
-
- See the COPYING file for a copy of the GNU General Public License.
-*/
-
-#ifndef __parse_h
-#define __parse_h
-
-#include "version.h"
-
-#include <libxml/parser.h>
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-typedef struct _ObParseInst ObParseInst;
-
-typedef void (*ParseCallback)(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data);
-
-ObParseInst* parse_startup();
-void parse_shutdown(ObParseInst *inst);
-
-/*! Loads Openbox's rc, from the normal paths
- @param file The path of the config to try load. NULL to load from the
- default path
- */
-gboolean parse_load_rc(const gchar *file, xmlDocPtr *doc, xmlNodePtr *root);
-/* Loads an Openbox menu, from the normal paths */
-gboolean parse_load_menu(const gchar *file, xmlDocPtr *doc, xmlNodePtr *root);
-/* Loads an Openbox theme, from the normal paths */
-gboolean parse_load_theme(const gchar *name, xmlDocPtr *doc, xmlNodePtr *root,
- gchar **path);
-
-void parse_register(ObParseInst *inst, const gchar *tag,
- ParseCallback func, gpointer data);
-void parse_tree(ObParseInst *inst, xmlDocPtr doc, xmlNodePtr node);
-
-
-/* open/close */
-
-gboolean parse_load(const gchar *path, const gchar *rootname,
- xmlDocPtr *doc, xmlNodePtr *root);
-gboolean parse_load_mem(gpointer data, guint len, const gchar *rootname,
- xmlDocPtr *doc, xmlNodePtr *root);
-void parse_close(xmlDocPtr doc);
-
-
-/* helpers */
-
-xmlNodePtr parse_find_node(const gchar *tag, xmlNodePtr node);
-
-gchar *parse_string(xmlDocPtr doc, xmlNodePtr node);
-gint parse_int(xmlDocPtr doc, xmlNodePtr node);
-gboolean parse_bool(xmlDocPtr doc, xmlNodePtr node);
-
-gboolean parse_contains(const gchar *val, xmlDocPtr doc, xmlNodePtr node);
-gboolean parse_attr_contains(const gchar *val, xmlNodePtr node,
- const gchar *name);
-
-gboolean parse_attr_string(const gchar *name, xmlNodePtr node, gchar **value);
-gboolean parse_attr_int(const gchar *name, xmlNodePtr node, gint *value);
-gboolean parse_attr_bool(const gchar *name, xmlNodePtr node, gboolean *value);
-
-/* paths */
-
-void parse_paths_startup();
-void parse_paths_shutdown();
-
-const gchar* parse_xdg_config_home_path();
-const gchar* parse_xdg_data_home_path();
-GSList* parse_xdg_config_dir_paths();
-GSList* parse_xdg_data_dir_paths();
-
-/*! Expands the ~ character to the home directory throughout the given
- string */
-gchar *parse_expand_tilde(const gchar *f);
-/*! Makes a directory */
-gboolean parse_mkdir(const gchar *path, gint mode);
-/*! Makes a directory and all its parents */
-gboolean parse_mkdir_path(const gchar *path, gint mode);
-
-G_END_DECLS
-
-#endif
openbox/client_list_menu.c
openbox/client_menu.c
openbox/config.c
+openbox/debug.c
openbox/keyboard.c
openbox/menu.c
openbox/mouse.c
openbox/session.c
openbox/startupnotify.c
openbox/translate.c
-openbox/xerror.c
openbox/prompt.c
#include "geom.h"
#include "image.h"
#include "color.h"
+#include "imagecache.h"
#include <glib.h>
#define FLOOR(i) ((i) & (~0UL << FRACTION))
#define AVERAGE(a, b) (((((a) ^ (b)) & 0xfefefefeL) >> 1) + ((a) & (b)))
-static void ImageCopyResampled(RrPixel32 *dst, RrPixel32 *src,
- gulong dstW, gulong dstH,
- gulong srcW, gulong srcH)
+void RrImagePicInit(RrImagePic *pic, gint w, gint h, RrPixel32 *data)
{
+ gint i;
+
+ pic->width = w;
+ pic->height = h;
+ pic->data = data;
+ pic->sum = 0;
+ for (i = w*h; i > 0; --i)
+ pic->sum += *(data++);
+}
+
+static void RrImagePicFree(RrImagePic *pic)
+{
+ if (pic) {
+ g_free(pic->data);
+ g_free(pic);
+ }
+}
+
+/*! Add a picture to an Image, that is, add another copy of the image at
+ another size. This may add it to the "originals" list or to the
+ "resized" list. */
+static void AddPicture(RrImage *self, RrImagePic ***list, gint *len,
+ RrImagePic *pic)
+{
+ gint i;
+
+ g_assert(pic->width > 0 && pic->height > 0);
+
+ g_assert(g_hash_table_lookup(self->cache->table, pic) == NULL);
+
+ /* grow the list */
+ *list = g_renew(RrImagePic*, *list, ++*len);
+
+ /* move everything else down one */
+ for (i = *len-1; i > 0; --i)
+ (*list)[i] = (*list)[i-1];
+
+ /* set the new picture up at the front of the list */
+ (*list)[0] = pic;
+
+ /* add the picture as a key to point to this image in the cache */
+ g_hash_table_insert(self->cache->table, (*list)[0], self);
+
+#ifdef DEBUG
+ g_message("Adding %s picture to the cache:\n "
+ "Image 0x%x, w %d h %d Hash %u\n",
+ (*list == self->original ? "ORIGINAL" : "RESIZED"),
+ (guint)self, pic->width, pic->height, RrImagePicHash(pic));
+#endif
+}
+
+/*! Remove a picture from an Image. This may remove it from the "originals"
+ list or the "resized" list. */
+static void RemovePicture(RrImage *self, RrImagePic ***list,
+ gint i, gint *len)
+{
+ gint j;
+
+#ifdef DEBUG
+ g_message("Removing %s picture from the cache:\n "
+ "Image 0x%x, w %d h %d Hash %u\n",
+ (*list == self->original ? "ORIGINAL" : "RESIZED"),
+ (guint)self, (*list)[i]->width, (*list)[i]->height,
+ RrImagePicHash((*list)[i]));
+#endif
+
+ /* remove the picture as a key in the cache */
+ g_hash_table_remove(self->cache->table, (*list)[i]);
+
+ /* free the picture */
+ RrImagePicFree((*list)[i]);
+ /* shift everything down one */
+ for (j = i; j < *len-1; ++j)
+ (*list)[j] = (*list)[j+1];
+ /* shrink the list */
+ *list = g_renew(RrImagePic*, *list, --*len);
+}
+
+/*! Given a picture in RGBA format, of a specified size, resize it to the new
+ requested size (but keep its aspect ratio). If the image does not need to
+ be resized (it is already the right size) then this returns NULL. Otherwise
+ it returns a newly allocated RrImagePic with the resized picture inside it
+*/
+static RrImagePic* ResizeImage(RrPixel32 *src,
+ gulong srcW, gulong srcH,
+ gulong dstW, gulong dstH)
+{
+ RrPixel32 *dst, *dststart;
+ RrImagePic *pic;
gulong dstX, dstY, srcX, srcY;
gulong srcX1, srcX2, srcY1, srcY2;
gulong ratioX, ratioY;
+ gulong aspectW, aspectH;
+
+ /* keep the aspect ratio */
+ aspectW = dstW;
+ aspectH = (gint)(dstW * ((gdouble)srcH / srcW));
+ if (aspectH > dstH) {
+ aspectH = dstH;
+ aspectW = (gint)(dstH * ((gdouble)srcW / srcH));
+ }
+ dstW = aspectW;
+ dstH = aspectH;
+
+ if (srcW == dstW && srcH == dstH)
+ return NULL; /* no scaling needed ! */
+
+ dststart = dst = g_new(RrPixel32, dstW * dstH);
ratioX = (srcW << FRACTION) / dstW;
ratioY = (srcH << FRACTION) / dstH;
(alpha << RrDefaultAlphaOffset);
}
}
+
+ pic = g_new(RrImagePic, 1);
+ RrImagePicInit(pic, dstW, dstH, dststart);
+
+ return pic;
}
-void RrImageDraw(RrPixel32 *target, RrTextureRGBA *rgba,
- gint target_w, gint target_h,
- RrRect *area)
+/*! This drawns an RGBA picture into the target, within the rectangle specified
+ by the area parameter. If the area's size differs from the source's then it
+ will be centered within the rectangle */
+void DrawRGBA(RrPixel32 *target, gint target_w, gint target_h,
+ RrPixel32 *source, gint source_w, gint source_h,
+ gint alpha, RrRect *area)
{
RrPixel32 *dest;
- RrPixel32 *source;
- gint sw, sh, dw, dh;
gint col, num_pixels;
+ gint dw, dh;
- sw = rgba->width;
- sh = rgba->height;
+ g_assert(source_w <= area->width && source_h <= area->height);
+ g_assert(area->x + area->width <= target_w);
+ g_assert(area->y + area->height <= target_h);
- /* keep the ratio */
+ /* keep the aspect ratio */
dw = area->width;
- dh = (gint)(dw * ((gdouble)sh / sw));
+ dh = (gint)(dw * ((gdouble)source_h / source_w));
if (dh > area->height) {
dh = area->height;
- dw = (gint)(dh * ((gdouble)sw / sh));
- }
-
- if (sw != dw || sh != dh) {
- /*if (!(rgba->cache && dw == rgba->cwidth && dh == rgba->cheight))*/ {
- g_free(rgba->cache);
- rgba->cache = g_new(RrPixel32, dw * dh);
- ImageCopyResampled(rgba->cache, rgba->data, dw, dh, sw, sh);
- rgba->cwidth = dw;
- rgba->cheight = dh;
- }
- source = rgba->cache;
- } else {
- source = rgba->data;
+ dw = (gint)(dh * ((gdouble)source_w / source_h));
}
/* copy source -> dest, and apply the alpha channel.
-
center the image if it is smaller than the area */
col = 0;
num_pixels = dw * dh;
dest = target + area->x + (area->width - dw) / 2 +
(target_w * (area->y + (area->height - dh) / 2));
while (num_pixels-- > 0) {
- guchar alpha, r, g, b, bgr, bgg, bgb;
+ guchar a, r, g, b, bgr, bgg, bgb;
/* apply the rgba's opacity as well */
- alpha = ((*source >> RrDefaultAlphaOffset) * rgba->alpha) >> 8;
+ a = ((*source >> RrDefaultAlphaOffset) * alpha) >> 8;
r = *source >> RrDefaultRedOffset;
g = *source >> RrDefaultGreenOffset;
b = *source >> RrDefaultBlueOffset;
bgg = *dest >> RrDefaultGreenOffset;
bgb = *dest >> RrDefaultBlueOffset;
- r = bgr + (((r - bgr) * alpha) >> 8);
- g = bgg + (((g - bgg) * alpha) >> 8);
- b = bgb + (((b - bgb) * alpha) >> 8);
+ r = bgr + (((r - bgr) * a) >> 8);
+ g = bgg + (((g - bgg) * a) >> 8);
+ b = bgb + (((b - bgb) * a) >> 8);
*dest = ((r << RrDefaultRedOffset) |
(g << RrDefaultGreenOffset) |
}
}
}
+
+/*! Draw an RGBA texture into a target pixel buffer. */
+void RrImageDrawRGBA(RrPixel32 *target, RrTextureRGBA *rgba,
+ gint target_w, gint target_h,
+ RrRect *area)
+{
+ RrImagePic *scaled;
+
+ scaled = ResizeImage(rgba->data, rgba->width, rgba->height,
+ area->width, area->height);
+
+ if (scaled) {
+#ifdef DEBUG
+ g_warning("Scaling an RGBA! You should avoid this and just make "
+ "it the right size yourself!");
+#endif
+ DrawRGBA(target, target_w, target_h,
+ scaled->data, scaled->width, scaled->height,
+ rgba->alpha, area);
+ }
+ else
+ DrawRGBA(target, target_w, target_h,
+ rgba->data, rgba->width, rgba->height,
+ rgba->alpha, area);
+}
+
+/*! Create a new RrImage, which is linked to an image cache */
+RrImage* RrImageNew(RrImageCache *cache)
+{
+ RrImage *self;
+
+ g_assert(cache != NULL);
+
+ self = g_new0(RrImage, 1);
+ self->ref = 1;
+ self->cache = cache;
+ return self;
+}
+
+void RrImageRef(RrImage *self)
+{
+ ++self->ref;
+}
+
+void RrImageUnref(RrImage *self)
+{
+ if (self && --self->ref == 0) {
+#ifdef DEBUG
+ g_message("Refcount to 0, removing ALL pictures from the cache:\n "
+ "Image 0x%x\n", (guint)self);
+#endif
+ while (self->n_original > 0)
+ RemovePicture(self, &self->original, 0, &self->n_original);
+ while (self->n_resized > 0)
+ RemovePicture(self, &self->resized, 0, &self->n_resized);
+ g_free(self);
+ }
+}
+
+/*! Add a new picture with the given RGBA pixel data and dimensions into the
+ RrImage. This adds an "original" picture to the image.
+*/
+void RrImageAddPicture(RrImage *self, RrPixel32 *data, gint w, gint h)
+{
+ gint i;
+ RrImagePic *pic;
+
+ /* make sure we don't already have this size.. */
+ for (i = 0; i < self->n_original; ++i)
+ if (self->original[i]->width == w && self->original[i]->height == h) {
+#ifdef DEBUG
+ g_message("Found duplicate ORIGINAL image:\n "
+ "Image 0x%x, w %d h %d\n", (guint)self, w, h);
+#endif
+ return;
+ }
+
+ /* remove any resized pictures of this same size */
+ for (i = 0; i < self->n_resized; ++i)
+ if (self->resized[i]->width == w || self->resized[i]->height == h) {
+ RemovePicture(self, &self->resized, i, &self->n_resized);
+ break;
+ }
+
+ /* add the new picture */
+ pic = g_new(RrImagePic, 1);
+ RrImagePicInit(pic, w, h, g_memdup(data, w*h*sizeof(RrPixel32)));
+ AddPicture(self, &self->original, &self->n_original, pic);
+}
+
+/*! Remove the picture from the RrImage which has the given dimensions. This
+ removes an "original" picture from the image.
+*/
+void RrImageRemovePicture(RrImage *self, gint w, gint h)
+{
+ gint i;
+
+ /* remove any resized pictures of this same size */
+ for (i = 0; i < self->n_original; ++i)
+ if (self->original[i]->width == w && self->original[i]->height == h) {
+ RemovePicture(self, &self->original, i, &self->n_original);
+ break;
+ }
+}
+
+/*! Draw an RrImage texture into a target pixel buffer. If the RrImage does
+ not contain a picture of the appropriate size, then one of its "original"
+ pictures will be resized and used (and stored in the RrImage as a "resized"
+ picture).
+ */
+void RrImageDrawImage(RrPixel32 *target, RrTextureImage *img,
+ gint target_w, gint target_h,
+ RrRect *area)
+{
+ gint i, min_diff, min_i, min_aspect_diff, min_aspect_i;
+ RrImage *self;
+ RrImagePic *pic;
+ gboolean free_pic;
+
+ self = img->image;
+ pic = NULL;
+ free_pic = FALSE;
+
+ /* is there an original of this size? (only w or h has to be right cuz
+ we maintain aspect ratios) */
+ for (i = 0; i < self->n_original; ++i)
+ if (self->original[i]->width == area->width ||
+ self->original[i]->height == area->height)
+ {
+ pic = self->original[i];
+ break;
+ }
+
+ /* is there a resize of this size? */
+ for (i = 0; i < self->n_resized; ++i)
+ if (self->resized[i]->width == area->width ||
+ self->resized[i]->height == area->height)
+ {
+ gint j;
+ RrImagePic *saved;
+
+ /* save the selected one */
+ saved = self->resized[i];
+
+ /* shift all the others down */
+ for (j = i; j > 0; --j)
+ self->resized[j] = self->resized[j-1];
+
+ /* and move the selected one to the top of the list */
+ self->resized[0] = saved;
+
+ pic = self->resized[0];
+ break;
+ }
+
+ if (!pic) {
+ gdouble aspect;
+
+ /* find an original with a close size */
+ min_diff = min_aspect_diff = -1;
+ min_i = min_aspect_i = 0;
+ aspect = ((gdouble)area->width) / area->height;
+ for (i = 0; i < self->n_original; ++i) {
+ gint diff;
+ gint wdiff, hdiff;
+ gdouble myasp;
+
+ /* our size difference metric.. */
+ wdiff = self->original[i]->width - area->width;
+ hdiff = self->original[i]->height - area->height;
+ diff = (wdiff * wdiff) + (hdiff * hdiff);
+
+ /* find the smallest difference */
+ if (min_diff < 0 || diff < min_diff) {
+ min_diff = diff;
+ min_i = i;
+ }
+ /* and also find the smallest difference with the same aspect
+ ratio (and prefer this one) */
+ myasp = ((gdouble)self->original[i]->width) /
+ self->original[i]->height;
+ if (ABS(aspect - myasp) < 0.0000001 &&
+ (min_aspect_diff < 0 || diff < min_aspect_diff))
+ {
+ min_aspect_diff = diff;
+ min_aspect_i = i;
+ }
+ }
+
+ /* use the aspect ratio correct source if there is one */
+ if (min_aspect_i >= 0)
+ min_i = min_aspect_i;
+
+ /* resize the original to the given area */
+ pic = ResizeImage(self->original[min_i]->data,
+ self->original[min_i]->width,
+ self->original[min_i]->height,
+ area->width, area->height);
+
+ /* add the resized image to the image, as the first in the resized
+ list */
+ if (self->n_resized >= self->cache->max_resized_saved)
+ /* remove the last one (last used one) */
+ RemovePicture(self, &self->resized, self->n_resized - 1,
+ &self->n_resized);
+ if (self->cache->max_resized_saved)
+ /* add it to the top of the resized list */
+ AddPicture(self, &self->resized, &self->n_resized, pic);
+ else
+ free_pic = TRUE; /* don't leak mem! */
+ }
+
+ g_assert(pic != NULL);
+
+ DrawRGBA(target, target_w, target_h,
+ pic->data, pic->width, pic->height,
+ img->alpha, area);
+ if (free_pic)
+ RrImagePicFree(pic);
+}
#include "render.h"
#include "geom.h"
-void RrImageDraw(RrPixel32 *target, RrTextureRGBA *rgba,
- gint target_w, gint target_h,
- RrRect *area);
+/*! Initialize an RrImagePicture to the specified dimensions and pixel data */
+void RrImagePicInit(RrImagePic *pic, gint w, gint h, RrPixel32 *data);
+
+void RrImageDrawImage(RrPixel32 *target, RrTextureImage *img,
+ gint target_w, gint target_h,
+ RrRect *area);
+void RrImageDrawRGBA(RrPixel32 *target, RrTextureRGBA *rgba,
+ gint target_w, gint target_h,
+ RrRect *area);
#endif
--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ imagecache.c for the Openbox window manager
+ Copyright (c) 2008 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#include "render.h"
+#include "imagecache.h"
+#include "image.h"
+
+static gboolean RrImagePicEqual(const RrImagePic *p1,
+ const RrImagePic *p2);
+
+RrImageCache* RrImageCacheNew(gint max_resized_saved)
+{
+ RrImageCache *self;
+
+ g_assert(max_resized_saved >= 0);
+
+ self = g_new(RrImageCache, 1);
+ self->ref = 1;
+ self->max_resized_saved = max_resized_saved;
+ self->table = g_hash_table_new((GHashFunc)RrImagePicHash,
+ (GEqualFunc)RrImagePicEqual);
+ return self;
+}
+
+void RrImageCacheRef(RrImageCache *self)
+{
+ ++self->ref;
+}
+
+void RrImageCacheUnref(RrImageCache *self)
+{
+ if (self && --self->ref == 0) {
+ g_assert(g_hash_table_size(self->table) == 0);
+ g_hash_table_unref(self->table);
+
+ g_free(self);
+ }
+}
+
+/*! Finds an image in the cache, if it is already in there */
+RrImage* RrImageCacheFind(RrImageCache *self,
+ RrPixel32 *data, gint w, gint h)
+{
+ RrImagePic pic;
+
+ RrImagePicInit(&pic, w, h, data);
+ return g_hash_table_lookup(self->table, &pic);
+}
+
+#define hashsize(n) ((RrPixel32)1<<(n))
+#define hashmask(n) (hashsize(n)-1)
+#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
+/* mix -- mix 3 32-bit values reversibly. */
+#define mix(a,b,c) \
+{ \
+ a -= c; a ^= rot(c, 4); c += b; \
+ b -= a; b ^= rot(a, 6); a += c; \
+ c -= b; c ^= rot(b, 8); b += a; \
+ a -= c; a ^= rot(c,16); c += b; \
+ b -= a; b ^= rot(a,19); a += c; \
+ c -= b; c ^= rot(b, 4); b += a; \
+}
+/* final -- final mixing of 3 32-bit values (a,b,c) into c */
+#define final(a,b,c) \
+{ \
+ c ^= b; c -= rot(b,14); \
+ a ^= c; a -= rot(c,11); \
+ b ^= a; b -= rot(a,25); \
+ c ^= b; c -= rot(b,16); \
+ a ^= c; a -= rot(c,4); \
+ b ^= a; b -= rot(a,14); \
+ c ^= b; c -= rot(b,24); \
+}
+
+/* This is a fast, reversable hash function called "lookup3", found here:
+ http://burtleburtle.net/bob/c/lookup3.c, by Bob Jenkins
+
+ This hashing algorithm is "reversible", that is, not cryptographically
+ secure at all. But we don't care about that, we just want something to
+ tell when images are the same or different relatively quickly.
+*/
+guint32 hashword(const guint32 *key, gint length, guint32 initval)
+{
+ guint32 a,b,c;
+
+ /* Set up the internal state */
+ a = b = c = 0xdeadbeef + (((guint32)length)<<2) + initval;
+
+ /* handle most of the key */
+ while (length > 3)
+ {
+ a += key[0];
+ b += key[1];
+ c += key[2];
+ mix(a,b,c);
+ length -= 3;
+ key += 3;
+ }
+
+ /* handle the last 3 guint32's */
+ switch(length) /* all the case statements fall through */
+ {
+ case 3: c+=key[2];
+ case 2: b+=key[1];
+ case 1: a+=key[0];
+ final(a,b,c);
+ case 0: /* case 0: nothing left to add */
+ break;
+ }
+ /* report the result */
+ return c;
+}
+
+/*! This is some arbitrary initial value for the hashing function. It's
+ constant so that you get the same result from the same data each time.
+*/
+#define HASH_INITVAL 0xf00d
+
+guint RrImagePicHash(const RrImagePic *p)
+{
+ return hashword(p->data, p->width * p->height, HASH_INITVAL);
+}
+
+static gboolean RrImagePicEqual(const RrImagePic *p1,
+ const RrImagePic *p2)
+{
+ return p1->width == p2->width && p1->height == p2->height &&
+ p1->sum == p2->sum;
+}
--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ imagecache.h for the Openbox window manager
+ Copyright (c) 2008 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#ifndef __imagecache_h
+#define __imagecache_h
+
+#include <glib.h>
+
+struct _RrImagePic;
+
+guint RrImagePicHash(const struct _RrImagePic *p);
+
+/*! Create a new image cache. An image cache is basically a hash table to look
+ up RrImages. Each RrImage in the cache may contain one or more Pictures,
+ that is one or more actual copies of image data at various sizes. For eg,
+ for a window, all of its various icons are loaded into the same RrImage.
+ When an RrImage is drawn and a picture inside it needs to be resized, that
+ is also saved within the RrImage.
+
+ For each picture that an RrImage has, the picture is hashed and that is used
+ as a key to find the RrImage. So, given any picture in any RrImage in the
+ cache, if you hash it, you will find the RrImage.
+*/
+struct _RrImageCache {
+ gint ref;
+ /*! When an original picture is resized for an RrImage, the resized picture
+ is saved in the RrImage. This specifies how many pictures should be
+ saved at a time. When this is exceeded, the least recently used
+ "resized" picture is deleted.
+ */
+ gint max_resized_saved;
+
+ GHashTable *table;
+};
+
+#endif
Name: ObRender
Description: Openbox Render Library
Version: @VERSION@
-Requires: obparser-3.0 glib-2.0 xft pangoxft
+Requires: obparser-4.0 glib-2.0 xft pangoxft
Libs: -L${libdir} -lobrender ${xlibs}
Cflags: -I${includedir}/openbox/@OB_VERSION@ ${xcflags}
}
RrPixmapMaskDraw(a->pixmap, &a->texture[i].data.mask, &tarea);
break;
+ case RR_TEXTURE_IMAGE:
+ g_assert(!transferred);
+ {
+ RrRect narea = tarea;
+ RrTextureImage *img = &a->texture[i].data.image;
+ if (img->twidth)
+ narea.width = MIN(tarea.width, img->twidth);
+ if (img->theight)
+ narea.height = MIN(tarea.height, img->theight);
+ narea.x += img->tx;
+ narea.y += img->ty;
+ RrImageDrawImage(a->surface.pixel_data,
+ &a->texture[i].data.image,
+ a->w, a->h,
+ &narea);
+ }
+ force_transfer = 1;
+ break;
case RR_TEXTURE_RGBA:
g_assert(!transferred);
- RrImageDraw(a->surface.pixel_data,
- &a->texture[i].data.rgba,
- a->w, a->h,
- &tarea);
+ {
+ RrRect narea = tarea;
+ RrTextureRGBA *rgb = &a->texture[i].data.rgba;
+ if (rgb->twidth)
+ narea.width = MIN(tarea.width, rgb->twidth);
+ if (rgb->theight)
+ narea.height = MIN(tarea.height, rgb->theight);
+ narea.x += rgb->tx;
+ narea.y += rgb->ty;
+ RrImageDrawRGBA(a->surface.pixel_data,
+ &a->texture[i].data.rgba,
+ a->w, a->h,
+ &narea);
+ }
force_transfer = 1;
break;
}
if (numtex) a->texture = g_new0(RrTexture, numtex);
}
+void RrAppearanceClearTextures(RrAppearance *a)
+{
+ memset(a->texture, 0, a->textures * sizeof(RrTexture));
+}
+
RrAppearance *RrAppearanceCopy(RrAppearance *orig)
{
RrSurface *spo, *spc;
RrAppearance *copy = g_new(RrAppearance, 1);
- gint i;
copy->inst = orig->inst;
copy->textures = orig->textures;
copy->texture = g_memdup(orig->texture,
orig->textures * sizeof(RrTexture));
- for (i = 0; i < copy->textures; ++i)
- if (copy->texture[i].type == RR_TEXTURE_RGBA) {
- copy->texture[i].data.rgba.cache = NULL;
- }
copy->pixmap = None;
copy->xftdraw = NULL;
copy->w = copy->h = 0;
void RrAppearanceFree(RrAppearance *a)
{
- gint i;
-
if (a) {
RrSurface *p;
if (a->pixmap != None) XFreePixmap(RrDisplay(a->inst), a->pixmap);
if (a->xftdraw != NULL) XftDrawDestroy(a->xftdraw);
- for (i = 0; i < a->textures; ++i)
- if (a->texture[i].type == RR_TEXTURE_RGBA) {
- g_free(a->texture[i].data.rgba.cache);
- a->texture[i].data.rgba.cache = NULL;
- }
if (a->textures)
g_free(a->texture);
p = &a->surface;
case RR_TEXTURE_RGBA:
w += MAX(w, a->texture[i].data.rgba.width);
break;
+ case RR_TEXTURE_IMAGE:
+ /* images resize so they don't contribute anything to the min */
+ break;
case RR_TEXTURE_LINE_ART:
w = MAX(w, MAX(a->texture[i].data.lineart.x1 - l - r,
a->texture[i].data.lineart.x2 - l - r));
case RR_TEXTURE_RGBA:
h += MAX(h, a->texture[i].data.rgba.height);
break;
+ case RR_TEXTURE_IMAGE:
+ /* images resize so they don't contribute anything to the min */
+ break;
case RR_TEXTURE_LINE_ART:
h = MAX(h, MAX(a->texture[i].data.lineart.y1 - t - b,
a->texture[i].data.lineart.y2 - t - b));
#define __render_h
#include "geom.h"
-#include "version.h"
+#include "render/version.h"
#include <X11/Xlib.h> /* some platforms dont include this as needed for Xft */
#include <pango/pangoxft.h>
typedef struct _RrTexture RrTexture;
typedef struct _RrTextureMask RrTextureMask;
typedef struct _RrTextureRGBA RrTextureRGBA;
+typedef struct _RrTextureImage RrTextureImage;
typedef struct _RrTextureText RrTextureText;
typedef struct _RrTextureLineArt RrTextureLineArt;
typedef struct _RrPixmapMask RrPixmapMask;
typedef struct _RrInstance RrInstance;
typedef struct _RrColor RrColor;
+typedef struct _RrImage RrImage;
+typedef struct _RrImagePic RrImagePic;
+typedef struct _RrImageCache RrImageCache;
typedef guint32 RrPixel32;
typedef guint16 RrPixel16;
RR_TEXTURE_MASK,
RR_TEXTURE_TEXT,
RR_TEXTURE_LINE_ART,
- RR_TEXTURE_RGBA
+ RR_TEXTURE_RGBA,
+ RR_TEXTURE_IMAGE
} RrTextureType;
typedef enum {
gint height;
gint alpha;
RrPixel32 *data;
-/* cached scaled so we don't have to scale often */
- gint cwidth;
- gint cheight;
- RrPixel32 *cache;
+ /* size and position to draw at (if these are zero, then it will be
+ drawn to fill the entire texture */
+ gint tx;
+ gint ty;
+ gint twidth;
+ gint theight;
+};
+
+struct _RrTextureImage {
+ RrImage *image;
+ gint alpha;
+ /* size and position to draw at (if these are zero, then it will be
+ drawn to fill the entire texture */
+ gint tx;
+ gint ty;
+ gint twidth;
+ gint theight;
};
struct _RrTextureLineArt {
union _RrTextureData {
RrTextureRGBA rgba;
+ RrTextureImage image;
RrTextureText text;
RrTextureMask mask;
RrTextureLineArt lineart;
};
struct _RrTexture {
+ /* If changing the type of a texture, you should DEFINITELY call
+ RrAppearanceClearTextures() first! */
RrTextureType type;
RrTextureData data;
};
gint w, h;
};
+/*! Holds a RGBA image picture */
+struct _RrImagePic {
+ gint width, height;
+ RrPixel32 *data;
+ /* The sum of all the pixels. This is used to compare pictures if their
+ hashes match. */
+ gint sum;
+};
+
+/*! An RrImage is a sort of meta-image. It can contain multiple versions of
+ an image at different sizes, which may or may not be completely different
+ pictures */
+struct _RrImage {
+ gint ref;
+ RrImageCache *cache;
+
+ /*! An array of "originals", that is of RrPictures that have been added
+ to the image in various sizes, and that have not been resized. These
+ are explicitly added to the RrImage. */
+ RrImagePic **original;
+ gint n_original;
+ /*! An array of "resized" pictures. When an "original" RrPicture
+ needs to be resized for drawing, it is saved in here so that it doesn't
+ need to be resized again. These are automatically added to the
+ RrImage. */
+ RrImagePic **resized;
+ gint n_resized;
+};
+
/* these are the same on all endian machines because it seems to be dependant
on the endianness of the gfx card, not the cpu. */
#define RrDefaultAlphaOffset 24
void RrAppearanceFree (RrAppearance *a);
void RrAppearanceRemoveTextures(RrAppearance *a);
void RrAppearanceAddTextures(RrAppearance *a, gint numtex);
+/*! Always call this when changing the type of a texture in an appearance */
+void RrAppearanceClearTextures(RrAppearance *a);
RrFont *RrFontOpen (const RrInstance *inst, const gchar *name,
gint size, RrFontWeight weight, RrFontSlant slant);
Pixmap pmap, Pixmap mask,
gint *w, gint *h, RrPixel32 **data);
+/*! Create a new image cache for RrImages.
+ @param max_resized_saved The number of resized copies of an image to save
+*/
+RrImageCache* RrImageCacheNew(gint max_resized_saved);
+void RrImageCacheRef(RrImageCache *self);
+void RrImageCacheUnref(RrImageCache *self);
+
+/*! Finds an image in the cache, if it is already in there */
+RrImage* RrImageCacheFind(RrImageCache *self,
+ RrPixel32 *data, gint w, gint h);
+
+RrImage* RrImageNew(RrImageCache *cache);
+void RrImageRef(RrImage *im);
+void RrImageUnref(RrImage *im);
+
+void RrImageAddPicture(RrImage *im, RrPixel32 *data, gint w, gint h);
+void RrImageRemovePicture(RrImage *im, gint w, gint h);
+
G_END_DECLS
#endif /*__render_h*/
#include "mask.h"
#include "theme.h"
#include "icon.h"
-#include "parser/parse.h"
+#include "obt/paths.h"
#include <X11/Xlib.h>
#include <X11/Xresource.h>
theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
}
+ /* up and down arrows */
+ {
+ guchar data[] = { 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00 };
+ theme->down_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data);
+ }
+ {
+ guchar data[] = { 0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00 };
+ theme->up_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data);
+ }
+
/* setup the default window icon */
theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
OB_DEFAULT_ICON_HEIGHT,
OB_DEFAULT_ICON_pixel_data);
+ theme->def_win_icon_w = OB_DEFAULT_ICON_WIDTH;
+ theme->def_win_icon_h = OB_DEFAULT_ICON_HEIGHT;
+
/* read the decoration textures */
if (!read_appearance(db, inst,
RrPixmapMaskFree(theme->close_hover_mask);
RrPixmapMaskFree(theme->close_pressed_mask);
RrPixmapMaskFree(theme->menu_bullet_mask);
+ RrPixmapMaskFree(theme->down_arrow_mask);
+ RrPixmapMaskFree(theme->up_arrow_mask);
RrFontClose(theme->win_font_focused);
RrFontClose(theme->win_font_unfocused);
*path = g_path_get_dirname(s);
g_free(s);
} else {
+ ObtPaths *p;
+
+ p = obt_paths_new();
+
/* XXX backwards compatibility, remove me sometime later */
s = g_build_filename(g_get_home_dir(), ".themes", name,
"openbox-3", "themerc", NULL);
*path = g_path_get_dirname(s);
g_free(s);
- for (it = parse_xdg_data_dir_paths(); !db && it;
- it = g_slist_next(it))
+ for (it = obt_paths_data_dirs(p); !db && it; it = g_slist_next(it))
{
s = g_build_filename(it->data, "themes", name,
"openbox-3", "themerc", NULL);
*path = g_path_get_dirname(s);
g_free(s);
}
+
+ obt_paths_unref(p);
}
if (db == NULL) {
gchar menu_text_disabled_selected_shadow_alpha;
/* style settings - pics */
- RrPixel32 *def_win_icon; /* 48x48 RGBA */
+ RrPixel32 *def_win_icon; /* RGBA */
+ gint def_win_icon_w;
+ gint def_win_icon_h;
/* style settings - masks */
RrPixmapMask *max_mask;
RrPixmapMask *menu_toggle_mask; /* menu boolean */
#endif
+ RrPixmapMask *down_arrow_mask;
+ RrPixmapMask *up_arrow_mask;
+
/* global appearances */
RrAppearance *a_disabled_focused_max;
RrAppearance *a_disabled_unfocused_max;
--- /dev/null
+#ifndef rr__version_h
+#define rr__version_h
+
+#define RR_MAJOR_VERSION @RR_MAJOR_VERSION@
+#define RR_MINOR_VERSION @RR_MINOR_VERSION@
+#define RR_MICRO_VERSION @RR_MICRO_VERSION@
+#define RR_VERSION RR_MAJOR_VERSION.RR_MINOR_VERSION.RR_MICRO_VERSION
+
+#define RR_CHECK_VERSION(major,minor,micro) \
+ (RR_MAJOR_VERSION > (major) || \
+ (RR_MAJOR_VERSION == (major) && RR_MINOR_VERSION > (minor)) || \
+ (RR_MAJOR_VERSION == (major) && RR_MINOR_VERSION == (minor) && \
+ RR_MICRO_VERSION >= (micro)))
+
+#endif
all: $(files:.c=)
%: %.c
- $(CC) $(CFLAGS) -o $@ $^ -lX11 -lXext -L/usr/X11R6/lib -I/usr/X11R6/include
+ $(CC) `pkg-config --cflags --libs glib-2.0` $(CFLAGS) -o $@ $^ -lX11 -lXext -L/usr/X11R6/lib -I/usr/X11R6/include
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
+#include <glib.h>
Window findClient(Display *d, Window win)
{
++image;
} while (ret_bytesleft > 0 && image < MAX_IMAGES);
+#define hashsize(n) ((guint32)1<<(n))
+#define hashmask(n) (hashsize(n)-1)
+#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
+
+#define mix(a,b,c) \
+{ \
+ a -= c; a ^= rot(c, 4); c += b; \
+ b -= a; b ^= rot(a, 6); a += c; \
+ c -= b; c ^= rot(b, 8); b += a; \
+ a -= c; a ^= rot(c,16); c += b; \
+ b -= a; b ^= rot(a,19); a += c; \
+ c -= b; c ^= rot(b, 4); b += a; \
+}
+
+#define final(a,b,c) \
+{ \
+ c ^= b; c -= rot(b,14); \
+ a ^= c; a -= rot(c,11); \
+ b ^= a; b -= rot(a,25); \
+ c ^= b; c -= rot(b,16); \
+ a ^= c; a -= rot(c,4); \
+ b ^= a; b -= rot(a,14); \
+ c ^= b; c -= rot(b,24); \
+}
+
+ /* hash the images */
+ for (j = 0; j < image; ++j) {
+ unsigned int w, h, length;
+ guint32 a,b,c;
+ guint32 initval = 0xf00d;
+ const guint32 *k = (guint32*)i[j]->data;
+
+ w = i[j]->width;
+ h = i[j]->height;
+ length = w * h;
+
+ /* Set up the internal state */
+ a = b = c = 0xdeadbeef + (((guint32)length)<<2) + initval;
+
+ /*---------------------------------------- handle most of the key */
+ while (length > 3)
+ {
+ a += k[0];
+ b += k[1];
+ c += k[2];
+ mix(a,b,c);
+ length -= 3;
+ k += 3;
+ }
+
+ /*--------------------------------- handle the last 3 uint32_t's */
+ switch(length) /* all the case statements fall through */
+ {
+ case 3 : c+=k[2];
+ case 2 : b+=k[1];
+ case 1 : a+=k[0];
+ final(a,b,c);
+ case 0: /* case 0: nothing left to add */
+ break;
+ }
+ /*------------------------------------ report the result */
+ printf("image[%d] %ux%u %lu\n", j, w, h, c);
+ }
+
win = XCreateSimpleWindow(d, RootWindow(d, s), 0, 0, winw, winh,
0, 0, 0);
assert(win);
--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ override.c for the Openbox window manager
+ Copyright (c) 2003-2007 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+
+int main (int argc, char *argv[]) {
+ XSetWindowAttributes xswa;
+ unsigned long xswamask;
+ Display *display;
+ Window win;
+ XEvent report;
+ int i,x=0,y=0,h=1,w=1;
+
+ for (i=0; i < argc; i++) {
+ if (!strcmp(argv[i], "-g") || !strcmp(argv[i], "-geometry")) {
+ XParseGeometry(argv[++i], &x, &y, &w, &h);
+ }
+ }
+
+ display = XOpenDisplay(NULL);
+
+ if (display == NULL) {
+ fprintf(stderr, "couldn't connect to X server :0\n");
+ return 0;
+ }
+
+ xswa.override_redirect = True;
+ xswamask = CWOverrideRedirect;
+
+ win = XCreateWindow(display, RootWindow(display, 0),
+ x, y, w, h, 0, 0, InputOnly,
+ CopyFromParent, xswamask, &xswa);
+
+ XMapWindow(display, win);
+ XFlush(display);
+
+ while (1) {
+ XNextEvent(display, &report);
+ }
+
+ return 1;
+}
+++ /dev/null
-#ifndef ob__version_h
-#define ob__version_h
-
-#define OB_MAJOR_VERSION @OB_MAJOR_VERSION@
-#define OB_MINOR_VERSION @OB_MINOR_VERSION@
-#define OB_MICRO_VERSION @OB_MICRO_VERSION@
-#define OB_VERSION OB_MAJOR_VERSION.OB_MINOR_VERSION.OB_MICRO_VERSION
-
-#define OB_CHECK_VERSION(major,minor,micro) \
- (OB_MAJOR_VERSION > (major) || \
- (OB_MAJOR_VERSION == (major) && OB_MINOR_VERSION > (minor)) || \
- (OB_MAJOR_VERSION == (major) && OB_MINOR_VERSION == (minor) && \
- OB_MICRO_VERSION >= (micro)))
-
-#endif