diff options
-rw-r--r-- | ChangeLog | 30 | ||||
-rw-r--r-- | configure.ac | 11 | ||||
-rw-r--r-- | src/core/mb-window-manager.c | 4 | ||||
-rw-r--r-- | src/core/mb-wm-client-base.c | 1 | ||||
-rw-r--r-- | src/core/mb-wm-client-base.h | 3 | ||||
-rw-r--r-- | src/core/mb-wm-client.c | 6 | ||||
-rw-r--r-- | src/core/mb-wm-client.h | 9 | ||||
-rw-r--r-- | src/core/mb-wm-decor.c | 1 | ||||
-rw-r--r-- | src/core/mb-wm-main-context.c | 130 | ||||
-rw-r--r-- | src/core/mb-wm-main-context.h | 27 | ||||
-rw-r--r-- | src/core/mb-wm-object.c | 2 | ||||
-rw-r--r-- | src/core/mb-wm-types.h | 18 | ||||
-rw-r--r-- | src/core/mb-wm-util.h | 2 | ||||
-rw-r--r-- | src/theme-engines/mb-wm-theme-cairo.h | 3 | ||||
-rw-r--r-- | src/theme-engines/mb-wm-theme-simple.h | 3 | ||||
-rw-r--r-- | src/theme-engines/mb-wm-theme.c | 10 | ||||
-rw-r--r-- | src/theme-engines/mb-wm-theme.h | 3 |
17 files changed, 230 insertions, 33 deletions
@@ -1,3 +1,33 @@ +2007-11-05 Tomas Frydrych <tf@o-hand.com> + + * configure.ac: + * src/core/mb-wm-main-context.c: + * src/core/mb-wm-main-context.h: + * src/core/mb-wm-types.h: + * src/core/mb-wm-client.c: + --enable-glib-main-loop: glib main loop support. + + * src/core/mb-wm-util.h: + Fixed handling of inline keyword when using glib. + + * src/theme-engines/mb-wm-theme-cairo.h: + * src/theme-engines/mb-wm-theme-simple.h: + * src/theme-engines/mb-wm-theme.c: + * src/theme-engines/mb-wm-theme.h: + * src/core/mb-wm-client-base.c: + * src/core/mb-wm-client-base.h: + * src/core/mb-wm-client.h: + * src/core/mb-wm-decor.c: + Added missing prototypes and includes. + + * src/core/mb-window-manager.c: + (mb_wm_handle_config_request): + (mb_wm_handle_map_request): + * src/core/mb-wm-object.c: + (mb_wm_object_init_recurse: + + Fixed missing return value. + 2007-11-02 Tomas Frydrych <tf@o-hand.com> * src/comp-mgr/mb-wm-comp-mgr.c: diff --git a/configure.ac b/configure.ac index a641ef6..d38397a 100644 --- a/configure.ac +++ b/configure.ac @@ -36,6 +36,10 @@ AC_ARG_ENABLE(compositing-manager, [ --enable-compositing-manager Enable compositing manager], [comp_mgr=$enableval], [comp_mgr=no]) +AC_ARG_ENABLE(glib-main-loop, + [ --enable-glib-main-loop Enable use of glib main loop], + [gmloop=$enableval], [gmloop=no]) + if test "x$use_cairo" = "xyes"; then needed_pkgs="$needed_pkgs pangocairo " else @@ -55,6 +59,11 @@ if test "x$want_debug" = "xyes"; then MBWM_DEBUG_LDFLAGS="$MBWM_DEBUG_LDFLAGS -rdynamic" fi +if test "x$gmloop" = "xyes"; then + needed_pkgs="$needed_pkgs glib-2.0 " + AC_DEFINE(USE_GLIB_MAINLOOP, 1, [Use glib main loop]) +fi + PKG_CHECK_MODULES(MBWM, $needed_pkgs) AM_CONDITIONAL(THEME_CAIRO, [test "x$use_cairo" = "xyes"]) @@ -167,5 +176,7 @@ echo " Compositing manager : ${comp_mgr} + Miscel: + Glib main loop : ${gmloop} Debugging output : ${want_debug} " diff --git a/src/core/mb-window-manager.c b/src/core/mb-window-manager.c index f120247..022bcc8 100644 --- a/src/core/mb-window-manager.c +++ b/src/core/mb-window-manager.c @@ -389,7 +389,7 @@ mb_wm_handle_config_request (XConfigureRequestEvent *xev, * per ICCCM. */ mb_wm_client_synthetic_config_event_queue (client); - return; + return True; } if (mb_wm_client_request_geometry (client, @@ -432,7 +432,7 @@ mb_wm_handle_map_request (XMapRequestEvent *xev, if ((client = mb_wm_managed_client_from_xwindow(wm, xev->window))) { mb_wm_activate_client (wm, client); - return; + return True; } if (!wm_class->client_new) diff --git a/src/core/mb-wm-client-base.c b/src/core/mb-wm-client-base.c index a3f0faf..e849f0f 100644 --- a/src/core/mb-wm-client-base.c +++ b/src/core/mb-wm-client-base.c @@ -19,6 +19,7 @@ */ #include "mb-wm.h" + #include <X11/Xmd.h> #ifdef ENABLE_COMPOSITE diff --git a/src/core/mb-wm-client-base.h b/src/core/mb-wm-client-base.h index 59c42fd..edc8008 100644 --- a/src/core/mb-wm-client-base.h +++ b/src/core/mb-wm-client-base.h @@ -38,6 +38,9 @@ typedef struct MBWMClientBaseClass } MBWMClientBaseClass; +int +mb_wm_client_base_class_type (); + void base_foo(void); #endif diff --git a/src/core/mb-wm-client.c b/src/core/mb-wm-client.c index a901021..d0ee6ea 100644 --- a/src/core/mb-wm-client.c +++ b/src/core/mb-wm-client.c @@ -19,6 +19,10 @@ */ #include "mb-wm.h" +#include "mb-wm-theme.h" + +#include <unistd.h> +#include <signal.h> struct MBWindowManagerClientPriv { @@ -626,7 +630,7 @@ mb_wm_client_ping_timeout_cb (void * userdata) MBWindowManagerClient * client = userdata; mb_wm_client_shutdown (client); - return True; + return False; } static void diff --git a/src/core/mb-wm-client.h b/src/core/mb-wm-client.h index b29575b..8501508 100644 --- a/src/core/mb-wm-client.h +++ b/src/core/mb-wm-client.h @@ -186,6 +186,9 @@ struct MBWindowManagerClient ( ((c)->frame_geometry.y + (c)->frame_geometry.height) \ - ((c)->window->geometry.y + (c)->window->geometry.height) ) +int +mb_wm_client_class_type (); + MBWMClientWindow* mb_wm_client_window_new (MBWindowManager *wm, Window window); @@ -226,6 +229,9 @@ Bool mb_wm_client_needs_geometry_sync (MBWindowManagerClient *client); Bool +mb_wm_client_needs_visibility_sync (MBWindowManagerClient *client); + +Bool mb_wm_client_needs_fullscreen_sync (MBWindowManagerClient *client); Bool @@ -272,6 +278,9 @@ void mb_wm_client_visibility_mark_dirty (MBWindowManagerClient *client); void +mb_wm_client_decor_mark_dirty (MBWindowManagerClient *client); + +void mb_wm_client_add_transient (MBWindowManagerClient *client, MBWindowManagerClient *transient); diff --git a/src/core/mb-wm-decor.c b/src/core/mb-wm-decor.c index 850ff2b..4805786 100644 --- a/src/core/mb-wm-decor.c +++ b/src/core/mb-wm-decor.c @@ -19,6 +19,7 @@ */ #include "mb-wm.h" +#include "mb-wm-theme.h" static void mb_wm_decor_destroy (MBWMObject *obj); diff --git a/src/core/mb-wm-main-context.c b/src/core/mb-wm-main-context.c index 3d046d3..fd2e5e8 100644 --- a/src/core/mb-wm-main-context.c +++ b/src/core/mb-wm-main-context.c @@ -55,6 +55,9 @@ mb_wm_main_context_check_timeouts (MBWMMainContext *ctx); static Bool mb_wm_main_context_check_fd_watches (MBWMMainContext * ctx); +static Bool +mb_wm_main_context_spin_xevent (MBWMMainContext *ctx); + struct MBWMTimeOutEventInfo { int ms; @@ -66,8 +69,8 @@ struct MBWMTimeOutEventInfo }; struct MBWMFdWatchInfo{ - int fd; - int events; + MBWMIOChannel *channel; + MBWMIOCondition events; MBWindowManagerFdWatchFunc func; void *userdata; unsigned long id; @@ -86,6 +89,18 @@ mb_wm_main_context_destroy (MBWMObject *this) { } +#ifdef USE_GLIB_MAINLOOP +static gboolean +mb_wm_main_context_gloop_xevent (gpointer userdata) +{ + MBWMMainContext * ctx = userdata; + + while (mb_wm_main_context_spin_xevent (ctx)); + + return TRUE; +} +#endif + static int mb_wm_main_context_init (MBWMObject *this, va_list vap) { @@ -109,6 +124,12 @@ mb_wm_main_context_init (MBWMObject *this, va_list vap) ctx->wm = wm; +#ifdef USE_GLIB_MAINLOOP + ctx->g_loop = g_main_loop_new (NULL, FALSE); + + g_idle_add (mb_wm_main_context_gloop_xevent, ctx); +#endif + return 1; } @@ -383,12 +404,12 @@ mb_wm_main_context_handle_x_event (XEvent *xev, } static Bool -mb_wm_main_context_spin_xevent (MBWMMainContext *ctx, Bool block) +mb_wm_main_context_spin_xevent (MBWMMainContext *ctx) { MBWindowManager * wm = ctx->wm; XEvent xev; - if (!block && !XEventsQueued (wm->xdpy, QueuedAfterFlush)) + if (!XEventsQueued (wm->xdpy, QueuedAfterFlush)) return False; XNextEvent(wm->xdpy, &xev); @@ -398,11 +419,25 @@ mb_wm_main_context_spin_xevent (MBWMMainContext *ctx, Bool block) return (XEventsQueued (wm->xdpy, QueuedAfterReading) != 0); } +static Bool +mb_wm_main_context_spin_xevent_blocking (MBWMMainContext *ctx) +{ + MBWindowManager * wm = ctx->wm; + XEvent xev; + + XNextEvent(wm->xdpy, &xev); + + mb_wm_main_context_handle_x_event (&xev, ctx); + + return (XEventsQueued (wm->xdpy, QueuedAfterReading) != 0); +} + void -mb_wm_main_context_loop(MBWMMainContext *ctx) +mb_wm_main_context_loop (MBWMMainContext *ctx) { MBWindowManager * wm = ctx->wm; +#ifndef USE_GLIB_MAINLOOP while (True) { Bool sources; @@ -415,17 +450,20 @@ mb_wm_main_context_loop(MBWMMainContext *ctx) /* No timeouts, idles, etc. -- wait for next * X event */ - mb_wm_main_context_spin_xevent (ctx, True); + mb_wm_main_context_spin_xevent_blocking (ctx); } else { /* Process any pending xevents */ - while (mb_wm_main_context_spin_xevent (ctx, False)); + while (mb_wm_main_context_spin_xevent (ctx)); } if (wm->sync_type) mb_wm_sync (wm); } +#else + g_main_loop_run (ctx->g_loop); +#endif } unsigned long @@ -581,6 +619,7 @@ mb_wm_main_context_x_event_handler_remove (MBWMMainContext *ctx, } } +#ifndef USE_GLIB_MAINLOOP static void mb_wm_main_context_timeout_setup (MBWMTimeOutEventInfo * tinfo, struct timeval * current_time) @@ -609,13 +648,13 @@ mb_wm_main_context_handle_timeout (MBWMTimeOutEventInfo *tinfo, (tinfo->triggers.tv_sec == current_time->tv_sec && tinfo->triggers.tv_usec <= current_time->tv_usec)) { - if (tinfo->func (tinfo->userdata)) - return True; + if (!tinfo->func (tinfo->userdata)) + return False; mb_wm_main_context_timeout_setup (tinfo, current_time); } - return False; + return True; } /* @@ -636,7 +675,7 @@ mb_wm_main_context_check_timeouts (MBWMMainContext *ctx) { MBWMTimeOutEventInfo * tinfo = l->data; - if (mb_wm_main_context_handle_timeout (tinfo, ¤t_time)) + if (!mb_wm_main_context_handle_timeout (tinfo, ¤t_time)) { MBWMList * prev = l->prev; MBWMList * next = l->next; @@ -660,6 +699,7 @@ mb_wm_main_context_check_timeouts (MBWMMainContext *ctx) return True; } +#endif /* !USE_GLIB_MAINLOOP */ unsigned long mb_wm_main_context_timeout_handler_add (MBWMMainContext *ctx, @@ -667,6 +707,7 @@ mb_wm_main_context_timeout_handler_add (MBWMMainContext *ctx, MBWindowManagerTimeOutFunc func, void *userdata) { +#ifndef USE_GLIB_MAINLOOP static unsigned long ids = 0; MBWMTimeOutEventInfo * tinfo; struct timeval current_time; @@ -686,12 +727,17 @@ mb_wm_main_context_timeout_handler_add (MBWMMainContext *ctx, mb_wm_util_list_append (ctx->event_funcs.timeout, tinfo); return ids; + +#else + return g_timeout_add (ms, func, userdata); +#endif } void mb_wm_main_context_timeout_handler_remove (MBWMMainContext *ctx, unsigned long id) { +#ifndef USE_GLIB_MAINLOOP MBWMList * l = ctx->event_funcs.timeout; while (l) @@ -719,15 +765,19 @@ mb_wm_main_context_timeout_handler_remove (MBWMMainContext *ctx, l = l->next; } +#else + g_source_remove (id); +#endif } unsigned long mb_wm_main_context_fd_watch_add (MBWMMainContext *ctx, - int fd, - int events, + MBWMIOChannel *channel, + MBWMIOCondition events, MBWindowManagerFdWatchFunc func, void *userdata) { +#ifndef USE_GLIB_MAINLOOP static unsigned long ids = 0; MBWMFdWatchInfo * finfo; struct pollfd * fds; @@ -737,7 +787,7 @@ mb_wm_main_context_fd_watch_add (MBWMMainContext *ctx, finfo = mb_wm_util_malloc0 (sizeof (MBWMFdWatchInfo)); finfo->func = func; finfo->id = ids; - finfo->fd = fd; + finfo->channel = channel; finfo->events = events; finfo->userdata = userdata; @@ -748,16 +798,21 @@ mb_wm_main_context_fd_watch_add (MBWMMainContext *ctx, ctx->poll_fds = realloc (ctx->poll_fds, sizeof (struct pollfd)); fds = ctx->poll_fds + (ctx->n_poll_fds - 1); - fds->fd = fd; + fds->fd = *channel; fds->events = events; return ids; + +#else + return g_io_add_watch (channel, events, func, userdata); +#endif } void mb_wm_main_context_fd_watch_remove (MBWMMainContext *ctx, unsigned long id) { +#ifndef USE_GLIB_MAINLOOP MBWMList * l = ctx->event_funcs.fd_watch; while (l) @@ -788,8 +843,45 @@ mb_wm_main_context_fd_watch_remove (MBWMMainContext *ctx, ctx->n_poll_fds--; ctx->poll_cache_dirty = True; +#else + g_source_remove (id); +#endif +} + +MBWMIOChannel * +mb_wm_main_context_io_channel_new (int fd) +{ +#ifndef USE_GLIB_MAINLOOP + MBWMIOChannel * c = mb_wm_util_malloc0 (sizeof (MBWMIOChannel)); + *c = fd; +#else + return g_io_channel_unix_new (fd); +#endif +} + + +void +mb_wm_main_context_io_channel_destroy (MBWMIOChannel * channel) +{ +#ifndef USE_GLIB_MAINLOOP + if (channel) + free (channel); +#else + g_io_channel_unref (channel); +#endif +} + +int +mb_wm_main_context_io_channel_get_fd (MBWMIOChannel * channel) +{ +#ifndef USE_GLIB_MAINLOOP + return *channel; +#else + g_io_channel_unix_get_fd (channel); +#endif } +#ifndef USE_GLIB_MAINLOOP static void mb_wm_main_context_setup_poll_cache (MBWMMainContext *ctx) { @@ -805,7 +897,7 @@ mb_wm_main_context_setup_poll_cache (MBWMMainContext *ctx) { MBWMFdWatchInfo *info = l->data; - ctx->poll_fds[i].fd = info->fd; + ctx->poll_fds[i].fd = *(info->channel); ctx->poll_fds[i].events = info->events; l = l->next; @@ -845,8 +937,8 @@ mb_wm_main_context_check_fd_watches (MBWMMainContext * ctx) if (ctx->poll_fds[i].revents & ctx->poll_fds[i].events) { - Bool zap = info->func (info->fd, ctx->poll_fds[i].revents, - info->userdata); + Bool zap = !info->func (info->channel, ctx->poll_fds[i].revents, + info->userdata); if (zap) { @@ -883,4 +975,4 @@ mb_wm_main_context_check_fd_watches (MBWMMainContext * ctx) return True; } - +#endif diff --git a/src/core/mb-wm-main-context.h b/src/core/mb-wm-main-context.h index 7d82f5a..6de64f4 100644 --- a/src/core/mb-wm-main-context.h +++ b/src/core/mb-wm-main-context.h @@ -46,8 +46,10 @@ typedef struct MBWMEventFuncs MBWMList *button_release; MBWMList *motion_notify; +#ifndef USE_GLIB_MAINLOOP MBWMList *timeout; MBWMList *fd_watch; +#endif } MBWMEventFuncs; @@ -61,6 +63,10 @@ struct MBWMMainContext struct pollfd *poll_fds; int n_poll_fds; Bool poll_cache_dirty; + +#ifdef USE_GLIB_MAINLOOP + GMainLoop * g_loop; +#endif }; struct MBWMMainContextClass @@ -87,19 +93,28 @@ mb_wm_main_context_x_event_handler_remove (MBWMMainContext *ctx, unsigned long id); unsigned long -mb_wm_context_timeout_handler_add (MBWMMainContext *ctx, - int ms, - MBWindowManagerTimeOutFunc func, - void *userdata); +mb_wm_main_context_timeout_handler_add (MBWMMainContext *ctx, + int ms, + MBWindowManagerTimeOutFunc func, + void *userdata); void mb_wm_main_context_timeout_handler_remove (MBWMMainContext *ctx, unsigned long id); +MBWMIOChannel * +mb_wm_main_context_io_channel_new (int fd); + +void +mb_wm_main_context_io_channel_destroy (MBWMIOChannel * channel); + +int +mb_wm_main_context_io_channel_get_fd (MBWMIOChannel * channel); + unsigned long mb_wm_main_context_fd_watch_add (MBWMMainContext *ctx, - int fd, - int events, + MBWMIOChannel *channel, + MBWMIOCondition events, MBWindowManagerFdWatchFunc func, void *userdata); diff --git a/src/core/mb-wm-object.c b/src/core/mb-wm-object.c index ea934b7..6b8ad4b 100644 --- a/src/core/mb-wm-object.c +++ b/src/core/mb-wm-object.c @@ -230,7 +230,7 @@ mb_wm_object_init_recurse (MBWMObject *obj, MBWMObjectClass *parent, if (parent->init) if (!parent->init (obj, vap)) - return; + return 0; va_end (vap2); diff --git a/src/core/mb-wm-types.h b/src/core/mb-wm-types.h index 74a23fb..f132cbf 100644 --- a/src/core/mb-wm-types.h +++ b/src/core/mb-wm-types.h @@ -21,6 +21,12 @@ #ifndef _HAVE_MB_WM_TYPES_H #define _HAVE_MB_WM_TYPES_H +#include <config.h> + +#ifdef USE_GLIB_MAINLOOP +#include <glib.h> +#endif + typedef struct MBWMFuncInfo { void *func; @@ -310,9 +316,17 @@ typedef Bool (*MBWindowManagerMotionNotifyFunc) typedef Bool (*MBWindowManagerTimeOutFunc) (void *userdata); +#ifdef USE_GLIB_MAINLOOP +typedef GIOChannel MBWMIOChannel; +typedef GIOCondition MBWMIOCondition; +#else +typedef int MBWMIOChannel; +typedef int MBWMIOCondition; +#endif + typedef Bool (*MBWindowManagerFdWatchFunc) - (int fd, - int events, + (MBWMIOChannel *channel, + MBWMIOCondition events, void *userdata); typedef struct MBWMXEventFuncInfo diff --git a/src/core/mb-wm-util.h b/src/core/mb-wm-util.h index 684b201..6ba4e96 100644 --- a/src/core/mb-wm-util.h +++ b/src/core/mb-wm-util.h @@ -5,7 +5,9 @@ /* See http://rlove.org/log/2005102601 */ #if __GNUC__ >= 3 +#ifndef USE_GLIB_MAINLOOP # define inline __attribute__ ((always_inline)) +#endif # define __pure__attribute__ ((pure)) # define __const__attribute__ ((const)) # define __noreturn__attribute__ ((noreturn)) diff --git a/src/theme-engines/mb-wm-theme-cairo.h b/src/theme-engines/mb-wm-theme-cairo.h index 7b31edc..91317c0 100644 --- a/src/theme-engines/mb-wm-theme-cairo.h +++ b/src/theme-engines/mb-wm-theme-cairo.h @@ -38,4 +38,7 @@ struct MBWMThemeCairo MBWMTheme parent; }; +int +mb_wm_theme_cairo_class_type (); + #endif diff --git a/src/theme-engines/mb-wm-theme-simple.h b/src/theme-engines/mb-wm-theme-simple.h index 54a78e6..20f49da 100644 --- a/src/theme-engines/mb-wm-theme-simple.h +++ b/src/theme-engines/mb-wm-theme-simple.h @@ -38,4 +38,7 @@ struct MBWMThemeSimple MBWMTheme parent; }; +int +mb_wm_theme_simple_class_type (); + #endif diff --git a/src/theme-engines/mb-wm-theme.c b/src/theme-engines/mb-wm-theme.c index a8d8357..c776068 100644 --- a/src/theme-engines/mb-wm-theme.c +++ b/src/theme-engines/mb-wm-theme.c @@ -21,6 +21,12 @@ #include "mb-wm-theme.h" #include "mb-wm-theme-xml.h" +#ifdef USE_CAIRO +#include "mb-wm-theme-cairo.h" +#else +#include "mb-wm-theme-simple.h" +#endif + #include <sys/stat.h> #include <expat.h> @@ -517,12 +523,12 @@ mb_wm_theme_create_decor (MBWMTheme *theme, MBWM_ASSERT (client); if (!theme || !client) - return; + return NULL; klass = MB_WM_THEME_CLASS(MB_WM_OBJECT_GET_CLASS (theme)); if (klass->create_decor) - klass->create_decor (theme, client, type); + return klass->create_decor (theme, client, type); } /* diff --git a/src/theme-engines/mb-wm-theme.h b/src/theme-engines/mb-wm-theme.h index 2e293bb..d0e7873 100644 --- a/src/theme-engines/mb-wm-theme.h +++ b/src/theme-engines/mb-wm-theme.h @@ -102,6 +102,9 @@ struct MBWMTheme MBWMCompMgrShadowType shadow_type; }; +int +mb_wm_theme_class_type (); + MBWMTheme * mb_wm_theme_new (MBWindowManager * wm, const char * theme_path); |