]> Dogcows Code - chaz/openbox/commitdiff
Merge branch 'backport'
authorDana Jansens <danakj@orodu.net>
Sun, 10 Feb 2008 00:07:55 +0000 (19:07 -0500)
committerDana Jansens <danakj@orodu.net>
Sun, 10 Feb 2008 00:07:55 +0000 (19:07 -0500)
108 files changed:
.gitignore
Makefile.am
README.GIT
configure.ac
data/rc.xml
m4/openbox.m4
obt/Makefile [moved from parser/Makefile with 100% similarity]
obt/display.c [new file with mode: 0644]
obt/display.h [new file with mode: 0644]
obt/internal.h [moved from openbox/xerror.h with 70% similarity]
obt/keyboard.c [moved from openbox/modkeys.c with 64% similarity]
obt/keyboard.h [moved from openbox/modkeys.h with 52% similarity]
obt/mainloop.c [moved from openbox/mainloop.c with 75% similarity]
obt/mainloop.h [new file with mode: 0644]
obt/obt-4.0.pc.in [new file with mode: 0644]
obt/parse.c [new file with mode: 0644]
obt/parse.h [new file with mode: 0644]
obt/paths.c [new file with mode: 0644]
obt/paths.h [new file with mode: 0644]
obt/prop.c [new file with mode: 0644]
obt/prop.h [new file with mode: 0644]
obt/util.h [new file with mode: 0644]
obt/version.h.in [new file with mode: 0644]
obt/xevent.c [new file with mode: 0644]
obt/xevent.h [new file with mode: 0644]
openbox/actions.c
openbox/actions.h
openbox/actions/addremovedesktop.c
openbox/actions/cyclewindows.c
openbox/actions/debug.c
openbox/actions/desktop.c
openbox/actions/directionalwindows.c
openbox/actions/execute.c
openbox/actions/focus.c
openbox/actions/growtoedge.c
openbox/actions/if.c
openbox/actions/layer.c
openbox/actions/maximize.c
openbox/actions/move.c
openbox/actions/moverelative.c
openbox/actions/moveresizeto.c
openbox/actions/movetoedge.c
openbox/actions/resize.c
openbox/actions/resizerelative.c
openbox/actions/restart.c
openbox/actions/showmenu.c
openbox/client.c
openbox/client.h
openbox/client_menu.c
openbox/config.c
openbox/config.h
openbox/debug.c
openbox/debug.h
openbox/dock.c
openbox/dock.h
openbox/event.c
openbox/event.h
openbox/extensions.c [deleted file]
openbox/extensions.h [deleted file]
openbox/focus.c
openbox/focus_cycle.c
openbox/focus_cycle.h
openbox/focus_cycle_indicator.c
openbox/focus_cycle_popup.c
openbox/focus_cycle_popup.h
openbox/frame.c
openbox/framerender.c
openbox/grab.c
openbox/keyboard.c
openbox/mainloop.h [deleted file]
openbox/menu.c
openbox/menu.h
openbox/menuframe.c
openbox/menuframe.h
openbox/misc.h
openbox/mouse.c
openbox/mouse.h
openbox/moveresize.c
openbox/openbox.c
openbox/openbox.h
openbox/ping.c
openbox/place.c
openbox/popup.c
openbox/prompt.c [new file with mode: 0644]
openbox/prompt.h [new file with mode: 0644]
openbox/resist.c
openbox/resist.h
openbox/screen.c
openbox/session.c
openbox/stacking.c
openbox/startupnotify.c
openbox/translate.c
openbox/translate.h
openbox/window.c
openbox/window.h
openbox/xerror.c [deleted file]
parser/obparser-3.0.pc.in [deleted file]
parser/parse.c [deleted file]
parser/parse.h [deleted file]
po/POTFILES.in
render/font.c
render/obrender-4.0.pc.in [moved from render/obrender-3.0.pc.in with 86% similarity]
render/render.c
render/render.h
render/theme.c
render/theme.h
render/version.h.in [new file with mode: 0644]
version.h.in [deleted file]

index 3baae1438b16b13785bf0bea7382c9c7fabdf0d5..e9374053e4bf091c737920b249a17535a55e6d46 100644 (file)
@@ -32,7 +32,7 @@ m4/*.m4
 missing
 .dirstamp
 openbox/openbox
-parser/obparser-3.0.pc
+parser/obparser-4.0.pc
 po/Makefile.in.in
 po/Makevars.template
 po/POTFILES
@@ -48,7 +48,8 @@ po/en@boldquot.insert-header
 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
index 9781ca840289eeba3eb1c7b7c1ed0641a338b42b..d8dba2c7a27cdbcfce52c614bc8e2632b88e0703 100644 (file)
@@ -8,7 +8,8 @@ rcdir           = $(configdir)/openbox
 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
 
@@ -24,8 +25,8 @@ check_PROGRAMS = \
        render/rendertest
 
 lib_LTLIBRARIES = \
-       parser/libobparser.la \
-       render/libobrender.la
+       render/libobrender.la \
+       obt/libobt.la
 
 bin_PROGRAMS = \
        openbox/openbox \
@@ -47,7 +48,7 @@ render_rendertest_CPPFLAGS = \
        $(GLIB_CFLAGS) \
        -DG_LOG_DOMAIN=\"RenderTest\"
 render_rendertest_LDADD = \
-       parser/libobparser.la \
+       obt/libobt.la \
        render/libobrender.la \
        $(GLIB_LIBS) \
        $(PANGO_LIBS) \
@@ -65,9 +66,9 @@ render_libobrender_la_CPPFLAGS = \
        -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) \
@@ -94,33 +95,52 @@ render_libobrender_la_SOURCES = \
        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) \
@@ -134,11 +154,6 @@ openbox_openbox_CPPFLAGS = \
        -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) \
@@ -147,7 +162,7 @@ openbox_openbox_LDADD = \
        $(EFENCE_LIBS) \
        $(LIBINTL) \
        render/libobrender.la \
-       parser/libobparser.la
+       obt/libobt.la
 openbox_openbox_LDFLAGS = -export-dynamic
 openbox_openbox_SOURCES = \
        gettext.h \
@@ -207,8 +222,6 @@ openbox_openbox_SOURCES = \
        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 \
@@ -230,15 +243,11 @@ openbox_openbox_SOURCES = \
        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 \
@@ -250,10 +259,10 @@ openbox_openbox_SOURCES = \
        openbox/ping.h \
        openbox/place.c \
        openbox/place.h \
+       openbox/prompt.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 \
@@ -267,10 +276,7 @@ openbox_openbox_SOURCES = \
        openbox/translate.c \
        openbox/translate.h \
        openbox/window.c \
-       openbox/window.h \
-       openbox/xerror.c \
-       openbox/xerror.h
-
+       openbox/window.h
 
 ## gnome-panel-control ##
 
@@ -376,7 +382,7 @@ dist_syscrash_theme_DATA= \
 
 ## public headers ##
 
-pubinclude_HEADERS = \
+rrpubinclude_HEADERS = \
        render/color.h \
        render/font.h \
        render/geom.h \
@@ -386,14 +392,22 @@ pubinclude_HEADERS = \
        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 ##
 
@@ -435,7 +449,6 @@ nodist_xsessions_DATA = \
        data/xsession/openbox-kde.desktop
 
 dist_noinst_DATA = \
-       version.h.in \
        data/rc.xsd \
        data/menu.xsd \
        data/xsession/openbox.desktop.in \
@@ -452,8 +465,10 @@ dist_noinst_DATA = \
        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 \
@@ -509,7 +524,7 @@ CLEANFILES = \
 #       $(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 \
index c50118edaf09dd10fc46f1aa670f2f943e662b69..b4b05576a0e01eda275ff22cfbd154008c5f971d 100644 (file)
@@ -3,7 +3,7 @@ To build Openbox from git you need:
 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
index 53e50013683365eb030912601724f9605f47087b..463e7fb352ac31e7885bc336b249e6f740b38992 100644 (file)
@@ -4,41 +4,65 @@ AM_INIT_AUTOMAKE
 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
@@ -154,9 +178,10 @@ AC_CONFIG_FILES([
   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])
index 98daf274a614f3e3df5bfaa8b2e3661ecf373245..ef3d9bdc9f3efe8979b6a92ed6c7ba9764c9a64d 100644 (file)
     </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>
index 29114360f3608e2433bf16797a9b054a302e497f..18e271788a1d969da9d7ce5380a7a33c66a4df10 100644 (file)
@@ -64,7 +64,7 @@ AC_DEFUN([OB_COMPILER_FLAGS],
     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
similarity index 100%
rename from parser/Makefile
rename to obt/Makefile
diff --git a/obt/display.c b/obt/display.c
new file mode 100644 (file)
index 0000000..d72f8ad
--- /dev/null
@@ -0,0 +1,152 @@
+/* -*- 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;
+}
diff --git a/obt/display.h b/obt/display.h
new file mode 100644 (file)
index 0000000..8c074b5
--- /dev/null
@@ -0,0 +1,68 @@
+/* -*- 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*/
similarity index 70%
rename from openbox/xerror.h
rename to obt/internal.h
index de1aa5a8e8f855d36be5aa943ddad3a699fa7a2b..dae854c1c7f76368313d089c424fce8bad93035c 100644 (file)
@@ -1,6 +1,7 @@
 /* -*- 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 */
similarity index 64%
rename from openbox/modkeys.c
rename to obt/keyboard.c
index 9e8da321b2adad407012375fce99e996bdb69428..710a94c23b33ccad97af9421f514214a71b474e8 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- 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
@@ -16,8 +16,8 @@
    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);
 
@@ -86,18 +92,21 @@ void modkeys_startup(gboolean reconfigure)
     }
 
     /* 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;
@@ -116,7 +125,7 @@ guint modkeys_keycode_to_mask(guint keycode)
     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 */
@@ -124,12 +133,12 @@ guint modkeys_only_modifier_masks(guint mask)
                           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];
 }
@@ -139,44 +148,44 @@ static void set_modkey_mask(guchar mask, KeySym sym)
     /* 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;
 
@@ -188,3 +197,28 @@ KeyCode modkeys_sym_to_code(KeySym sym)
     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;
+}
similarity index 52%
rename from openbox/modkeys.h
rename to obt/keyboard.h
index dc72f28e442bf7b898e5339e3488ee9b88117062..a9029df39bd7337c7805778301078abcea7432fe 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- 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 */
similarity index 75%
rename from openbox/mainloop.c
rename to obt/mainloop.c
index b2921207b45ab716b4263c433f2d41ed0624b662..64972dd708eb17aecec0fae7fa9190d6c1be12aa 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- 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 */
@@ -64,11 +66,13 @@ static gint core_signals[] =
 #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 */
@@ -90,7 +94,7 @@ struct _ObMainLoop
     GSList *signal_handlers[NUM_SIGNALS];
 };
 
-struct _ObMainLoopTimer
+struct _ObtMainLoopTimer
 {
     gulong delay;
     GSourceFunc func;
@@ -110,42 +114,41 @@ struct _ObMainLoopTimer
     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);
@@ -185,24 +188,29 @@ ObMainLoop *ob_main_loop_new(Display *display)
     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);
         }
@@ -211,9 +219,9 @@ void ob_main_loop_destroy(ObMainLoop *loop)
 
         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);
@@ -230,7 +238,7 @@ void ob_main_loop_destroy(ObMainLoop *loop)
             }
         }
 
-        g_free(loop);
+        obt_free0(loop, ObtMainLoop, 1);
     }
 }
 
@@ -238,14 +246,14 @@ static void fd_handle_foreach(gpointer key,
                               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;
@@ -268,7 +276,7 @@ void ob_main_loop_run(ObMainLoop *loop)
                 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]--;
@@ -277,12 +285,12 @@ void ob_main_loop_run(ObMainLoop *loop)
             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);
@@ -312,35 +320,45 @@ void ob_main_loop_run(ObMainLoop *loop)
     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);
@@ -348,6 +366,11 @@ void ob_main_loop_x_remove(ObMainLoop *loop,
             g_free(h);
         }
     }
+
+    if (!loop->x_handlers) {
+        FD_CLR(loop->fd_x, &loop->fd_set);
+        calc_max_fd(loop);
+    }
 }
 
 /*** SIGNAL WATCHERS ***/
@@ -372,23 +395,23 @@ static void sighandler(gint sig)
         }
 
     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;
@@ -412,15 +435,15 @@ void ob_main_loop_signal_add(ObMainLoop *loop,
     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);
 
@@ -447,28 +470,28 @@ void ob_main_loop_signal_remove(ObMainLoop *loop,
 
 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;
@@ -482,7 +505,7 @@ void ob_main_loop_fd_add(ObMainLoop *loop,
 
 static void fd_handler_destroy(gpointer data)
 {
-    ObMainLoopFdHandlerType *h = data;
+    ObtMainLoopFdHandlerType *h = data;
 
     FD_CLR(h->fd, &h->loop->fd_set);
 
@@ -490,16 +513,17 @@ static void fd_handler_destroy(gpointer data)
         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)
 {
@@ -508,11 +532,11 @@ 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;
@@ -522,14 +546,14 @@ static void insert_timer(ObMainLoop *loop, ObMainLoopTimer *ins)
         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 */
 
@@ -546,25 +570,25 @@ void ob_main_loop_timeout_add(ObMainLoop *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)
@@ -574,7 +598,7 @@ void ob_main_loop_timeout_remove_data(ObMainLoop *loop, GSourceFunc handler,
 }
 
 /* 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;
@@ -594,7 +618,7 @@ static gboolean nearest_timeout_wait(ObMainLoop *loop, GTimeVal *tm)
   return TRUE;
 }
 
-static void timer_dispatch(ObMainLoop *loop, GTimeVal **wait)
+static void timer_dispatch(ObtMainLoop *loop, GTimeVal **wait)
 {
     GSList *it, *next;
 
@@ -603,7 +627,7 @@ static void timer_dispatch(ObMainLoop *loop, GTimeVal **wait)
     g_get_current_time(&loop->now);
 
     for (it = loop->timers; it; it = next) {
-        ObMainLoopTimer *curr;
+        ObtMainLoopTimer *curr;
 
         next = g_slist_next(it);
 
diff --git a/obt/mainloop.h b/obt/mainloop.h
new file mode 100644 (file)
index 0000000..cce7d5b
--- /dev/null
@@ -0,0 +1,81 @@
+/* -*- 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
diff --git a/obt/obt-4.0.pc.in b/obt/obt-4.0.pc.in
new file mode 100644 (file)
index 0000000..ee2a3f0
--- /dev/null
@@ -0,0 +1,14 @@
+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}
diff --git a/obt/parse.c b/obt/parse.c
new file mode 100644 (file)
index 0000000..d181b67
--- /dev/null
@@ -0,0 +1,413 @@
+/* -*- 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;
+}
diff --git a/obt/parse.h b/obt/parse.h
new file mode 100644 (file)
index 0000000..8e5acd7
--- /dev/null
@@ -0,0 +1,85 @@
+/* -*- 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
diff --git a/obt/paths.c b/obt/paths.c
new file mode 100644 (file)
index 0000000..6100499
--- /dev/null
@@ -0,0 +1,247 @@
+/* -*- 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;
+}
diff --git a/obt/paths.h b/obt/paths.h
new file mode 100644 (file)
index 0000000..a6e32ae
--- /dev/null
@@ -0,0 +1,44 @@
+/* -*- 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
diff --git a/obt/prop.c b/obt/prop.c
new file mode 100644 (file)
index 0000000..89d3950
--- /dev/null
@@ -0,0 +1,495 @@
+/* -*- 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);
+}
diff --git a/obt/prop.h b/obt/prop.h
new file mode 100644 (file)
index 0000000..e123611
--- /dev/null
@@ -0,0 +1,278 @@
+/* -*- 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 */
diff --git a/obt/util.h b/obt/util.h
new file mode 100644 (file)
index 0000000..ff44d36
--- /dev/null
@@ -0,0 +1,37 @@
+/* -*- 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*/
diff --git a/obt/version.h.in b/obt/version.h.in
new file mode 100644 (file)
index 0000000..8adfcf8
--- /dev/null
@@ -0,0 +1,15 @@
+#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
diff --git a/obt/xevent.c b/obt/xevent.c
new file mode 100644 (file)
index 0000000..9732c8f
--- /dev/null
@@ -0,0 +1,134 @@
+/* -*- 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);
+}
diff --git a/obt/xevent.h b/obt/xevent.h
new file mode 100644 (file)
index 0000000..a93a1a6
--- /dev/null
@@ -0,0 +1,48 @@
+/* -*- 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*/
index b7ba5b44291c59a548a71dc3b00cf2e252544f63..11581af6b199d94900b082cf739de86b9a964253 100644 (file)
@@ -36,7 +36,6 @@ static ObActionsAct* actions_build_act_from_string(const gchar *name);
 
 static ObActionsAct *interactive_act = NULL;
 static guint         interactive_initial_state = 0;
-static gboolean      replay_pointer = FALSE;
 
 struct _ObActionsDefinition {
     guint ref;
@@ -160,23 +159,21 @@ ObActionsAct* actions_parse_string(const gchar *name)
 
     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);
     }
@@ -224,16 +221,6 @@ static void actions_setup_data(ObActionsData *data,
     data->client = client;
 }
 
-void actions_set_need_pointer_replay_before_move(gboolean replay)
-{
-    replay_pointer = replay;
-}
-
-gboolean actions_get_need_pointer_replay_before_move()
-{
-    return replay_pointer;
-}
-
 void actions_run_acts(GSList *acts,
                       ObUserAction uact,
                       guint state,
@@ -346,14 +333,8 @@ gboolean actions_interactive_input_event(XEvent *e)
 void actions_client_move(ObActionsData *data, gboolean start)
 {
     static gulong ignore_start = 0;
-    if (start) {
+    if (start)
         ignore_start = event_start_ignore_all_enters();
-        if (replay_pointer) {
-            /* replay the pointer event before any windows move */
-            XAllowEvents(ob_display, ReplayPointer, event_curtime);
-            replay_pointer = FALSE;
-        }
-    }
     else if (config_focus_follow &&
              data->context != OB_FRAME_CONTEXT_CLIENT)
     {
index 6db6f8d666f6bca878f38f3bc8be60c835b6bee5..7975d4ebd1f1996f5b61613e3581b942b9bdd5e4 100644 (file)
@@ -18,7 +18,8 @@
 
 #include "misc.h"
 #include "frame.h"
-#include "parser/parse.h"
+#include "obt/parse.h"
+
 #include <glib.h>
 #include <X11/Xlib.h>
 
@@ -30,8 +31,7 @@ typedef struct _ObActionsGlobalData   ObActionsGlobalData;
 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);
@@ -64,9 +64,7 @@ gboolean actions_register(const gchar *name,
                           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);
index 8125b9bb8a205892d68bcc9830a19e24453c3277..b6e621ab0c5f74a523f748a86caa76c6f554548e 100644 (file)
@@ -7,36 +7,28 @@ typedef struct {
     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"))
@@ -47,28 +39,20 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
     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)
 {
index cb341af7e1f679d9f75b2e5b4611aee40a85f4d7..44d87cf6cf4a3fff0d3c0e34f6547b263030d375 100644 (file)
@@ -8,23 +8,21 @@
 
 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,
@@ -43,38 +41,42 @@ void action_cyclewindows_startup(void)
                      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 {
@@ -89,18 +91,16 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
     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;
 }
@@ -129,7 +129,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
                      o->linear,
                      TRUE,
                      o->bar,
-                     o->dialog,
+                     o->dialog_mode,
                      FALSE, FALSE);
     cycling = TRUE;
 
@@ -189,7 +189,7 @@ static void end_cycle(gboolean cancel, guint state, Options *o)
                      o->linear,
                      TRUE,
                      o->bar,
-                     o->dialog,
+                     o->dialog_mode,
                      TRUE, cancel);
     cycling = FALSE;
 
index f71b685df8a81357a9806dedbbfc62dd3c12719b..99e838a64c7dbee4a88d365cef6b6384dfcee480 100644 (file)
@@ -5,39 +5,32 @@ typedef struct {
     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 */
index d939ed511ad5dd938fe92bd9d7da645444173b7c..37268bba9900c42d29fb4ffbb450f68168388c9b 100644 (file)
@@ -26,10 +26,8 @@ typedef struct {
     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)
@@ -40,8 +38,7 @@ 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;
@@ -53,8 +50,8 @@ static gpointer setup_go_func(ObParseInst *i, xmlDocPtr doc,
     /* 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")) {
@@ -89,29 +86,28 @@ static gpointer setup_go_func(ObParseInst *i, xmlDocPtr doc,
         }
         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;
 }
index 55c9e606a6591727804cbb48a19c1099bf33bc6a..c5c25c11329b0aa7768df61a60f0c55597069fab 100644 (file)
@@ -20,11 +20,9 @@ typedef struct {
 
 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,
@@ -43,7 +41,7 @@ void action_directionalwindows_startup(void)
                      run_func, NULL, NULL);
 }
 
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
 {
     xmlNodePtr n;
     Options *o;
@@ -52,18 +50,18 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
     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;
@@ -87,14 +85,14 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
         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 {
@@ -109,18 +107,16 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
     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;
 }
index a857b1b83e45e242d5c411872b289e5b0722b9ce..c534ba8b3de5b5fc629658b592a8c1aee161e7dc 100644 (file)
@@ -2,6 +2,7 @@
 #include "openbox/event.h"
 #include "openbox/startupnotify.h"
 #include "openbox/screen.h"
+#include "obt/paths.h"
 #include "gettext.h"
 
 #ifdef HAVE_STDLIB_H
@@ -16,7 +17,7 @@ typedef struct {
     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);
 /*
@@ -29,38 +30,34 @@ static void     i_cancel_func(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;
 }
index 67c1479fa95e77171a0e3d7719bef8a481cb3b0f..4d0f220d1320dcc9ada4b8546d26c2aee35ec498 100644 (file)
@@ -7,38 +7,26 @@ typedef struct {
     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)
 {
@@ -55,7 +43,9 @@ static gboolean run_func(ObActionsData *data, gpointer options)
             (data->context != OB_FRAME_CONTEXT_CLIENT &&
              data->context != OB_FRAME_CONTEXT_FRAME))
         {
+            actions_client_move(data, TRUE);
             client_activate(data->client, o->here, FALSE, FALSE, TRUE);
+            actions_client_move(data, FALSE);
         }
     } else if (data->context == OB_FRAME_CONTEXT_DESKTOP) {
         /* focus action on the root window. make keybindings work for this
index 69b8ef77b33ce4db0621992c08ceafe9b26e7a15..a37e3a26e093606100ea82581e368bcf7bb4fff1 100644 (file)
@@ -7,31 +7,32 @@
 
 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;
@@ -50,11 +51,14 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
     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)
@@ -98,11 +102,13 @@ static gboolean run_func(ObActionsData *data, gpointer options)
         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 :
index a35c61fce70a96c4df8944c4294957ea4e986409..63a7fbcd20d10c235282ce5e6fe99888e9dec06b 100644 (file)
@@ -23,81 +23,77 @@ typedef struct {
     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");
         }
     }
 
@@ -108,6 +104,15 @@ static void free_func(gpointer options)
 {
     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);
 }
 
index 92fa4806ebd36990d934117c7711d3beed2ab855..bbfda57218f122ae1784dc11ba03c9372d4cebf1 100644 (file)
@@ -6,11 +6,9 @@ typedef struct {
     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)
@@ -23,7 +21,7 @@ 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;
@@ -31,8 +29,7 @@ static gpointer setup_func_top(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
     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;
@@ -40,16 +37,15 @@ static gpointer setup_func_bottom(ObParseInst *i, xmlDocPtr doc,
     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;
index bb6f470ac557ab54084e2d67f12a1fa7be2c6141..45e8b38ed55801812a61f897c473fbd860c5db08 100644 (file)
@@ -12,7 +12,7 @@ typedef struct {
     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);
@@ -27,7 +27,7 @@ void action_maximize_startup(void)
                      NULL, NULL);
 }
 
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
 {
     xmlNodePtr n;
     Options *o;
@@ -35,8 +35,8 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
     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;
index 1a8ea2047c0475a139222b2228e617c4e13b0b92..ddd3f59af7d1a76fb9144132c933e0612e112f59 100644 (file)
@@ -1,6 +1,6 @@
 #include "openbox/actions.h"
-#include "openbox/prop.h"
 #include "openbox/moveresize.h"
+#include "obt/prop.h"
 
 static gboolean run_func(ObActionsData *data, gpointer options);
 
@@ -19,8 +19,8 @@ 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);
     }
index 1d1189cdb7c089d26ef74dd00e3052ef77cce863..ccdff545d5702d02c4a470e98df31b3249c7e823 100644 (file)
@@ -9,41 +9,29 @@ typedef struct {
     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)
 {
index 860bf73af33704133fa38c9adc2c1a948b8ee28d..d355dafdc5c30ea0535c1b239a2a62275899e364 100644 (file)
@@ -21,23 +21,18 @@ typedef struct {
     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;
@@ -53,7 +48,7 @@ static void parse_coord(xmlDocPtr doc, xmlNodePtr n, gint *pos,
     g_free(s);
 }
 
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
 {
     xmlNodePtr n;
     Options *o;
@@ -65,32 +60,32 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
     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);
     }
@@ -98,13 +93,6 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
     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)
 {
index 5941bde97fa73979e0d8c2c89d2340d41152fc25..f360ddd03da63309ea0da0ddc26a989b350a7e8e 100644 (file)
@@ -9,20 +9,15 @@ typedef struct {
     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;
@@ -30,8 +25,8 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
     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;
@@ -50,13 +45,6 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
     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)
 {
index 3714e38b0c534af980061140198c9351492cd547..47f45f5b2de4aadcfb3dbcc88870d67ae86bf701 100644 (file)
@@ -1,16 +1,15 @@
 #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,
@@ -18,40 +17,36 @@ 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;
 
@@ -60,13 +55,6 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
     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)
 {
@@ -77,7 +65,7 @@ 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
@@ -163,30 +151,30 @@ static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch,
     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
index f705c292bf8b75d4f30607cf6bf9875378e73ba0..5742e1fcff0a963e589aa370de47e6d11377c135 100644 (file)
@@ -11,47 +11,36 @@ typedef struct {
     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)
 {
index 4b52f9d36f4ee222bae649a4c71caead045d4791..47f332b184ee9cd4f04c45aa8855550ab4af47f6 100644 (file)
@@ -1,35 +1,32 @@
 #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;
@@ -38,11 +35,8 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
 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 */
index c1d53e41d8c76fbc74ac7d147cccdcfa69b50fd7..9590bd1589561eaedd7616606f3d1f5c38c7e4ed 100644 (file)
@@ -6,7 +6,7 @@ typedef struct {
     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);
 
@@ -16,15 +16,15 @@ void action_showmenu_startup(void)
                      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;
 }
 
index e7290ca51135b3f874a5d6f5ce7622b968ab7638..dd1f5e72b92c8535f1e29516d5f82a1b2ed13f45 100644 (file)
 #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 "grab.h"
+#include "prompt.h"
 #include "focus.h"
 #include "stacking.h"
 #include "openbox.h"
@@ -42,6 +40,8 @@
 #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>
@@ -104,6 +104,7 @@ static GSList *client_search_all_top_parents_internal(ObClient *self,
                                                       ObStackingLayer layer);
 static void client_call_notifies(ObClient *self, GSList *list);
 static void client_ping_event(ObClient *self, gboolean dead);
+static void client_prompt_kill(ObClient *self);
 
 
 void client_startup(gboolean reconfig)
@@ -166,8 +167,8 @@ void client_set_list(void)
     } 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);
@@ -175,111 +176,34 @@ void client_set_list(void)
     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]);
-        }
-    }
-    XFree(children);
-}
-
-void client_manage(Window window)
+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();
 
-    /* choose the events we want to receive on the CLIENT window */
-    attrib_set.event_mask = CLIENT_EVENTMASK;
+    /* choose the events we want to receive on the CLIENT window
+       (ObPrompt windows can request events too) */
+    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;
 
     /* non-zero defaults */
     self->wmstate = WithdrawnState; /* make sure it gets updated first time */
@@ -289,8 +213,8 @@ void client_manage(Window window)
     /* 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
@@ -298,8 +222,10 @@ void client_manage(Window window)
     client_setup_decor_and_functions(self, FALSE);
 
     /* specify that if we exit, the window should not be destroyed and
-       should be reparented back to root automatically */
-    XChangeSaveSet(ob_display, window, SetModeInsert);
+       should be reparented back to root automatically, unless we are managing
+       an internal ObPrompt window  */
+    if (!self->prompt)
+        XChangeSaveSet(obt_display, window, SetModeInsert);
 
     /* create the decoration frame for the client window */
     self->frame = frame_new(self);
@@ -344,7 +270,7 @@ void client_manage(Window window)
     }
 
     /* 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 */
@@ -357,7 +283,7 @@ void client_manage(Window 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" :
@@ -365,7 +291,7 @@ void client_manage(Window window)
                      "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" :
@@ -437,7 +363,7 @@ void client_manage(Window window)
         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;
@@ -447,11 +373,11 @@ void client_manage(Window window)
     }
 
     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);
 
@@ -466,7 +392,7 @@ void client_manage(Window window)
     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;
@@ -474,7 +400,7 @@ void client_manage(Window window)
         /* 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);
 
@@ -484,7 +410,7 @@ void client_manage(Window window)
             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 */
@@ -498,7 +424,7 @@ void client_manage(Window window)
             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 &&
@@ -515,14 +441,14 @@ void client_manage(Window window)
                 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.
@@ -533,7 +459,7 @@ void client_manage(Window window)
                 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 */
@@ -542,7 +468,7 @@ void client_manage(Window window)
                 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))
@@ -558,7 +484,7 @@ void client_manage(Window window)
         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 */
@@ -603,7 +529,7 @@ void client_manage(Window window)
 
     /* 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))
@@ -624,10 +550,8 @@ void client_manage(Window window)
     /* 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;
 }
 
 
@@ -636,7 +560,7 @@ ObClient *client_fake_manage(Window window)
     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 */
 
@@ -654,7 +578,7 @@ ObClient *client_fake_manage(Window window)
     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);
 
@@ -676,7 +600,7 @@ void client_unmanage(ObClient *self)
     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 : "");
 
@@ -684,7 +608,7 @@ void client_unmanage(ObClient *self)
 
     /* 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)
@@ -692,15 +616,17 @@ void client_unmanage(ObClient *self)
 
     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);
 
     mouse_grab_for_client(self, FALSE);
 
-    /* remove the window from our save set */
-    XChangeSaveSet(ob_display, self->window, SetModeDelete);
+    /* remove the window from our save set, unless we are managing an internal
+       ObPrompt window */
+    if (!self->prompt)
+        XChangeSaveSet(obt_display, self->window, SetModeDelete);
 
     /* update the focus lists */
     focus_order_remove(self);
@@ -709,9 +635,13 @@ void client_unmanage(ObClient *self)
         focus_client = NULL;
     }
 
+    /* if we're prompting to kill the client, close that */
+    prompt_unref(self->kill_prompt);
+    self->kill_prompt = NULL;
+
     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 */
@@ -764,7 +694,7 @@ void client_unmanage(ObClient *self)
         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);
     }
@@ -777,25 +707,25 @@ void client_unmanage(ObClient *self)
     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 */
     g_slist_free(self->transients);
@@ -807,6 +737,7 @@ void client_unmanage(ObClient *self)
     g_free(self->wm_command);
     g_free(self->title);
     g_free(self->icon_title);
+    g_free(self->original_title);
     g_free(self->name);
     g_free(self->class);
     g_free(self->role);
@@ -853,7 +784,7 @@ static ObAppSettings *client_get_settings_state(ObClient *self)
             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 */
@@ -908,17 +839,17 @@ static void client_restore_session_state(ObClient *self)
     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);
@@ -928,13 +859,13 @@ static void client_restore_session_state(ObClient *self)
         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;
@@ -1161,10 +1092,11 @@ static void client_get_all(ObClient *self, gboolean real)
 
 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)
@@ -1172,14 +1104,14 @@ 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);
 }
 
@@ -1187,12 +1119,12 @@ static void client_get_desktop(ObClient *self)
 {
     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;
@@ -1215,7 +1147,7 @@ static void client_get_desktop(ObClient *self)
         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 */
@@ -1223,13 +1155,13 @@ static void client_get_desktop(ObClient *self)
             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);
         }
     }
@@ -1240,32 +1172,32 @@ static void client_get_state(ObClient *self)
     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;
         }
 
@@ -1277,14 +1209,14 @@ static void client_get_shaped(ObClient *self)
 {
     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);
@@ -1298,22 +1230,22 @@ void client_update_transient_for(ObClient *self)
     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;
@@ -1449,8 +1381,8 @@ static void client_get_mwm_hints(ObClient *self)
 
     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];
@@ -1469,26 +1401,27 @@ void client_get_type_and_transientness(ObClient *self)
     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 |
@@ -1502,7 +1435,7 @@ void client_get_type_and_transientness(ObClient *self)
         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) {
@@ -1528,26 +1461,26 @@ void client_get_type_and_transientness(ObClient *self)
 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 */
@@ -1563,7 +1496,8 @@ void client_update_sync_request_counter(ObClient *self)
 {
     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;
@@ -1574,7 +1508,7 @@ static void client_get_colormap(ObClient *self)
 {
     XWindowAttributes wa;
 
-    if (XGetWindowAttributes(ob_display, self->window, &wa))
+    if (XGetWindowAttributes(obt_display, self->window, &wa))
         client_update_colormap(self, wa.colormap);
 }
 
@@ -1582,7 +1516,7 @@ void client_update_colormap(ObClient *self, Colormap 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 */
@@ -1606,7 +1540,7 @@ void client_update_normal_hints(ObClient *self)
     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))
         */
@@ -1637,15 +1571,15 @@ void client_update_normal_hints(ObClient *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)
@@ -1818,38 +1752,38 @@ static void client_change_allowed_actions(ObClient *self)
 
     /* 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);
@@ -1873,7 +1807,7 @@ void client_update_wmhints(ObClient *self)
     /* 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)
@@ -1959,12 +1893,13 @@ void client_update_title(ObClient *self)
     gchar *visible = NULL;
 
     g_free(self->title);
+    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:
@@ -1975,6 +1910,7 @@ void client_update_title(ObClient *self)
                 data = g_strdup("Unnamed Window");
         }
     }
+    self->original_title = g_strdup(data);
 
     if (self->client_machine) {
         visible = g_strdup_printf("%s (%s)", data, self->client_machine);
@@ -1984,14 +1920,14 @@ void client_update_title(ObClient *self)
 
     if (self->not_responding) {
         data = visible;
-        if (self->close_tried_term)
+        if (self->kill_level > 0)
             visible = g_strdup_printf("%s - [%s]", data, _("Killing..."));
         else
             visible = g_strdup_printf("%s - [%s]", data, _("Not Responding"));
         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)
@@ -2002,10 +1938,10 @@ void client_update_title(ObClient *self)
     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) {
@@ -2016,14 +1952,14 @@ void client_update_title(ObClient *self)
 
     if (self->not_responding) {
         data = visible;
-        if (self->close_tried_term)
+        if (self->kill_level > 0)
             visible = g_strdup_printf("%s - [%s]", data, _("Killing..."));
         else
             visible = g_strdup_printf("%s - [%s]", data, _("Not Responding"));
         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;
 }
 
@@ -2034,8 +1970,9 @@ void client_update_strut(ObClient *self)
     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,
@@ -2047,7 +1984,7 @@ void client_update_strut(ObClient *self)
     }
 
     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;
 
@@ -2099,7 +2036,7 @@ void client_update_icons(ObClient *self)
         g_free(self->icons);
     self->nicons = 0;
 
-    if (PROP_GETA32(self->window, net_wm_icon, cardinal, &data, &num)) {
+    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;
@@ -2172,11 +2109,11 @@ void client_update_icons(ObClient *self)
     } else {
         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);
+                obt_display_ignore_errors(TRUE);
                 if (!RrPixmapToRGBA(ob_rr_inst,
                                     hints->icon_pixmap,
                                     (hints->flags & IconMaskHint ?
@@ -2188,7 +2125,7 @@ void client_update_icons(ObClient *self)
                     g_free(self->icons);
                     self->nicons = 0;
                 }
-                xerror_set_ignore(FALSE);
+                obt_display_ignore_errors(FALSE);
             }
             XFree(hints);
         }
@@ -2212,7 +2149,7 @@ void client_update_icons(ObClient *self)
                 (((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);
+        OBT_PROP_SETA32(self->window, NET_WM_ICON, CARDINAL, data, 48*48+2);
         g_free(data);
     } else if (self->frame)
         /* don't draw the icon empty if we're just setting one now anyways,
@@ -2227,7 +2164,8 @@ 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 */
@@ -2244,23 +2182,23 @@ static void client_get_session_ids(ObClient *self)
     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]) {
@@ -2277,9 +2215,9 @@ static void client_get_session_ids(ObClient *self)
     /* 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;
@@ -2290,9 +2228,9 @@ static void client_get_session_ids(ObClient *self)
     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 */
@@ -2315,9 +2253,9 @@ static void client_get_session_ids(ObClient *self)
     /* 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];
@@ -2332,7 +2270,7 @@ static void client_get_session_ids(ObClient *self)
 
         /* 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;
     }
 }
@@ -2352,12 +2290,12 @@ static void client_change_wm_state(ObClient *self)
         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);
     }
 }
 
@@ -2368,30 +2306,30 @@ static void client_change_state(ObClient *self)
 
     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);
@@ -2572,6 +2510,10 @@ gboolean client_show(ObClient *self)
     gboolean show = FALSE;
 
     if (client_should_show(self)) {
+        /* replay pending pointer event before showing the window, in case it
+           should be going to something under the window */
+        mouse_replay_pointer();
+
         frame_show(self->frame);
         show = TRUE;
 
@@ -2613,6 +2555,10 @@ gboolean client_hide(ObClient *self)
            so trying to ignore them is futile in case 3 anyways
         */
 
+        /* replay pending pointer event before hiding the window, in case it
+           should be going to the window */
+        mouse_replay_pointer();
+
         frame_hide(self->frame);
         hide = TRUE;
 
@@ -2689,7 +2635,7 @@ static void client_apply_startup_state(ObClient *self,
        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;
@@ -2729,7 +2675,7 @@ static void client_apply_startup_state(ObClient *self,
     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
@@ -3005,7 +2951,7 @@ void client_configure(ObClient *self, gint x, gint y, gint w, gint h,
 
     /* 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);
@@ -3028,6 +2974,10 @@ void client_configure(ObClient *self, gint x, gint y, gint w, gint h,
         if (!user)
             ignore_start = event_start_ignore_all_enters();
 
+        /* replay pending pointer event before move the window, in case it
+           would change what window gets the event */
+        mouse_replay_pointer();
+
         frame_adjust_area(self->frame, fmoved, fresized, FALSE);
 
         if (!user)
@@ -3067,11 +3017,11 @@ void client_configure(ObClient *self, gint x, gint y, gint w, gint h,
         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 */
@@ -3093,11 +3043,11 @@ void client_configure(ObClient *self, gint x, gint y, gint w, gint h,
      */
     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 */
@@ -3148,7 +3098,7 @@ void client_fullscreen(ObClient *self, gboolean fs)
         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);
@@ -3174,7 +3124,7 @@ static void client_iconify_recursive(ObClient *self,
 
 
     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) {
@@ -3318,9 +3268,14 @@ static void client_ping_event(ObClient *self, gboolean dead)
     client_update_title(self);
 
     if (!dead) {
-        /* try kill it nicely the first time again, if it started responding
-           at some point */
-        self->close_tried_term = FALSE;
+        /* it came back to life ! */
+
+        if (self->kill_prompt) {
+            prompt_unref(self->kill_prompt);
+            self->kill_prompt = NULL;
+        }
+
+        self->kill_level = 0;
     }
 }
 
@@ -3328,42 +3283,98 @@ void client_close(ObClient *self)
 {
     if (!(self->functions & OB_CLIENT_FUNC_CLOSE)) return;
 
+    if (self->prompt) {
+        prompt_cancel(self->prompt);
+        return;
+    }
+
     /* in the case that the client provides no means to requesting that it
        close, we just kill it */
     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);
-    else if (self->not_responding)
-        client_kill(self);
-    else
+        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);
+
+        if (self->not_responding)
+            client_prompt_kill(self);
+    }
+}
+
+#define OB_KILL_RESULT_NO 0
+#define OB_KILL_RESULT_YES 1
+
+static void client_kill_requested(ObPrompt *p, gint result, gpointer data)
+{
+    ObClient *self = data;
+
+    if (result == OB_KILL_RESULT_YES)
+        client_kill(self);
+
+    prompt_unref(self->kill_prompt);
+    self->kill_prompt = NULL;
+}
+
+static void client_prompt_kill(ObClient *self)
+{
+    /* check if we're already prompting */
+    if (!self->kill_prompt) {
+        ObPromptAnswer answers[] = {
+            { _("No"), OB_KILL_RESULT_NO },
+            { _("Yes"), OB_KILL_RESULT_YES }
+        };
+        gchar *m;
+        const gchar *sig;
+
+        if (self->kill_level == 0)
+            sig = "terminate";
+        else
+            sig = "kill";
+
+        m = g_strdup_printf
+            (_("The window \"%s\" does not seem to be responding.  Do you want to force it to exit by sending the %s signal?"), self->original_title, sig);
+
+        self->kill_prompt = prompt_new(m, answers,
+                                       sizeof(answers)/sizeof(answers[0]),
+                                       OB_KILL_RESULT_NO, /* default = no */
+                                       OB_KILL_RESULT_NO, /* cancel = no */
+                                       client_kill_requested, self);
+        g_free(m);
+    }
+
+    prompt_show(self->kill_prompt, self);
 }
 
 void client_kill(ObClient *self)
 {
+    /* don't kill our own windows */
+    if (self->prompt) return;
+
     if (!self->client_machine && self->pid) {
         /* running on the local host */
-        if (!self->close_tried_term) {
-            ob_debug("killing window 0x%x with pid %lu, with SIGTERM\n",
+        if (self->kill_level == 0) {
+            ob_debug("killing window 0x%x with pid %lu, with SIGTERM",
                      self->window, self->pid);
             kill(self->pid, SIGTERM);
-            self->close_tried_term = TRUE;
+            ++self->kill_level;
 
             /* show that we're trying to kill it */
             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
-        XKillClient(ob_display, self->window);
+    else {
+        /* running on a remote host */
+        XKillClient(obt_display, self->window);
+    }
 }
 
 void client_hilite(ObClient *self, gboolean hilite)
@@ -3392,13 +3403,13 @@ static void client_set_desktop_recursive(ObClient *self,
 
     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 */
@@ -3454,11 +3465,12 @@ gboolean client_validate(ObClient *self)
 {
     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;
     }
 
@@ -3493,9 +3505,9 @@ void client_set_state(ObClient *self, Atom action, glong data1, glong data2)
     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;
 
@@ -3505,103 +3517,103 @@ void client_set_state(ObClient *self, Atom action, glong data1, glong data2)
         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;
             }
         }
@@ -3693,12 +3705,12 @@ gboolean client_focus(ObClient *self)
 
     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
@@ -3714,35 +3726,35 @@ gboolean client_focus(ObClient *self)
     */
     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,
@@ -4067,15 +4079,15 @@ static void detect_edge(Rect area, ObDirection dir,
             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;
     }
@@ -4140,7 +4152,7 @@ void client_find_edge_directional(ObClient *self, ObDirection dir,
             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);
@@ -4261,10 +4273,10 @@ void client_find_resize_directional(ObClient *self, ObDirection side,
         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;
index 83fdc9afd94464b6f41677d832c509277a7ea136..dbe93d2835dd28af87b2014b29859825ef09ade2 100644 (file)
@@ -37,6 +37,7 @@
 struct _ObFrame;
 struct _ObGroup;
 struct _ObSessionState;
+struct _ObPrompt;
 
 typedef struct _ObClient      ObClient;
 typedef struct _ObClientIcon  ObClientIcon;
@@ -82,6 +83,10 @@ struct _ObClient
     ObWindow obwin;
     Window  window;
 
+    /*! If this client is managing an ObPrompt window, then this is set to the
+      prompt */
+    struct _ObPrompt *prompt;
+
     /*! The window's decorations. NULL while the window is being managed! */
     struct _ObFrame *frame;
 
@@ -115,6 +120,8 @@ struct _ObClient
     gchar *title;
     /*! Window title when iconified */
     gchar *icon_title;
+    /*! The title as requested by the client, without any of our own changes */
+    gchar *original_title;
     /*! Hostname of machine running the client */
     gchar *client_machine;
     /*! The command used to run the program. Pre-XSMP window identification. */
@@ -231,8 +238,11 @@ struct _ObClient
     /*! Indicates if the client is trying to close but has stopped responding
       to pings */
     gboolean not_responding;
+    /*! A prompt shown when you are trying to close a client that is not
+      responding.  It asks if you want to kill the client */
+    struct _ObPrompt *kill_prompt;
     /*! We tried to close the window with a SIGTERM */
-    gboolean close_tried_term;
+    gint kill_level;
 
 #ifdef SYNC
     /*! The client wants to sync during resizes */
@@ -322,11 +332,11 @@ typedef void (*ObClientCallback)(ObClient *client, gpointer data);
 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.
 */
-void client_manage(Window win);
+void client_manage(Window win, struct _ObPrompt *prompt);
 /*! Unmanages all managed windows */
 void client_unmanage_all();
 /*! Unmanages a given client */
index f35b5bd312d138326ddeb8b7f6397112ec7eafc2..04f50e857fb31d6e34fe0d0c8cfbe989ec3ec473 100644 (file)
@@ -27,8 +27,8 @@
 #include "frame.h"
 #include "moveresize.h"
 #include "event.h"
-#include "prop.h"
 #include "gettext.h"
+#include "obt/prop.h"
 
 #include <glib.h>
 
@@ -141,7 +141,7 @@ static void client_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
 
         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 */
@@ -150,7 +150,7 @@ static void client_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
 
         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);
index 673af4bdbeee9c69be5d6e54474ea7fd1cadcaea..a268eb5b82e003144764f51c070fe389f363efd5 100644 (file)
 #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;
@@ -144,10 +143,9 @@ void config_app_settings_copy_non_defaults(const ObAppSettings *src,
     }
 }
 
-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 {
@@ -189,10 +187,9 @@ static void config_parse_gravity_coord(xmlDocPtr doc, xmlNodePtr node,
    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;
     gboolean name_set, class_set;
     gboolean x_pos_given;
@@ -200,8 +197,8 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
     while (app) {
         name_set = class_set = x_pos_given = FALSE;
 
-        class_set = parse_attr_string("class", app, &class);
-        name_set = parse_attr_string("name", app, &name);
+        class_set = obt_parse_attr_string(app, "class", &class);
+        name_set = obt_parse_attr_string(app, "name", &name);
         if (class_set || name_set) {
             xmlNodePtr n, c;
             ObAppSettings *settings = config_create_app_settings();;
@@ -212,57 +209,55 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
             if (class_set)
                 settings->class = g_pattern_spec_new(class);
 
-            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;
                     }
@@ -270,9 +265,9 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
                 }
             }
 
-            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"))
@@ -282,25 +277,25 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
                     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;
@@ -309,7 +304,7 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
                         settings->max_vert = TRUE;
                     } else
                         settings->max_horz = settings->max_vert =
-                            parse_bool(doc, n);
+                            obt_parse_node_bool(n);
                     g_free(s);
                 }
 
@@ -321,7 +316,7 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
             name = class = role = NULL;
         }
 
-        app = parse_find_node("application", app->next);
+        app = obt_parse_find_node(app->next, "application");
     }
 }
 
@@ -335,34 +330,33 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
 
 */
 
-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");
         }
     }
 
@@ -373,25 +367,24 @@ static void parse_key(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
     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");
         }
 }
 
@@ -405,8 +398,7 @@ static void parse_keyboard(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
 
 */
 
-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;
@@ -417,141 +409,137 @@ static void parse_mouse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
 
     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;
@@ -560,35 +548,35 @@ static void parse_theme(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
         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"))
@@ -599,28 +587,27 @@ static void parse_theme(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
         *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;
 
@@ -629,123 +616,122 @@ static void parse_desktops(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
         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);
             }
         }
     }
 }
 
-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;
@@ -757,42 +743,40 @@ static void parse_dock(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
     }
 }
 
-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
@@ -883,7 +867,7 @@ static void bind_default_mouse(void)
                    actions_parse_string(it->actname));
 }
 
-void config_startup(ObParseInst *i)
+void config_startup(ObtParseInst *i)
 {
     config_focus_new = TRUE;
     config_focus_follow = FALSE;
@@ -892,17 +876,17 @@ void config_startup(ObParseInst *i)
     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;
 
@@ -915,14 +899,14 @@ void config_startup(ObParseInst *i)
     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 */
@@ -930,7 +914,7 @@ void config_startup(ObParseInst *i)
     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;
@@ -945,14 +929,14 @@ void config_startup(ObParseInst *i)
     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;
@@ -960,12 +944,12 @@ void config_startup(ObParseInst *i)
 
     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;
@@ -974,11 +958,11 @@ void config_startup(ObParseInst *i)
     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)
index 3fd1b879a61b5246f98ab8fc1f2fefd2c61e312b..cf9eb43efb2489e45148922ba2a6af3824a8494e 100644 (file)
 #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
@@ -186,7 +185,7 @@ extern GSList *config_menu_files;
 /*! 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 */
index 0fceba489d64e90c79178b041830d7e9b1c07f2f..42644868ca78619416f678c257c8ea05458aa85a 100644 (file)
 */
 
 #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);
 }
index 3c6bedf5dde3cc5d0ca1497abd06455e6c2039ec..3af413a7d528ffdb05580bd3d035c9f5b8c3e8b0 100644 (file)
 
 #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,
index 4c183e2c755f11793b94f5f1a3cbc38dcbc6a512..ee1202c724ec459bc58b886d6c5ff03002c65233 100644 (file)
 
 #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)
@@ -51,6 +50,9 @@ static void dock_app_grab_button(ObDockApp *app, gboolean grab)
     }
 }
 
+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;
@@ -58,9 +60,9 @@ void dock_startup(gboolean reconfig)
     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);
@@ -79,14 +81,17 @@ void dock_startup(gboolean reconfig)
                       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),
@@ -94,15 +99,15 @@ void dock_startup(gboolean reconfig)
                                 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));
 }
 
@@ -118,25 +123,25 @@ void dock_shutdown(gboolean reconfig)
         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])
@@ -148,7 +153,7 @@ void dock_add(Window win, XWMHints *wmhints)
     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 {
@@ -156,9 +161,10 @@ void dock_add(Window win, XWMHints *wmhints)
     }
 
     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
@@ -168,51 +174,53 @@ void dock_add(Window win, XWMHints *wmhints)
     */
     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);
@@ -273,7 +281,7 @@ void dock_configure(void)
             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 */
@@ -523,14 +531,14 @@ void dock_configure(void)
         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 */
@@ -636,19 +644,21 @@ void dock_hide(gboolean hide)
 {
     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);
         }
     }
 }
@@ -658,3 +668,8 @@ void dock_get_area(Rect *a)
     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);
+}
index 57c1f393170e4aa8568166f0ac2a0928b30109c9..d632ee744ecc6b60550ed210eb09c207a714437e 100644 (file)
@@ -44,15 +44,14 @@ struct _ObDock
     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;
@@ -71,14 +70,16 @@ void dock_shutdown(gboolean reconfig);
 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
index 7e2766f0d7f9ee1dc2acfd93b06d9e681782dbb4..cedac2e3f29e28d758494f8bc197e3e7905239f4 100644 (file)
 #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 "grab.h"
 #include "menu.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>
@@ -86,8 +84,9 @@ typedef struct
 
 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);
 static void event_handle_client(ObClient *c, XEvent *e);
@@ -123,9 +122,9 @@ static void ice_watch(IceConn conn, IcePointer data, Bool opening,
 
     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;
     }
 }
@@ -135,7 +134,7 @@ void event_startup(gboolean reconfig)
 {
     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);
@@ -162,9 +161,15 @@ static Window event_get_window(XEvent *e)
     /* 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:
@@ -181,7 +186,9 @@ static Window event_get_window(XEvent *e)
         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;
@@ -191,8 +198,8 @@ static Window event_get_window(XEvent *e)
         } 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
@@ -230,8 +237,8 @@ static void event_set_curtime(XEvent *e)
         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;
         }
@@ -259,34 +266,34 @@ static void event_hack_mods(XEvent *e)
     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;
@@ -316,7 +323,7 @@ static gboolean wanted_focusevent(XEvent *e, gboolean in_client_only)
 
         /* 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)
@@ -337,7 +344,7 @@ static gboolean wanted_focusevent(XEvent *e, gboolean 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;
         }
@@ -370,7 +377,7 @@ static gboolean wanted_focusevent(XEvent *e, gboolean in_client_only)
             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.. */
@@ -426,7 +433,7 @@ static void print_focusevent(XEvent *e)
 
     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);
@@ -452,39 +459,47 @@ static gboolean event_ignore(XEvent *e, ObClient *client)
 
 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 */
     ee = *ec;
     e = &ee;
 
     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 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;
@@ -498,12 +513,7 @@ static void event_process(const XEvent *ec, gpointer data)
 
     /* 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)
         {
@@ -528,7 +538,7 @@ static void event_process(const XEvent *ec, gpointer data)
             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)
@@ -549,12 +559,12 @@ static void event_process(const XEvent *ec, gpointer data)
                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.
 
@@ -570,7 +580,7 @@ static void event_process(const XEvent *ec, gpointer data)
         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.
@@ -589,25 +599,25 @@ static void event_process(const XEvent *ec, gpointer data)
         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 {
@@ -618,7 +628,7 @@ static void event_process(const XEvent *ec, gpointer data)
                 /* 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);
             }
@@ -636,22 +646,25 @@ static void event_process(const XEvent *ec, gpointer data)
         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);
+        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);
@@ -662,8 +675,8 @@ static void event_process(const XEvent *ec, gpointer data)
             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);
@@ -684,14 +697,14 @@ static void event_process(const XEvent *ec, gpointer data)
 
         /* 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)
@@ -699,10 +712,12 @@ static void event_process(const XEvent *ec, gpointer data)
     }
 #endif
 
-    if (e->type == ButtonPress || e->type == ButtonRelease) {
+    if (prompt && event_handle_prompt(prompt, e))
+        ;
+    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);
@@ -712,7 +727,7 @@ static void event_process(const XEvent *ec, gpointer data)
         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);
@@ -735,7 +750,7 @@ static void event_handle_root(XEvent *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;
 
@@ -743,41 +758,41 @@ static void event_handle_root(XEvent *e)
         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:
@@ -805,17 +820,17 @@ void event_enter_client(ObClient *client)
         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;
@@ -993,7 +1008,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
                 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));
@@ -1005,9 +1020,9 @@ static void event_handle_client(ObClient *client, XEvent *e)
                    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:
@@ -1049,7 +1064,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
             {
                 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,
@@ -1059,7 +1074,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
             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,
@@ -1090,10 +1105,10 @@ static void event_handle_client(ObClient *client, XEvent *e)
         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)
@@ -1117,8 +1132,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
             /* 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)
                 {
@@ -1174,7 +1188,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
         }
 
         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,
@@ -1200,7 +1214,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
             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;
@@ -1228,25 +1242,25 @@ static void event_handle_client(ObClient *client, XEvent *e)
 
             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:
@@ -1262,13 +1276,13 @@ static void event_handle_client(ObClient *client, XEvent *e)
 
         /* 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
@@ -1283,29 +1297,29 @@ static void event_handle_client(ObClient *client, XEvent *e)
         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;
@@ -1314,11 +1328,11 @@ static void event_handle_client(ObClient *client, XEvent *e)
                 (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"),
@@ -1332,11 +1346,11 @@ static void event_handle_client(ObClient *client, XEvent *e)
                              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" :
@@ -1350,50 +1364,50 @@ static void event_handle_client(ObClient *client, XEvent *e)
                 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, FALSE, 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;
@@ -1432,7 +1446,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
             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);
@@ -1442,17 +1456,16 @@ static void event_handle_client(ObClient *client, XEvent *e)
             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)
                     {
@@ -1461,7 +1474,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
                     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 ||
@@ -1486,7 +1499,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
                 } 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]);
             }
         }
@@ -1496,7 +1509,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
         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;
 
@@ -1508,28 +1521,28 @@ static void event_handle_client(ObClient *client, XEvent *e)
 
             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);
@@ -1546,32 +1559,32 @@ static void event_handle_client(ObClient *client, XEvent *e)
             /* 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)))
             {
@@ -1579,7 +1592,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
             }
         }
 #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
@@ -1590,7 +1603,9 @@ static void event_handle_client(ObClient *client, XEvent *e)
     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);
         }
@@ -1629,13 +1644,13 @@ static void event_handle_dockapp(ObDockApp *app, XEvent *e)
             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);
@@ -1667,124 +1682,174 @@ static ObMenuFrame* find_active_or_last_menu(void)
     return ret;
 }
 
-static gboolean event_handle_menu_keyboard(XEvent *ev)
+static gboolean event_handle_prompt(ObPrompt *p, XEvent *e)
+{
+    switch (e->type) {
+    case ButtonPress:
+    case ButtonRelease:
+    case MotionNotify:
+        return prompt_mouse_event(p, e);
+        break;
+    case KeyPress:
+        return prompt_key_event(p, e);
+        break;
+    }
+    return FALSE;
+}
+
+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;
+                }
             }
         }
     }
@@ -1792,27 +1857,12 @@ static gboolean event_handle_menu_keyboard(XEvent *ev)
     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)
@@ -1836,21 +1886,7 @@ static gboolean event_handle_menu(XEvent *ev)
             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)
@@ -1860,7 +1896,7 @@ 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 */
@@ -1918,20 +1954,20 @@ static gboolean focus_delay_func(gpointer data)
 
 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)
@@ -1946,11 +1982,11 @@ 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)
@@ -1961,7 +1997,7 @@ 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)
@@ -1988,24 +2024,24 @@ void event_cancel_all_key_grabs(void)
 {
     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)
@@ -2038,9 +2074,9 @@ Time event_get_server_time(void)
     /* 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;
 }
index a8d1aeaf9160aad2dc742cf59e3b58ff3c24926f..65ff915bc5f76d4b7c84477ce33746cb9d7f43ec 100644 (file)
@@ -33,11 +33,6 @@ extern Time event_curtime;
 /*! 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);
 
diff --git a/openbox/extensions.c b/openbox/extensions.c
deleted file mode 100644 (file)
index cd188dd..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/* -*- 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);
-}
diff --git a/openbox/extensions.h b/openbox/extensions.h
deleted file mode 100644 (file)
index 3155874..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- 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
index c2d7e11e5dd879d8a776fd7bfb65ce0524d1d3db..cff81bfb03918a0b5fe0e982cd5bedbea17d7e97 100644 (file)
 #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>
@@ -52,7 +52,7 @@ void focus_shutdown(gboolean reconfig)
     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)
@@ -74,7 +74,7 @@ void focus_set_client(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;
@@ -99,8 +99,7 @@ void focus_set_client(ObClient *client)
     /* 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);
     }
 }
 
@@ -112,18 +111,18 @@ static ObClient* focus_fallback_target(gboolean allow_refocus,
     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:
@@ -139,12 +138,12 @@ static ObClient* focus_fallback_target(gboolean allow_refocus,
             (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:
@@ -158,7 +157,7 @@ static ObClient* focus_fallback_target(gboolean allow_refocus,
             (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;
         }
     }
@@ -207,7 +206,7 @@ void focus_nothing(void)
     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);
 }
 
index 2348f8d0364b7d4802aa41bc01e3a836e3cb65b1..dbf79c9a7d2207ef899c91402222b711a4f583c9 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "focus_cycle.h"
 #include "focus_cycle_indicator.h"
-#include "focus_cycle_popup.h"
 #include "client.h"
 #include "frame.h"
 #include "focus.h"
@@ -70,7 +69,7 @@ void focus_cycle_stop(ObClient *ifclient)
 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;
@@ -131,13 +130,13 @@ ObClient* focus_cycle(gboolean forward, gboolean all_desktops,
                     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;
index 6e1c2c9dbad183f990ff8fb70addc494bd63a3a5..c31abc81f47abe8165030342703c28e95604e2d2 100644 (file)
@@ -21,6 +21,7 @@
 #define __focus_cycle_h
 
 #include "misc.h"
+#include "focus_cycle_popup.h"
 
 #include <X11/Xlib.h>
 #include <glib.h>
@@ -37,7 +38,7 @@ void focus_cycle_shutdown(gboolean reconfig);
 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,
index 7c5d5290539cb46c38d1bd95760e0ad59d3c7671..495a72305be16d2d86d1fe738e4015b2e13b46eb 100644 (file)
 
 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;
@@ -45,7 +45,7 @@ static gboolean      visible;
 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);
 
@@ -59,38 +59,38 @@ void focus_cycle_indicator_startup(gboolean reconfig)
 
     if (reconfig) return;
 
-    focus_indicator.top.obwin.type = Window_Internal;
-    focus_indicator.left.obwin.type = Window_Internal;
-    focus_indicator.right.obwin.type = Window_Internal;
-    focus_indicator.bottom.obwin.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);
-    focus_indicator.top.win =
-        create_window(RootWindow(ob_display, ob_screen),
+    attr.background_pixel = BlackPixel(obt_display, ob_screen);
+    focus_indicator.top.window =
+        create_window(obt_root(ob_screen),
                       CWOverrideRedirect | CWBackPixel, &attr);
-    focus_indicator.left.win =
-        create_window(RootWindow(ob_display, ob_screen),
+    focus_indicator.left.window =
+        create_window(obt_root(ob_screen),
                       CWOverrideRedirect | CWBackPixel, &attr);
-    focus_indicator.right.win =
-        create_window(RootWindow(ob_display, ob_screen),
+    focus_indicator.right.window =
+        create_window(obt_root(ob_screen),
                       CWOverrideRedirect | CWBackPixel, &attr);
-    focus_indicator.bottom.win =
-        create_window(RootWindow(ob_display, ob_screen),
+    focus_indicator.bottom.window =
+        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.win,
-                        &focus_indicator.top);
-    g_hash_table_insert(window_map, &focus_indicator.left.win,
-                        &focus_indicator.left);
-    g_hash_table_insert(window_map, &focus_indicator.right.win,
-                        &focus_indicator.right);
-    g_hash_table_insert(window_map, &focus_indicator.bottom.win,
-                        &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);
 
@@ -117,20 +117,20 @@ void focus_cycle_indicator_shutdown(gboolean reconfig)
 
     RrAppearanceFree(a_focus_indicator);
 
-    g_hash_table_remove(window_map, &focus_indicator.top.win);
-    g_hash_table_remove(window_map, &focus_indicator.left.win);
-    g_hash_table_remove(window_map, &focus_indicator.right.win);
-    g_hash_table_remove(window_map, &focus_indicator.bottom.win);
+    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.win);
-    XDestroyWindow(ob_display, focus_indicator.left.win);
-    XDestroyWindow(ob_display, focus_indicator.right.win);
-    XDestroyWindow(ob_display, focus_indicator.bottom.win);
+    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)
@@ -141,10 +141,10 @@ 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.win);
-        XUnmapWindow(ob_display, focus_indicator.left.win);
-        XUnmapWindow(ob_display, focus_indicator.right.win);
-        XUnmapWindow(ob_display, focus_indicator.bottom.win);
+        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);
 
@@ -170,7 +170,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         /* kill enter events cause by this moving */
         ignore_start = event_start_ignore_all_enters();
 
-        XMoveResizeWindow(ob_display, focus_indicator.top.win,
+        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;
@@ -188,7 +188,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         a_focus_indicator->texture[3].data.lineart.y1 = h-1;
         a_focus_indicator->texture[3].data.lineart.x2 = w - wr;
         a_focus_indicator->texture[3].data.lineart.y2 = h-1;
-        RrPaint(a_focus_indicator, focus_indicator.top.win,
+        RrPaint(a_focus_indicator, focus_indicator.top.window,
                 w, h);
 
         x = c->frame->area.x;
@@ -196,7 +196,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         w = wl;
         h = c->frame->area.height;
 
-        XMoveResizeWindow(ob_display, focus_indicator.left.win,
+        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;
@@ -214,7 +214,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         a_focus_indicator->texture[3].data.lineart.y1 = wt-1;
         a_focus_indicator->texture[3].data.lineart.x2 = w-1;
         a_focus_indicator->texture[3].data.lineart.y2 = h - wb;
-        RrPaint(a_focus_indicator, focus_indicator.left.win,
+        RrPaint(a_focus_indicator, focus_indicator.left.window,
                 w, h);
 
         x = c->frame->area.x + c->frame->area.width - wr;
@@ -222,7 +222,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         w = wr;
         h = c->frame->area.height ;
 
-        XMoveResizeWindow(ob_display, focus_indicator.right.win,
+        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;
@@ -240,7 +240,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         a_focus_indicator->texture[3].data.lineart.y1 = wt-1;
         a_focus_indicator->texture[3].data.lineart.x2 = 0;
         a_focus_indicator->texture[3].data.lineart.y2 = h - wb;
-        RrPaint(a_focus_indicator, focus_indicator.right.win,
+        RrPaint(a_focus_indicator, focus_indicator.right.window,
                 w, h);
 
         x = c->frame->area.x;
@@ -248,7 +248,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         w = c->frame->area.width;
         h = wb;
 
-        XMoveResizeWindow(ob_display, focus_indicator.bottom.win,
+        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;
@@ -266,13 +266,13 @@ void focus_cycle_draw_indicator(ObClient *c)
         a_focus_indicator->texture[3].data.lineart.y1 = 0;
         a_focus_indicator->texture[3].data.lineart.x2 = w - wr;
         a_focus_indicator->texture[3].data.lineart.y2 = 0;
-        RrPaint(a_focus_indicator, focus_indicator.bottom.win,
+        RrPaint(a_focus_indicator, focus_indicator.bottom.window,
                 w, h);
 
-        XMapWindow(ob_display, focus_indicator.top.win);
-        XMapWindow(ob_display, focus_indicator.left.win);
-        XMapWindow(ob_display, focus_indicator.right.win);
-        XMapWindow(ob_display, focus_indicator.bottom.win);
+        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);
 
index f0cf25e2e3cd9e908c13bb89f1eff91c53c94d4b..4d1dfaa35a87533dd9ab3b6bf66c2efcb1d9f684 100644 (file)
 #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;
@@ -43,7 +55,9 @@ struct _ObFocusCyclePopupTarget
 {
     ObClient *client;
     gchar *text;
-    Window win;
+    Window iconwin;
+    /* This is used when the popup is in list mode */
+    Window textwin;
 };
 
 struct _ObFocusCyclePopup
@@ -51,7 +65,11 @@ 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;
@@ -60,13 +78,17 @@ struct _ObFocusCyclePopup
 
     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 */
@@ -87,7 +109,7 @@ static void   popup_render   (ObFocusCyclePopup *p,
 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);
 }
@@ -95,65 +117,119 @@ static Window create_window(Window parent, guint bwidth, gulong mask,
 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_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);
+
     popup.a_icon->texture[0].type = RR_TEXTURE_RGBA;
 
-    RrAppearanceAddTextures(popup.a_bg, 1);
-    popup.a_bg->texture[0].type = RR_TEXTURE_RGBA;
+    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;
 
         g_free(t->text);
-        XDestroyWindow(ob_display, t->win);
+        XDestroyWindow(obt_display, t->iconwin);
+        XDestroyWindow(obt_display, t->textwin);
 
         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);
 }
@@ -189,16 +265,15 @@ static void popup_setup(ObFocusCyclePopup *p, gboolean create_targets,
             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->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;
@@ -243,16 +318,29 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c)
     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();
 
@@ -265,199 +353,317 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c)
     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;
+    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 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;
-
-    /* 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) {
+        /* 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;
             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);
+            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);
+            icon = client_icon(target->client, ICON_SIZE, ICON_SIZE);
             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.twidth = ICON_SIZE;
+            p->a_icon->texture[0].data.rgba.theight = ICON_SIZE;
+            p->a_icon->texture[0].data.rgba.tx = HILITE_OFFSET;
+            p->a_icon->texture[0].data.rgba.ty = HILITE_OFFSET;
             p->a_icon->texture[0].data.rgba.alpha =
                 target->client->iconic ? OB_ICONIC_ALPHA : 0xff;
             p->a_icon->texture[0].data.rgba.data = icon->data;
 
+            /* 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();
     }
@@ -469,8 +675,8 @@ void focus_cycle_popup_hide(void)
 
     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);
 
@@ -480,16 +686,14 @@ void focus_cycle_popup_hide(void)
         ObFocusCyclePopupTarget *t = popup.targets->data;
 
         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,
@@ -522,7 +726,8 @@ 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, HILITE_SIZE,
+                                                    HILITE_SIZE));
     g_free(text);
     screen_hide_desktop_popup();
 }
index ded39e202896a2c5433ae5e1e187f73d8077a99c..b940583bc5339d2c8b8064e6ee5ede7f2354940e 100644 (file)
@@ -24,12 +24,19 @@ struct _ObClient;
 
 #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,
index 8fee3b69e439bcb6f8a354d9d0f83ea21cb3050f..0975214cbf4ddef804dc7e849d49a9c171b4fec8 100644 (file)
 #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 | \
@@ -56,7 +55,7 @@ static void frame_adjust_cursors(ObFrame *self);
 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);
@@ -73,7 +72,7 @@ static Visual *check_32bit_client(ObClient *c)
     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);
 
@@ -102,13 +101,12 @@ ObFrame *frame_new(ObClient *client)
         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 */
@@ -179,9 +177,9 @@ ObFrame *frame_new(ObClient *client)
     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;
@@ -196,25 +194,25 @@ ObFrame *frame_new(ObClient *client)
 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);
 }
 
@@ -226,9 +224,9 @@ void frame_free(ObFrame *self)
 {
     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);
 }
@@ -242,8 +240,8 @@ void frame_show(ObFrame *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);
     }
 }
@@ -253,10 +251,10 @@ void frame_hide(ObFrame *self)
     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;
     }
 }
@@ -275,13 +273,13 @@ void frame_adjust_shape(ObFrame *self)
 
     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,
@@ -307,7 +305,7 @@ void frame_adjust_shape(ObFrame *self)
             ++num;
         }
 
-        XShapeCombineRectangles(ob_display, self->window,
+        XShapeCombineRectangles(obt_display, self->window,
                                 ShapeBounding, 0, 0, xrect, num,
                                 ShapeUnion, Unsorted);
     }
@@ -382,17 +380,17 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                 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 -
@@ -400,22 +398,22 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                                   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 -
@@ -423,35 +421,35 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                                   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),
@@ -459,13 +457,13 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                                   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) {
@@ -474,16 +472,16 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                 /* 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,
@@ -492,11 +490,11 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                                   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,
@@ -504,73 +502,73 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                                       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))
@@ -581,7 +579,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
             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 +
@@ -592,7 +590,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
 
 
                 if (sidebwidth) {
-                    XMoveResizeWindow(ob_display, self->lgripleft,
+                    XMoveResizeWindow(obt_display, self->lgripleft,
                                       0,
                                       self->size.top +
                                       self->client->area.height +
@@ -604,7 +602,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                                       (!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,
@@ -619,20 +617,20 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                                        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,
@@ -641,29 +639,29 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                                   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,
@@ -671,13 +669,13 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                                           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 -
@@ -687,77 +685,77 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                                           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,
@@ -765,15 +763,15 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                                   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,
@@ -782,11 +780,11 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                                   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);
@@ -818,7 +816,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                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,
@@ -828,7 +826,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
            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) {
@@ -843,10 +841,10 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
             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
@@ -855,7 +853,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
             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);
 
 }
@@ -877,58 +875,58 @@ static void frame_adjust_cursors(ObFrame *self)
         /* 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);
 }
@@ -944,7 +942,7 @@ void frame_adjust_focus(ObFrame *self, gboolean hilite)
     self->focused = hilite;
     self->need_render = TRUE;
     framerender_frame(self);
-    XFlush(ob_display);
+    XFlush(obt_display);
 }
 
 void frame_adjust_title(ObFrame *self)
@@ -967,7 +965,7 @@ void frame_grab_client(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
@@ -980,54 +978,54 @@ void frame_grab_client(ObFrame *self)
 
     /* 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)
@@ -1036,11 +1034,11 @@ 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
@@ -1052,7 +1050,7 @@ void frame_release_client(ObFrame *self)
         */
         if (ev.xreparent.parent != self->window) {
             reparent = FALSE;
-            XPutBackEvent(ob_display, &ev);
+            XPutBackEvent(obt_display, &ev);
             break;
         }
     }
@@ -1060,60 +1058,58 @@ void frame_release_client(ObFrame *self)
     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? */
@@ -1239,54 +1235,54 @@ static void layout_title(ObFrame *self)
 
     /* 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)
@@ -1341,7 +1337,7 @@ ObFrameContext frame_context(ObClient *client, Window win, gint x, gint y)
     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) {
@@ -1634,12 +1630,12 @@ void frame_flash_start(ObFrame *self)
     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);
 
@@ -1728,8 +1724,8 @@ static gboolean frame_animate_iconify(gpointer p)
     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 */
@@ -1741,7 +1737,7 @@ void frame_end_iconify_animation(ObFrame *self)
     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
@@ -1754,12 +1750,12 @@ void frame_end_iconify_animation(ObFrame *self)
     /* 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)
@@ -1798,18 +1794,18 @@ 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);
     }
 }
index e4db2a06e6734812a8cfbcc60c0e038490a4bf80..87706b2b2921d84ea6eb7a3fa35085f16143bb2f 100644 (file)
@@ -49,67 +49,67 @@ void framerender_frame(ObFrame *self)
               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)
@@ -117,8 +117,8 @@ void framerender_frame(ObFrame *self)
                   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) {
@@ -341,7 +341,7 @@ void framerender_frame(ObFrame *self)
         }
     }
 
-    XFlush(ob_display);
+    XFlush(obt_display);
 }
 
 static void framerender_label(ObFrame *self, RrAppearance *a)
index 43e9a8155a6bfeb3eb5dcb384be6d2f0278a7e20..522fbf96b812cfd213e3cca276b325190a95ca06 100644 (file)
 */
 
 #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>
@@ -74,7 +74,7 @@ gboolean grab_keyboard_full(gboolean grab)
 
     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)
@@ -87,7 +87,7 @@ gboolean grab_keyboard_full(gboolean grab)
             ret = TRUE;
     } else if (kgrabs > 0) {
         if (--kgrabs == 0) {
-            XUngrabKeyboard(ob_display, ungrab_time());
+            XUngrabKeyboard(obt_display, ungrab_time());
         }
         ret = TRUE;
     }
@@ -102,11 +102,10 @@ gboolean grab_pointer_full(gboolean grab, gboolean owner_events,
 
     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;
@@ -116,7 +115,7 @@ gboolean grab_pointer_full(gboolean grab, gboolean owner_events,
             ret = TRUE;
     } else if (pgrabs > 0) {
         if (--pgrabs == 0) {
-            XUngrabPointer(ob_display, ungrab_time());
+            XUngrabPointer(obt_display, ungrab_time());
         }
         ret = TRUE;
     }
@@ -128,13 +127,13 @@ gint grab_server(gboolean grab)
     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;
@@ -145,9 +144,9 @@ void grab_startup(gboolean reconfig)
     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;
@@ -174,13 +173,13 @@ void grab_button_full(guint button, guint state, Window win, guint mask,
 {
     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);
 }
 
@@ -189,26 +188,26 @@ void ungrab_button(guint button, guint state, Window win)
     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)
@@ -223,7 +222,7 @@ void ungrab_passive_key(void)
     /*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;
     }
 }
index c23d83e627881bb7180d57e6e232ce08b23fa5f5..02ae6a304642ef4ce7a735ca0a55c827393f6e34 100644 (file)
@@ -17,7 +17,6 @@
    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"
@@ -26,7 +25,6 @@
 #include "grab.h"
 #include "client.h"
 #include "actions.h"
-#include "prop.h"
 #include "menuframe.h"
 #include "config.h"
 #include "keytree.h"
@@ -46,20 +44,20 @@ static void grab_keys(gboolean grab)
 {
     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);
     }
 }
 
@@ -221,7 +219,7 @@ void keyboard_event(ObClient *client, const XEvent *e)
     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;
     }
@@ -239,11 +237,11 @@ void keyboard_event(ObClient *client, const XEvent *e)
                 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);
@@ -316,7 +314,7 @@ void keyboard_startup(gboolean reconfig)
 
 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);
diff --git a/openbox/mainloop.h b/openbox/mainloop.h
deleted file mode 100644 (file)
index 373528e..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- 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
index d9426e9062dcc17e715a49166576457eb21efed2..768630bd2939a9b80c35a0492c0380cd96b71ef3 100644 (file)
@@ -20,7 +20,6 @@
 #include "debug.h"
 #include "menu.h"
 #include "openbox.h"
-#include "mainloop.h"
 #include "stacking.h"
 #include "grab.h"
 #include "client.h"
@@ -35,7 +34,8 @@
 #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;
 
@@ -46,18 +46,14 @@ struct _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);
@@ -72,8 +68,6 @@ static void client_dest(ObClient *client, gpointer data)
 
 void menu_startup(gboolean reconfig)
 {
-    xmlDocPtr doc;
-    xmlNodePtr node;
     gboolean loaded = FALSE;
     GSList *it;
 
@@ -84,29 +78,37 @@ void menu_startup(gboolean reconfig)
     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");
@@ -123,7 +125,7 @@ void menu_shutdown(gboolean reconfig)
     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);
@@ -157,8 +159,6 @@ void menu_clear_pipe_caches(void)
 
 void menu_pipe_execute(ObMenu *self)
 {
-    xmlDocPtr doc;
-    xmlNodePtr node;
     gchar *output;
     GError *err = NULL;
 
@@ -174,13 +174,13 @@ void menu_pipe_execute(ObMenu *self)
         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);
     }
@@ -263,19 +263,18 @@ static gunichar parse_shortcut(const gchar *label, gboolean allow_shortcut,
     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);
                 }
@@ -285,16 +284,14 @@ static void parse_menu_item(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
     }
 }
 
-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);
@@ -302,30 +299,29 @@ static void parse_menu_separator(ObParseInst *i,
     }
 }
 
-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;
             }
         }
@@ -457,10 +453,10 @@ void menu_show(gchar *name, gint x, gint y, gboolean mouse, ObClient *client)
             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);
         }
     }
 }
index 8832a1241f5c1d49dbeb5ce07b97abb6903f2bfc..752a6771461de01d61d08976fe40fa0cb1e08097 100644 (file)
@@ -22,7 +22,6 @@
 #include "window.h"
 #include "geom.h"
 #include "render/render.h"
-#include "parser/parse.h"
 
 #include <glib.h>
 
index fb9b6c5b3a05708742cdf6ec727ed10a594524d1..598bc005f6c5e4a32b60272897e1c66698dfebb1 100644 (file)
@@ -24,7 +24,6 @@
 #include "actions.h"
 #include "grab.h"
 #include "openbox.h"
-#include "mainloop.h"
 #include "config.h"
 #include "render/theme.h"
 
@@ -51,7 +50,7 @@ static void menu_frame_hide(ObMenuFrame *self);
 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);
 }
@@ -78,7 +77,7 @@ ObMenuFrame* menu_frame_new(ObMenu *menu, guint show_from, ObClient *client)
     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;
@@ -86,16 +85,17 @@ ObMenuFrame* menu_frame_new(ObMenu *menu, guint show_from, ObClient *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;
 }
@@ -108,11 +108,12 @@ void menu_frame_free(ObMenuFrame *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);
     }
@@ -144,8 +145,10 @@ static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry,
         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;
 }
@@ -155,16 +158,18 @@ static void menu_entry_frame_free(ObMenuEntryFrame *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);
         }
 
@@ -175,7 +180,7 @@ static void menu_entry_frame_free(ObMenuEntryFrame *self)
 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)
@@ -334,7 +339,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
         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;
@@ -393,7 +398,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
 
     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);
@@ -404,7 +409,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
                 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);
@@ -417,7 +422,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
     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 -
@@ -433,7 +438,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
             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;
@@ -458,7 +463,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
     {
         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,
@@ -483,14 +488,14 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
                 - 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,
@@ -522,13 +527,13 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
                 - 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,
@@ -543,11 +548,11 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
         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
@@ -665,10 +670,10 @@ void menu_frame_render(ObMenuFrame *self)
         }
 
         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));
 
 
@@ -750,7 +755,7 @@ void menu_frame_render(ObMenuFrame *self)
     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;
 
@@ -764,7 +769,7 @@ void menu_frame_render(ObMenuFrame *self)
 
     RECT_SET_SIZE(self->area, w, h);
 
-    XFlush(ob_display);
+    XFlush(obt_display);
 }
 
 static void menu_frame_update(ObMenuFrame *self)
@@ -946,7 +951,7 @@ gboolean menu_frame_show_topmenu(ObMenuFrame *self, gint x, gint y,
 
     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);
@@ -989,7 +994,7 @@ gboolean menu_frame_show_submenu(ObMenuFrame *self, ObMenuFrame *parent,
     }
     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);
@@ -1026,7 +1031,7 @@ static void menu_frame_hide(ObMenuFrame *self)
         ungrab_keyboard();
     }
 
-    XUnmapWindow(ob_display, self->window);
+    XUnmapWindow(obt_display, self->window);
 
     menu_frame_free(self);
 }
@@ -1037,8 +1042,8 @@ void menu_frame_hide_all(void)
 
     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);
@@ -1052,8 +1057,8 @@ void menu_frame_hide_all_client(ObClient *client)
         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);
         }
@@ -1119,8 +1124,8 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry,
 
     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;
@@ -1136,11 +1141,11 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *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);
             }
index 1b1dcc703f73eebffffdb03f0a6f9aff0c6ec1bd..daac34d2d2803860be63baa8094a23eba106b8f0 100644 (file)
@@ -38,7 +38,7 @@ extern GList *menu_frame_visible;
 struct _ObMenuFrame
 {
     /* stuff to be an ObWindow */
-    Window_InternalType type;
+    ObWindow obwin;
     Window window;
 
     struct _ObMenu *menu;
index 2b5584d73072e84a24a1cf7a8837a27c3e46c4ab..c73c92658be2c974060f56eb7595525563cfc719 100644 (file)
@@ -51,6 +51,8 @@ typedef enum
     OB_KEY_RIGHT,
     OB_KEY_UP,
     OB_KEY_DOWN,
+    OB_KEY_TAB,
+    OB_KEY_SPACE,
     OB_NUM_KEYS
 } ObKey;
 
index 711317ec77514946964c456a0b36e6dfad655891..071a23b2ecb5e146e003a415572d4ea88559eac8 100644 (file)
 
 #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>
 
@@ -46,6 +45,9 @@ typedef struct {
 
 /* Array of GSList*s of ObMouseBinding*s. */
 static GSList *bound_contexts[OB_FRAME_NUM_CONTEXTS];
+/* TRUE when we have a grab on the pointer and need to reply the pointer event
+   to send it to other applications */
+static gboolean replay_pointer_needed;
 
 ObFrameContext mouse_button_frame_context(ObFrameContext context,
                                           guint button,
@@ -200,6 +202,15 @@ static gboolean fire_binding(ObMouseAction a, ObFrameContext context,
     return TRUE;
 }
 
+void mouse_replay_pointer()
+{
+    if (replay_pointer_needed) {
+        /* replay the pointer event before any windows move */
+        XAllowEvents(obt_display, ReplayPointer, event_curtime);
+        replay_pointer_needed = FALSE;
+    }
+}
+
 void mouse_event(ObClient *client, XEvent *e)
 {
     static Time ltime;
@@ -229,12 +240,17 @@ void mouse_event(ObClient *client, XEvent *e)
            XAllowEvents with ReplayPointer at some point, to send the event
            through to the client.  when this happens though depends.  if
            windows are going to be moved on screen, then the click will end
-           up going somewhere wrong, so have the action system perform the
-           ReplayPointer for us if that is the case. */
+           up going somewhere wrong, set that we need it, and if nothing
+           else causes the replay pointer to be run, then we will do it
+           after all the actions are finished.
+
+           (We do it after all the actions because FocusIn interrupts
+           dragging for kdesktop, so if we send the button event now, and
+           then they get a focus event after, it breaks.  Instead, wait to send
+           the button press until after the actions when possible.)
+        */
         if (CLIENT_CONTEXT(context, client))
-            actions_set_need_pointer_replay_before_move(TRUE);
-        else
-            actions_set_need_pointer_replay_before_move(FALSE);
+            replay_pointer_needed = TRUE;
 
         fire_binding(OB_MOUSE_ACTION_PRESS, context,
                      client, e->xbutton.state,
@@ -248,8 +264,7 @@ void mouse_event(ObClient *client, XEvent *e)
 
         /* replay the pointer event if it hasn't been replayed yet (i.e. no
            windows were moved) */
-        if (actions_get_need_pointer_replay_before_move())
-            XAllowEvents(ob_display, ReplayPointer, event_curtime);
+        mouse_replay_pointer();
 
         /* in the client context, we won't get a button release because of the
            way it is grabbed, so just fake one */
@@ -271,10 +286,10 @@ void mouse_event(ObClient *client, XEvent *e)
             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 &&
index 44d563a3b640262ae97234723b43bebe96312e7d..a862fe5b4a5f8ee9a0a552feb34b704db4bad967 100644 (file)
@@ -40,4 +40,9 @@ void mouse_grab_for_client(struct _ObClient *client, gboolean grab);
 ObFrameContext mouse_button_frame_context(ObFrameContext context,
                                           guint button, guint state);
 
+/*! If a replay pointer is needed, then do it.  Call this when windows are
+  going to be moving/appearing/disappearing, so that you know the mouse click
+  will go to the right window */
+void mouse_replay_pointer();
+
 #endif
index 9374f8b5f77930e96eb37828540a2d9daf2181ee..ddc518adbb299d905ffc0f3bde9c12808362e761 100644 (file)
 #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>
@@ -168,8 +167,8 @@ static void popup_coords(ObClient *c, const gchar *format, gint a, gint b)
 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;
 
@@ -179,32 +178,37 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr)
           (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();
@@ -251,7 +255,7 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr)
     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)
     {
@@ -263,7 +267,7 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr)
 
         /* 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 */
@@ -279,7 +283,7 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr)
         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 |
@@ -308,11 +312,11 @@ void moveresize_end(gboolean cancel)
 #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,
@@ -367,7 +371,7 @@ static void do_resize(void)
     }
 
 #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)
     {
@@ -384,24 +388,24 @@ static void do_resize(void)
 
         /* 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
 
@@ -580,10 +584,10 @@ static void do_edge_warp(gint x, gint y)
         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;
     }
@@ -591,7 +595,7 @@ static void do_edge_warp(gint x, gint y)
 
 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)
@@ -601,7 +605,7 @@ 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;
 
@@ -619,8 +623,11 @@ static void move_with_keys(gint keycode, gint state)
         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;
 
@@ -635,12 +642,12 @@ static void move_with_keys(gint keycode, gint state)
     }
 
     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);
 
@@ -701,7 +708,7 @@ static void resize_with_keys(gint keycode, gint state)
     }
 
     /* 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))
@@ -726,7 +733,9 @@ static void resize_with_keys(gint keycode, gint state)
             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;
         }
@@ -738,7 +747,9 @@ static void resize_with_keys(gint keycode, gint state)
             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;
         }
@@ -792,12 +803,12 @@ static void resize_with_keys(gint keycode, gint state)
         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);
 
@@ -840,41 +851,44 @@ gboolean moveresize_event(XEvent *e)
             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;
@@ -888,15 +902,15 @@ gboolean moveresize_event(XEvent *e)
             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;
             }
@@ -916,17 +930,19 @@ gboolean moveresize_event(XEvent *e)
                    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 */
index 12106f6b2b1cf5b7642cd26adb82829888dd9094..a6a81cef7dec11e813e67f9ac8dd5d3b23b0fd1d 100644 (file)
 #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;
+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;
@@ -121,6 +118,8 @@ gint main(gint argc, gchar **argv)
 
     state = OB_STATE_STARTING;
 
+    ob_debug_startup();
+
     /* initialize the locale */
     if (!setlocale(LC_ALL, ""))
         g_message("Couldn't set locale from environment.");
@@ -128,10 +127,6 @@ gint main(gint argc, gchar **argv)
     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 */
@@ -140,49 +135,40 @@ gint main(gint argc, gchar **argv)
     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."));
 
-    XSynchronize(ob_display, xsync);
+    XSynchronize(obt_display, xsync);
 
     /* check for locale support */
     if (!XSupportsLocale())
@@ -190,12 +176,9 @@ gint main(gint argc, gchar **argv)
     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;
@@ -216,30 +199,26 @@ gint main(gint argc, gchar **argv)
     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_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);
@@ -247,9 +226,13 @@ gint main(gint argc, gchar **argv)
                 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"));
@@ -260,16 +243,15 @@ gint main(gint argc, gchar **argv)
                     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 */
@@ -288,8 +270,8 @@ gint main(gint argc, gchar **argv)
                 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) {
@@ -314,6 +296,7 @@ gint main(gint argc, gchar **argv)
             grab_startup(reconfigure);
             group_startup(reconfigure);
             ping_startup(reconfigure);
+            prompt_startup(reconfigure);
             client_startup(reconfigure);
             dock_startup(reconfigure);
             moveresize_startup(reconfigure);
@@ -327,14 +310,13 @@ gint main(gint argc, gchar **argv)
                 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));
                 }
@@ -358,13 +340,11 @@ gint main(gint argc, gchar **argv)
             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);
@@ -373,6 +353,7 @@ gint main(gint argc, gchar **argv)
             moveresize_shutdown(reconfigure);
             dock_shutdown(reconfigure);
             client_shutdown(reconfigure);
+            prompt_shutdown(reconfigure);
             ping_shutdown(reconfigure);
             group_shutdown(reconfigure);
             grab_shutdown(reconfigure);
@@ -386,20 +367,17 @@ gint main(gint argc, gchar **argv)
             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);
     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) {
@@ -455,6 +433,8 @@ gint main(gint argc, gchar **argv)
     g_free(ob_sm_id);
     g_free(program_name);
 
+    ob_debug_shutdown();
+
     return exitcode;
 }
 
@@ -462,11 +442,11 @@ static void signal_handler(gint signal, gpointer data)
 {
     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:
@@ -474,7 +454,7 @@ static void signal_handler(gint signal, gpointer data)
         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));
     }
@@ -509,6 +489,7 @@ static void print_help()
     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);
 }
@@ -555,16 +536,19 @@ static void parse_args(gint *argc, gchar **argv)
             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;
         }
@@ -596,7 +580,7 @@ static void parse_args(gint *argc, gchar **argv)
                 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);
             }
         }
@@ -608,7 +592,7 @@ static void parse_args(gint *argc, gchar **argv)
                 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")) {
@@ -633,10 +617,10 @@ static Cursor load_cursor(const gchar *name, guint fontval)
     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;
 }
 
@@ -668,14 +652,14 @@ void ob_reconfigure()
 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)
index b768fee31f22ed0d0d669c80f13405545eccdf7d..47d92042e2eed946931c7a0dcb49ba3fe2a18683 100644 (file)
 
 #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 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;
index 37b5d30c84b6ae72d2902eec68def036acdf4300..42487ab099b3dc44565db6458e878a59e1bbd8a9 100644 (file)
 
 #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
 {
@@ -78,8 +78,8 @@ void ping_start(struct _ObClient *client, ObPingEventHandler h)
     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. */
@@ -99,7 +99,7 @@ void ping_got_pong(guint32 id)
     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 */
@@ -108,7 +108,7 @@ void ping_got_pong(guint32 id)
         t->waiting = 0; /* not waiting for a reply anymore */
     }
     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)
@@ -131,10 +131,10 @@ static void ping_send(ObPingTarget *t)
         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)
@@ -159,7 +159,8 @@ static void ping_end(ObClient *client, 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);
     }
index 45d7f07ff72bb56b6ac1b613e98e5a0f279ae282..aac40e8a099249c0620e7513269f556b766c56d8 100644 (file)
@@ -76,7 +76,7 @@ static Rect **pick_head(ObClient *c)
     /* 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));
     }
 
@@ -92,7 +92,7 @@ static Rect **pick_head(ObClient *c)
                  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));
             }
         }
@@ -103,7 +103,7 @@ static Rect **pick_head(ObClient *c)
             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));
             }
         }
     }
@@ -113,7 +113,7 @@ static Rect **pick_head(ObClient *c)
         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));
     }
 
@@ -125,7 +125,7 @@ static Rect **pick_head(ObClient *c)
         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;
         }
     }
index 15d1bf52bed291cb342b3ffee40263003e407468..02c87848675c3b30fe5f455d716c1a48510b0797 100644 (file)
@@ -25,7 +25,6 @@
 #include "stacking.h"
 #include "event.h"
 #include "screen.h"
-#include "mainloop.h"
 #include "render/render.h"
 #include "render/theme.h"
 
@@ -34,7 +33,7 @@ ObPopup *popup_new(void)
     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);
@@ -42,34 +41,34 @@ ObPopup *popup_new(void)
     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);
     }
@@ -141,7 +140,7 @@ static gboolean popup_show_timeout(gpointer data)
 {
     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;
@@ -273,7 +272,7 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text)
     }
 
     /* 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
     */
@@ -284,7 +283,7 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text)
         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);
     }
 
@@ -296,9 +295,9 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text)
         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 {
@@ -315,12 +314,12 @@ void popup_hide(ObPopup *self)
         /* 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;
     }
 }
@@ -332,7 +331,7 @@ static void icon_popup_draw_icon(gint x, gint y, gint w, gint h, gpointer data)
     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);
 }
 
@@ -343,11 +342,11 @@ ObIconPopup *icon_popup_new(void)
     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;
@@ -359,7 +358,7 @@ ObIconPopup *icon_popup_new(void)
 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);
@@ -484,7 +483,7 @@ static void pager_popup_draw_icon(gint px, gint py, gint w, gint h,
                 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);
             }
@@ -519,7 +518,7 @@ void pager_popup_free(ObPagerPopup *self)
         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);
@@ -535,7 +534,7 @@ void pager_popup_delay_show(ObPagerPopup *self, gulong usec,
 
     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);
@@ -546,12 +545,12 @@ void pager_popup_delay_show(ObPagerPopup *self, gulong usec,
 
             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;
diff --git a/openbox/prompt.c b/openbox/prompt.c
new file mode 100644 (file)
index 0000000..aa5eb06
--- /dev/null
@@ -0,0 +1,477 @@
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+   prompt.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 "prompt.h"
+#include "openbox.h"
+#include "screen.h"
+#include "client.h"
+#include "event.h"
+#include "obt/display.h"
+#include "obt/keyboard.h"
+#include "obt/prop.h"
+#include "gettext.h"
+
+static GList *prompt_list = NULL;
+
+/* we construct these */
+static RrAppearance *prompt_a_button;
+static RrAppearance *prompt_a_focus;
+static RrAppearance *prompt_a_press;
+/* we change the max width which would screw with others */
+static RrAppearance *prompt_a_msg;
+
+static void prompt_layout(ObPrompt *self);
+static void render_all(ObPrompt *self);
+static void render_button(ObPrompt *self, ObPromptElement *e);
+
+void prompt_startup(gboolean reconfig)
+{
+    RrColor *c_button, *c_focus, *c_press;
+
+    prompt_a_button = RrAppearanceCopy(ob_rr_theme->a_focused_unpressed_close);
+    prompt_a_focus = RrAppearanceCopy(ob_rr_theme->a_hover_focused_close);
+    prompt_a_press = RrAppearanceCopy(ob_rr_theme->a_focused_pressed_close);
+
+    c_button = prompt_a_button->texture[0].data.mask.color;
+    c_focus = prompt_a_focus->texture[0].data.mask.color;
+    c_press = prompt_a_press->texture[0].data.mask.color;
+
+    RrAppearanceRemoveTextures(prompt_a_button);
+    RrAppearanceRemoveTextures(prompt_a_focus);
+    RrAppearanceRemoveTextures(prompt_a_press);
+
+    RrAppearanceAddTextures(prompt_a_button, 1);
+    RrAppearanceAddTextures(prompt_a_focus, 1);
+    RrAppearanceAddTextures(prompt_a_press, 1);
+
+    /* totally cheating here.. */
+    prompt_a_button->texture[0] = ob_rr_theme->osd_hilite_label->texture[0];
+    prompt_a_focus->texture[0] = ob_rr_theme->osd_hilite_label->texture[0];
+    prompt_a_press->texture[0] = ob_rr_theme->osd_hilite_label->texture[0];
+
+    prompt_a_button->texture[0].data.text.justify = RR_JUSTIFY_CENTER;
+    prompt_a_focus->texture[0].data.text.justify = RR_JUSTIFY_CENTER;
+    prompt_a_press->texture[0].data.text.justify = RR_JUSTIFY_CENTER;
+
+    prompt_a_button->texture[0].data.text.color = c_button;
+    prompt_a_focus->texture[0].data.text.color = c_focus;
+    prompt_a_press->texture[0].data.text.color = c_press;
+
+    prompt_a_msg = RrAppearanceCopy(ob_rr_theme->osd_hilite_label);
+    prompt_a_msg->texture[0].data.text.flow = TRUE;
+
+    if (reconfig) {
+        GList *it;
+        for (it = prompt_list; it; it = g_list_next(it)) {
+            ObPrompt *p = it->data;
+            prompt_layout(p);
+            render_all(p);
+        }
+    }
+}
+
+void prompt_shutdown(gboolean reconfig)
+{
+    RrAppearanceFree(prompt_a_button);
+    RrAppearanceFree(prompt_a_focus);
+    RrAppearanceFree(prompt_a_press);
+    RrAppearanceFree(prompt_a_msg);
+}
+
+ObPrompt* prompt_new(const gchar *msg,
+                     const ObPromptAnswer *answers, gint n_answers,
+                     gint default_result, gint cancel_result,
+                     ObPromptCallback func, gpointer data)
+{
+    ObPrompt *self;
+    XSetWindowAttributes attrib;
+    gint i;
+
+    attrib.override_redirect = FALSE;
+    attrib.border_pixel = RrColorPixel(ob_rr_theme->osd_border_color);
+
+    self = g_new0(ObPrompt, 1);
+    self->ref = 1;
+    self->func = func;
+    self->data = data;
+    self->default_result = default_result;
+    self->cancel_result = cancel_result;
+    self->super.type = OB_WINDOW_CLASS_PROMPT;
+    self->super.window = XCreateWindow(obt_display, obt_root(ob_screen),
+                                       0, 0, 1, 1, ob_rr_theme->obwidth,
+                                       CopyFromParent, InputOutput,
+                                       CopyFromParent,
+                                       CWOverrideRedirect | CWBorderPixel,
+                                       &attrib);
+
+    /* make it a dialog type window */
+    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;
+
+    /* we make a copy of this appearance for each prompt */
+    self->a_bg = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg);
+
+    /* set up the text message widow */
+    self->msg.text = g_strdup(msg);
+    self->msg.window = XCreateWindow(obt_display, self->super.window,
+                                     0, 0, 1, 1, 0,
+                                     CopyFromParent, InputOutput,
+                                     CopyFromParent, 0, NULL);
+    XMapWindow(obt_display, self->msg.window);
+
+    /* set up the buttons from the answers */
+
+    self->n_buttons = n_answers;
+    if (!self->n_buttons)
+        self->n_buttons = 1;
+
+    self->button = g_new0(ObPromptElement, self->n_buttons);
+
+    if (n_answers == 0) {
+        g_assert(self->n_buttons == 1); /* should be set to this above.. */
+        self->button[0].text = g_strdup(_("OK"));
+    }
+    else {
+        g_assert(self->n_buttons > 0);
+        for (i = 0; i < self->n_buttons; ++i) {
+            self->button[i].text = g_strdup(answers[i].text);
+            self->button[i].result = answers[i].result;
+        }
+    }
+
+    for (i = 0; i < self->n_buttons; ++i) {
+        self->button[i].window = XCreateWindow(obt_display, self->super.window,
+                                               0, 0, 1, 1, 0,
+                                               CopyFromParent, InputOutput,
+                                               CopyFromParent, 0, NULL);
+        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(obt_display, self->button[i].window,
+                     ButtonPressMask | ButtonReleaseMask | ButtonMotionMask);
+    }
+
+    prompt_list = g_list_prepend(prompt_list, self);
+
+    return self;
+}
+
+void prompt_ref(ObPrompt *self)
+{
+    ++self->ref;
+}
+
+void prompt_unref(ObPrompt *self)
+{
+    if (self && --self->ref == 0) {
+        gint i;
+
+        prompt_list = g_list_remove(prompt_list, self);
+
+        for (i = 0; i < self->n_buttons; ++i) {
+            window_remove(self->button[i].window);
+            XDestroyWindow(obt_display, self->button[i].window);
+        }
+
+        XDestroyWindow(obt_display, self->msg.window);
+
+        RrAppearanceFree(self->a_bg);
+
+        XDestroyWindow(obt_display, self->super.window);
+        g_free(self);
+    }
+}
+
+static void prompt_layout(ObPrompt *self)
+{
+    gint l, r, t, b;
+    gint i;
+    gint allbuttonsw, allbuttonsh, buttonx;
+    gint w, h;
+    gint maxw;
+
+    const gint OUTSIDE_MARGIN = 4;
+    const gint MSG_BUTTON_SEPARATION = 4;
+    const gint BUTTON_SEPARATION = 4;
+    const gint BUTTON_VMARGIN = 4;
+    const gint BUTTON_HMARGIN = 12;
+    const gint MAX_WIDTH = 600;
+
+    RrMargins(self->a_bg, &l, &t, &r, &b);
+    l += OUTSIDE_MARGIN;
+    t += OUTSIDE_MARGIN;
+    r += OUTSIDE_MARGIN;
+    b += OUTSIDE_MARGIN;
+
+    {
+        Rect *area = screen_physical_area_all_monitors();
+        maxw = MIN(MAX_WIDTH, area->width*4/5);
+        g_free(area);
+    }
+
+    /* find the button sizes and how much space we need for them */
+    allbuttonsw = allbuttonsh = 0;
+    for (i = 0; i < self->n_buttons; ++i) {
+        gint bw, bh;
+
+        prompt_a_button->texture[0].data.text.string = self->button[i].text;
+        prompt_a_focus->texture[0].data.text.string = self->button[i].text;
+        prompt_a_press->texture[0].data.text.string = self->button[i].text;
+        RrMinSize(prompt_a_button, &bw, &bh);
+        self->button[i].width = bw;
+        self->button[i].height = bh;
+        RrMinSize(prompt_a_focus, &bw, &bh);
+        self->button[i].width = MAX(self->button[i].width, bw);
+        self->button[i].height = MAX(self->button[i].height, bh);
+        RrMinSize(prompt_a_press, &bw, &bh);
+        self->button[i].width = MAX(self->button[i].width, bw);
+        self->button[i].height = MAX(self->button[i].height, bh);
+
+        self->button[i].width += BUTTON_HMARGIN * 2;
+        self->button[i].height += BUTTON_VMARGIN * 2;
+
+        allbuttonsw += self->button[i].width + (i > 0 ? BUTTON_SEPARATION : 0);
+        allbuttonsh = MAX(allbuttonsh, self->button[i].height);
+    }
+
+    self->msg_wbound = MAX(allbuttonsw, maxw);
+
+    /* measure the text message area */
+    prompt_a_msg->texture[0].data.text.string = self->msg.text;
+    prompt_a_msg->texture[0].data.text.maxwidth = self->msg_wbound;
+    RrMinSize(prompt_a_msg, &self->msg.width, &self->msg.height);
+
+    /* width and height inside the outer margins */
+    w = MAX(self->msg.width, allbuttonsw);
+    h = self->msg.height + MSG_BUTTON_SEPARATION + allbuttonsh;
+
+    /* position the text message */
+    self->msg.x = l + (w - self->msg.width) / 2;
+    self->msg.y = t;
+
+    /* position the button buttons on the right of the dialog */
+    buttonx = l + w;
+    for (i = self->n_buttons - 1; i >= 0; --i) {
+        self->button[i].x = buttonx - self->button[i].width;
+        buttonx -= self->button[i].width + BUTTON_SEPARATION;
+        self->button[i].y = t + h - allbuttonsh;
+        self->button[i].y += (allbuttonsh - self->button[i].height) / 2;
+    }
+
+    /* size and position the toplevel window */
+    self->width = w + l + r;
+    self->height = h + t + b;
+
+    /* move and resize the actual windows */
+    XResizeWindow(obt_display, self->super.window, self->width, self->height);
+    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(obt_display, self->button[i].window,
+                          self->button[i].x, self->button[i].y,
+                          self->button[i].width, self->button[i].height);
+}
+
+static void render_button(ObPrompt *self, ObPromptElement *e)
+{
+    RrAppearance *a;
+
+    if (e->pressed) a = prompt_a_press;
+    else if (self->focus == e) a = prompt_a_focus;
+    else a = prompt_a_button;
+
+    a->surface.parent = self->a_bg;
+    a->surface.parentx = e->x;
+    a->surface.parentx = e->y;
+
+    a->texture[0].data.text.string = e->text;
+    RrPaint(a, e->window, e->width, e->height);
+}
+
+static void render_all(ObPrompt *self)
+{
+    gint i;
+
+    RrPaint(self->a_bg, self->super.window, self->width, self->height);
+
+    prompt_a_msg->surface.parent = self->a_bg;
+    prompt_a_msg->surface.parentx = self->msg.x;
+    prompt_a_msg->surface.parenty = self->msg.y;
+
+    prompt_a_msg->texture[0].data.text.string = self->msg.text;
+    prompt_a_msg->texture[0].data.text.maxwidth = self->msg_wbound;
+    RrPaint(prompt_a_msg, self->msg.window, self->msg.width, self->msg.height);
+
+    for (i = 0; i < self->n_buttons; ++i)
+        render_button(self, &self->button[i]);
+}
+
+void prompt_show(ObPrompt *self, ObClient *parent)
+{
+    XSizeHints hints;
+    gint i;
+
+    if (self->mapped) {
+        /* activate the prompt */
+        OBT_PROP_MSG(ob_screen, self->super.window, NET_ACTIVE_WINDOW,
+                     1, /* from an application.. */
+                     event_curtime,
+                     0,
+                     0, 0);
+        return;
+    }
+
+    /* set the focused button (if not found then the first button is used) */
+    self->focus = &self->button[0];
+    for (i = 0; i < self->n_buttons; ++i)
+        if (self->button[i].result == self->default_result) {
+            self->focus = &self->button[i];
+            break;
+        }
+
+    /* you can't resize the prompt */
+    hints.flags = PMinSize | PMaxSize;
+    hints.min_width = hints.max_width = self->width;
+    hints.min_height = hints.max_height = self->height;
+    XSetWMNormalHints(obt_display, self->super.window, &hints);
+
+    XSetTransientForHint(obt_display, self->super.window,
+                         (parent ? parent->window : 0));
+
+    /* set up the dialog and render it */
+    prompt_layout(self);
+    render_all(self);
+
+    client_manage(self->super.window, self);
+
+    self->mapped = TRUE;
+}
+
+void prompt_hide(ObPrompt *self)
+{
+    XUnmapWindow(obt_display, self->super.window);
+    self->mapped = FALSE;
+}
+
+gboolean prompt_key_event(ObPrompt *self, XEvent *e)
+{
+    gboolean shift;
+    guint shift_mask;
+
+    if (e->type != KeyPress) return FALSE;
+
+    shift_mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SHIFT);
+    shift = !!(e->xkey.state & shift_mask);
+
+    /* only accept shift */
+    if (e->xkey.state != 0 && e->xkey.state != shift_mask)
+        return FALSE;
+
+    if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE))
+        prompt_cancel(self);
+    else if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN) ||
+             e->xkey.keycode == ob_keycode(OB_KEY_SPACE))
+    {
+        if (self->func) self->func(self, self->focus->result, self->data);
+        prompt_hide(self);
+    }
+    else if (e->xkey.keycode == ob_keycode(OB_KEY_TAB) ||
+             e->xkey.keycode == ob_keycode(OB_KEY_LEFT) ||
+             e->xkey.keycode == ob_keycode(OB_KEY_RIGHT))
+    {
+        gint i;
+        gboolean left;
+        ObPromptElement *oldfocus;
+
+        left = e->xkey.keycode == ob_keycode(OB_KEY_LEFT) ||
+            (e->xkey.keycode == ob_keycode(OB_KEY_TAB) && shift);
+        oldfocus = self->focus;
+
+        for (i = 0; i < self->n_buttons; ++i)
+            if (self->focus == &self->button[i]) break;
+        i += (left ? -1 : 1);
+        if (i < 0) i = self->n_buttons - 1;
+        else if (i >= self->n_buttons) i = 0;
+        self->focus = &self->button[i];
+
+        if (oldfocus != self->focus) render_button(self, oldfocus);
+        render_button(self, self->focus);
+    }
+    return TRUE;
+}
+
+gboolean prompt_mouse_event(ObPrompt *self, XEvent *e)
+{
+    gint i;
+    ObPromptElement *but;
+
+    if (e->type != ButtonPress && e->type != ButtonRelease &&
+        e->type != MotionNotify) return FALSE;
+
+    /* find the button */
+    but = NULL;
+    for (i = 0; i < self->n_buttons; ++i)
+        if (self->button[i].window ==
+            (e->type == MotionNotify ? e->xmotion.window : e->xbutton.window))
+        {
+            but = &self->button[i];
+            break;
+        }
+    if (!but) return FALSE;
+
+    if (e->type == ButtonPress) {
+        ObPromptElement *oldfocus;
+
+        oldfocus = self->focus;
+
+        but->pressed = TRUE;
+        self->focus = but;
+
+        if (oldfocus != but) render_button(self, oldfocus);
+        render_button(self, but);
+    }
+    else if (e->type == ButtonRelease) {
+        if (but->pressed) {
+            if (self->func) self->func(self, but->result, self->data);
+            prompt_hide(self);
+        }
+    }
+    else if (e->type == MotionNotify) {
+        gboolean press;
+
+        press = (e->xmotion.x >= 0 && e->xmotion.y >= 0 &&
+                 e->xmotion.x < but->width && e->xmotion.y < but->height);
+
+        if (press != but->pressed) {
+            but->pressed = press;
+            render_button(self, but);
+        }
+    }
+    return TRUE;
+}
+
+void prompt_cancel(ObPrompt *self)
+{
+    if (self->func) self->func(self, self->cancel_result, self->data);
+    prompt_hide(self);
+}
diff --git a/openbox/prompt.h b/openbox/prompt.h
new file mode 100644 (file)
index 0000000..1bcd66c
--- /dev/null
@@ -0,0 +1,110 @@
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+   prompt.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 ob__prompt_h
+#define ob__prompt_h
+
+#include "window.h"
+#include "geom.h"
+#include "render/render.h"
+#include <glib.h>
+#include <X11/Xlib.h>
+
+typedef struct _ObPrompt       ObPrompt;
+typedef struct _ObPromptElement ObPromptElement;
+typedef struct _ObPromptAnswer ObPromptAnswer;
+
+typedef void (*ObPromptCallback)(ObPrompt *p, gint result, gpointer data);
+
+struct _ObPromptElement {
+    gchar *text;
+    Window window;
+
+    gint x, y, width, height;
+    gboolean pressed;
+    gint result;
+};
+
+struct _ObPrompt
+{
+    ObInternalWindow super;
+    gint ref;
+
+    guint event_mask;
+
+    /* keep a copy of this because we re-render things that may need it
+       (i.e. the buttons) */
+    RrAppearance *a_bg;
+
+    gboolean mapped;
+    gint width, height;
+    gint msg_wbound;
+
+    ObPromptElement msg;
+
+    /* one for each answer */
+    ObPromptElement *button;
+    gint n_buttons;
+
+    /* points to the button with the focus */
+    ObPromptElement *focus;
+    /* the default button to have selected */
+    gint default_result;
+    /* the cancel result if the dialog is closed */
+    gint cancel_result;
+
+    ObPromptCallback func;
+    gpointer data;
+};
+
+struct _ObPromptAnswer {
+    const gchar *text;
+    gint result;
+};
+
+void prompt_startup(gboolean reconfig);
+void prompt_shutdown(gboolean reconfig);
+
+/*! Create a new prompt
+  @param answers A number of ObPromptAnswers which define the buttons which
+                 will appear in the dialog from left to right, and the result
+                 returned when they are selected.
+  @param n_answers The number of answers
+  @param default_result The result for the answer button selected by default
+  @param cancel_result The result that is given if the dialog is closed instead
+         of having a button presssed
+  @param func The callback function which is called when the dialog is closed
+         or a button is pressed
+  @param data User defined data which will be passed to the callback
+*/
+ObPrompt* prompt_new(const gchar *msg,
+                     const ObPromptAnswer *answers, gint n_answers,
+                     gint default_result, gint cancel_result,
+                     ObPromptCallback func, gpointer data);
+void prompt_ref(ObPrompt *self);
+void prompt_unref(ObPrompt *self);
+
+/*! Show the prompt.  It will be centered within the given area rectangle */
+void prompt_show(ObPrompt *self, struct _ObClient *parent);
+void prompt_hide(ObPrompt *self);
+
+gboolean prompt_key_event(ObPrompt *self, XEvent *e);
+gboolean prompt_mouse_event(ObPrompt *self, XEvent *e);
+void prompt_cancel(ObPrompt *self);
+
+#endif
index f21eb8e682e3c8eb63c7453f4ec41c472e9f4d36..3bcb95ffc4db5779f870d29b47f7fdb6fbd9f129 100644 (file)
    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>
 
index a2b3f1602c1fd52574830ff092b66d942a775dc5..31cc7177e06422e72276b6bb427ec8ce5df7dc36 100644 (file)
 #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
 */
index da490778357a81d5e54ab73d383d31f7bf9fd628..90f8b27c76cbd13c29c74c07e78ab79cf9bfd8e9 100644 (file)
 #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
@@ -91,10 +90,10 @@ static gboolean replace_wm(void)
     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) {
@@ -103,24 +102,23 @@ static gboolean replace_wm(void)
                       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;
@@ -133,7 +131,7 @@ static gboolean replace_wm(void)
       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;
@@ -148,9 +146,9 @@ static gboolean replace_wm(void)
     }
 
     /* 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;
 }
@@ -160,37 +158,33 @@ gboolean screen_annex(void)
     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;
     }
 
@@ -198,114 +192,110 @@ gboolean screen_annex(void)
 
     /* 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();
@@ -337,14 +327,14 @@ static void screen_tell_ksplash(void)
        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)
@@ -368,9 +358,7 @@ 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;
     }
@@ -391,7 +379,8 @@ void screen_startup(gboolean reconfig)
             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);
     }
@@ -401,8 +390,8 @@ void screen_startup(gboolean reconfig)
        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."),
@@ -418,8 +407,8 @@ void screen_startup(gboolean reconfig)
 
     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);
@@ -433,8 +422,8 @@ void screen_startup(gboolean reconfig)
 
     /* 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))
@@ -452,17 +441,16 @@ void screen_shutdown(gboolean reconfig)
     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;
@@ -475,8 +463,8 @@ void screen_resize(void)
     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;
 
@@ -485,8 +473,8 @@ void screen_resize(void)
     /* 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;
@@ -510,13 +498,12 @@ void screen_set_num_desktops(guint num)
 
     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 */
@@ -611,8 +598,7 @@ void screen_set_desktop(guint num, gboolean dofocus)
 
     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 */
@@ -620,10 +606,15 @@ void screen_set_desktop(guint num, gboolean dofocus)
         /* If screen_desktop_timeout is true, then we've been on this desktop
            long enough and we can save it as the last desktop. */
 
-        /* save the "last desktop" as the "old desktop" */
-        screen_old_desktop = screen_last_desktop;
-        /* save the desktop we're coming from as the "last desktop" */
-        screen_last_desktop = previous;
+        if (screen_last_desktop == previous)
+            /* this is the startup state only */
+            screen_old_desktop = screen_desktop;
+        else {
+            /* save the "last desktop" as the "old desktop" */
+            screen_old_desktop = screen_last_desktop;
+            /* save the desktop we're coming from as the "last desktop" */
+            screen_last_desktop = previous;
+        }
     }
     else {
         /* If screen_desktop_timeout is false, then we just got to this desktop
@@ -673,11 +664,11 @@ void screen_set_desktop(guint num, gboolean dofocus)
         }
     }
     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();
@@ -734,7 +725,7 @@ void screen_add_desktop(gboolean current)
                    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);
             }
         }
@@ -775,7 +766,7 @@ void screen_remove_desktop(gboolean current)
                    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
@@ -785,7 +776,7 @@ void screen_remove_desktop(gboolean current)
                 (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);
             }
         }
     }
@@ -793,7 +784,7 @@ void screen_remove_desktop(gboolean current)
     /* 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);
@@ -934,15 +925,15 @@ void screen_show_desktop_popup(guint d)
                           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);
 }
 
@@ -1101,13 +1092,13 @@ void screen_update_layout(void)
     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;
@@ -1115,13 +1106,13 @@ void screen_update_layout(void)
             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;
@@ -1146,8 +1137,8 @@ void screen_update_desktop_names(void)
     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;
@@ -1173,8 +1164,8 @@ void screen_update_desktop_names(void)
 
         /* 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 */
@@ -1241,24 +1232,23 @@ void screen_show_desktop(gboolean show, ObClient *show_only)
     }
 
     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);
     }
 }
 
@@ -1300,6 +1290,54 @@ typedef struct {
     } \
 }
 
+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;
@@ -1308,7 +1346,7 @@ void screen_update_areas(void)
     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]);
@@ -1417,8 +1455,8 @@ void screen_update_areas(void)
 
     /* 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))
@@ -1659,10 +1697,10 @@ Rect* screen_physical_area_active(void)
 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));
 }
 
@@ -1673,12 +1711,12 @@ gboolean screen_pointer_pos(gint *x, gint *y)
     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;
     }
index 96d7563faf3f5df622637ec7c884038a7e7849fe..267d17ef54ebb9582ca76b1f0ea5b2af8f308935 100644 (file)
@@ -38,10 +38,10 @@ GList* session_state_find(struct _ObClient *c) { return NULL; }
 #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>
@@ -91,22 +91,26 @@ static void session_state_free(ObSessionState *state);
 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);
         }
@@ -173,7 +177,7 @@ static gboolean session_connect()
 
     /* 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 |
@@ -183,9 +187,9 @@ static gboolean session_connect()
                                 &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;
 }
 
@@ -202,7 +206,7 @@ static void session_setup_program()
         .vals = &vals
     };
     SmProp *list = &prop;
-    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);
@@ -223,7 +227,7 @@ static void session_setup_user()
         .vals = &vals
     };
     SmProp *list = &prop;
-    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);
@@ -245,7 +249,7 @@ static void session_setup_restart_style(gboolean restart)
         .vals = &vals
     };
     SmProp *list = &prop;
-    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);
@@ -266,7 +270,7 @@ static void session_setup_pid()
         .vals = &vals
     };
     SmProp *list = &prop;
-    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);
@@ -289,7 +293,7 @@ static void session_setup_priority()
         .vals = &vals
     };
     SmProp *list = &prop;
-    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);
@@ -308,11 +312,11 @@ static void session_setup_clone_command()
     };
     SmProp *list = &prop;
 
-    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);
@@ -334,26 +338,26 @@ static void session_setup_restart_command()
     };
     SmProp *list = &prop;
 
-    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);
@@ -381,9 +385,9 @@ static void sm_save_yourself_2(SmcConn conn, SmPointer data)
     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);
@@ -392,7 +396,7 @@ static void sm_save_yourself_2(SmcConn conn, SmPointer data)
     /* 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);
 }
 
@@ -403,10 +407,10 @@ static void sm_save_yourself(SmcConn conn, SmPointer data, gint save_type,
     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
@@ -417,7 +421,7 @@ static void sm_save_yourself(SmcConn conn, SmPointer data, gint save_type,
     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);
     }
@@ -425,18 +429,18 @@ static void sm_save_yourself(SmcConn conn, SmPointer data, gint save_type,
 
 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)
@@ -494,18 +498,18 @@ 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;
@@ -604,20 +608,20 @@ static void session_state_free(ObSessionState *state)
 
 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)) ||
@@ -652,101 +656,106 @@ GList* session_state_find(ObClient *c)
 
 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 */
@@ -801,7 +810,7 @@ static void session_load_file(const gchar *path)
         }
     }
 
-    xmlFreeDoc(doc);
+    obt_parse_instance_unref(i);
 }
 
 #endif
index 4c24e3e87f06ed2414006f41abe266e3872ba7a9..3c05df49c64c0c23f470a87aa4e090ee33fb4d29 100644 (file)
@@ -18,7 +18,6 @@
 */
 
 #include "openbox.h"
-#include "prop.h"
 #include "screen.h"
 #include "focus.h"
 #include "client.h"
@@ -27,6 +26,7 @@
 #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
@@ -55,8 +55,8 @@ void stacking_set_list(void)
         }
     }
 
-    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);
 }
@@ -105,7 +105,7 @@ static void do_restack(GList *wins, GList *before)
 #endif
 
     if (!pause_changes)
-        XRestackWindows(ob_display, win, i);
+        XRestackWindows(obt_display, win, i);
     g_free(win);
 
     stacking_set_list();
@@ -132,7 +132,7 @@ void stacking_temp_raise(ObWindow *window)
 
     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;
@@ -150,7 +150,7 @@ void stacking_restore(void)
     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);
 
@@ -633,21 +633,20 @@ gboolean stacking_restack_request(ObClient *client, ObClient *sibling,
                     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 */
@@ -657,13 +656,13 @@ gboolean stacking_restack_request(ObClient *client, ObClient *sibling,
         }
         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));
@@ -671,8 +670,7 @@ gboolean stacking_restack_request(ObClient *client, ObClient *sibling,
         }
         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));
index e13aa55c688a55f84f50a66d6ebaa9392c389a34..3e8799f8dd9ea7f4a9bc4b0e5d6fda66cdca2e3e 100644 (file)
@@ -43,7 +43,6 @@ void sn_spawn_cancel() {}
 #else
 
 #include "openbox.h"
-#include "mainloop.h"
 #include "screen.h"
 
 #define SN_API_NOT_YET_FROZEN
@@ -63,12 +62,12 @@ void sn_startup(gboolean reconfig)
 {
     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)
@@ -77,7 +76,7 @@ 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);
@@ -140,10 +139,10 @@ static void sn_event_func(SnMonitorEvent *ev, gpointer 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:
@@ -154,8 +153,8 @@ static void sn_event_func(SnMonitorEvent *ev, gpointer data)
     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;
@@ -261,10 +260,10 @@ void sn_setup_spawn_environment(const gchar *program, const gchar *name,
 
     /* 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);
 
index c697679d1291fd03da7f0837f384ac1475f8e11f..7e89e32cf0cc03de34d383ce2fef6a0d0c6b961f 100644 (file)
@@ -19,9 +19,9 @@
 
 #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>
@@ -38,23 +38,23 @@ static guint translate_modifier(gchar *str)
 
     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);
 
@@ -145,7 +145,7 @@ gboolean translate_key(const gchar *str, guint *state, guint *keycode)
             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);
@@ -158,30 +158,3 @@ translation_fail:
     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;
-}
index 6d9e23bcb26f332305ab64734e380539371e98e7..8249514e10e5fdd47051f4abe96a1fe5f2aa6cda 100644 (file)
 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
index c5e6a4ea9c81eb63e89e1806b1ea690c5dc2cbe6..c8951741bf44fa72713a54b697f713943eeb286d 100644 (file)
 #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; }
@@ -46,18 +50,16 @@ void window_shutdown(gboolean reconfig)
 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)->win;
+    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;
@@ -66,19 +68,141 @@ Window window_top(ObWindow *self)
 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:
+    case OB_WINDOW_CLASS_PROMPT:
         return OB_STACKING_LAYER_INTERNAL;
     }
     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();
+}
index a172cfce62f10664bcb708e8deb0d9b4464ff3b8..24a7d07bc7d7163024941c5d9471d7417b05e770 100644 (file)
@@ -28,55 +28,66 @@ typedef struct _ObWindow         ObWindow;
 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_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 {
-    ObWindow obwin;
-    Window win;
-} 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_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 _ObDockApp;
 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
diff --git a/openbox/xerror.c b/openbox/xerror.c
deleted file mode 100644 (file)
index 2657b8e..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- 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;
-}
diff --git a/parser/obparser-3.0.pc.in b/parser/obparser-3.0.pc.in
deleted file mode 100644 (file)
index 75d04c9..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-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@
diff --git a/parser/parse.c b/parser/parse.c
deleted file mode 100644 (file)
index 636b451..0000000
+++ /dev/null
@@ -1,529 +0,0 @@
-/* -*- 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;
-}
diff --git a/parser/parse.h b/parser/parse.h
deleted file mode 100644 (file)
index 28af64b..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- 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
index f7918cec6f61c96d215d4095581ef5713ff335fe..6de409fcda3932eef7a2c06eb2161af6802e7166 100644 (file)
@@ -6,6 +6,7 @@ openbox/client_list_combined_menu.c
 openbox/client_list_menu.c
 openbox/client_menu.c
 openbox/config.c
+openbox/debug.c
 openbox/keyboard.c
 openbox/menu.c
 openbox/mouse.c
@@ -14,4 +15,4 @@ openbox/screen.c
 openbox/session.c
 openbox/startupnotify.c
 openbox/translate.c
-openbox/xerror.c
+openbox/prompt.c
index 356b9c6ebd757432c6d278e8406183241f23cce2..5ccfb8fd2850f6267025b58f57c0a2ec69a5f0ec 100644 (file)
@@ -108,7 +108,7 @@ RrFont *RrFontOpen(const RrInstance *inst, const gchar *name, gint size,
 
     /* setup the layout */
     pango_layout_set_font_description(out->layout, out->font_desc);
-    pango_layout_set_single_paragraph_mode(out->layout, TRUE);
+    pango_layout_set_wrap(out->layout, PANGO_WRAP_WORD_CHAR);
 
     /* get the ascent and descent */
     measure_font(inst, out);
@@ -139,12 +139,23 @@ void RrFontClose(RrFont *f)
 }
 
 static void font_measure_full(const RrFont *f, const gchar *str,
-                              gint *x, gint *y, gint shadow_x, gint shadow_y)
+                              gint *x, gint *y, gint shadow_x, gint shadow_y,
+                              gboolean flow, gint maxwidth)
 {
     PangoRectangle rect;
 
     pango_layout_set_text(f->layout, str, -1);
-    pango_layout_set_width(f->layout, -1);
+    if (flow) {
+        pango_layout_set_single_paragraph_mode(f->layout, FALSE);
+        pango_layout_set_width(f->layout, maxwidth * PANGO_SCALE);
+        pango_layout_set_ellipsize(f->layout, PANGO_ELLIPSIZE_NONE);
+    }
+    else {
+        /* single line mode */
+        pango_layout_set_single_paragraph_mode(f->layout, TRUE);
+        pango_layout_set_width(f->layout, -1);
+        pango_layout_set_ellipsize(f->layout, PANGO_ELLIPSIZE_MIDDLE);
+    }
 
     /* pango_layout_get_pixel_extents lies! this is the right way to get the
        size of the text's area */
@@ -163,11 +174,16 @@ static void font_measure_full(const RrFont *f, const gchar *str,
 }
 
 RrSize *RrFontMeasureString(const RrFont *f, const gchar *str,
-                            gint shadow_x, gint shadow_y)
+                            gint shadow_x, gint shadow_y,
+                            gboolean flow, gint maxwidth)
 {
     RrSize *size;
+
+    g_assert(!flow || maxwidth > 0);
+
     size = g_new(RrSize, 1);
-    font_measure_full(f, str, &size->width, &size->height, shadow_x, shadow_y);
+    font_measure_full(f, str, &size->width, &size->height, shadow_x, shadow_y,
+                      flow, maxwidth);
     return size;
 }
 
@@ -208,36 +224,47 @@ void RrFontDraw(XftDraw *d, RrTextureText *t, RrRect *area)
     PangoAttrList *attrlist;
     PangoEllipsizeMode ell;
 
-    /* center the text vertically
-       We do this centering based on the 'baseline' since different fonts have
-       different top edges. It looks bad when the whole string is moved when 1
-       character from a non-default language is included in the string */
-    y = area->y +
-        font_calculate_baseline(t->font, area->height);
+    g_assert(!t->flow || t->maxwidth > 0);
+
+    y = area->y;
+    if (!t->flow)
+        /* center the text vertically
+           We do this centering based on the 'baseline' since different fonts
+           have different top edges. It looks bad when the whole string is
+           moved when 1 character from a non-default language is included in
+           the string */
+        y += font_calculate_baseline(t->font, area->height);
 
     /* the +2 and -4 leave a small blank edge on the sides */
     x = area->x + 2;
-    w = area->width - 4;
+    w = area->width;
+    if (t->flow) w = MAX(w, t->maxwidth);
+    w -= 4;
     h = area->height;
 
-    switch (t->ellipsize) {
-    case RR_ELLIPSIZE_NONE:
+    if (t->flow)
         ell = PANGO_ELLIPSIZE_NONE;
-        break;
-    case RR_ELLIPSIZE_START:
-        ell = PANGO_ELLIPSIZE_START;
-        break;
-    case RR_ELLIPSIZE_MIDDLE:
-        ell = PANGO_ELLIPSIZE_MIDDLE;
-        break;
-    case RR_ELLIPSIZE_END:
-        ell = PANGO_ELLIPSIZE_END;
-        break;
+    else {
+        switch (t->ellipsize) {
+        case RR_ELLIPSIZE_NONE:
+            ell = PANGO_ELLIPSIZE_NONE;
+            break;
+        case RR_ELLIPSIZE_START:
+            ell = PANGO_ELLIPSIZE_START;
+            break;
+        case RR_ELLIPSIZE_MIDDLE:
+            ell = PANGO_ELLIPSIZE_MIDDLE;
+            break;
+        case RR_ELLIPSIZE_END:
+            ell = PANGO_ELLIPSIZE_END;
+            break;
+        }
     }
 
     pango_layout_set_text(t->font->layout, t->string, -1);
     pango_layout_set_width(t->font->layout, w * PANGO_SCALE);
     pango_layout_set_ellipsize(t->font->layout, ell);
+    pango_layout_set_single_paragraph_mode(t->font->layout, !t->flow);
 
     /* * * end of setting up the layout * * */
 
@@ -265,10 +292,23 @@ void RrFontDraw(XftDraw *d, RrTextureText *t, RrRect *area)
         c.pixel = t->shadow_color->pixel;
 
         /* see below... */
-        pango_xft_render_layout_line
-            (d, &c, pango_layout_get_line(t->font->layout, 0),
-             (x + t->shadow_offset_x) * PANGO_SCALE,
-             (y + t->shadow_offset_y) * PANGO_SCALE);
+        if (!t->flow) {
+            pango_xft_render_layout_line
+                (d, &c,
+#if PANGO_VERSION_MAJOR > 1 || \
+    (PANGO_VERSION_MAJOR == 1 && PANGO_VERSION_MINOR >= 16)
+                 pango_layout_get_line_readonly(t->font->layout, 0),
+#else
+                 pango_layout_get_line(t->font->layout, 0),
+#endif
+                 (x + t->shadow_offset_x) * PANGO_SCALE,
+                 (y + t->shadow_offset_y) * PANGO_SCALE);
+        }
+        else {
+            pango_xft_render_layout(d, &c, t->font->layout,
+                                    (x + t->shadow_offset_x) * PANGO_SCALE,
+                                    (y + t->shadow_offset_y) * PANGO_SCALE);
+        }
     }
 
     c.color.red = t->color->r | t->color->r << 8;
@@ -295,9 +335,23 @@ void RrFontDraw(XftDraw *d, RrTextureText *t, RrRect *area)
 
     /* layout_line() uses y to specify the baseline
        The line doesn't need to be freed, it's a part of the layout */
-    pango_xft_render_layout_line
-        (d, &c, pango_layout_get_line(t->font->layout, 0),
-         x * PANGO_SCALE, y * PANGO_SCALE);
+    if (!t->flow) {
+        pango_xft_render_layout_line
+            (d, &c,
+#if PANGO_VERSION_MAJOR > 1 || \
+    (PANGO_VERSION_MAJOR == 1 && PANGO_VERSION_MINOR >= 16)
+             pango_layout_get_line_readonly(t->font->layout, 0),
+#else
+             pango_layout_get_line(t->font->layout, 0),
+#endif
+             x * PANGO_SCALE,
+             y * PANGO_SCALE);
+    }
+    else {
+        pango_xft_render_layout(d, &c, t->font->layout,
+                                x * PANGO_SCALE,
+                                y * PANGO_SCALE);
+    }
 
     if (t->shortcut) {
         t->font->shortcut_underline->start_index = 0;
similarity index 86%
rename from render/obrender-3.0.pc.in
rename to render/obrender-4.0.pc.in
index ebb17ef3aa1b319cd29f272a55ec42fd43a48b6d..9c310569c98850dfaca60958d5305a0211d5523a 100644 (file)
@@ -9,6 +9,6 @@ xlibs=@X_LIBS@
 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}
index 4119dc7fb9f62484fe90ec3755ab327bb3bd843b..49485c8a1dea41f0de7c3c6781e2e51b884754f2 100644 (file)
@@ -132,10 +132,20 @@ Pixmap RrPaintPixmap(RrAppearance *a, gint w, gint h)
             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;
+                RrImageDraw(a->surface.pixel_data,
+                            &a->texture[i].data.rgba,
+                            a->w, a->h,
+                            &narea);
+            }
             force_transfer = 1;
         break;
         }
@@ -178,6 +188,12 @@ RrAppearance *RrAppearanceNew(const RrInstance *inst, gint numtex)
   return out;
 }
 
+void RrAppearanceRemoveTextures(RrAppearance *a)
+{
+    g_free(a->texture);
+    a->textures = 0;
+}
+
 void RrAppearanceAddTextures(RrAppearance *a, gint numtex)
 {
     g_assert(a->textures == 0);
@@ -378,7 +394,9 @@ gint RrMinWidth(RrAppearance *a)
             m = RrFontMeasureString(a->texture[i].data.text.font,
                                     a->texture[i].data.text.string,
                                     a->texture[i].data.text.shadow_offset_x,
-                                    a->texture[i].data.text.shadow_offset_y);
+                                    a->texture[i].data.text.shadow_offset_y,
+                                    a->texture[i].data.text.flow,
+                                    a->texture[i].data.text.maxwidth);
             w = MAX(w, m->width);
             g_free(m);
             break;
@@ -404,6 +422,7 @@ gint RrMinHeight(RrAppearance *a)
 {
     gint i;
     gint l, t, r, b;
+    RrSize *m;
     gint h = 0;
 
     for (i = 0; i < a->textures; ++i) {
@@ -414,8 +433,24 @@ gint RrMinHeight(RrAppearance *a)
             h = MAX(h, a->texture[i].data.mask.mask->height);
             break;
         case RR_TEXTURE_TEXT:
-            h += MAX(h, RrFontHeight(a->texture[i].data.text.font,
-                                     a->texture[i].data.text.shadow_offset_y));
+            if (a->texture[i].data.text.flow) {
+                g_assert(a->texture[i].data.text.string != NULL);
+
+                m = RrFontMeasureString
+                    (a->texture[i].data.text.font,
+                     a->texture[i].data.text.string,
+                     a->texture[i].data.text.shadow_offset_x,
+                     a->texture[i].data.text.shadow_offset_y,
+                     a->texture[i].data.text.flow,
+                     a->texture[i].data.text.maxwidth);
+                h += MAX(h, m->height);
+                g_free(m);
+            }
+            else
+                h += MAX(h,
+                         RrFontHeight
+                         (a->texture[i].data.text.font,
+                          a->texture[i].data.text.shadow_offset_y));
             break;
         case RR_TEXTURE_RGBA:
             h += MAX(h, a->texture[i].data.rgba.height);
index 1f87c6e08a91648b1a0e799f81d36b071c2c317a..260ebeb0bf9f931fe63b1690fd2ba4de3cca7659 100644 (file)
@@ -22,7 +22,7 @@
 #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>
@@ -141,6 +141,8 @@ struct _RrTextureText {
     gboolean shortcut; /*!< Underline a character */
     guint shortcut_pos; /*!< Position in bytes of the character to underline */
     RrEllipsizeMode ellipsize;
+    gboolean flow; /* allow multiple lines.  must set maxwidth below */
+    gint maxwidth;
 };
 
 struct _RrPixmapMask {
@@ -165,6 +167,11 @@ struct _RrTextureRGBA {
     gint cwidth;
     gint cheight;
     RrPixel32 *cache;
+/* size and position to draw at */
+    gint tx;
+    gint ty;
+    gint twidth;
+    gint theight;
 };
 
 struct _RrTextureLineArt {
@@ -244,6 +251,7 @@ GC       RrColorGC    (RrColor *c);
 RrAppearance *RrAppearanceNew  (const RrInstance *inst, gint numtex);
 RrAppearance *RrAppearanceCopy (RrAppearance *a);
 void          RrAppearanceFree (RrAppearance *a);
+void          RrAppearanceRemoveTextures(RrAppearance *a);
 void          RrAppearanceAddTextures(RrAppearance *a, gint numtex);
 
 RrFont *RrFontOpen          (const RrInstance *inst, const gchar *name,
@@ -251,7 +259,8 @@ RrFont *RrFontOpen          (const RrInstance *inst, const gchar *name,
 RrFont *RrFontOpenDefault   (const RrInstance *inst);
 void    RrFontClose         (RrFont *f);
 RrSize *RrFontMeasureString (const RrFont *f, const gchar *str,
-                             gint shadow_offset_x, gint shadow_offset_y);
+                             gint shadow_offset_x, gint shadow_offset_y,
+                             gboolean flow, gint maxwidth);
 gint    RrFontHeight        (const RrFont *f, gint shadow_offset_y);
 gint    RrFontMaxCharWidth  (const RrFont *f);
 
@@ -262,6 +271,8 @@ Pixmap RrPaintPixmap (RrAppearance *a, gint w, gint h);
 void   RrPaint       (RrAppearance *a, Window win, gint w, gint h);
 void   RrMinSize     (RrAppearance *a, gint *w, gint *h);
 gint   RrMinWidth    (RrAppearance *a);
+/* For text textures, if flow is TRUE, then the string must be set before
+   calling this, otherwise it doesn't need to be */
 gint   RrMinHeight   (RrAppearance *a);
 void   RrMargins     (RrAppearance *a, gint *l, gint *t, gint *r, gint *b);
 
index 9fc1f1db356b782d2961179fd83a514c84196c4e..a6931be664923a4980c23d736592671976917766 100644 (file)
@@ -23,7 +23,7 @@
 #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>
@@ -538,6 +538,16 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
         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,
@@ -1446,6 +1456,8 @@ void RrThemeFree(RrTheme *theme)
         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);
@@ -1556,6 +1568,10 @@ static XrmDatabase loaddb(const gchar *name, gchar **path)
             *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);
@@ -1563,8 +1579,7 @@ static XrmDatabase loaddb(const gchar *name, gchar **path)
             *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);
@@ -1572,6 +1587,8 @@ static XrmDatabase loaddb(const gchar *name, gchar **path)
                 *path = g_path_get_dirname(s);
             g_free(s);
         }
+
+        obt_paths_unref(p);
     }
 
     if (db == NULL) {
index 2c35284f466b50dba4855edffc75bd57cdf1f572..9f51fabd905793c75a1fe61264348bb04871494a 100644 (file)
@@ -144,6 +144,9 @@ struct _RrTheme {
     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;
diff --git a/render/version.h.in b/render/version.h.in
new file mode 100644 (file)
index 0000000..0ff30b5
--- /dev/null
@@ -0,0 +1,15 @@
+#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
diff --git a/version.h.in b/version.h.in
deleted file mode 100644 (file)
index da3f02e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#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
This page took 0.568088 seconds and 4 git commands to generate.