diff options
-rw-r--r-- | ChangeLog | 39 | ||||
-rw-r--r-- | configure.ac | 26 | ||||
-rw-r--r-- | src/core/mb-wm-client.h | 27 | ||||
-rw-r--r-- | src/core/mb-wm-layout.c | 100 | ||||
-rw-r--r-- | src/core/mb-wm-types.h | 4 | ||||
-rw-r--r-- | src/managers/Makefile.am | 2 | ||||
-rw-r--r-- | src/managers/maemo/Makefile.am | 37 | ||||
-rw-r--r-- | src/managers/maemo/maemo-toolbar.c | 145 | ||||
-rw-r--r-- | src/managers/maemo/maemo-toolbar.h | 52 | ||||
-rw-r--r-- | src/managers/maemo/maemo-window-manager.c | 143 | ||||
-rw-r--r-- | src/managers/maemo/maemo-window-manager.h | 46 | ||||
-rw-r--r-- | src/managers/maemo/matchbox-window-manager-2-maemo.c | 145 | ||||
-rw-r--r-- | src/theme-engines/mb-wm-theme-xml.c | 8 | ||||
-rw-r--r-- | src/theme-engines/mb-wm-theme.c | 32 | ||||
-rw-r--r-- | src/theme-engines/mb-wm-theme.h | 4 |
15 files changed, 758 insertions, 52 deletions
@@ -1,6 +1,43 @@ 2007-10-09 Tomas Frydrych <tf@o-hand.com> - *src/core/mb-window-manager.c: + * src/core/mb-wm-client.h: + * src/core/mb-wm-layout.c: + Added LayoutPrefFixedX, LayoutPrefFixedY to allow for themes to + specify client size (e.g., png theme may want to specify height of + a horizontal panel to tie with size of other elements on screen). + + Added LayoutPrefOverlaps to indicate that client expects to + overlap with other clients rather than lay exclusive claim to its + allocated real-estate (e.g., maemo toolbar). + + * src/core/mb-wm-types.h: + Changed MBGeom.width and MBGeom.height from unsigned to signed so + that negative values can be used to indicate that value is not set + when querying theme for client geometry. + + * src/theme-engines/mb-wm-theme.c: + * src/theme-engines/mb-wm-theme.h: + (mb_wm_theme_get_client_geometry): + Function to query if theme requests specific geometry values for + particular client type. + + * src/theme-engines/mb-wm-theme-xml.c + (mb_wm_xml_client_new): + Initialized x, y, width and height values to -1. + + * configure.ac: + * src/managers/Makefile.am: + * src/managers/maemo/Makefile.am: + * src/managers/maemo/maemo-toolbar.c: + * src/managers/maemo/maemo-toolbar.h: + * src/managers/maemo/maemo-window-manager.c: + * src/managers/maemo/maemo-window-manager.h: + * src/managers/maemo/matchbox-window-manager-2-maemo.c: + Added maemo directory for maemo-specific WM. + +2007-10-09 Tomas Frydrych <tf@o-hand.com> + + * src/core/mb-window-manager.c: (mb_wm_process_cmdline): Added -theme to the default commandline handler. diff --git a/configure.ac b/configure.ac index 69e020d..411fbfe 100644 --- a/configure.ac +++ b/configure.ac @@ -68,6 +68,24 @@ if test "$use_gtk" = yes; then AC_DEFINE(USE_GTK, 1, [GTK Integration]) fi +AC_ARG_ENABLE(simple-manager, + [ --disable-simple-manager Do not build simple window manager], + [simple_manager=$enableval], [simple_manager=yes]) + +AC_ARG_ENABLE(maemo-manager, + [ --enable-maemo-manager Build maemo window manager], + [maemo_manager=$enableval], [maemo_manager=no]) + +if test $simple_manager = yes; then + MANAGERS="$MANAGERS simple" +fi + +if test $maemo_manager = yes; then + MANAGERS="$MANAGERS maemo" +fi + +AC_SUBST(MANAGERS) + MBWM_INCS='-I$(top_srcdir)/src/core -I$(top_srcdir)/src/client-types -I$(top_srcdir)/src/theme-engines' MBWM_CORE_LIB='$(top_builddir)/src/core/libmatchbox-window-manager-2-core.a' MBWM_CLIENT_LIBS='$(top_builddir)/src/client-types' @@ -86,11 +104,12 @@ AC_SUBST([MBWM_DEBUG_LDFLAGS]) AC_OUTPUT([ Makefile -src/Makefile +src/Makefile src/core/Makefile src/client-types/Makefile src/managers/Makefile src/managers/simple/Makefile +src/managers/maemo/Makefile src/theme-engines/Makefile data/Makefile data/themes/Makefile @@ -107,5 +126,8 @@ echo " Cairo theme: ${use_cairo} PNG theme: ${png_theme} GTK integration: ${use_gtk} + + Simple manager: ${simple_manager} + Maemo manager: ${maemo_manager} Debugging output: ${want_debug} -"
\ No newline at end of file +" diff --git a/src/core/mb-wm-client.h b/src/core/mb-wm-client.h index 5106881..4b23add 100644 --- a/src/core/mb-wm-client.h +++ b/src/core/mb-wm-client.h @@ -50,18 +50,21 @@ MBWMStackLayerType; */ typedef enum MBWMClientLayoutHints { - LayoutPrefReserveEdgeNorth = (1<<1), /* panels */ - LayoutPrefReserveEdgeSouth = (1<<2), - LayoutPrefReserveEdgeEast = (1<<3), - LayoutPrefReserveEdgeWest = (1<<4), - LayoutPrefReserveNorth = (1<<5), /* Input wins */ - LayoutPrefReserveSouth = (1<<6), - LayoutPrefReserveEast = (1<<7), - LayoutPrefReserveWest = (1<<8), - LayoutPrefGrowToFreeSpace = (1<<9), /* Free space left by above */ - LayoutPrefFullscreen = (1<<10), /* Fullscreen and desktop wins */ - LayoutPrefPositionFree = (1<<11), /* Dialog, panel in titlebar */ - LayoutPrefVisible = (1<<12), /* Flag is toggled by stacking */ + LayoutPrefReserveEdgeNorth = (1<< 0), /* panels */ + LayoutPrefReserveEdgeSouth = (1<< 1), + LayoutPrefReserveEdgeEast = (1<< 2), + LayoutPrefReserveEdgeWest = (1<< 3), + LayoutPrefReserveNorth = (1<< 4), /* Input wins */ + LayoutPrefReserveSouth = (1<< 5), + LayoutPrefReserveEast = (1<< 6), + LayoutPrefReserveWest = (1<< 7), + LayoutPrefGrowToFreeSpace = (1<< 8), /* Free space left by above */ + LayoutPrefFullscreen = (1<< 9), /* Fullscreen and desktop wins */ + LayoutPrefPositionFree = (1<<10), /* Dialog */ + LayoutPrefVisible = (1<<11), /* Flag is toggled by stacking */ + LayoutPrefFixedX = (1<<12), /* X and width are fixed*/ + LayoutPrefFixedY = (1<<13), + LayoutPrefOverlaps = (1<<14), /* stacked over other windows */ } MBWMClientLayoutHints; diff --git a/src/core/mb-wm-layout.c b/src/core/mb-wm-layout.c index b431eb4..55e8046 100644 --- a/src/core/mb-wm-layout.c +++ b/src/core/mb-wm-layout.c @@ -204,15 +204,19 @@ mb_wm_layout_panels (MBWindowManager * wm, MBGeometry * avail_geom) /* FIXME: need to enumerate by *age* in case multiple panels ? */ mb_wm_stack_enumerate(wm, client) - if (client->layout_hints == - (LayoutPrefReserveEdgeNorth|LayoutPrefVisible)) + if ((client->layout_hints & LayoutPrefReserveEdgeNorth) && + (client->layout_hints & LayoutPrefVisible)) { + int flags = SET_Y; + + if (!(client->layout_hints & LayoutPrefFixedX)) + flags |= SET_X | SET_WIDTH; + mb_wm_client_get_coverage (client, &coverage); /* set x,y to avail and max width */ need_change = mb_wm_layout_maximise_geometry (&coverage, - avail_geom, - SET_X|SET_Y|SET_WIDTH); + avail_geom, flags); /* Too high */ need_change |= mb_wm_layout_clip_geometry (&coverage, avail_geom, SET_HEIGHT); @@ -223,48 +227,65 @@ mb_wm_layout_panels (MBWindowManager * wm, MBGeometry * avail_geom) MBWMClientReqGeomIsViaLayoutManager); /* FIXME: what if this returns False ? */ - avail_geom->y = coverage.y + coverage.height; - avail_geom->height = avail_geom->height - coverage.height; + if (!(client->layout_hints & LayoutPrefOverlaps)) + { + avail_geom->y = coverage.y + coverage.height; + avail_geom->height = avail_geom->height - coverage.height; + } } mb_wm_stack_enumerate(wm, client) - if (client->layout_hints == - (LayoutPrefReserveEdgeSouth|LayoutPrefVisible)) + if ((client->layout_hints & LayoutPrefReserveEdgeSouth) && + (client->layout_hints & LayoutPrefVisible)) { + int y; + mb_wm_client_get_coverage (client, &coverage); /* set x,y to avail and max width */ - need_change = mb_wm_layout_maximise_geometry (&coverage, - avail_geom, - SET_X|SET_WIDTH); - /* Too high */ - need_change |= mb_wm_layout_clip_geometry (&coverage, - avail_geom, SET_HEIGHT); + if (!(client->layout_hints & LayoutPrefFixedX)) + need_change = mb_wm_layout_maximise_geometry (&coverage, + avail_geom, + SET_X | SET_WIDTH); + else + need_change = False; - if (coverage.y != avail_geom->y + avail_geom->height - coverage.height) + y = avail_geom->y + avail_geom->height - coverage.height; + + if (y != coverage.y) { - coverage.y = avail_geom->y + avail_geom->height - coverage.height; + coverage.y = y; need_change = True; } + /* Too high */ + need_change |= mb_wm_layout_clip_geometry (&coverage, + avail_geom, SET_HEIGHT); + if (need_change) mb_wm_client_request_geometry (client, &coverage, MBWMClientReqGeomIsViaLayoutManager); - avail_geom->height = avail_geom->height - coverage.height; + if (!(client->layout_hints & LayoutPrefOverlaps)) + avail_geom->height = avail_geom->height - coverage.height; } - mb_wm_stack_enumerate(wm, client) - if (client->layout_hints == (LayoutPrefReserveEdgeWest|LayoutPrefVisible)) + if ((client->layout_hints & LayoutPrefReserveEdgeWest) && + (client->layout_hints & LayoutPrefVisible)) { + int flags = SET_X; + + if (!(client->layout_hints & LayoutPrefFixedY)) + flags |= SET_Y | SET_HEIGHT; + mb_wm_client_get_coverage (client, &coverage); /* set x,y to avail and max width */ need_change = mb_wm_layout_maximise_geometry (&coverage, avail_geom, - SET_X|SET_Y|SET_HEIGHT); + flags); /* Too wide */ need_change |= mb_wm_layout_clip_geometry (&coverage, avail_geom, SET_WIDTH); @@ -274,20 +295,38 @@ mb_wm_layout_panels (MBWindowManager * wm, MBGeometry * avail_geom) &coverage, MBWMClientReqGeomIsViaLayoutManager); - avail_geom->x = coverage.x + coverage.width; - avail_geom->width = avail_geom->width - coverage.width; + if (!(client->layout_hints & LayoutPrefOverlaps)) + { + avail_geom->x = coverage.x + coverage.width; + avail_geom->width = avail_geom->width - coverage.width; + } } mb_wm_stack_enumerate(wm, client) - if (client->layout_hints == (LayoutPrefReserveEdgeEast|LayoutPrefVisible)) + if ((client->layout_hints & LayoutPrefReserveEdgeEast) && + (client->layout_hints & LayoutPrefVisible)) { + int x; + mb_wm_client_get_coverage (client, &coverage); /* set x,y to avail and max width */ - need_change = mb_wm_layout_maximise_geometry (&coverage, - avail_geom, - SET_Y|SET_HEIGHT); + if (!(client->layout_hints & LayoutPrefFixedY)) + need_change = mb_wm_layout_maximise_geometry (&coverage, + avail_geom, + SET_Y|SET_HEIGHT); + else + need_change = False; + + x = avail_geom->x + avail_geom->width - coverage.width; + + if (x != coverage.x) + { + coverage.x = x; + need_change = True; + } + /* Too wide */ need_change |= mb_wm_layout_clip_geometry (&coverage, avail_geom, SET_WIDTH); @@ -297,13 +336,8 @@ mb_wm_layout_panels (MBWindowManager * wm, MBGeometry * avail_geom) &coverage, MBWMClientReqGeomIsViaLayoutManager); - if (coverage.x != avail_geom->x + avail_geom->width - coverage.width) - { - coverage.x = avail_geom->x + avail_geom->width - coverage.width; - need_change = True; - } - - avail_geom->width = avail_geom->width - coverage.width; + if (!(client->layout_hints & LayoutPrefOverlaps)) + avail_geom->width = avail_geom->width - coverage.width; } } diff --git a/src/core/mb-wm-types.h b/src/core/mb-wm-types.h index 1659777..ef94502 100644 --- a/src/core/mb-wm-types.h +++ b/src/core/mb-wm-types.h @@ -32,8 +32,8 @@ typedef struct MBWMFuncInfo typedef struct MBGeometry { - int x,y; - unsigned int width,height; + int x,y; + int width,height; } MBGeometry; diff --git a/src/managers/Makefile.am b/src/managers/Makefile.am index 8095c10..07e2f28 100644 --- a/src/managers/Makefile.am +++ b/src/managers/Makefile.am @@ -1 +1 @@ -SUBDIRS=simple
\ No newline at end of file +SUBDIRS=$(MANAGERS)
\ No newline at end of file diff --git a/src/managers/maemo/Makefile.am b/src/managers/maemo/Makefile.am new file mode 100644 index 0000000..2314e38 --- /dev/null +++ b/src/managers/maemo/Makefile.am @@ -0,0 +1,37 @@ +INCLUDES = \ + @MBWM_INCS@ \ + @MBWM_CFLAGS@ + +CLIENT_LIBS = \ + @MBWM_CLIENT_LIBS@/libmb-wm-client-panel.a \ + @MBWM_CLIENT_LIBS@/libmb-wm-client-dialog.a \ + @MBWM_CLIENT_LIBS@/libmb-wm-client-app.a \ + @MBWM_CLIENT_LIBS@/libmb-wm-client-input.a \ + @MBWM_CLIENT_LIBS@/libmb-wm-client-desktop.a + + +THEME_LIBS = @MBWM_THEME_LIBS@/libmb-theme.a + +bin_PROGRAMS = matchbox-window-manager-2-maemo + +matchbox_window_manager_2_maemo_SOURCES = \ + maemo-toolbar.c \ + maemo-window-manager.c \ + matchbox-window-manager-2-maemo.c + +matchbox_window_manager_2_maemo_LDFLAGS = \ + $(MBWM_DEBUG_LDFLAGS) \ + $(LDFLAGS) + +matchbox_window_manager_2_maemo_LDADD = \ + @MBWM_LIBS@ \ + @MBWM_CORE_LIB@ \ + $(THEME_LIBS) \ + $(CLIENT_LIBS) + +matchbox_window_manager_2_maemo_DEPENDENCIES = \ + @MBWM_CORE_LIB@ \ + $(THEME_LIBS) \ + $(CLIENT_LIBS) + +MAINTAINERCLEANFILES = config.h.in Makefile.in
\ No newline at end of file diff --git a/src/managers/maemo/maemo-toolbar.c b/src/managers/maemo/maemo-toolbar.c new file mode 100644 index 0000000..8d972e5 --- /dev/null +++ b/src/managers/maemo/maemo-toolbar.c @@ -0,0 +1,145 @@ +/* + * Matchbox Window Manager II - A lightweight window manager not for the + * desktop. + * + * Authored by Tomas Frydrych <tf@o-hand.com> + * + * Copyright (c) 2007 OpenedHand Ltd - http://o-hand.com + * + * 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 "maemo-toolbar.h" + +static void +maemo_toolbar_class_init (MBWMObjectClass *klass) +{ + MBWindowManagerClientClass *client; + + client = (MBWindowManagerClientClass *)klass; + + client->client_type = MBWMClientTypePanel; + +#ifdef MBWM_WANT_DEBUG + klass->klass_name = "MaemoToolbar"; +#endif +} + +static int +maemo_toolbar_init (MBWMObject *this, va_list vap) +{ + MBWindowManagerClient * client = MB_WM_CLIENT (this); + MBWindowManager * wm = client->wmref; + MBGeometry geom; + MBWMClientWindow * win = client->window; + + client->stacking_layer = MBWMStackLayerTop; + client->want_focus = 0; + + mb_wm_client_set_layout_hints (client, + LayoutPrefReserveEdgeNorth | + LayoutPrefVisible | + LayoutPrefFixedX | + LayoutPrefOverlaps); + + + if (!wm->theme) + return 1; + + if (mb_wm_theme_get_client_geometry (wm->theme, client, &geom)) + { + /* The theme prescribes geometry for the panel, resize the + * window accordingly + */ + int x, y, w, h; + int g_x, g_y; + unsigned int g_w, g_h, g_bw, g_d; + + x = geom.x; + y = geom.y; + w = geom.width; + h = geom.height; + + /* If some of the theme values are unset, we have to get the current + * values for the window in their place -- this is a round trip, so + * we only do this when necessary + */ + if (x < 0 || y < 0 || w < 0 || h < 0) + { + Window root; + XGetGeometry (wm->xdpy, win->xwindow, + &root, &g_x, &g_y, &g_w, &g_h, &g_bw, &g_d); + } + + if (x < 0) + x = g_x; + + if (y < 0) + y = g_y; + + if (w < 0) + w = g_w; + + if (h < 0) + h = g_h; + + win->geometry.x = x; + win->geometry.y = y; + win->geometry.width = w; + win->geometry.height = h; + + XMoveResizeWindow (wm->xdpy, win->xwindow, x, y, w, h); + } + + return 1; +} + +static void +maemo_toolbar_destroy (MBWMObject *this) +{ +} + +int +maemo_toolbar_class_type () +{ + static int type = 0; + + if (UNLIKELY(type == 0)) + { + static MBWMObjectClassInfo info = { + sizeof (MaemoToolbarClass), + sizeof (MaemoToolbar), + maemo_toolbar_init, + maemo_toolbar_destroy, + maemo_toolbar_class_init + }; + + type = mb_wm_object_register_class (&info, MB_WM_TYPE_CLIENT_PANEL, 0); + } + + return type; +} + +MBWindowManagerClient* +maemo_toolbar_new (MBWindowManager *wm, MBWMClientWindow *win) +{ + MBWindowManagerClient *client = NULL; + + client = MB_WM_CLIENT (mb_wm_object_new (MB_WM_TYPE_MAEMO_TOOLBAR, + MBWMObjectPropWm, wm, + MBWMObjectPropClientWindow, win, + NULL)); + + return client; +} + + diff --git a/src/managers/maemo/maemo-toolbar.h b/src/managers/maemo/maemo-toolbar.h new file mode 100644 index 0000000..5b5b53d --- /dev/null +++ b/src/managers/maemo/maemo-toolbar.h @@ -0,0 +1,52 @@ +/* + * Matchbox Window Manager II - A lightweight window manager not for the + * desktop. + * + * Authored by Tomas Frydrych <tf@o-hand.com> + * + * Copyright (c) 2007 OpenedHand Ltd - http://o-hand.com + * + * 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_MAEMO_TOOLBAR_H +#define _HAVE_MAEMO_TOOLBAR_H + +#include "mb-wm.h" +#include "mb-wm-client-panel.h" + +typedef struct MaemoToolbar MaemoToolbar; +typedef struct MaemoToolbarClass MaemoToolbarClass; + +#define MAEMO_TOOLBAR(c) ((MaemoToolbar*)(c)) +#define MAEMO_TOOLBAR_CLASS(c) ((MaemoToolbarClass*)(c)) +#define MB_WM_TYPE_MAEMO_TOOLBAR (maemo_toolbar_class_type ()) +#define MB_WM_IS_MAEMO_TOOLBAR(c) \ + (MB_WM_OBJECT_TYPE(c)==MB_WM_TYPE_MAEMO_TOOLBAR) + +struct MaemoToolbar +{ + MBWMClientPanel parent; +}; + +struct MaemoToolbarClass +{ + MBWMClientPanelClass parent; +}; + +MBWindowManagerClient* +maemo_toolbar_new(MBWindowManager *wm, MBWMClientWindow *win); + +int +maemo_toolbar_class_type (); + +#endif diff --git a/src/managers/maemo/maemo-window-manager.c b/src/managers/maemo/maemo-window-manager.c new file mode 100644 index 0000000..b260c67 --- /dev/null +++ b/src/managers/maemo/maemo-window-manager.c @@ -0,0 +1,143 @@ +/* + * Matchbox Window Manager II - A lightweight window manager not for the + * desktop. + * + * Authored by Tomas Frydrych <tf@o-hand.com> + * + * Copyright (c) 2007 OpenedHand Ltd - http://o-hand.com + * + * 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 "maemo-window-manager.h" +#include "maemo-toolbar.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" + +#include <stdarg.h> + +static void +maemo_window_manager_process_cmdline (MBWindowManager *, int , char **); + +static MBWindowManagerClient* +maemo_window_manager_client_new_func (MBWindowManager *wm, + MBWMClientWindow *win) +{ + if (win->net_type == wm->atoms[MBWM_ATOM_NET_WM_WINDOW_TYPE_DOCK]) + { + printf("### is panel ###\n"); + return maemo_toolbar_new (wm, win); + } + else if (win->net_type == wm->atoms[MBWM_ATOM_NET_WM_WINDOW_TYPE_DIALOG]) + { + printf("### is dialog ###\n"); + return mb_wm_client_dialog_new (wm, win); + } + else if (win->net_type == wm->atoms[MBWM_ATOM_NET_WM_WINDOW_TYPE_DESKTOP]) + { + printf("### is desktop ###\n"); + /* Only one desktop allowed */ + if (wm->desktop) + return NULL; + + return mb_wm_client_desktop_new (wm, win); + } + else if (win->net_type == wm->atoms[MBWM_ATOM_NET_WM_WINDOW_TYPE_TOOLBAR]) + { + printf("### is input ###\n"); + return mb_wm_client_input_new (wm, win); + } + else + { + return mb_wm_client_app_new(wm, win); + } +} + +static void +maemo_window_manager_class_init (MBWMObjectClass *klass) +{ + MBWindowManagerClass *wm_class; + + MBWM_MARK(); + + wm_class = (MBWindowManagerClass *)klass; + + wm_class->process_cmdline = maemo_window_manager_process_cmdline; + wm_class->client_new = maemo_window_manager_client_new_func; + +#ifdef MBWM_WANT_DEBUG + klass->klass_name = "MaemoWindowManager"; +#endif +} + +static void +maemo_window_manager_destroy (MBWMObject *this) +{ +} + +static int +maemo_window_manager_init (MBWMObject *this, va_list vap) +{ + return 1; +} + +int +maemo_window_manager_class_type () +{ + static int type = 0; + + if (UNLIKELY(type == 0)) + { + static MBWMObjectClassInfo info = { + sizeof (MBWindowManagerClass), + sizeof (MBWindowManager), + maemo_window_manager_init, + maemo_window_manager_destroy, + maemo_window_manager_class_init + }; + + type = mb_wm_object_register_class (&info, MB_TYPE_WINDOW_MANAGER, 0); + } + + return type; +} + +MBWindowManager* +maemo_window_manager_new (int argc, char **argv) +{ + MBWindowManager *wm = NULL; + + wm = MB_WINDOW_MANAGER (mb_wm_object_new (MB_TYPE_MAEMO_WINDOW_MANAGER, + MBWMObjectPropArgc, argc, + MBWMObjectPropArgv, argv, + NULL)); + + if (!wm) + return wm; + + return wm; +} + +static void +maemo_window_manager_process_cmdline (MBWindowManager *wm, + int argc, char **argv) +{ + MBWindowManagerClass * wm_class = MB_WM_OBJECT_GET_PARENT_CLASS (wm); + + if (wm_class->process_cmdline) + wm_class->process_cmdline (wm, argc, argv); +} + diff --git a/src/managers/maemo/maemo-window-manager.h b/src/managers/maemo/maemo-window-manager.h new file mode 100644 index 0000000..65b91f1 --- /dev/null +++ b/src/managers/maemo/maemo-window-manager.h @@ -0,0 +1,46 @@ +/* + * Matchbox Window Manager II - A lightweight window manager not for the + * desktop. + * + * Authored by Tomas Frydrych <tf@o-hand.com> + * + * Copyright (c) 2007 OpenedHand Ltd - http://o-hand.com + * + * 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_MAEMO_WINDOW_MANAGER_H +#define _HAVE_MAEMO_WINDOW_MANAGER_H + +#include "mb-wm.h" + +typedef struct MaemoWindowManagerClass MaemoWindowManagerClass; +typedef struct MaemoWindowManagerPriv MaemoWindowManagerPriv; + +#define MAEMO_WINDOW_MANAGER(c) ((MaemoWindowManager*)(c)) +#define MAEMO_WINDOW_MANAGER_CLASS(c) ((MaemoWindowManagerClass*)(c)) +#define MB_TYPE_MAEMO_WINDOW_MANAGER (maemo_window_manager_class_type ()) + +struct MaemoWindowManager +{ + MBWindowManager parent; +}; + +struct MaemoWindowManagerClass +{ + MBWindowManagerClass parent; +}; + +MBWindowManager * +maemo_window_manager_new (int argc, char **argv); + +#endif diff --git a/src/managers/maemo/matchbox-window-manager-2-maemo.c b/src/managers/maemo/matchbox-window-manager-2-maemo.c new file mode 100644 index 0000000..befe0c3 --- /dev/null +++ b/src/managers/maemo/matchbox-window-manager-2-maemo.c @@ -0,0 +1,145 @@ +/* + * Matchbox Window Manager II - A lightweight window manager not for the + * desktop. + * + * Authored by Tomas Frydrych <tf@o-hand.com> + * + * Copyright (c) 2007 OpenedHand Ltd - http://o-hand.com + * + * 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 <signal.h> + +enum { + KEY_ACTION_PAGE_NEXT, + KEY_ACTION_PAGE_PREV, + KEY_ACTION_TOGGLE_FULLSCREEN, + KEY_ACTION_TOGGLE_DESKTOP, +}; + +static MBWindowManager *wm = NULL; + +#ifdef 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); + break; + case KEY_ACTION_PAGE_PREV: + printf(" ### KEY_ACTION_PAGE_PREV ### \n"); + 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) +{ + MBWMLayout * layout; + +#ifdef 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 = maemo_window_manager_new(argc, argv); + + if (wm == NULL) + mb_wm_util_fatal_error("OOM?"); + + layout = mb_wm_layout_new (wm); + + if (layout == NULL) + mb_wm_util_fatal_error("OOM?"); + + mb_wm_set_layout (wm, layout); + + 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)); + +#ifdef MBWM_WANT_DEBUG + mb_wm_object_dump (); +#endif + + return 1; +} diff --git a/src/theme-engines/mb-wm-theme-xml.c b/src/theme-engines/mb-wm-theme-xml.c index 93478cc..31ea39d 100644 --- a/src/theme-engines/mb-wm-theme-xml.c +++ b/src/theme-engines/mb-wm-theme-xml.c @@ -1,4 +1,4 @@ -/* +/* * Matchbox Window Manager 2 - A lightweight window manager not for the * desktop. * @@ -76,6 +76,12 @@ MBWMXmlClient * mb_wm_xml_client_new () { MBWMXmlClient * c = mb_wm_util_malloc0 (sizeof (MBWMXmlClient)); + + c->x = -1; + c->y = -1; + c->width = -1; + c->height = -1; + return c; } diff --git a/src/theme-engines/mb-wm-theme.c b/src/theme-engines/mb-wm-theme.c index e9f6e97..0ac0c5a 100644 --- a/src/theme-engines/mb-wm-theme.c +++ b/src/theme-engines/mb-wm-theme.c @@ -429,6 +429,38 @@ mb_wm_theme_create_decor (MBWMTheme *theme, } /* + * Returns True if the theme prescribes at least one value for the geometry + */ +Bool +mb_wm_theme_get_client_geometry (MBWMTheme * theme, + MBWindowManagerClient * client, + MBGeometry * geom) +{ + MBWMXmlClient * c; + MBWMClientType c_type; + + if (!geom || !client || !theme) + return False; + + c_type = MB_WM_CLIENT_CLIENT_TYPE (client); + + if (!theme || !theme->xml_clients || + !(c = mb_wm_xml_client_find_by_type (theme->xml_clients, c_type)) || + (c->x < 0 && c->y < 0 && c->width < 0 && c->height < 0)) + { + return False; + } + + geom->x = c->x; + geom->y = c->y; + geom->width = c->width; + geom->height = c->height; + + return True; +} + + +/* * Expat callback stuff */ diff --git a/src/theme-engines/mb-wm-theme.h b/src/theme-engines/mb-wm-theme.h index 8b8bb53..b77dd98 100644 --- a/src/theme-engines/mb-wm-theme.h +++ b/src/theme-engines/mb-wm-theme.h @@ -140,5 +140,9 @@ mb_wm_theme_create_decor (MBWMTheme *theme, MBWindowManagerClient *client, MBWMDecorType type); +Bool +mb_wm_theme_get_client_geometry (MBWMTheme * theme, + MBWindowManagerClient * client, + MBGeometry * geom); #endif |