aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2010-08-18 13:29:24 +0100
committerRobert Bragg <robert@linux.intel.com>2010-08-18 13:29:24 +0100
commit09541ac4ddc60732c82e617340a103e0ae529391 (patch)
treeb9deecb2f870fd615c8c3a82d95b0c482a20961b
parent9d4e7660cce20effc1d8fb67969e39eef0872296 (diff)
downloadlibmatchboxwm2-09541ac4ddc60732c82e617340a103e0ae529391.tar.gz
libmatchboxwm2-09541ac4ddc60732c82e617340a103e0ae529391.tar.bz2
libmatchboxwm2-09541ac4ddc60732c82e617340a103e0ae529391.zip
build: add missing files for managers/clutter
-rw-r--r--managers/clutter/Makefile.am22
-rw-r--r--managers/clutter/matchbox-window-manager-2-clutter.c155
2 files changed, 177 insertions, 0 deletions
diff --git a/managers/clutter/Makefile.am b/managers/clutter/Makefile.am
new file mode 100644
index 0000000..e207df5
--- /dev/null
+++ b/managers/clutter/Makefile.am
@@ -0,0 +1,22 @@
+INCLUDES = \
+ $(MBWM_INCS) \
+ $(MBWM_CFLAGS)
+
+bin_PROGRAMS = matchbox-window-manager-2-clutter
+
+matchbox_window_manager_2_clutter_SOURCES = \
+ matchbox-window-manager-2-clutter.c \
+ mb-wm-comp-mgr-clutter.h \
+ mb-wm-comp-mgr-clutter.c \
+ tidy/tidy-texture-frame.h \
+ tidy/tidy-texture-frame.c
+
+
+matchbox_window_manager_2_clutter_LDFLAGS = \
+ $(MBWM_DEBUG_LDFLAGS) \
+ $(LDFLAGS)
+
+matchbox_window_manager_2_clutter_LDADD = \
+ $(top_builddir)/matchbox/libmatchbox-@MBWM_API_VERSION@.la \
+ $(MBWM_LIBS)
+
diff --git a/managers/clutter/matchbox-window-manager-2-clutter.c b/managers/clutter/matchbox-window-manager-2-clutter.c
new file mode 100644
index 0000000..ab3b227
--- /dev/null
+++ b/managers/clutter/matchbox-window-manager-2-clutter.c
@@ -0,0 +1,155 @@
+#include "mb-wm-comp-mgr-clutter.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();
+#endif
+
+ /*
+ * If using clutter, we share the display connection, and hook
+ * our xevent handler into the clutter main loop.
+ *
+ * If we are also doing gtk integration, we need to make clutter to
+ * use the gtk display connection.
+ */
+ if (dpy)
+ clutter_x11_set_display (dpy);
+
+#if USE_GTK
+ clutter_x11_disable_event_retrieval ();
+#endif
+
+ clutter_init (&argc, &argv);
+
+ if (!dpy)
+ dpy = clutter_x11_get_default_display ();
+
+ wm = mb_wm_manager_new_with_dpy (argc, argv, dpy);
+ compositor = mb_wm_comp_mgr_clutter_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;
+}