aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2010-08-18 21:43:36 +0100
committerRobert Bragg <robert@linux.intel.com>2010-12-09 22:46:47 +0000
commit41059683747e80790218b3bf67f71df5c56f39a7 (patch)
treedc2df1ccf47df146ab6483a04018bbc81fba996b
parentfe05e654ee61f3f3dc72691401a30e22344f660a (diff)
downloadlibmatchboxwm2-41059683747e80790218b3bf67f71df5c56f39a7.tar.gz
libmatchboxwm2-41059683747e80790218b3bf67f71df5c56f39a7.tar.bz2
libmatchboxwm2-41059683747e80790218b3bf67f71df5c56f39a7.zip
managers: Adds an example xrender based compositor
Like the clutter based compositor it is based on the code of the simple manager and it builds on the mb-wm-comp-mgr-xrender code that used to live under the matchbox directory but has now been moved to part of the compositor itself.
-rw-r--r--configure.ac11
-rw-r--r--managers/xrender/Makefile.am20
-rw-r--r--managers/xrender/matchbox-window-manager-2-xrender.c139
-rw-r--r--managers/xrender/mb-wm-comp-mgr-xrender.c (renamed from matchbox/mb-wm-comp-mgr-xrender.c)0
-rw-r--r--managers/xrender/mb-wm-comp-mgr-xrender.h (renamed from matchbox/mb-wm-comp-mgr-xrender.h)2
5 files changed, 170 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 1cce666..d814d44 100644
--- a/configure.ac
+++ b/configure.ac
@@ -87,6 +87,7 @@ AC_ARG_ENABLE(managers,
Build the specified managers. Available managers are:
* simple
* maemo
+ * xrender
* clutter],
[managers=$enableval], [managers=no])
@@ -110,7 +111,7 @@ if test "x$compositing" != xno; then
needed_pkgs="$needed_pkgs xcomposite xdamage "
fi
-all_managers="simple,maemo,clutter"
+all_managers="simple,maemo,xrender,clutter"
included_managers=""
# If no managers specified, include all
@@ -217,6 +218,13 @@ if test x"$MANAGER_maemo" = xyes; then
fi
AC_SUBST(ENABLE_MAEMO_MANAGER)
+AM_CONDITIONAL(ENABLE_XRENDER_MANAGER, [test x"$MANAGER_xrender" = xyes])
+if test x"$MANAGER_xrender" = xyes; then
+ ENABLE_XRENDER_MANAGER=1
+ MANAGERS="$MANAGERS xrender"
+fi
+AC_SUBST(ENABLE_XRENDER_MANAGER)
+
AM_CONDITIONAL(ENABLE_CLUTTER_MANAGER, [test x"$MANAGER_clutter" = xyes])
if test x"$MANAGER_clutter" = xyes; then
ENABLE_CLUTTER_MANAGER=1
@@ -273,6 +281,7 @@ managers/simple/Makefile
managers/maemo/Makefile
managers/maemo/theme/Makefile
managers/clutter/Makefile
+managers/xrender/Makefile
data/Makefile
data/themes/Makefile
data/themes/Default/Makefile
diff --git a/managers/xrender/Makefile.am b/managers/xrender/Makefile.am
new file mode 100644
index 0000000..bd5318c
--- /dev/null
+++ b/managers/xrender/Makefile.am
@@ -0,0 +1,20 @@
+INCLUDES = \
+ $(MBWM_INCS) \
+ $(MBWM_CFLAGS)
+
+bin_PROGRAMS = matchbox-window-manager-2-xrender
+
+matchbox_window_manager_2_xrender_SOURCES = \
+ matchbox-window-manager-2-xrender.c \
+ mb-wm-comp-mgr-xrender.h \
+ mb-wm-comp-mgr-xrender.c
+
+
+matchbox_window_manager_2_xrender_LDFLAGS = \
+ $(MBWM_DEBUG_LDFLAGS) \
+ $(LDFLAGS)
+
+matchbox_window_manager_2_xrender_LDADD = \
+ $(top_builddir)/matchbox/libmatchbox-@MBWM_API_VERSION@.la \
+ $(MBWM_LIBS)
+
diff --git a/managers/xrender/matchbox-window-manager-2-xrender.c b/managers/xrender/matchbox-window-manager-2-xrender.c
new file mode 100644
index 0000000..70e6855
--- /dev/null
+++ b/managers/xrender/matchbox-window-manager-2-xrender.c
@@ -0,0 +1,139 @@
+#include "mb-wm-comp-mgr-xrender.h"
+#include <clutter/x11/clutter-x11.h>
+
+#include <matchbox/matchbox.h>
+#include <signal.h>
+
+#if USE_GTK
+#include <gdk/gdkx.h>
+#endif
+
+enum {
+ KEY_ACTION_PAGE_NEXT,
+ KEY_ACTION_PAGE_PREV,
+ KEY_ACTION_TOGGLE_FULLSCREEN,
+ KEY_ACTION_TOGGLE_DESKTOP,
+};
+
+static MBWMManager *wm = NULL;
+
+#if MBWM_WANT_DEBUG
+/*
+ * The Idea behind this is quite simple: when all managed windows are closed
+ * and the WM exits, there should have been an unref call for each ref call. To
+ * test do something like
+ *
+ * export DISPLAY=:whatever;
+ * export MB_DEBUG=obj-ref,obj-unref
+ * matchbox-window-manager-2-simple &
+ * gedit
+ * kill -TERM $(pidof gedit)
+ * kill -TERM $(pidof matchbox-window-manager-2-simple)
+ *
+ * If you see '=== object count at exit x ===' then we either have a leak
+ * (x > 0) or are unrefing a dangling pointer (x < 0).
+ */
+static void
+signal_handler (int sig)
+{
+ if (sig == SIGTERM)
+ {
+ int count;
+
+ mb_wm_object_unref (MB_WM_OBJECT (wm));
+ mb_wm_object_dump ();
+
+ exit (sig);
+ }
+}
+#endif
+
+void
+key_binding_func (MBWMManager *wm,
+ MBWMKeyBinding *binding,
+ void *userdata)
+{
+ printf(" ### got key press ### \n");
+ int action;
+
+ action = (int)(userdata);
+
+ switch (action)
+ {
+ case KEY_ACTION_PAGE_NEXT:
+ mb_wm_manager_cycle_apps (wm, False);
+ break;
+ case KEY_ACTION_PAGE_PREV:
+ mb_wm_manager_cycle_apps (wm, True);
+ break;
+ case KEY_ACTION_TOGGLE_FULLSCREEN:
+ printf(" ### KEY_ACTION_TOGGLE_FULLSCREEN ### \n");
+ break;
+ case KEY_ACTION_TOGGLE_DESKTOP:
+ printf(" ### KEY_ACTION_TOGGLE_DESKTOP ### \n");
+ mb_wm_manager_toggle_desktop (wm);
+ break;
+ }
+}
+
+int
+main(int argc, char **argv)
+{
+ Display * dpy = NULL;
+ MBWMCompMgr *compositor;
+
+#if MBWM_WANT_DEBUG
+ struct sigaction sa;
+ sigfillset(&sa.sa_mask);
+ sa.sa_handler = signal_handler;
+ sigaction(SIGTERM, &sa, NULL);
+#endif
+
+ mb_wm_object_init();
+
+#if USE_GTK
+ printf ("initializing gtk\n");
+
+ gtk_init (&argc, &argv);
+ dpy = GDK_DISPLAY();
+
+ wm = mb_wm_manager_new_with_dpy (argc, argv, dpy);
+#else
+ wm = mb_wm_manager_new (argc, argv);
+#endif
+
+ compositor = mb_wm_comp_mgr_xrender_new (wm);
+ mb_wm_manager_run_with_compositor (wm, compositor);
+ mb_wm_object_unref (MB_WM_OBJECT (compositor));
+
+ if (wm == NULL)
+ mb_wm_util_fatal_error("OOM?");
+
+ mb_wm_keys_binding_add_with_spec (wm,
+ "<alt>d",
+ key_binding_func,
+ NULL,
+ (void*)KEY_ACTION_TOGGLE_DESKTOP);
+
+ mb_wm_keys_binding_add_with_spec (wm,
+ "<alt>n",
+ key_binding_func,
+ NULL,
+ (void*)KEY_ACTION_PAGE_NEXT);
+
+ mb_wm_keys_binding_add_with_spec (wm,
+ "<alt>p",
+ key_binding_func,
+ NULL,
+ (void*)KEY_ACTION_PAGE_PREV);
+
+ mb_wm_manager_main_loop(wm);
+
+ mb_wm_object_unref (MB_WM_OBJECT (wm));
+
+#if MBWM_WANT_DEBUG
+ mb_wm_object_dump ();
+#endif
+
+ return 1;
+}
diff --git a/matchbox/mb-wm-comp-mgr-xrender.c b/managers/xrender/mb-wm-comp-mgr-xrender.c
index 635f653..635f653 100644
--- a/matchbox/mb-wm-comp-mgr-xrender.c
+++ b/managers/xrender/mb-wm-comp-mgr-xrender.c
diff --git a/matchbox/mb-wm-comp-mgr-xrender.h b/managers/xrender/mb-wm-comp-mgr-xrender.h
index 708508c..ceadcc8 100644
--- a/matchbox/mb-wm-comp-mgr-xrender.h
+++ b/managers/xrender/mb-wm-comp-mgr-xrender.h
@@ -22,7 +22,7 @@
#ifndef _HAVE_MB_WM_COMP_MGR_DEFAULT_H
#define _HAVE_MB_WM_COMP_MGR_DEFAULT_H
-#include <matchbox/mb-wm-config.h>
+#include <matchbox/matchbox.h>
#define MB_WM_COMP_MGR_DEFAULT(c) ((MBWMCompMgrDefault*)(c))
#define MB_WM_COMP_MGR_DEFAULT_CLASS(c) ((MBWMCompMgrDefaultClass*)(c))