diff --git a/src/modules/illume2/e_mod_config.c b/src/modules/illume2/e_mod_config.c index dab43549d..eb11221b6 100644 --- a/src/modules/illume2/e_mod_config.c +++ b/src/modules/illume2/e_mod_config.c @@ -24,7 +24,7 @@ il_config_init(E_Module *m) E_CONFIG_VAL(D, T, policy.vkbd.class, STR); E_CONFIG_VAL(D, T, policy.vkbd.name, STR); E_CONFIG_VAL(D, T, policy.vkbd.title, STR); - E_CONFIG_VAL(D, T, policy.vkbd.win_type, STR); + E_CONFIG_VAL(D, T, policy.vkbd.win_type, INT); E_CONFIG_VAL(D, T, policy.vkbd.match.class, INT); E_CONFIG_VAL(D, T, policy.vkbd.match.name, INT); E_CONFIG_VAL(D, T, policy.vkbd.match.title, INT); @@ -32,7 +32,7 @@ il_config_init(E_Module *m) E_CONFIG_VAL(D, T, policy.softkey.class, STR); E_CONFIG_VAL(D, T, policy.softkey.name, STR); E_CONFIG_VAL(D, T, policy.softkey.title, STR); - E_CONFIG_VAL(D, T, policy.softkey.win_type, STR); + E_CONFIG_VAL(D, T, policy.softkey.win_type, INT); E_CONFIG_VAL(D, T, policy.softkey.match.class, INT); E_CONFIG_VAL(D, T, policy.softkey.match.name, INT); E_CONFIG_VAL(D, T, policy.softkey.match.title, INT); @@ -40,7 +40,7 @@ il_config_init(E_Module *m) E_CONFIG_VAL(D, T, policy.home.class, STR); E_CONFIG_VAL(D, T, policy.home.name, STR); E_CONFIG_VAL(D, T, policy.home.title, STR); - E_CONFIG_VAL(D, T, policy.home.win_type, STR); + E_CONFIG_VAL(D, T, policy.home.win_type, INT); E_CONFIG_VAL(D, T, policy.home.match.class, INT); E_CONFIG_VAL(D, T, policy.home.match.name, INT); E_CONFIG_VAL(D, T, policy.home.match.title, INT); @@ -48,7 +48,7 @@ il_config_init(E_Module *m) E_CONFIG_VAL(D, T, policy.indicator.class, STR); E_CONFIG_VAL(D, T, policy.indicator.name, STR); E_CONFIG_VAL(D, T, policy.indicator.title, STR); - E_CONFIG_VAL(D, T, policy.indicator.win_type, STR); + E_CONFIG_VAL(D, T, policy.indicator.win_type, INT); E_CONFIG_VAL(D, T, policy.indicator.match.class, INT); E_CONFIG_VAL(D, T, policy.indicator.match.name, INT); E_CONFIG_VAL(D, T, policy.indicator.match.title, INT); @@ -80,7 +80,7 @@ il_config_init(E_Module *m) eina_stringshare_add("E"); il_cfg->policy.vkbd.title = eina_stringshare_add("Virtual Keyboard"); - il_cfg->policy.vkbd.win_type = NULL; + il_cfg->policy.vkbd.win_type = ECORE_X_WINDOW_TYPE_NORMAL; il_cfg->policy.vkbd.match.class = 0; il_cfg->policy.vkbd.match.name = 0; il_cfg->policy.vkbd.match.title = 0; @@ -91,7 +91,7 @@ il_config_init(E_Module *m) eina_stringshare_add("Illume-Softkey"); il_cfg->policy.softkey.title = eina_stringshare_add("Illume Softkey"); - il_cfg->policy.softkey.win_type = NULL; + il_cfg->policy.softkey.win_type = ECORE_X_WINDOW_TYPE_NORMAL; il_cfg->policy.softkey.match.class = 0; il_cfg->policy.softkey.match.name = 0; il_cfg->policy.softkey.match.title = 0; @@ -102,7 +102,7 @@ il_config_init(E_Module *m) eina_stringshare_add("Illume-Home"); il_cfg->policy.home.title = eina_stringshare_add("Illume Home"); - il_cfg->policy.home.win_type = NULL; + il_cfg->policy.home.win_type = ECORE_X_WINDOW_TYPE_NORMAL; il_cfg->policy.home.match.class = 0; il_cfg->policy.home.match.name = 0; il_cfg->policy.home.match.title = 0; @@ -113,7 +113,7 @@ il_config_init(E_Module *m) eina_stringshare_add("Illume-Indicator"); il_cfg->policy.indicator.title = eina_stringshare_add("Illume Indicator"); - il_cfg->policy.indicator.win_type = NULL; + il_cfg->policy.indicator.win_type = ECORE_X_WINDOW_TYPE_NORMAL; il_cfg->policy.indicator.match.class = 0; il_cfg->policy.indicator.match.name = 0; il_cfg->policy.indicator.match.title = 0; @@ -149,8 +149,6 @@ il_config_shutdown(void) eina_stringshare_del(il_cfg->policy.vkbd.name); if (il_cfg->policy.vkbd.title) eina_stringshare_del(il_cfg->policy.vkbd.title); - if (il_cfg->policy.vkbd.win_type) - eina_stringshare_del(il_cfg->policy.vkbd.win_type); if (il_cfg->policy.softkey.class) eina_stringshare_del(il_cfg->policy.softkey.class); @@ -158,8 +156,6 @@ il_config_shutdown(void) eina_stringshare_del(il_cfg->policy.softkey.name); if (il_cfg->policy.softkey.title) eina_stringshare_del(il_cfg->policy.softkey.title); - if (il_cfg->policy.softkey.win_type) - eina_stringshare_del(il_cfg->policy.softkey.win_type); if (il_cfg->policy.home.class) eina_stringshare_del(il_cfg->policy.home.class); @@ -167,8 +163,6 @@ il_config_shutdown(void) eina_stringshare_del(il_cfg->policy.home.name); if (il_cfg->policy.home.title) eina_stringshare_del(il_cfg->policy.home.title); - if (il_cfg->policy.home.win_type) - eina_stringshare_del(il_cfg->policy.home.win_type); if (il_cfg->policy.indicator.class) eina_stringshare_del(il_cfg->policy.indicator.class); @@ -176,8 +170,6 @@ il_config_shutdown(void) eina_stringshare_del(il_cfg->policy.indicator.name); if (il_cfg->policy.indicator.title) eina_stringshare_del(il_cfg->policy.indicator.title); - if (il_cfg->policy.indicator.win_type) - eina_stringshare_del(il_cfg->policy.indicator.win_type); if (il_cfg->mod_dir) eina_stringshare_del(il_cfg->mod_dir); diff --git a/src/modules/illume2/e_mod_config.h b/src/modules/illume2/e_mod_config.h index 98f4de59c..6054bb411 100644 --- a/src/modules/illume2/e_mod_config.h +++ b/src/modules/illume2/e_mod_config.h @@ -26,7 +26,7 @@ struct _Il_Config const char *class; const char *name; const char *title; - const char *win_type; + int win_type; struct { int class, name, title, win_type; diff --git a/src/modules/illume2/e_mod_layout.c b/src/modules/illume2/e_mod_layout.c index c9386d106..243f2876d 100644 --- a/src/modules/illume2/e_mod_layout.c +++ b/src/modules/illume2/e_mod_layout.c @@ -167,8 +167,10 @@ illume_border_is_keyboard(E_Border *bd) if ((bd->client.vkbd.vkbd) || /* explicit hint that its a virtual keyboard */ /* legacy */ ( /* trap the matchbox qwerty and multitap kbd's */ - (((bd->client.icccm.title) && (!strcmp(bd->client.icccm.title, "Keyboard"))) || - ((bd->client.icccm.name) && ((!strcmp(bd->client.icccm.name, "multitap-pad"))))) + (((bd->client.icccm.title) && + (!strcmp(bd->client.icccm.title, "Keyboard"))) || + ((bd->client.icccm.name) && + ((!strcmp(bd->client.icccm.name, "multitap-pad"))))) && (bd->client.netwm.state.skip_taskbar) && (bd->client.netwm.state.skip_pager))) return 1; @@ -181,7 +183,8 @@ illume_border_is_bottom_panel(E_Border *bd) { if (((bd->client.netwm.type == ECORE_X_WINDOW_TYPE_DOCK) || (bd->client.qtopia.soft_menu)) || - (bd->client.icccm.name) && ((!strcmp(bd->client.icccm.name, "Illume-Softkey")))) + (bd->client.icccm.name) && + ((!strcmp(bd->client.icccm.name, "Illume-Softkey")))) return 1; return 0; } @@ -190,7 +193,7 @@ illume_border_is_bottom_panel(E_Border *bd) Eina_Bool illume_border_is_top_shelf(E_Border *bd) { - if ((bd->client.icccm.name) && + if ((bd->client.icccm.name) && (strstr(bd->client.icccm.name, "Illume-Indicator"))) return 1; // FIXME: detect @@ -220,7 +223,7 @@ illume_border_is_home(E_Border *bd) if (((bd->client.icccm.name) && (!strcmp(bd->client.icccm.name, "Illume-Home"))) || ((bd->client.icccm.title) && - (strstr(bd->client.icccm.title, "Home")))) + (strstr(bd->client.icccm.title, "Home")))) return 1; return 0; } diff --git a/src/modules/illume2/e_mod_windows.c b/src/modules/illume2/e_mod_windows.c index 172139b24..700bd3e37 100644 --- a/src/modules/illume2/e_mod_windows.c +++ b/src/modules/illume2/e_mod_windows.c @@ -13,12 +13,23 @@ static void _il_config_windows_select_window_create(void); static int _il_config_windows_cb_key_down(void *data, int type, void *event); static int _il_config_windows_cb_mouse_up(void *data, int type, void *event); static void _il_config_windows_select_home(void *data, void *data2); +static void _il_config_windows_select_vkbd(void *data, void *data2); +static void _il_config_windows_select_softkey(void *data, void *data2); +static void _il_config_windows_select_indicator(void *data, void *data2); +static void _il_config_windows_event_free(void *data, void *event); +static int _il_config_windows_home_selected(void *data, int type, void *event); +static int _il_config_windows_vkbd_selected(void *data, int type, void *event); +static int _il_config_windows_softkey_selected(void *data, int type, void *event); +static int _il_config_windows_indicator_selected(void *data, int type, void *event); /* local variables */ +EAPI int IL_EVENT_WINDOW_SELECTED = 0; Ecore_Timer *_windows_change_timer = NULL; static Ecore_X_Window input_window = 0; +static Ecore_X_Window selected_window = 0; static Ecore_Event_Handler *mouse_hdl = 0; static Ecore_Event_Handler *key_hdl = 0; +static Ecore_Event_Handler *sel_hdl = 0; /* public functions */ EAPI void @@ -28,6 +39,9 @@ il_config_windows_show(E_Container *con, const char *params) E_Config_Dialog_View *v; if (e_config_dialog_find("E", "_config_illume_windows_settings")) return; + + IL_EVENT_WINDOW_SELECTED = ecore_event_type_new(); + v = E_NEW(E_Config_Dialog_View, 1); v->create_cfdata = _il_config_windows_create; v->free_cfdata = _il_config_windows_free; @@ -51,7 +65,17 @@ _il_config_windows_create(E_Config_Dialog *cfd) static void _il_config_windows_free(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) { + IL_EVENT_WINDOW_SELECTED = 0; + if (_windows_change_timer) ecore_timer_del(_windows_change_timer); + ecore_x_keyboard_ungrab(); + if (input_window) ecore_x_window_free(input_window); + input_window = 0; + selected_window = 0; + + if (key_hdl) ecore_event_handler_del(key_hdl); + if (mouse_hdl) ecore_event_handler_del(mouse_hdl); + if (sel_hdl) ecore_event_handler_del(sel_hdl); } static Evas_Object * @@ -88,7 +112,8 @@ _il_config_windows_ui(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf e_widget_list_object_append(list, of, 1, 0, 0.0); of = e_widget_framelist_add(evas, _("Indicator"), 0); - ow = e_widget_button_add(evas, _("Select Window"), NULL, NULL, NULL, NULL); + ow = e_widget_button_add(evas, _("Select Window"), NULL, + _il_config_windows_select_indicator, NULL, NULL); e_widget_framelist_object_append(of, ow); ow = e_widget_check_add(evas, _("Match Window Class"), &il_cfg->policy.indicator.match.class); @@ -113,7 +138,8 @@ _il_config_windows_ui(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf e_widget_list_object_append(list, of, 1, 0, 0.0); of = e_widget_framelist_add(evas, _("Keyboard"), 0); - ow = e_widget_button_add(evas, _("Select Window"), NULL, NULL, NULL, NULL); + ow = e_widget_button_add(evas, _("Select Window"), NULL, + _il_config_windows_select_vkbd, NULL, NULL); e_widget_framelist_object_append(of, ow); ow = e_widget_check_add(evas, _("Match Window Class"), &il_cfg->policy.vkbd.match.class); @@ -138,7 +164,8 @@ _il_config_windows_ui(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf e_widget_list_object_append(list, of, 1, 0, 0.0); of = e_widget_framelist_add(evas, _("Softkey"), 0); - ow = e_widget_button_add(evas, _("Select Window"), NULL, NULL, NULL, NULL); + ow = e_widget_button_add(evas, _("Select Window"), NULL, + _il_config_windows_select_softkey, NULL, NULL); e_widget_framelist_object_append(of, ow); ow = e_widget_check_add(evas, _("Match Window Class"), &il_cfg->policy.softkey.match.class); @@ -194,6 +221,7 @@ _il_config_windows_select_window_create(void) Ecore_X_Cursor cursor = 0; int x, y, w, h; + selected_window = 0; root = ecore_x_window_root_first_get(); ecore_x_window_geometry_get(root, &x, &y, &w, &h); if (input_window) ecore_x_window_free(input_window); @@ -222,6 +250,8 @@ _il_config_windows_cb_key_down(void *data, int type, void *event) ecore_x_keyboard_ungrab(); ecore_x_window_free(input_window); input_window = 0; + selected_window = 0; + if (sel_hdl) ecore_event_handler_del(sel_hdl); return 0; } return 1; @@ -231,28 +261,184 @@ static int _il_config_windows_cb_mouse_up(void *data, int type, void *event) { Ecore_Event_Mouse_Button *ev; - Ecore_X_Window win; int x, y; ev = event; if (ev->buttons != 1) return 1; if (ev->window != input_window) return 1; ecore_x_pointer_last_xy_get(&x, &y); - win = ecore_x_window_at_xy_get(x, y); + selected_window = ecore_x_window_at_xy_get(x, y); if (key_hdl) ecore_event_handler_del(key_hdl); if (mouse_hdl) ecore_event_handler_del(mouse_hdl); ecore_x_keyboard_ungrab(); ecore_x_window_free(input_window); input_window = 0; - if (win) - { - - } + if (selected_window) + ecore_event_add(IL_EVENT_WINDOW_SELECTED, NULL, + _il_config_windows_event_free, NULL); return 0; } static void _il_config_windows_select_home(void *data, void *data2) { + sel_hdl = + ecore_event_handler_add(IL_EVENT_WINDOW_SELECTED, + _il_config_windows_home_selected, NULL); _il_config_windows_select_window_create(); } + +static void +_il_config_windows_select_vkbd(void *data, void *data2) +{ + sel_hdl = + ecore_event_handler_add(IL_EVENT_WINDOW_SELECTED, + _il_config_windows_vkbd_selected, NULL); + _il_config_windows_select_window_create(); +} + +static void +_il_config_windows_select_softkey(void *data, void *data2) +{ + sel_hdl = + ecore_event_handler_add(IL_EVENT_WINDOW_SELECTED, + _il_config_windows_softkey_selected, NULL); + _il_config_windows_select_window_create(); +} + +static void +_il_config_windows_select_indicator(void *data, void *data2) +{ + sel_hdl = + ecore_event_handler_add(IL_EVENT_WINDOW_SELECTED, + _il_config_windows_indicator_selected, NULL); + _il_config_windows_select_window_create(); +} + +static void +_il_config_windows_event_free(void *data, void *event) +{ + if (sel_hdl) ecore_event_handler_del(sel_hdl); + sel_hdl = NULL; + selected_window = 0; +} + +static int +_il_config_windows_home_selected(void *data, int type, void *event) +{ + char *title, *name, *class; + Ecore_X_Window_Type wtype; + + if (!selected_window) return 1; + title = ecore_x_icccm_title_get(selected_window); + ecore_x_icccm_name_class_get(selected_window, &name, &class); + ecore_x_netwm_window_type_get(selected_window, &wtype); + + if (il_cfg->policy.home.title) + eina_stringshare_del(il_cfg->policy.home.title); + if (il_cfg->policy.home.class) + eina_stringshare_del(il_cfg->policy.home.class); + if (il_cfg->policy.home.name) + eina_stringshare_del(il_cfg->policy.home.name); + + il_cfg->policy.home.title = eina_stringshare_add(title); + il_cfg->policy.home.class = eina_stringshare_add(class); + il_cfg->policy.home.name = eina_stringshare_add(name); + il_cfg->policy.home.win_type = wtype; + + if (title) free(title); + if (name) free(name); + if (class) free(class); + + return 1; +} + +static int +_il_config_windows_vkbd_selected(void *data, int type, void *event) +{ + char *title, *name, *class; + Ecore_X_Window_Type wtype; + + if (!selected_window) return 1; + title = ecore_x_icccm_title_get(selected_window); + ecore_x_icccm_name_class_get(selected_window, &name, &class); + ecore_x_netwm_window_type_get(selected_window, &wtype); + + if (il_cfg->policy.vkbd.title) + eina_stringshare_del(il_cfg->policy.vkbd.title); + if (il_cfg->policy.vkbd.class) + eina_stringshare_del(il_cfg->policy.vkbd.class); + if (il_cfg->policy.vkbd.name) + eina_stringshare_del(il_cfg->policy.vkbd.name); + + il_cfg->policy.vkbd.title = eina_stringshare_add(title); + il_cfg->policy.vkbd.class = eina_stringshare_add(class); + il_cfg->policy.vkbd.name = eina_stringshare_add(name); + il_cfg->policy.vkbd.win_type = wtype; + + if (title) free(title); + if (name) free(name); + if (class) free(class); + + return 1; +} + +static int +_il_config_windows_softkey_selected(void *data, int type, void *event) +{ + char *title, *name, *class; + Ecore_X_Window_Type wtype; + + if (!selected_window) return 1; + title = ecore_x_icccm_title_get(selected_window); + ecore_x_icccm_name_class_get(selected_window, &name, &class); + ecore_x_netwm_window_type_get(selected_window, &wtype); + + if (il_cfg->policy.softkey.title) + eina_stringshare_del(il_cfg->policy.softkey.title); + if (il_cfg->policy.softkey.class) + eina_stringshare_del(il_cfg->policy.softkey.class); + if (il_cfg->policy.softkey.name) + eina_stringshare_del(il_cfg->policy.softkey.name); + + il_cfg->policy.softkey.title = eina_stringshare_add(title); + il_cfg->policy.softkey.class = eina_stringshare_add(class); + il_cfg->policy.softkey.name = eina_stringshare_add(name); + il_cfg->policy.softkey.win_type = wtype; + + if (title) free(title); + if (name) free(name); + if (class) free(class); + + return 1; +} + +static int +_il_config_windows_indicator_selected(void *data, int type, void *event) +{ + char *title, *name, *class; + Ecore_X_Window_Type wtype; + + if (!selected_window) return 1; + title = ecore_x_icccm_title_get(selected_window); + ecore_x_icccm_name_class_get(selected_window, &name, &class); + ecore_x_netwm_window_type_get(selected_window, &wtype); + + if (il_cfg->policy.indicator.title) + eina_stringshare_del(il_cfg->policy.indicator.title); + if (il_cfg->policy.indicator.class) + eina_stringshare_del(il_cfg->policy.indicator.class); + if (il_cfg->policy.indicator.name) + eina_stringshare_del(il_cfg->policy.indicator.name); + + il_cfg->policy.indicator.title = eina_stringshare_add(title); + il_cfg->policy.indicator.class = eina_stringshare_add(class); + il_cfg->policy.indicator.name = eina_stringshare_add(name); + il_cfg->policy.indicator.win_type = wtype; + + if (title) free(title); + if (name) free(name); + if (class) free(class); + + return 1; +} diff --git a/src/modules/illume2/e_mod_windows.h b/src/modules/illume2/e_mod_windows.h index 34e8a2173..0371e2123 100644 --- a/src/modules/illume2/e_mod_windows.h +++ b/src/modules/illume2/e_mod_windows.h @@ -3,4 +3,6 @@ EAPI void il_config_windows_show(E_Container *con, const char *params); +extern EAPI int IL_EVENT_WINDOW_SELECTED; + #endif