diff --git a/configure.in b/configure.in index 559b8308c..112295939 100644 --- a/configure.in +++ b/configure.in @@ -248,6 +248,8 @@ src/modules/ibox/Makefile src/modules/ibox/module.desktop src/modules/start/Makefile src/modules/start/module.desktop +src/modules/layout/Makefile +src/modules/layout/module.desktop src/preload/Makefile data/Makefile data/fonts/Makefile diff --git a/src/bin/e_border.c b/src/bin/e_border.c index 1f119f422..8a14137a9 100644 --- a/src/bin/e_border.c +++ b/src/bin/e_border.c @@ -100,7 +100,9 @@ static void _e_border_pointer_resize_begin(E_Border *bd); static void _e_border_pointer_resize_end(E_Border *bd); static void _e_border_pointer_move_begin(E_Border *bd); static void _e_border_pointer_move_end(E_Border *bd); - + +static void _e_border_hook_call(E_Border_Hook_Point hookpoint, E_Border *bd); + /* local subsystem globals */ static Evas_List *handlers = NULL; static Evas_List *borders = NULL; @@ -1704,7 +1706,7 @@ e_border_maximize(E_Border *bd, E_Maximize max) { int x1, y1, x2, y2; - int w, h; + int w, h, pw, ph; bd->pre_res_change.valid = 0; if (!(bd->maximized & E_MAXIMIZE_HORIZONTAL)) @@ -1753,8 +1755,8 @@ e_border_maximize(E_Border *bd, E_Maximize max) } w = bd->zone->w; h = bd->zone->h; + e_border_resize_limit(bd, &w, &h); /* center x-direction */ -// e_border_resize_limit(bd, &w, &h); x1 = bd->zone->x + (bd->zone->w - w) / 2; /* center y-direction */ y1 = bd->zone->y + (bd->zone->h - h) / 2; @@ -1782,7 +1784,13 @@ e_border_maximize(E_Border *bd, E_Maximize max) w = x2 - x1; h = y2 - y1; + pw = w; + ph = h; e_border_resize_limit(bd, &w, &h); + /* center x-direction */ + x1 = x1 + (pw - w) / 2; + /* center y-direction */ + y1 = y1 + (ph - h) / 2; if ((max & E_MAXIMIZE_DIRECTION) == E_MAXIMIZE_BOTH) e_border_move_resize(bd, x1, y1, w, h); else if ((max & E_MAXIMIZE_DIRECTION) == E_MAXIMIZE_VERTICAL) @@ -1805,7 +1813,13 @@ e_border_maximize(E_Border *bd, E_Maximize max) w = x2 - x1; h = y2 - y1; + pw = w; + ph = h; e_border_resize_limit(bd, &w, &h); + /* center x-direction */ + x1 = x1 + (pw - w) / 2; + /* center y-direction */ + y1 = y1 + (ph - h) / 2; if ((max & E_MAXIMIZE_DIRECTION) == E_MAXIMIZE_BOTH) e_border_move_resize(bd, x1, y1, w, h); else if ((max & E_MAXIMIZE_DIRECTION) == E_MAXIMIZE_VERTICAL) @@ -5631,6 +5645,8 @@ _e_border_eval(E_Border *bd) bd->user_skip_winlist = rem->prop.skip_winlist; } } + + _e_border_hook_call(E_BORDER_HOOK_EVAL_POST_FETCH, bd); if ((bd->client.border.changed) && (!bd->shaded) && (!(((bd->maximized & E_MAXIMIZE_TYPE) == E_MAXIMIZE_FULLSCREEN)))) @@ -7345,3 +7361,73 @@ _e_border_pointer_move_end(E_Border *bd) { e_pointer_type_pop(bd->pointer, bd, "move"); } + +static Evas_List *_e_border_hooks = NULL; +static int _e_border_hooks_delete = 0; +static int _e_border_hooks_walking = 0; + +static void +_e_border_hooks_clean(void) +{ + Evas_List *l, *pl; + + for (l = _e_border_hooks; l;) + { + E_Border_Hook *bh; + + bh = l->data; + pl = l; + l = l->next; + if (bh->delete_me) + { + _e_border_hooks = evas_list_remove_list(_e_border_hooks, pl); + free(bh); + } + } +} + +static void +_e_border_hook_call(E_Border_Hook_Point hookpoint, E_Border *bd) +{ + Evas_List *l; + + _e_border_hooks_walking++; + for (l = _e_border_hooks; l; l = l->next) + { + E_Border_Hook *bh; + + bh = l->data; + if (bh->delete_me) continue; + if (bh->hookpoint == hookpoint) bh->func(bh->data, bd); + } + _e_border_hooks_walking--; + if ((_e_border_hooks_walking == 0) && (_e_border_hooks_delete > 0)) + _e_border_hooks_clean(); +} + +EAPI E_Border_Hook * +e_border_hook_add(E_Border_Hook_Point hookpoint, void (*func) (void *data, E_Border *bd), void *data) +{ + E_Border_Hook *bh; + + bh = E_NEW(E_Border_Hook, 1); + if (!bh) return NULL; + bh->hookpoint = hookpoint; + bh->func = func; + bh->data = data; + _e_border_hooks = evas_list_append(_e_border_hooks, bh); + return bh; +} + +EAPI void +e_border_hook_del(E_Border_Hook *bh) +{ + bh->delete_me = 1; + if (_e_border_hooks_walking == 0) + { + _e_border_hooks = evas_list_remove(_e_border_hooks, bh); + free(bh); + } + else + _e_border_hooks_delete++; +} diff --git a/src/bin/e_border.h b/src/bin/e_border.h index bfe20feea..58a22dd78 100644 --- a/src/bin/e_border.h +++ b/src/bin/e_border.h @@ -71,8 +71,14 @@ typedef enum _E_Window_Placement E_WINDOW_PLACEMENT_MANUAL } E_Window_Placement; +typedef enum _E_Border_Hook_Point +{ + E_BORDER_HOOK_EVAL_POST_FETCH +} E_Border_Hook_Point; + typedef struct _E_Border E_Border; typedef struct _E_Border_Pending_Move_Resize E_Border_Pending_Move_Resize; +typedef struct _E_Border_Hook E_Border_Hook; typedef struct _E_Event_Border_Resize E_Event_Border_Resize; typedef struct _E_Event_Border_Move E_Event_Border_Move; typedef struct _E_Event_Border_Add E_Event_Border_Add; @@ -472,6 +478,14 @@ struct _E_Border_Pending_Move_Resize unsigned char resize : 1; }; +struct _E_Border_Hook +{ + E_Border_Hook_Point hookpoint; + void (*func) (void *data, E_Border *bd); + void *data; + unsigned char delete_me : 1; +}; + struct _E_Event_Border_Resize { E_Border *border; @@ -644,6 +658,9 @@ EAPI void e_border_signal_resize_begin(E_Border *bd, const char *dir, const char EAPI void e_border_signal_resize_end(E_Border *bd, const char *dir, const char *sig, const char *src); EAPI void e_border_resize_limit(E_Border *bd, int *w, int *h); +EAPI E_Border_Hook *e_border_hook_add(E_Border_Hook_Point hookpoint, void (*func) (void *data, E_Border *bd), void *data); +EAPI void e_border_hook_del(E_Border_Hook *bh); + extern EAPI int E_EVENT_BORDER_RESIZE; extern EAPI int E_EVENT_BORDER_MOVE; extern EAPI int E_EVENT_BORDER_ADD; diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am index f8fcc8292..c9d12014c 100644 --- a/src/modules/Makefile.am +++ b/src/modules/Makefile.am @@ -8,4 +8,5 @@ battery \ temperature \ cpufreq \ ibox \ -start +start \ +layout diff --git a/src/modules/layout/Makefile.am b/src/modules/layout/Makefile.am new file mode 100644 index 000000000..763c2d4c9 --- /dev/null +++ b/src/modules/layout/Makefile.am @@ -0,0 +1,28 @@ +MAINTAINERCLEANFILES = Makefile.in +MODULE = layout + +# data files for the module +filesdir = $(libdir)/enlightenment/modules/$(MODULE) +files_DATA = \ +e-module-$(MODULE).edj module.desktop + +EXTRA_DIST = $(files_DATA) + +# the module .so file +INCLUDES = -I. \ + -I$(top_srcdir) \ + -I$(top_srcdir)/src/modules/$(MODULE) \ + -I$(top_srcdir)/src/bin \ + -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/modules \ + @e_cflags@ +pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH) +pkg_LTLIBRARIES = module.la +module_la_SOURCES = e_mod_main.c \ + e_mod_main.h +module_la_LIBADD = @e_libs@ @dlopen_libs@ +module_la_LDFLAGS = -module -avoid-version +module_la_DEPENDENCIES = $(top_builddir)/config.h + +uninstall: + rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE) diff --git a/src/modules/layout/e-module-layout.edj b/src/modules/layout/e-module-layout.edj new file mode 100644 index 000000000..a59e24c61 Binary files /dev/null and b/src/modules/layout/e-module-layout.edj differ diff --git a/src/modules/layout/e_mod_main.c b/src/modules/layout/e_mod_main.c new file mode 100644 index 000000000..6b3993d27 --- /dev/null +++ b/src/modules/layout/e_mod_main.c @@ -0,0 +1,106 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ +#include "e.h" +#include "e_mod_main.h" + +/***************************************************************************/ +/**/ +/* actual module specifics */ + +static E_Module *layout_module = NULL; +static E_Border_Hook *hook = NULL; + +static void +_e_module_layout_cb_hook(void *data, E_Border *bd) +{ + /* FIXME: make some modification based on policy */ + printf("Window:\n" + " Title: [%s][%s]\n" + " Class: %s::%s\n" + " Geometry: %ix%i+%i+%i\n" + " New: %i\n" + , bd->client.icccm.title, bd->client.netwm.name + , bd->client.icccm.name, bd->client.icccm.class + , bd->x, bd->y, bd->w, bd->h + , bd->new_client + ); + if ((bd->client.icccm.transient_for != 0) || + (bd->client.netwm.type == ECORE_X_WINDOW_TYPE_DIALOG)) + { + bd->client.e.state.centered = 1; + } + else + { + e_border_unmaximize(bd, E_MAXIMIZE_BOTH); + e_border_move(bd, + bd->zone->x + (bd->zone->w / 2), + bd->zone->y + (bd->zone->h / 2)); + e_border_resize(bd, 1, 1); + if (bd->bordername) evas_stringshare_del(bd->bordername); + bd->bordername = evas_stringshare_add("borderless"); + bd->client.icccm.base_w = 1; + bd->client.icccm.base_h = 1; + bd->client.icccm.min_w = 1; + bd->client.icccm.min_h = 1; + bd->client.icccm.max_w = 32767; + bd->client.icccm.max_h = 32767; + bd->client.icccm.min_aspect = 0.0; + bd->client.icccm.max_aspect = 0.0; + } + e_border_maximize(bd, E_MAXIMIZE_FILL | E_MAXIMIZE_BOTH); +} + +/**/ +/***************************************************************************/ + +/***************************************************************************/ +/**/ + +/**/ +/***************************************************************************/ + +/***************************************************************************/ +/**/ +/* module setup */ +EAPI E_Module_Api e_modapi = +{ + E_MODULE_API_VERSION, + "Layout" +}; + +EAPI void * +e_modapi_init(E_Module *m) +{ + layout_module = m; + + hook = e_border_hook_add(E_BORDER_HOOK_EVAL_POST_FETCH, + _e_module_layout_cb_hook, NULL); + return m; +} + +EAPI int +e_modapi_shutdown(E_Module *m) +{ + if (hook) + { + e_border_hook_del(hook); + hook = NULL; + } + layout_module = NULL; + return 1; +} + +EAPI int +e_modapi_save(E_Module *m) +{ + return 1; +} + +EAPI int +e_modapi_about(E_Module *m) +{ + e_module_dialog_show(m, _("Enlightenment Layout Module"), + _("Can restrict or implement specific window layout policies for specialised situations.")); + return 1; +} diff --git a/src/modules/layout/e_mod_main.h b/src/modules/layout/e_mod_main.h new file mode 100644 index 000000000..a24ec2e3e --- /dev/null +++ b/src/modules/layout/e_mod_main.h @@ -0,0 +1,15 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ +#ifndef E_MOD_MAIN_H +#define E_MOD_MAIN_H + +EAPI extern E_Module_Api e_modapi; + +EAPI void *e_modapi_init (E_Module *m); +EAPI int e_modapi_shutdown (E_Module *m); +EAPI int e_modapi_save (E_Module *m); +EAPI int e_modapi_about (E_Module *m); +EAPI int e_modapi_config (E_Module *m); + +#endif diff --git a/src/modules/layout/module.desktop.in b/src/modules/layout/module.desktop.in new file mode 100644 index 000000000..fda60112a --- /dev/null +++ b/src/modules/layout/module.desktop.in @@ -0,0 +1,4 @@ +[Desktop Entry] +Type=Link +Name=Layout +Icon=e-module-layout