Hi Simon, this patch adds to mb2 a custom window manager for sugar, based on the existing maemo one. Applies to:
svn co http://svn.o-hand.com/repos/matchbox/trunk/matchbox-window-manager-2 Regards, Tomeu
Index: configure.ac =================================================================== --- configure.ac (revision 2000) +++ configure.ac (working copy) @@ -234,6 +234,10 @@ [ --enable-maemo-manager Build maemo window manager], [maemo_manager=$enableval], [maemo_manager=no]) +AC_ARG_ENABLE(sugar-manager, + [ --enable-sugar-manager Build sugar window manager], + [sugar_manager=$enableval], [sugar_manager=no]) + if test $simple_manager = yes; then MANAGERS="$MANAGERS simple" fi @@ -242,6 +246,10 @@ MANAGERS="$MANAGERS maemo" fi +if test $sugar_manager = yes; then + MANAGERS="$MANAGERS sugar" +fi + AC_SUBST(MANAGERS) PKG_CHECK_MODULES(XFIXES, xfixes >= 4.0, have_xfixes=yes, have_xfixes=no) @@ -291,6 +299,7 @@ matchbox/managers/simple/Makefile matchbox/managers/maemo/Makefile matchbox/managers/maemo/theme/Makefile +matchbox/managers/sugar/Makefile matchbox/theme-engines/Makefile data/Makefile data/themes/Makefile @@ -322,6 +331,7 @@ Managers: Simple manager : ${simple_manager} Maemo manager : ${maemo_manager} + Sugar manager : ${sugar_manager} Compositing managers : ${comp_mgr} Index: matchbox/managers/sugar/sugar-window-manager.c =================================================================== --- matchbox/managers/sugar/sugar-window-manager.c (revision 0) +++ matchbox/managers/sugar/sugar-window-manager.c (revision 0) @@ -0,0 +1,169 @@ +/* + * Matchbox Window Manager II - A lightweight window manager not for the + * desktop. + * + * Based in code by Tomas Frydrych <[EMAIL PROTECTED]> + * + * Copyright (c) 2007 OpenedHand Ltd - http://o-hand.com + * Copyright (c) 2008 One Laptop Per Child + * + * 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, 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. + * + */ + +#include "sugar-window-manager.h" +#include "mb-wm-client-app.h" +#include "mb-wm-client-panel.h" +#include "mb-wm-client-dialog.h" +#include "mb-wm-client-desktop.h" +#include "mb-wm-client-input.h" +#include "mb-window-manager.h" + +#if ENABLE_COMPOSITE +#include "mb-wm-client-override.h" +#endif + +#include <stdarg.h> + +static void +sugar_window_manager_process_cmdline (MBWindowManager *, int, char **); + +static Bool +sugar_window_manager_client_activate (MBWindowManager * wm, + MBWindowManagerClient *c); + +static MBWindowManagerClient* +sugar_window_manager_client_new_func (MBWindowManager *wm, + MBWMClientWindow *win) +{ + if (win->override_redirect) + { + printf ("### override-redirect window ###\n"); +#if ENABLE_COMPOSITE + return mb_wm_client_override_new (wm, win); +#else + return NULL; +#endif + } + + char * name = XGetAtomName (wm->xdpy, win->net_type); + printf("### unhandled window type %s (%x) ###\n", name, win->xwindow); + XFree (name); + + return mb_wm_client_app_new (wm, win); +} + +static void +sugar_window_manager_class_init (MBWMObjectClass *klass) +{ + MBWindowManagerClass *wm_class; + + MBWM_MARK(); + + wm_class = (MBWindowManagerClass *)klass; + + wm_class->process_cmdline = sugar_window_manager_process_cmdline; + wm_class->client_new = sugar_window_manager_client_new_func; + wm_class->client_activate = sugar_window_manager_client_activate; + +#if MBWM_WANT_DEBUG + klass->klass_name = "SugarWindowManager"; +#endif +} + +static void +sugar_window_manager_destroy (MBWMObject *this) +{ +} + +static int +sugar_window_manager_init (MBWMObject *this, va_list vap) +{ + MBWindowManager *wm = MB_WINDOW_MANAGER (this); + wm->modality_type = MBWMModalitySystem; + + return 1; +} + +int +sugar_window_manager_class_type () +{ + static int type = 0; + + if (UNLIKELY(type == 0)) + { + static MBWMObjectClassInfo info = { + sizeof (SugarWindowManagerClass), + sizeof (SugarWindowManager), + sugar_window_manager_init, + sugar_window_manager_destroy, + sugar_window_manager_class_init + }; + + type = mb_wm_object_register_class (&info, MB_TYPE_WINDOW_MANAGER, 0); + } + + return type; +} + +MBWindowManager* +sugar_window_manager_new (int argc, char **argv) +{ + MBWindowManager *wm = NULL; + + wm = MB_WINDOW_MANAGER (mb_wm_object_new (MB_TYPE_SUGAR_WINDOW_MANAGER, + MBWMObjectPropArgc, argc, + MBWMObjectPropArgv, argv, + NULL)); + + if (!wm) + return wm; + + return wm; +} + +static void +sugar_window_manager_process_cmdline (MBWindowManager *wm, + int argc, char **argv) +{ + MBWindowManagerClass * wm_class = + MB_WINDOW_MANAGER_CLASS(MB_WM_OBJECT_GET_PARENT_CLASS(MB_WM_OBJECT(wm))); + + if (wm_class->process_cmdline) + wm_class->process_cmdline (wm); +} + +static Bool +sugar_window_manager_client_activate (MBWindowManager * wm, + MBWindowManagerClient *c) +{ + MBWindowManagerClass *parent_klass; + MBWMClientType c_type; + + /* Get parent klass so we can chain up to the parent method */ + parent_klass = + MB_WINDOW_MANAGER_CLASS(MB_WM_OBJECT_GET_PARENT_CLASS(MB_WM_OBJECT(wm))); + + MBWM_ASSERT (parent_klass->client_activate); + + if (!c) + return False; + + c_type = MB_WM_CLIENT_CLIENT_TYPE (c); + + if (c_type == MBWMClientTypeApp && c != mb_wm_get_visible_main_client (wm)) + { + /* Agressive ping to weed out any hungup applications */ + mb_wm_client_ping_start (c); + } + + return parent_klass->client_activate (wm, c); +} Index: matchbox/managers/sugar/matchbox-window-manager-2-sugar.c =================================================================== --- matchbox/managers/sugar/matchbox-window-manager-2-sugar.c (revision 0) +++ matchbox/managers/sugar/matchbox-window-manager-2-sugar.c (revision 0) @@ -0,0 +1,139 @@ +/* + * Matchbox Window Manager II - A lightweight window manager not for the + * desktop. + * + * Based in code by Tomas Frydrych <[EMAIL PROTECTED]> + * + * Copyright (c) 2007 OpenedHand Ltd - http://o-hand.com + * Copyright (c) 2008 One Laptop Per Child + * + * 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, 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. + * + */ + +#include "mb-wm.h" +#include "mb-wm-object.h" +#include <signal.h> + +enum { + KEY_ACTION_PAGE_NEXT, + KEY_ACTION_PAGE_PREV, + KEY_ACTION_TOGGLE_FULLSCREEN, + KEY_ACTION_TOGGLE_DESKTOP, +}; + +static MBWindowManager *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 (MBWindowManager *wm, + MBWMKeyBinding *binding, + void *userdata) +{ + printf(" ### got key press ### \n"); + int action; + + action = (int)(userdata); + + switch (action) + { + case KEY_ACTION_PAGE_NEXT: + mb_wm_cycle_apps (wm, False); + break; + case KEY_ACTION_PAGE_PREV: + mb_wm_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_toggle_desktop (wm); + break; + } +} + +int +main(int argc, char **argv) +{ +#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(); + + wm = sugar_window_manager_new(argc, argv); + mb_wm_init (wm); + + 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_main_loop (wm); + + mb_wm_object_unref (MB_WM_OBJECT (wm)); + +#if MBWM_WANT_DEBUG + mb_wm_object_dump (); +#endif + + return 1; +} Index: matchbox/managers/sugar/sugar-window-manager.h =================================================================== --- matchbox/managers/sugar/sugar-window-manager.h (revision 0) +++ matchbox/managers/sugar/sugar-window-manager.h (revision 0) @@ -0,0 +1,48 @@ +/* + * Matchbox Window Manager II - A lightweight window manager not for the + * desktop. + * + * Based in code by Tomas Frydrych <[EMAIL PROTECTED]> + * + * Copyright (c) 2007 OpenedHand Ltd - http://o-hand.com + * Copyright (c) 2008 One Laptop Per Child + * + * 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, 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. + * + */ + +#ifndef _HAVE_SUGAR_WINDOW_MANAGER_H +#define _HAVE_SUGAR_WINDOW_MANAGER_H + +#include <matchbox/core/mb-wm.h> + +typedef struct SugarWindowManager SugarWindowManager; +typedef struct SugarWindowManagerClass SugarWindowManagerClass; +typedef struct SugarWindowManagerPriv SugarWindowManagerPriv; + +#define SUGAR_WINDOW_MANAGER(c) ((SugarWindowManager*)(c)) +#define SUGAR_WINDOW_MANAGER_CLASS(c) ((SugarWindowManagerClass*)(c)) +#define MB_TYPE_SUGAR_WINDOW_MANAGER (sugar_window_manager_class_type ()) + +struct SugarWindowManager +{ + MBWindowManager parent; +}; + +struct SugarWindowManagerClass +{ + MBWindowManagerClass parent; +}; + +MBWindowManager * +sugar_window_manager_new (int argc, char **argv); + +#endif Index: matchbox/managers/sugar/Makefile.am =================================================================== --- matchbox/managers/sugar/Makefile.am (revision 0) +++ matchbox/managers/sugar/Makefile.am (revision 0) @@ -0,0 +1,44 @@ +INCLUDES = \ + @MBWM_INCS@ \ + @MBWM_CFLAGS@ + +CLIENT_LIBS = \ + @MBWM_CLIENT_BUILDDIR@/libmb-wm-client-panel.a \ + @MBWM_CLIENT_BUILDDIR@/libmb-wm-client-dialog.a \ + @MBWM_CLIENT_BUILDDIR@/libmb-wm-client-note.a \ + @MBWM_CLIENT_BUILDDIR@/libmb-wm-client-app.a \ + @MBWM_CLIENT_BUILDDIR@/libmb-wm-client-input.a \ + @MBWM_CLIENT_BUILDDIR@/libmb-wm-client-desktop.a \ + @MBWM_CLIENT_BUILDDIR@/libmb-wm-client-menu.a + +THEME_LIBS = @MBWM_THEME_BUILDDIR@/libmb-theme.a + +if ENABLE_COMPOSITE [EMAIL PROTECTED]@/libmatchbox-window-manager-2-compmgr.a \ + @MBWM_CLIENT_BUILDDIR@/libmb-wm-client-override.a +endif + +bin_PROGRAMS = matchbox-window-manager-2-sugar + +matchbox_window_manager_2_sugar_SOURCES = \ + sugar-window-manager.c \ + matchbox-window-manager-2-sugar.c + +matchbox_window_manager_2_sugar_LDFLAGS = \ + $(MBWM_DEBUG_LDFLAGS) \ + $(LDFLAGS) + +matchbox_window_manager_2_sugar_LDADD = \ + @MBWM_LIBS@ \ + @MBWM_CORE_LIB@ \ + $(THEME_LIBS) \ + $(CLIENT_LIBS) \ + $(COMPMGR_LIBS) + +matchbox_window_manager_2_sugar_DEPENDENCIES = \ + @MBWM_CORE_LIB@ \ + $(THEME_LIBS) \ + $(CLIENT_LIBS) \ + $(COMPMGR_LIBS) + +MAINTAINERCLEANFILES = config.h.in Makefile.in
_______________________________________________ Sugar mailing list Sugar@lists.laptop.org http://lists.laptop.org/listinfo/sugar