aboutsummaryrefslogtreecommitdiffstats
path: root/managers
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2010-08-19 04:36:22 +0100
committerRobert Bragg <robert@linux.intel.com>2010-12-09 22:46:47 +0000
commitea84bd26d72ae05bfa9aef2cc8000919421641be (patch)
treee4b8d900e7ed31647b3b2cd31571ec2925be932d /managers
parent41059683747e80790218b3bf67f71df5c56f39a7 (diff)
downloadlibmatchboxwm2-ea84bd26d72ae05bfa9aef2cc8000919421641be.tar.gz
libmatchboxwm2-ea84bd26d72ae05bfa9aef2cc8000919421641be.tar.bz2
libmatchboxwm2-ea84bd26d72ae05bfa9aef2cc8000919421641be.zip
Overhaul our mainloop integration
This removes mb-wm-main-context.c since we now just use a glib mainloop context instead. The new mainloop integration API allows matchbox to be fed X events from an external toolkit so core matchbox no longer needs to have any gtk specific event source integration code, since it should be straightforward for a gtk based wm/compositor to decide to take ownership of event fetching and pass those events through to matchbox manually if they want. In the process of removing references to the mb-wm-main-context API it was necessary to refactor how we handle mouse grabs for moving and resizing windows. Previously we would do an X grab and then then immediately enter a tight loop, polling for X mouse events and handling them until something triggers an ungrab and then resume fetching events in the normal way. Now though when we do the mouse grab we just use mb_wm_manager_add_event_handler to register a temporary interest in mouse events and mb_wm_manager_remove_event_handler when the grab is finished. This means we can continue to use the normal event delivery mechanism during a grab and more importantly we don't block the mainloop which would really upset window managers and compositors needing to process other asynchronous events during a grab.
Diffstat (limited to 'managers')
-rw-r--r--managers/clutter/matchbox-window-manager-2-clutter.c38
-rw-r--r--managers/maemo/matchbox-window-manager-2-maemo.c2
-rw-r--r--managers/simple/matchbox-window-manager-2-simple.c13
-rw-r--r--managers/xrender/matchbox-window-manager-2-xrender.c15
4 files changed, 18 insertions, 50 deletions
diff --git a/managers/clutter/matchbox-window-manager-2-clutter.c b/managers/clutter/matchbox-window-manager-2-clutter.c
index ab3b227..68d0431 100644
--- a/managers/clutter/matchbox-window-manager-2-clutter.c
+++ b/managers/clutter/matchbox-window-manager-2-clutter.c
@@ -4,10 +4,6 @@
#include <matchbox/matchbox.h>
#include <signal.h>
-#if USE_GTK
-#include <gdk/gdkx.h>
-#endif
-
enum {
KEY_ACTION_PAGE_NEXT,
KEY_ACTION_PAGE_PREV,
@@ -76,6 +72,15 @@ key_binding_func (MBWMManager *wm,
}
}
+ClutterX11FilterReturn
+forward_xevent (XEvent *xevent,
+ ClutterEvent *event,
+ void *user_data)
+{
+ mb_wm_manager_handle_xlib_event (wm, xevent);
+ return CLUTTER_X11_FILTER_CONTINUE;
+}
+
int
main(int argc, char **argv)
{
@@ -91,35 +96,22 @@ main(int argc, char **argv)
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.
+ /* We share Clutter's display connection, and hook our xevent
+ * handler into the clutter main loop.
*/
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 ();
+ clutter_x11_add_filter (forward_xevent, wm);
+
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_manager_start_with_compositor (wm, compositor);
mb_wm_object_unref (MB_WM_OBJECT (compositor));
if (wm == NULL)
@@ -143,7 +135,7 @@ main(int argc, char **argv)
NULL,
(void*)KEY_ACTION_PAGE_PREV);
- mb_wm_manager_main_loop(wm);
+ clutter_main ();
mb_wm_object_unref (MB_WM_OBJECT (wm));
diff --git a/managers/maemo/matchbox-window-manager-2-maemo.c b/managers/maemo/matchbox-window-manager-2-maemo.c
index 577a1b2..c24559e 100644
--- a/managers/maemo/matchbox-window-manager-2-maemo.c
+++ b/managers/maemo/matchbox-window-manager-2-maemo.c
@@ -102,7 +102,7 @@ main(int argc, char **argv)
mb_wm_object_init();
wm = maemo_window_manager_new(argc, argv);
- mb_wm_manager_run (wm);
+ mb_wm_manager_start (wm);
if (wm == NULL)
mb_wm_util_fatal_error("OOM?");
diff --git a/managers/simple/matchbox-window-manager-2-simple.c b/managers/simple/matchbox-window-manager-2-simple.c
index 8881895..52445cc 100644
--- a/managers/simple/matchbox-window-manager-2-simple.c
+++ b/managers/simple/matchbox-window-manager-2-simple.c
@@ -1,10 +1,6 @@
#include <matchbox/matchbox.h>
#include <signal.h>
-#if USE_GTK
-#include <gdk/gdkx.h>
-#endif
-
enum {
KEY_ACTION_PAGE_NEXT,
KEY_ACTION_PAGE_PREV,
@@ -87,15 +83,8 @@ main(int argc, char **argv)
mb_wm_object_init();
-#if USE_GTK
- printf ("initializing gtk\n");
-
- gtk_init (&argc, &argv);
- dpy = GDK_DISPLAY();
-#endif
-
wm = mb_wm_manager_new_with_dpy (argc, argv, dpy);
- mb_wm_manager_run (wm);
+ mb_wm_manager_start (wm);
if (wm == NULL)
mb_wm_util_fatal_error("OOM?");
diff --git a/managers/xrender/matchbox-window-manager-2-xrender.c b/managers/xrender/matchbox-window-manager-2-xrender.c
index 70e6855..cdde66b 100644
--- a/managers/xrender/matchbox-window-manager-2-xrender.c
+++ b/managers/xrender/matchbox-window-manager-2-xrender.c
@@ -4,10 +4,6 @@
#include <matchbox/matchbox.h>
#include <signal.h>
-#if USE_GTK
-#include <gdk/gdkx.h>
-#endif
-
enum {
KEY_ACTION_PAGE_NEXT,
KEY_ACTION_PAGE_PREV,
@@ -91,19 +87,10 @@ main(int argc, char **argv)
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_manager_start_with_compositor (wm, compositor);
mb_wm_object_unref (MB_WM_OBJECT (compositor));
if (wm == NULL)