1 #include "e_illume_private.h"
2 #include "policy_util.h"
5 #if 1 // for visibility
12 #define LOG_TAG "E17_EXTRA_MODULES"
15 /* NB: DIALOG_USES_PIXEL_BORDER is an experiment in setting dialog windows
16 * to use the 'pixel' type border. This is done because some dialogs,
17 * when shown, blend into other windows too much. Pixel border adds a
18 * little distinction between the dialog window and an app window.
19 * Disable if this is not wanted */
20 //#define DIALOG_USES_PIXEL_BORDER 1
23 #define ILLUME2_DEBUG 0
25 #define ILLUME2_TRACE printf
27 #define ILLUME2_TRACE(...)
30 typedef struct _E_Illume_Print_Info
34 } E_Illume_Print_Info;
37 #define COMP_MODULE_CONTROL
40 /*****************************/
41 /* local function prototypes */
42 /*****************************/
43 static void _policy_border_set_focus(E_Border *bd);
44 static void _policy_border_move(E_Border *bd, int x, int y);
45 static void _policy_border_resize(E_Border *bd, int w, int h);
46 static void _policy_border_show_below(E_Border *bd);
47 static void _policy_zone_layout_update(E_Zone *zone);
48 static void _policy_zone_layout_indicator(E_Border *bd, E_Illume_Config_Zone *cz);
49 static void _policy_zone_layout_quickpanel(E_Border *bd);
50 static void _policy_zone_layout_quickpanel_popup(E_Border *bd);
51 static void _policy_zone_layout_keyboard(E_Border *bd, E_Illume_Config_Zone *cz);
52 static void _policy_zone_layout_fullscreen(E_Border *bd);
53 static void _policy_zone_layout_dialog(E_Border *bd, E_Illume_Config_Zone *cz);
54 static void _policy_zone_layout_splash(E_Border *bd, E_Illume_Config_Zone *cz);
55 static void _policy_zone_layout_clipboard(E_Border *bd, E_Illume_Config_Zone *cz);
56 static void _policy_zone_layout_apptray(E_Border *bd);
58 static int _policy_window_rotation_angle_get(Ecore_X_Window win);
59 static Ecore_X_Window _policy_active_window_get(Ecore_X_Window root);
60 static int _policy_border_indicator_state_get(E_Border *bd);
62 static void _policy_layout_quickpanel_rotate (E_Illume_Quickpanel* qp, int angle);
64 static E_Illume_Border_Info* _policy_get_border_info (E_Border* bd);
65 static E_Illume_Border_Info* _policy_add_border_info_list (E_Border* bd);
66 static void _policy_delete_border_info_list (E_Border* bd);
67 static int _policy_compare_cb_border (E_Illume_Border_Info* data1, E_Illume_Border_Info* data2);
69 static void _policy_zone_layout_app_single_new (E_Illume_Border_Info* bd_info, E_Illume_Config_Zone* cz);
70 static void _policy_zone_layout_app_dual_top_new (E_Illume_Border_Info* bd_info, E_Illume_Config_Zone* cz);
71 static void _policy_zone_layout_app_dual_left_new (E_Illume_Border_Info* bd_info, E_Illume_Config_Zone* cz);
72 static void _policy_zone_layout_app_dual_custom_new (E_Illume_Border_Info* bd_info, E_Illume_Config_Zone* cz);
74 static int _policy_border_get_notification_level (Ecore_X_Window win);
75 static int _policy_notification_level_map(int level);
77 static void _policy_change_quickpanel_layer (E_Illume_Quickpanel* qp, E_Border* indi_bd, int layer, int level);
78 static void _policy_change_indicator_layer(E_Border *indi_bd, E_Border *bd, int layer, int level);
80 /* for property change */
81 static void _policy_property_window_state_change (Ecore_X_Event_Window_Property *event);
82 static void _policy_property_indicator_geometry_change (Ecore_X_Event_Window_Property *event);
83 static void _policy_property_clipboard_geometry_change (Ecore_X_Event_Window_Property *event);
84 static void _policy_property_clipboard_state_change (Ecore_X_Event_Window_Property *event);
85 static void _policy_property_indicator_geometry_change (Ecore_X_Event_Window_Property *event);
86 static void _policy_property_enlightenment_scale_change (Ecore_X_Event_Window_Property *event);
87 static void _policy_property_rotate_win_angle_change (Ecore_X_Event_Window_Property *event);
88 static void _policy_property_indicator_state_change (Ecore_X_Event_Window_Property *event);
89 static void _policy_property_indicator_opacity_change(Ecore_X_Event_Window_Property *event);
90 static void _policy_property_active_win_change (Ecore_X_Event_Window_Property *event);
91 static void _policy_property_win_type_change (Ecore_X_Event_Window_Property *event);
92 static void _policy_property_rotate_root_angle_change (Ecore_X_Event_Window_Property *event);
93 static void _policy_property_notification_level_change (Ecore_X_Event_Window_Property *event);
94 static void _policy_property_overlay_win_change (Ecore_X_Event_Window_Property *event);
95 static void _policy_property_window_opaque_change (Ecore_X_Event_Window_Property *event);
96 static void _policy_property_illume_window_state_change(Ecore_X_Event_Window_Property *event);
97 static void _policy_property_indicator_cmd_win_change(Ecore_X_Event_Window_Property *event);
98 static void _policy_property_active_indicator_win_change(Ecore_X_Event_Window_Property *event);
100 static void _policy_border_illume_window_state_change(E_Border *bd, unsigned int state);
102 static Eina_Bool _policy_border_cb_mouse_down(void *data, int type __UNUSED__, void *event);
103 static Eina_Bool _policy_border_cb_mouse_up(void *data, int type __UNUSED__, void *event);
104 static Eina_Bool _policy_border_cb_mouse_move(void *data, int type __UNUSED__, void *event);
106 static int _policy_property_window_opaque_get (Ecore_X_Window win);
108 static void _policy_border_focus_top_stack_set(E_Border *bd);
111 void _policy_border_list_print (Ecore_X_Window win);
113 #ifdef COMP_MODULE_CONTROL
114 static void _policy_property_composite_module_change (Ecore_X_Event_Window_Property *ev);
117 #if 1 // for visibility
118 static void _policy_manage_xwins (E_Manager* man);
119 static E_Illume_XWin_Info* _policy_xwin_info_find (Ecore_X_Window win);
120 static Eina_Bool _policy_xwin_info_add (Ecore_X_Window win);
121 static Eina_Bool _policy_xwin_info_delete (Ecore_X_Window win);
123 static void _policy_send_visibility_notify (Ecore_X_Window win, int visibility);
124 static void _policy_calculate_visibility (void);
127 static Eina_Bool _policy_root_angle_set(E_Border *bd);
128 static void _policy_change_root_angle_by_border_angle (E_Border* bd);
129 static void _policy_indicator_angle_change (E_Border* indi_bd, int angle);
131 static void _policy_border_transient_for_group_make(E_Border *bd, Eina_List** list);
132 static E_Border* _policy_border_transient_for_border_top_get(E_Border *bd);
133 static void _policy_border_transient_for_layer_set(E_Border *bd, E_Border *parent_bd, int layer);
135 /* for desktop mode */
136 static void _policy_zone_layout_app_single_monitor(E_Illume_Border_Info *bd_info, E_Illume_Config_Zone *cz);
138 /* for controling indicator */
139 static void _policy_border_indicator_control(E_Border *indi_bd);
140 static Eina_Bool _policy_border_indicator_state_change(E_Border *indi_bd, E_Border *bd);
141 static Ecore_X_Window _policy_indicator_cmd_win_get(Ecore_X_Window win);
142 static Ecore_X_Window _policy_active_indicator_win_get(Ecore_X_Window win);
144 static void _policy_resize_start(E_Illume_Border_Info *bd_info);
145 static void _policy_resize_end(E_Illume_Border_Info *bd_info);
146 static void _policy_border_illume_handlers_add(E_Illume_Border_Info *bd_info);
147 static void _policy_border_illume_handlers_remove(E_Illume_Border_Info *bd_info);
149 static void _policy_border_root_angle_control(E_Zone *zone);
150 static int _policy_border_layer_map(int layer);
153 static void _policy_msg_handler(void *data, const char *name, const char *info, int val, E_Object *obj, void *msgdata);
156 static void _policy_border_force_iconify(E_Border *bd);
157 static void _policy_border_force_uniconify(E_Border *bd);
158 static void _policy_border_iconify_by_illume(E_Illume_XWin_Info *xwin_info);
159 static void _policy_border_uniconify_below_borders_by_illume(E_Illume_XWin_Info *xwin_info);
160 static E_Border* _policy_border_find_below(E_Border *bd);
161 static void _policy_border_uniconify_below_borders(E_Border *bd);
162 static void _policy_border_uniconify_top_border(E_Border *bd);
164 /* for supporting rotation */
165 static void _policy_border_dependent_rotation(E_Border *bd);
166 static Eina_List* _policy_dependent_rotation_list_make(E_Border *bd);
168 /*******************/
169 /* local variables */
170 /*******************/
172 /* for active/deactive message */
173 static Ecore_X_Window g_active_win = 0;
174 static Ecore_X_Window g_active_pid = 0;
177 int g_root_angle = 0;
178 Ecore_X_Window g_rotated_win = 0;
180 /* for focus stack */
181 static Eina_List *_pol_focus_stack;
183 /* for border information */
184 static Eina_List* e_border_info_list = NULL;
186 /* for notification level */
187 static Ecore_X_Atom E_ILLUME_ATOM_NOTIFICATION_LEVEL;
189 /* for active/deactive message */
190 static Ecore_X_Atom E_ILLUME_ATOM_ACTIVATE_WINDOW;
191 static Ecore_X_Atom E_ILLUME_ATOM_DEACTIVATE_WINDOW;
194 static Ecore_X_Atom E_ILLUME_ATOM_OVERAY_WINDOW;
195 static Ecore_X_Atom E_ILLUME_ATOM_WINDOW_OPAQUE;
198 static Ecore_X_Atom E_ILLUME_ATOM_STACK_DISPLAY;
199 static Ecore_X_Atom E_ILLUME_ATOM_STACK_DISPLAY_DONE;
202 static Ecore_X_Window g_indi_control_win;
204 #ifdef COMP_MODULE_CONTROL
205 static Ecore_X_Atom E_ILLUME_ATOM_COMP_MODULE_ENABLED;
208 /* for supporting rotation */
209 static Ecore_X_Atom E_INDICATOR_CMD_WIN;
210 static Ecore_X_Atom E_ACTIVE_INDICATOR_WIN;
212 #if 1 // for visibility
213 static Eina_Hash* _e_illume_xwin_info_hash = NULL;
214 static Eina_Inlist* _e_illume_xwin_info_list = NULL;
215 static Ecore_X_Window _e_overlay_win = 0;
216 static int _g_root_width;
217 static int _g_root_height;
221 static E_Msg_Handler *_e_illume_msg_handler = NULL;
222 static Eina_Bool _e_use_comp = EINA_FALSE;
223 static Eina_Bool _g_visibility_changed = EINA_FALSE;
225 /* for supporing rotation */
226 typedef struct _E_Policy_Rotation_Dependent E_Policy_Rotation_Dependent;
228 struct _E_Policy_Rotation_Dependent
235 Ecore_X_Window cmd_win;
236 Ecore_X_Window active_win;
242 static E_Policy_Rotation_Dependent dep_rot =
250 /* local functions */
252 _policy_border_set_focus(E_Border *bd)
256 /* if focus is locked out then get out */
257 if (bd->lock_focus_out) return;
259 /* make sure the border can accept or take focus */
260 if ((bd->client.icccm.accepts_focus) || (bd->client.icccm.take_focus))
262 /* check E's focus settings */
263 if ((e_config->focus_setting == E_FOCUS_NEW_WINDOW) ||
265 ((e_config->focus_setting == E_FOCUS_NEW_DIALOG) ||
266 ((bd->parent->focused) &&
267 (e_config->focus_setting == E_FOCUS_NEW_DIALOG_IF_OWNER_FOCUSED)))))
269 /* if the border was hidden due to layout, we need to unhide */
270 if (!bd->visible) e_illume_border_show(bd);
272 /* if the border is iconified then uniconify */
275 /* if the user is allowed to uniconify, then do it */
276 if (!bd->lock_user_iconify) e_border_uniconify(bd);
279 /* if we can raise the border do it */
280 if (!bd->lock_user_stacking) e_border_raise(bd);
282 /* focus the border */
283 e_border_focus_set(bd, 1, 1);
285 /* NB: since we skip needless border evals when container layout
286 * is called (to save cpu cycles), we need to
287 * signal this border that it's focused so that the edj gets
290 * This is potentially useless as THIS policy
291 * makes all windows borderless anyway, but it's in here for
293 e_border_focus_latest_set(bd);
295 edje_object_signal_emit(bd->bg_object, "e,state,focused", "e");
297 edje_object_signal_emit(bd->icon_object, "e,state,focused", "e");
298 e_focus_event_focus_in(bd);
305 _policy_border_move(E_Border *bd, int x, int y)
309 /* NB: Qt uses a weird window type called 'VCLSalFrame' that needs to
310 * have bd->placed set else it doesn't position correctly...
311 * this could be a result of E honoring the icccm request position,
314 e_border_move (bd, x, y);
318 _policy_border_resize(E_Border *bd, int w, int h)
322 e_border_resize (bd, w, h);
326 _policy_border_show_below(E_Border *bd)
332 // printf("Show Borders Below: %s %d %d\n",
333 // bd->client.icccm.class, bd->x, bd->y);
337 if (bd->client.icccm.transient_for)
339 if ((prev = e_border_find_by_client_window(bd->client.icccm.transient_for)))
341 _policy_border_set_focus(prev);
346 /* determine layering position */
347 pos = _policy_border_layer_map(bd->layer);
349 /* Find the windows below this one */
350 for (i = pos; i >= 2; i--)
354 EINA_LIST_REVERSE_FOREACH(bd->zone->container->layers[i].clients, l, b)
358 /* skip if it's the same border */
359 if (b == bd) continue;
361 /* skip if it's not on this zone */
362 if (b->zone != bd->zone) continue;
364 /* skip special borders */
365 if (e_illume_border_is_indicator(b)) continue;
366 if (e_illume_border_is_keyboard(b)) continue;
367 if (e_illume_border_is_keyboard_sub(b)) continue;
368 if (e_illume_border_is_quickpanel(b)) continue;
369 if (e_illume_border_is_quickpanel_popup(b)) continue;
370 if (e_illume_border_is_clipboard(b)) continue;
372 if ((bd->fullscreen) || (bd->need_fullscreen))
374 _policy_border_set_focus(b);
379 /* need to check x/y position */
380 if (E_CONTAINS(bd->x, bd->y, bd->w, bd->h,
381 b->x, b->y, b->w, b->h))
383 _policy_border_set_focus(b);
390 /* if we reach here, then there is a problem with showing a window below
391 * this one, so show previous window in stack */
392 EINA_LIST_REVERSE_FOREACH(_pol_focus_stack, l, prev)
395 if (prev->zone != bd->zone) continue;
396 _policy_border_set_focus(prev);
402 _policy_zone_layout_update(E_Zone *zone)
409 EINA_LIST_FOREACH(e_border_client_list(), l, bd)
413 /* skip borders not on this zone */
414 if (bd->zone != zone) continue;
416 /* skip special windows */
417 if (e_illume_border_is_keyboard(bd)) continue;
418 if (e_illume_border_is_keyboard_sub(bd)) continue;
419 if (e_illume_border_is_quickpanel(bd)) continue;
420 if (e_illume_border_is_quickpanel_popup(bd)) continue;
422 /* signal a changed pos here so layout gets updated */
429 _policy_zone_layout_indicator(E_Border *bd, E_Illume_Config_Zone *cz)
431 ILLUME2_TRACE ("[ILLUME2] %s (%d) win = 0x%07x\n", __func__, __LINE__, bd->client.win);
433 if ((!bd) || (!cz)) return;
435 /* grab minimum indicator size */
436 //e_illume_border_min_get(bd, NULL, &cz->indicator.size);
438 /* no point in doing anything here if indicator is hidden */
439 if ((!bd->new_client) && (!bd->visible)) return;
441 /* if we are dragging, then skip it for now */
442 if (bd->client.illume.drag.drag)
444 /* when dragging indicator, we need to trigger a layout update */
445 _policy_zone_layout_update(bd->zone);
449 /* lock indicator window from dragging if we need to */
450 if ((cz->mode.dual == 1) && (cz->mode.side == 0))
451 ecore_x_e_illume_drag_locked_set(bd->client.win, 0);
453 ecore_x_e_illume_drag_locked_set(bd->client.win, 1);
455 /* make sure it's the required width & height */
456 int rotation = _policy_window_rotation_angle_get(bd->client.win);
457 if(rotation == -1) return;
459 ILLUME2_TRACE ("ILLUME2] INDICATOR'S ANGLE = %d\n", rotation);
461 // check indicator's rotation info and then set it's geometry
462 if (rotation == 0 || rotation == 180)
464 ecore_x_e_illume_indicator_geometry_set(bd->zone->black_win, bd->x, bd->y, bd->w, bd->h);
465 ecore_x_e_illume_indicator_geometry_set(bd->zone->container->manager->root, bd->x, bd->y, bd->w, bd->h);
469 ecore_x_e_illume_indicator_geometry_set(bd->zone->black_win, bd->zone->x, bd->zone->y, bd->h, bd->w);
470 ecore_x_e_illume_indicator_geometry_set(bd->zone->container->manager->root, bd->zone->x, bd->zone->y, bd->h, bd->w);
475 _policy_zone_layout_quickpanel(E_Border *bd)
479 if (E_ILLUME_BORDER_IS_IN_MOBILE(bd))
481 if ((bd->w != bd->zone->w) || (bd->h != bd->zone->h))
482 _policy_border_resize(bd, bd->zone->w, bd->zone->h);
487 rotation = _policy_window_rotation_angle_get (bd->client.win);
488 ILLUME2_TRACE ("[ILLUME2-QUICKPANEL] _policy_zone_layout_quickpanel..(%d) rotation angle = %d\n", __LINE__, rotation);
490 if (rotation == 0 || rotation == 180)
492 if ((bd->w != bd->zone->w))
494 ILLUME2_TRACE ("[ILLUME2-QUICKPANEL] CHANGE QUICK-PANEL SIZE to Portrait..(%d) old (%d, %d) new (%d, %d)\n", __LINE__, bd->w, bd->h, bd->zone->w, bd->h);
495 _policy_border_resize(bd, bd->zone->w, bd->h);
500 if ((bd->h != bd->zone->h))
502 ILLUME2_TRACE ("[ILLUME2-QUICKPANEL] CHANGE QUICK-PANEL SIZE to Landscape..(%d) old (%d, %d) new (%d, %d)\n", __LINE__, bd->w, bd->h, bd->w, bd->zone->h);
503 _policy_border_resize(bd, bd->w, bd->zone->h);
509 static void _policy_zone_layout_quickpanel_popup(E_Border *bd)
517 _policy_zone_layout_keyboard(E_Border *bd, E_Illume_Config_Zone *cz)
519 if ((!bd) || (!cz)) return;
521 /* no point in adjusting size or position if it's not visible */
522 if (!bd->visible) return;
524 /* set layer if needed */
525 if (bd->client.icccm.transient_for == 0)
527 if (bd->layer != POL_KEYBOARD_LAYER)
528 e_border_layer_set(bd, POL_KEYBOARD_LAYER);
534 _policy_zone_layout_fullscreen(E_Border *bd)
536 // printf("\tLayout Fullscreen: %s\n", bd->client.icccm.name);
540 /* make sure it's the required width & height */
541 if ((bd->w != bd->zone->w) || (bd->h != bd->zone->h))
542 _policy_border_resize(bd, bd->zone->w, bd->zone->h);
544 /* set layer if needed */
545 if (bd->layer != POL_FULLSCREEN_LAYER)
546 e_border_layer_set(bd, POL_FULLSCREEN_LAYER);
550 _policy_zone_layout_dialog(E_Border *bd, E_Illume_Config_Zone *cz)
554 Eina_Bool resize = EINA_FALSE;
555 Eina_Bool move = EINA_FALSE;
557 // printf("\tLayout Dialog: %s\n", bd->client.icccm.name);
559 /* NB: This policy ignores any ICCCM requested positions and centers the
560 * dialog on it's parent (if it exists) or on the zone */
562 if ((!bd) || (!cz)) return;
564 /* no point in adjusting size or position if it's not visible */
565 if (!bd->visible) return;
567 /* grab minimum size */
568 e_illume_border_min_get(bd, &mw, &mh);
570 /* make sure it fits in this zone */
571 if (mw > bd->zone->w) mw = bd->zone->w;
572 if (mh > bd->zone->h) mh = bd->zone->h;
574 if (mw < bd->w) mw = bd->w;
575 if (mh < bd->h) mh = bd->h;
577 /* try to get this dialog's parent if it exists */
578 parent = e_illume_border_parent_get(bd);
580 /* if we have no parent, or we are in dual mode, then center on zone */
581 /* NB: we check dual mode because if we are in dual mode, dialogs tend to
582 * be too small to be useful when positioned on the parent, so center
583 * on zone. We could check their size first here tho */
584 if ((!parent) || (cz->mode.dual == 1))
586 /* no parent or dual mode, center on screen */
587 nx = (bd->zone->x + ((bd->zone->w - mw) / 2));
588 ny = (bd->zone->y + ((bd->zone->h - mh) / 2));
592 /* NB: there is an assumption here that the parent has already been
593 * layed out on screen. This could be bad. Needs Testing */
595 /* make sure we are not larger than the parent window */
596 if (mw > parent->w) mw = parent->w;
597 if (mh > parent->h) mh = parent->h;
599 /* center on parent */
600 nx = (parent->x + ((parent->w - mw) / 2));
601 ny = (parent->y + ((parent->h - mh) / 2));
604 /* make sure it's the required width & height */
605 if ((bd->w != mw) || (bd->h != mh))
608 /* make sure it's in the correct position */
609 if ((bd->x != nx) || (bd->y != ny))
613 e_border_move_resize(bd, nx, ny, mw, mh);
615 _policy_border_resize(bd, mw, mh);
617 _policy_border_move(bd, nx, ny);
619 /* set layer if needed */
620 if (bd->layer != POL_DIALOG_LAYER) e_border_layer_set(bd, POL_DIALOG_LAYER);
624 _policy_zone_layout_splash(E_Border *bd, E_Illume_Config_Zone *cz)
627 Eina_Bool resize = EINA_FALSE;
628 Eina_Bool move = EINA_FALSE;
630 if ((!bd) || (!cz)) return;
632 /* no point in adjusting size or position if it's not visible */
633 if ((!bd->new_client) && (!bd->visible)) return;
635 /* grab minimum size */
636 e_illume_border_min_get(bd, &mw, &mh);
638 /* make sure it fits in this zone */
639 if (mw > bd->zone->w) mw = bd->zone->w;
640 if (mh > bd->zone->h) mh = bd->zone->h;
642 if (mw < bd->w) mw = bd->w;
643 if (mh < bd->h) mh = bd->h;
645 nx = (bd->zone->x + ((bd->zone->w - mw) / 2));
646 ny = (bd->zone->y + ((bd->zone->h - mh) / 2));
648 if ((bd->w != mw) || (bd->h != mh))
651 if ((bd->x != nx) || (bd->y != ny))
655 e_border_move_resize(bd, nx, ny, mw, mh);
657 _policy_border_resize(bd, mw, mh);
659 _policy_border_move(bd, nx, ny);
663 _policy_zone_layout_clipboard(E_Border *bd, E_Illume_Config_Zone *cz)
665 /* no point in adjusting size or position if it's not visible */
666 if (!bd->visible) return;
668 /* set layer if needed */
669 if (bd->layer != POL_CLIPBOARD_LAYER)
670 e_border_layer_set(bd, POL_CLIPBOARD_LAYER);
674 _policy_zone_layout_apptray(E_Border *bd)
678 if (E_ILLUME_BORDER_IS_IN_MOBILE(bd))
680 if ((bd->w != bd->zone->w) || (bd->h != bd->zone->h))
681 _policy_border_resize(bd, bd->zone->w, bd->zone->h);
684 /* set layer if needed */
685 if (bd->layer != POL_APPTRAY_LAYER)
686 e_border_layer_set(bd, POL_APPTRAY_LAYER);
690 _policy_zone_layout_miniapptray(E_Border *bd)
694 if (E_ILLUME_BORDER_IS_IN_MOBILE(bd))
696 if ((bd->w != bd->zone->w) || (bd->h != bd->zone->h))
697 _policy_border_resize(bd, bd->zone->w, bd->zone->h);
700 /* set layer if needed */
701 if (bd->layer != POL_APPTRAY_LAYER)
702 e_border_layer_set(bd, POL_APPTRAY_LAYER);
705 /* policy functions */
707 _policy_border_add(E_Border *bd)
709 // printf("Border added: %s\n", bd->client.icccm.class);
713 /* NB: this call sets an atom on the window that specifices the zone.
714 * the logic here is that any new windows created can access the zone
715 * window by a 'get' call. This is useful for elementary apps as they
716 * normally would not have access to the zone window. Typical use case
717 * is for indicator & softkey windows so that they can send messages
718 * that apply to their respective zone only. Example: softkey sends close
719 * messages (or back messages to cycle focus) that should pertain just
720 * to it's current zone */
721 ecore_x_e_illume_zone_set(bd->client.win, bd->zone->black_win);
723 ILLUME2_TRACE ("[ILLUME2-NEW] %s(%d)... bd = 0x%07x\n", __func__, __LINE__, bd->client.win);
725 /* ignore stolen borders. These are typically quickpanel or keyboards */
728 if (e_illume_border_is_quickpanel(bd) ||
729 e_illume_border_is_quickpanel_popup(bd))
732 E_Illume_Border_Info* bd_info = NULL;
733 E_Illume_Border_Info* indi_bd_info = NULL;
735 /* try to get the Indicator on this zone */
736 if ((indi_bd = e_illume_border_indicator_get(bd->zone)))
738 if ((indi_bd_info = _policy_get_border_info(indi_bd)))
740 if ((bd_info = _policy_get_border_info(bd)))
741 bd_info->level = indi_bd_info->level;
748 /* Add this border to our focus stack if it can accept or take focus */
749 if ((bd->client.icccm.accepts_focus) || (bd->client.icccm.take_focus))
750 _pol_focus_stack = eina_list_append(_pol_focus_stack, bd);
752 if (e_illume_border_is_indicator(bd))
753 _policy_zone_layout_update(bd->zone);
756 /* set focus on new border if we can */
757 _policy_border_set_focus(bd);
760 if (e_illume_border_is_indicator (bd))
762 E_Illume_Config_Zone *cz;
763 cz = e_illume_zone_config_get(bd->zone->id);
766 ILLUME2_TRACE ("[ILLUME2] ADD INDICATOR WINDOW... win = 0x%07x, Save indicator's size = %d!!!\n", bd->client.win, bd->h);
767 cz->indicator.size = bd->h;
770 if (_e_illume_cfg->use_indicator_widget)
772 L(LT_ANGLE, "[ILLUME2][ANGLE] %s(%d)... Control Root Angle.\n", __func__, __LINE__);
773 _policy_border_root_angle_control(bd->zone);
777 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... win = 0x%07x.. Control Indicator.\n", __func__, __LINE__, bd->client.win);
778 _policy_border_indicator_control(bd);
784 _policy_border_del(E_Border *bd)
786 // printf("Border deleted: %s\n", bd->client.icccm.class);
787 E_Illume_XWin_Info* xwin_info;
788 Eina_Bool is_rotated_win = EINA_FALSE;
792 /* if this is a fullscreen window, than we need to show indicator window */
793 /* NB: we could use the e_illume_border_is_fullscreen function here
794 * but we save ourselves a function call this way */
795 if ((bd->fullscreen) || (bd->need_fullscreen))
799 /* try to get the Indicator on this zone */
800 if ((indi_bd = e_illume_border_indicator_get(bd->zone)))
802 /* we have the indicator, show it if needed */
803 if (!indi_bd->visible)
805 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... Show Indicator (by win: 0x%07x)\n", __func__, __LINE__, bd->client.win);
806 e_illume_border_show(indi_bd);
811 if (e_illume_border_is_clipboard(bd))
813 ecore_x_e_illume_clipboard_state_set(bd->zone->black_win, ECORE_X_ILLUME_CLIPBOARD_STATE_OFF);
816 /* remove from our focus stack */
817 if ((bd->client.icccm.accepts_focus) || (bd->client.icccm.take_focus))
818 _pol_focus_stack = eina_list_remove(_pol_focus_stack, bd);
820 if (g_rotated_win == bd->client.win)
822 is_rotated_win = EINA_TRUE;
826 xwin_info = _policy_xwin_info_find (bd->win);
829 if (_e_illume_cfg->use_force_iconify)
831 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d)... DELETE win:0x%07x\n", __func__, __LINE__, bd->client.win);
832 if (!(e_illume_border_is_indicator(bd) ||
833 e_illume_border_is_keyboard(bd) ||
834 e_illume_border_is_keyboard_sub(bd) ||
835 e_illume_border_is_quickpanel(bd) ||
836 e_illume_border_is_quickpanel_popup(bd) ||
837 e_illume_border_is_clipboard(bd) ||
838 e_illume_border_is_app_tray(bd) ||
839 e_illume_border_is_miniapp_tray(bd)))
841 _policy_border_uniconify_below_borders_by_illume(xwin_info);
845 if (xwin_info->visibility != E_ILLUME_VISIBILITY_FULLY_OBSCURED)
847 if (_e_illume_cfg->use_indicator_widget)
849 if ((bd->w == bd->zone->w) && (bd->h == bd->zone->h))
851 L(LT_ANGLE, "[ILLUME2][ANGLE] %s(%d)... Deleted win:0x%07x. Control Root Angle.\n", __func__, __LINE__, bd->client.win);
852 _policy_border_root_angle_control(bd->zone);
858 indi_bd = e_illume_border_indicator_get(bd->zone);
861 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... win = 0x%07x.. Control Indicator.\n", __func__, __LINE__, bd->client.win);
862 _policy_border_indicator_control(indi_bd);
866 xwin_info->bd_info = NULL;
867 xwin_info->attr.visible = 0;
868 xwin_info->viewable = EINA_FALSE;
869 xwin_info->is_drawed = EINA_FALSE;
872 E_Illume_Border_Info* bd_info = _policy_get_border_info(bd);
875 if (bd_info->resize_req.mouse.down)
877 e_grabinput_release(bd->event_win, bd->event_win);
879 if (bd_info->resize_req.mouse.resize)
881 Evas_Object *o = (Evas_Object *)e_object_data_get(E_OBJECT(bd));
882 if (o) evas_object_del(o);
885 /* set property on zone window that a drag is finished */
886 ecore_x_e_illume_drag_set(bd->zone->black_win, 0);
888 _policy_border_illume_handlers_remove(bd_info);
892 _policy_delete_border_info_list (bd);
894 if (e_illume_border_is_indicator(bd))
896 E_Illume_Config_Zone *cz;
898 /* get the config for this zone */
899 cz = e_illume_zone_config_get(bd->zone->id);
900 if (cz) cz->indicator.size = 0;
901 _policy_zone_layout_update(bd->zone);
905 /* show the border below this one */
906 _policy_border_show_below(bd);
909 if (e_illume_border_is_lock_screen(bd))
911 if (_e_illume_cfg->use_mem_trim)
913 /* heap and stack trim */
914 e_illume_util_mem_trim();
918 // for supporting rotation such as quickpanel
919 if (e_illume_border_is_quickpanel(bd) ||
920 e_illume_border_is_miniapp_tray(bd))
921 dep_rot.list = eina_list_remove(dep_rot.list, bd);
925 _policy_border_focus_in(E_Border *bd __UNUSED__)
927 // printf("Border focus in: %s\n", bd->client.icccm.name);
931 _policy_border_focus_out(E_Border *bd)
933 // printf("Border focus out: %s\n", bd->client.icccm.name);
937 /* NB: if we got this focus_out event on a deleted border, we check if
938 * it is a transient (child) of another window. If it is, then we
939 * transfer focus back to the parent window */
940 if (e_object_is_del(E_OBJECT(bd)))
942 if (e_illume_border_is_dialog(bd))
946 if ((parent = e_illume_border_parent_get(bd)))
947 _policy_border_set_focus(parent);
953 _policy_border_activate(E_Border *bd)
955 // printf("Border Activate: %s\n", bd->client.icccm.name);
958 /* NB: stolen borders may or may not need focus call...have to test */
959 if (bd->stolen) return;
961 /* NB: We cannot use our set_focus function here because it does,
962 * occasionally fall through wrt E's focus policy, so cherry pick the good
963 * parts and use here :) */
965 /* if the border is iconified then uniconify if allowed */
966 if ((bd->iconic) && (!bd->lock_user_iconify))
967 e_border_uniconify(bd);
969 ILLUME2_TRACE ("[ILLUME2] _policy_border_activate.. (%d) ACTIVE WIN = 0x%07x\n", __LINE__, bd->client.win);
971 /* NB: since we skip needless border evals when container layout
972 * is called (to save cpu cycles), we need to
973 * signal this border that it's focused so that the edj gets
976 * This is potentially useless as THIS policy
977 * makes all windows borderless anyway, but it's in here for
979 e_border_focus_latest_set(bd);
981 edje_object_signal_emit(bd->bg_object, "e,state,focused", "e");
983 edje_object_signal_emit(bd->icon_object, "e,state,focused", "e");
984 e_focus_event_focus_in(bd);
989 _policy_border_post_fetch(E_Border *bd)
991 // printf("Border post fetch\n");
995 /* NB: for this policy we disable all remembers set on a border */
996 if (bd->remember) e_remember_del(bd->remember);
999 /* set this border to borderless */
1000 #ifdef DIALOG_USES_PIXEL_BORDER
1001 if ((e_illume_border_is_dialog(bd)) && (e_illume_border_parent_get(bd)))
1002 eina_stringshare_replace(&bd->bordername, "pixel");
1006 /* for desktop mode */
1007 if (E_ILLUME_BORDER_IS_IN_MOBILE(bd))
1009 else if (E_ILLUME_BORDER_IS_IN_DESKTOP(bd))
1011 if (!bd->client.illume.win_state.state)
1018 // for supporting rotation such as quickpanel
1019 if (e_illume_border_is_quickpanel(bd) ||
1020 e_illume_border_is_miniapp_tray(bd))
1022 bd->client.e.state.rot.type = E_BORDER_ROTATION_TYPE_DEPENDENT;
1023 if (eina_list_data_find(dep_rot.list, bd) != bd)
1025 dep_rot.list = eina_list_append(dep_rot.list, bd);
1029 /* tell E the border has changed */
1030 bd->client.border.changed = 1;
1035 _policy_border_post_new_border(E_Border *bd)
1038 E_Illume_Border_Info* bd_info = NULL;
1042 bd_info = _policy_get_border_info(bd);
1043 if (!bd_info) return;
1045 bd_info->win_type = bd->client.netwm.type;
1047 if (e_illume_border_is_notification(bd))
1049 bd_info->level = _policy_border_get_notification_level(bd->client.win);
1050 layer = _policy_notification_level_map(bd_info->level);
1051 e_border_layer_set(bd, layer);
1052 L (LT_NOTIFICATION, "[ILLUME2][NOTIFICATION] %s(%d)... win (0x%07x) is notification window... level = %d\n",
1053 __func__, __LINE__, bd->client.win, bd_info->level);
1059 _check_parent_in_transient_for_tree(E_Border *bd, E_Border *parent_bd)
1063 if (!bd || !parent_bd) return EINA_FALSE;
1065 ancestor = parent_bd;
1066 while (ancestor->parent)
1068 if (ancestor->parent == bd)
1070 // This is very bad. bd and parent_bd are transient_for each other
1072 LOGD("[WM] Transient_for Error!!! Win:0x%07x and Parent:0x%07x are transient_for each other.", bd->client.win, parent_bd->client.win);
1074 ELBF(ELBT_ILLUME, 0, bd->client.win, "BAD. Transient_for Error. Parent:0x%07x is descendant", parent_bd->client.win);
1077 ancestor = ancestor->parent;
1084 _policy_border_pre_fetch(E_Border *bd)
1086 #ifdef _F_DEICONIFY_APPROVE_
1087 Eina_Bool change_parent = EINA_TRUE;
1095 state = ecore_x_e_illume_window_state_get(bd->client.win);
1096 _policy_border_illume_window_state_change(bd, state);
1099 /* Below code are same to _e_border_eval0 in e_border.c.
1100 But we added code to handle notification window */
1101 if (bd->client.icccm.fetch.transient_for)
1103 /* TODO: What do to if the transient for isn't mapped yet? */
1104 E_Border *bd_parent = NULL;
1105 E_Illume_XWin_Info *xwin_info = NULL;
1106 Eina_Bool transient_each_other;
1108 if (_e_illume_cfg->use_force_iconify)
1109 xwin_info = _policy_xwin_info_find(bd->win);
1111 bd->client.icccm.transient_for = ecore_x_icccm_transient_for_get(bd->client.win);
1112 if (bd->client.icccm.transient_for)
1114 bd_parent = e_border_find_by_client_window(bd->client.icccm.transient_for);
1117 /* If we already have a parent, remove it */
1120 #ifdef _F_DEICONIFY_APPROVE_
1121 if (bd_parent == bd->parent) change_parent = EINA_FALSE;
1123 bd->parent->transients = eina_list_remove(bd->parent->transients, bd);
1124 if (bd->parent->modal == bd) bd->parent->modal = NULL;
1128 L(LT_TRANSIENT_FOR, "[ILLUME2][TRANSIENT_FOR] %s(%d)... win:0x%07x, parent:0x%07x\n", __func__, __LINE__, bd->client.win, bd->client.icccm.transient_for);
1131 transient_each_other = _check_parent_in_transient_for_tree(bd, bd_parent);
1132 if (!transient_each_other)
1134 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d).. win:0x%07x(iconic:%d, by_wm:%d), parent:0x%07x(iconic:%d)\n", __func__, __LINE__, bd->client.win, bd->iconic, xwin_info ? xwin_info->iconify_by_wm : -100, bd_parent->client.win, bd_parent->iconic);
1135 if (_e_illume_cfg->use_force_iconify)
1137 if (!bd_parent->iconic)
1139 if (xwin_info && xwin_info->iconify_by_wm)
1143 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d).. FORCE UNICONIFY... win:0x%07x\n", __func__, __LINE__, bd->client.win);
1144 _policy_border_force_uniconify(bd);
1150 if (bd_parent != bd)
1152 bd->parent = bd_parent;
1153 _policy_border_transient_for_layer_set(bd, bd->parent, bd->parent->layer);
1154 bd_parent->transients = eina_list_append(bd_parent->transients, bd);
1156 if ((e_config->modal_windows) && (bd->client.netwm.state.modal))
1157 bd->parent->modal = bd;
1159 if (e_config->focus_setting == E_FOCUS_NEW_DIALOG ||
1160 (bd->parent->focused && (e_config->focus_setting == E_FOCUS_NEW_DIALOG_IF_OWNER_FOCUSED)))
1166 #ifdef _F_DEICONIFY_APPROVE_
1169 E_Border *ancestor_bd;
1170 bd->client.e.state.deiconify_approve.render_done = 0;
1172 ancestor_bd = bd->client.e.state.deiconify_approve.ancestor;
1173 if ((ancestor_bd) &&
1174 (!e_object_is_del(E_OBJECT(ancestor_bd))))
1176 ancestor_bd->client.e.state.deiconify_approve.req_list = eina_list_remove(ancestor_bd->client.e.state.deiconify_approve.req_list, bd);
1177 bd->client.e.state.deiconify_approve.ancestor = NULL;
1179 if ((ancestor_bd->client.e.state.deiconify_approve.req_list == NULL) &&
1180 (ancestor_bd->client.e.state.deiconify_approve.render_done))
1182 if (ancestor_bd->client.e.state.deiconify_approve.wait_timer)
1184 ecore_timer_del(ancestor_bd->client.e.state.deiconify_approve.wait_timer);
1185 ancestor_bd->client.e.state.deiconify_approve.wait_timer = NULL;
1186 e_border_uniconify(ancestor_bd);
1193 bd->client.icccm.fetch.transient_for = 0;
1198 _policy_border_new_border(E_Border *bd)
1203 ecore_x_e_illume_zone_set(bd->client.win, bd->zone->black_win);
1205 _policy_add_border_info_list(bd);
1208 #ifdef _F_BORDER_HOOK_PATCH_
1210 _policy_border_del_border(E_Border *bd)
1216 _policy_border_del(bd);
1222 _policy_border_post_assign(E_Border *bd)
1224 // printf("Border post assign\n");
1227 if (!bd->new_client) return;
1229 bd->internal_no_remember = 1;
1231 /* do not allow client to change these properties */
1232 bd->lock_client_shade = 1;
1234 if (e_illume_border_is_utility (bd))
1236 ILLUME2_TRACE ("[ILLUME2-NEW] %s(%d)... win(0x%07x) is UTILITY type.. SET REQUEST_POS!!!\n", __func__, __LINE__, bd->client.win);
1237 bd->client.icccm.request_pos = 1;
1240 /* do not allow the user to change these properties */
1241 /* for desktop mode */
1242 if (E_ILLUME_BORDER_IS_IN_MOBILE(bd))
1244 if (bd->client.illume.win_state.state)
1246 bd->lock_user_location = 0;
1247 bd->lock_user_size = 0;
1251 bd->lock_user_location = 1;
1252 bd->lock_user_size = 1;
1254 bd->lock_user_shade = 1;
1255 if (bd->client.icccm.request_pos == 0)
1258 bd->changes.pos = 1;
1262 bd->lock_user_shade = 1;
1264 /* clear any centered states */
1265 /* NB: this is mainly needed for E's main config dialog */
1266 bd->client.e.state.centered = 0;
1268 /* lock the border type so user/client cannot change */
1269 bd->lock_border = 1;
1273 _policy_border_show(E_Border *bd)
1277 /* make sure we have a name so that we don't handle windows like E's root */
1278 if (!bd->client.icccm.name) return;
1280 // printf("Border Show: %s\n", bd->client.icccm.class);
1282 /* trap for special windows so we can ignore hides below them */
1283 if (e_illume_border_is_indicator(bd)) return;
1284 if (e_illume_border_is_quickpanel(bd)) return;
1285 if (e_illume_border_is_quickpanel_popup(bd)) return;
1287 if (e_illume_border_is_keyboard(bd))
1290 angle = _policy_window_rotation_angle_get(bd->client.win);
1293 if (angle != g_root_angle)
1295 L(LT_ANGLE, "[ILLUME2][ANGLE] %s(%d)... win = 0x%07x.. SEND client Event with angle = %d\n", __func__, __LINE__, bd->client.win, g_root_angle);
1296 ecore_x_client_message32_send(bd->client.win, ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE,
1297 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, g_root_angle, g_active_win, 0, 0, 0);
1304 if (e_illume_border_is_clipboard(bd))
1306 ecore_x_e_illume_clipboard_state_set(bd->zone->black_win, ECORE_X_ILLUME_CLIPBOARD_STATE_ON);
1307 ecore_x_e_illume_clipboard_geometry_set(bd->zone->black_win, bd->x, bd->y, bd->w, bd->h);
1313 _policy_border_cb_move(E_Border *bd)
1317 if (e_illume_border_is_app_tray(bd) ||
1318 e_illume_border_is_miniapp_tray(bd))
1320 _policy_border_focus_top_stack_set(bd);
1327 _policy_zone_layout(E_Zone *zone)
1329 E_Illume_Config_Zone *cz;
1333 // printf("Zone Layout: %d\n", zone->id);
1337 /* get the config for this zone */
1338 cz = e_illume_zone_config_get(zone->id);
1341 /* loop through border list and update layout */
1342 E_Illume_Border_Info* bd_info;
1343 EINA_LIST_FOREACH(e_border_info_list, l, bd_info)
1345 if (!bd_info) continue;
1347 bd = bd_info->border;
1349 /* skip borders that are being deleted */
1350 if (e_object_is_del(E_OBJECT(bd))) continue;
1352 /* skip borders not on this zone */
1353 if (bd->zone != zone) continue;
1355 /* only update layout for this border if it really needs it */
1356 if ((!bd->new_client) && (!bd->changes.pos) && (!bd->changes.size) &&
1357 (!bd->changes.visible) && (!bd->pending_move_resize) &&
1358 (!bd->need_shape_export) && (!bd->need_shape_merge)) continue;
1360 /* are we laying out an indicator ? */
1361 if (e_illume_border_is_indicator(bd))
1362 _policy_zone_layout_indicator(bd, cz);
1364 /* are we layout out a quickpanel ? */
1365 else if (e_illume_border_is_quickpanel(bd))
1366 _policy_zone_layout_quickpanel(bd);
1368 else if (e_illume_border_is_quickpanel_popup(bd))
1369 _policy_zone_layout_quickpanel_popup(bd);
1371 /* are we laying out a keyboard ? */
1372 else if (e_illume_border_is_keyboard(bd))
1373 _policy_zone_layout_keyboard(bd, cz);
1375 else if (e_illume_border_is_keyboard_sub(bd))
1376 _policy_zone_layout_keyboard(bd, cz);
1378 /* are we laying out a fullscreen window ? */
1379 /* NB: we could use the e_illume_border_is_fullscreen function here
1380 * but we save ourselves a function call this way. */
1381 else if ((bd->fullscreen) || (bd->need_fullscreen))
1382 _policy_zone_layout_fullscreen(bd);
1384 /* are we laying out a dialog ? */
1385 else if (e_illume_border_is_dialog(bd))
1386 _policy_zone_layout_dialog(bd, cz);
1388 else if (e_illume_border_is_splash(bd))
1389 _policy_zone_layout_splash(bd, cz);
1391 else if (e_illume_border_is_clipboard(bd))
1392 _policy_zone_layout_clipboard(bd, cz);
1394 else if (e_illume_border_is_app_tray(bd))
1395 _policy_zone_layout_apptray(bd);
1397 else if (e_illume_border_is_miniapp_tray(bd))
1398 _policy_zone_layout_miniapptray(bd);
1400 /* must be an app */
1403 /* are we in single mode ? */
1406 /* for desktop mode */
1407 if (E_ILLUME_BORDER_IS_IN_MOBILE(bd))
1408 _policy_zone_layout_app_single_new(bd_info, cz);
1409 else if (E_ILLUME_BORDER_IS_IN_DESKTOP(bd))
1410 _policy_zone_layout_app_single_monitor(bd_info, cz);
1412 _policy_zone_layout_app_single_new(bd_info, cz);
1416 /* we are in dual-mode, check orientation */
1417 if (cz->mode.side == 0)
1421 /* grab the indicator position so we can tell if it
1422 * is in a custom position or not (user dragged it) */
1423 e_illume_border_indicator_pos_get(bd->zone, NULL, &ty);
1424 if (ty <= bd->zone->y)
1425 _policy_zone_layout_app_dual_top_new (bd_info, cz);
1427 _policy_zone_layout_app_dual_custom_new (bd_info, cz);
1430 _policy_zone_layout_app_dual_left_new (bd_info, cz);
1437 _policy_zone_move_resize(E_Zone *zone)
1442 // printf("Zone move resize\n");
1446 ecore_x_window_size_get (zone->container->manager->root, &_g_root_width, &_g_root_height);
1448 EINA_LIST_FOREACH(e_border_client_list(), l, bd)
1451 /* skip borders not on this zone */
1452 if (bd->zone != zone) continue;
1454 /* signal a changed pos here so layout gets updated */
1455 bd->changes.pos = 1;
1461 _policy_zone_mode_change(E_Zone *zone, Ecore_X_Atom mode)
1463 E_Illume_Config_Zone *cz;
1466 // printf("Zone mode change: %d\n", zone->id);
1470 /* get the config for this zone */
1471 cz = e_illume_zone_config_get(zone->id);
1474 /* update config with new mode */
1475 if (mode == ECORE_X_ATOM_E_ILLUME_MODE_SINGLE)
1480 if (mode == ECORE_X_ATOM_E_ILLUME_MODE_DUAL_TOP)
1482 else if (mode == ECORE_X_ATOM_E_ILLUME_MODE_DUAL_LEFT)
1485 e_config_save_queue();
1487 /* lock indicator window from dragging if we need to */
1488 bd = e_illume_border_indicator_get(zone);
1491 /* only dual-top mode can drag */
1492 if ((cz->mode.dual == 1) && (cz->mode.side == 0))
1494 /* only set locked if we need to */
1495 if (bd->client.illume.drag.locked != 0)
1496 ecore_x_e_illume_drag_locked_set(bd->client.win, 0);
1500 /* only set locked if we need to */
1501 if (bd->client.illume.drag.locked != 1)
1502 ecore_x_e_illume_drag_locked_set(bd->client.win, 1);
1506 /* Need to trigger a layout update here */
1507 _policy_zone_layout_update(zone);
1511 _policy_zone_close(E_Zone *zone)
1515 // printf("Zone close\n");
1519 /* make sure we have a focused border */
1520 if (!(bd = e_border_focused_get())) return;
1522 /* make sure focused border is on this zone */
1523 if (bd->zone != zone) return;
1525 /* close this border */
1526 e_border_act_close_begin(bd);
1530 _policy_drag_start(E_Border *bd)
1532 // printf("Drag start\n");
1536 /* ignore stolen borders */
1537 if (bd->stolen) return;
1539 if (!bd->visible) return;
1541 /* set property on this border to say we are dragging */
1542 ecore_x_e_illume_drag_set(bd->client.win, 1);
1544 /* set property on zone window that a drag is happening */
1545 ecore_x_e_illume_drag_set(bd->zone->black_win, 1);
1549 _policy_drag_end(E_Border *bd)
1551 // printf("Drag end\n");
1555 /* ignore stolen borders */
1556 if (bd->stolen) return;
1558 /* set property on this border to say we are done dragging */
1559 ecore_x_e_illume_drag_set(bd->client.win, 0);
1561 /* set property on zone window that a drag is finished */
1562 ecore_x_e_illume_drag_set(bd->zone->black_win, 0);
1566 _policy_resize_start(E_Illume_Border_Info *bd_info)
1574 bd = bd_info->border;
1577 if (bd->stolen) return;
1578 if (!bd->client.illume.win_state.state) return;
1579 if (!bd_info->resize_req.mouse.down) return;
1581 bd_info->resize_req.need_change = 0;
1582 bd_info->resize_req.mouse.locked = 1;
1583 bd_info->resize_req.mouse.resize = 1;
1584 int ang = _policy_window_rotation_angle_get(bd->client.win);
1585 if (ang == -1) ang = 0;
1586 bd_info->resize_req.angle = ang;
1588 m = e_manager_current_get();
1590 canvas = e_manager_comp_evas_get(m);
1591 if (!canvas) return;
1593 o = evas_object_rectangle_add(canvas);
1594 evas_object_color_set(o, 100, 100, 100, 100);
1596 nx = bd->x - bd->zone->x;
1597 ny = bd->y - bd->zone->y;
1598 evas_object_move(o, nx, ny);
1599 evas_object_resize(o, bd->w, bd->h);
1600 e_object_data_set(E_OBJECT(bd), o);
1601 evas_object_show(o);
1605 _policy_resize_end(E_Illume_Border_Info *bd_info)
1608 bd = bd_info->border;
1612 Evas_Object *o = (Evas_Object *)e_object_data_get(E_OBJECT(bd));
1613 if (o) evas_object_del(o);
1615 if (bd->stolen) return;
1616 if (!bd->client.illume.win_state.state) return;
1617 if (!bd_info->resize_req.mouse.down) return;
1619 bd_info->resize_req.mouse.locked = 0;
1620 bd_info->resize_req.mouse.resize = 0;
1624 _policy_focus_back(E_Zone *zone)
1626 Eina_List *l, *fl = NULL;
1630 if (eina_list_count(_pol_focus_stack) < 1) return;
1632 // printf("Focus back\n");
1634 EINA_LIST_FOREACH(_pol_focus_stack, l, bd)
1637 if (bd->zone != zone) continue;
1638 fl = eina_list_append(fl, bd);
1641 if (!(fbd = e_border_focused_get())) return;
1642 if (fbd->parent) return;
1644 EINA_LIST_REVERSE_FOREACH(fl, l, bd)
1646 if ((fbd) && (bd == fbd))
1650 if ((l->next) && (b = l->next->data))
1652 _policy_border_set_focus(b);
1657 /* we've reached the end of the list. Set focus to first */
1658 if ((b = eina_list_nth(fl, 0)))
1660 _policy_border_set_focus(b);
1670 _policy_focus_forward(E_Zone *zone)
1672 Eina_List *l, *fl = NULL;
1676 if (eina_list_count(_pol_focus_stack) < 1) return;
1678 // printf("Focus forward\n");
1680 EINA_LIST_FOREACH(_pol_focus_stack, l, bd)
1683 if (bd->zone != zone) continue;
1684 fl = eina_list_append(fl, bd);
1687 if (!(fbd = e_border_focused_get())) return;
1688 if (fbd->parent) return;
1690 EINA_LIST_FOREACH(fl, l, bd)
1692 if ((fbd) && (bd == fbd))
1696 if ((l->next) && (b = l->next->data))
1698 _policy_border_set_focus(b);
1703 /* we've reached the end of the list. Set focus to first */
1704 if ((b = eina_list_nth(fl, 0)))
1706 _policy_border_set_focus(b);
1715 /* enable/disable composite module - 100320 yigl */
1716 #ifdef COMP_MODULE_CONTROL
1718 _policy_property_composite_module_change(Ecore_X_Event_Window_Property *ev)
1722 int current_enabled = 0;
1723 unsigned char* prop_data = NULL;
1724 E_Module* comp = NULL;
1726 ret = ecore_x_window_prop_property_get (ev->win, E_ILLUME_ATOM_COMP_MODULE_ENABLED, ECORE_X_ATOM_CARDINAL, 32, &prop_data, &count);
1727 if( ret && prop_data )
1729 memcpy (&enable, prop_data, sizeof (int));
1730 fprintf( stdout, "[E17-illume2-tizen] %s(%d) enable: %s ", __func__, __LINE__, enable ? "true" : "false" );
1732 comp = e_module_find ("comp-tizen");
1735 current_enabled = e_module_enabled_get(comp);
1736 fprintf( stdout, "current: %s ", current_enabled ? "true" : "false" );
1738 if( current_enabled && !enable )
1740 fprintf( stdout, "e_module_disable(comp-tizen) " );
1741 e_module_disable(comp);
1743 else if( !current_enabled && enable )
1745 fprintf( stdout, "e_module_enable(comp-tizen) " );
1746 e_module_enable(comp);
1750 fprintf( stdout, "skip... " );
1753 fprintf( stdout, "\n" );
1757 fprintf( stderr, "\n[E17-illume2-tizen] %s(%d) can't find comp module.\n", __func__, __LINE__ );
1761 if (prop_data) free (prop_data);
1767 static void _policy_property_window_state_change (Ecore_X_Event_Window_Property *event)
1769 E_Border *bd, *indi_bd;
1771 if (!(bd = e_border_find_by_client_window(event->win))) return;
1773 /* not interested in stolen or invisible borders */
1774 if ((bd->stolen) || (!bd->visible)) return;
1776 /* make sure the border has a name or class */
1777 /* NB: this check is here because some E borders get State Changes
1778 * but do not have a name/class associated with them. Not entirely sure
1779 * which ones they are, but I would guess Managers, Containers, or Zones.
1780 * At any rate, we're not interested in those types of borders */
1781 if ((!bd->client.icccm.name) || (!bd->client.icccm.class)) return;
1783 /* NB: If we have reached this point, then it should be a fullscreen
1784 * border that has toggled fullscreen on/off */
1786 /* if the window is not active window, then it doesn't need to hande indicator */
1787 if (g_active_win != bd->client.win) return;
1789 /* try to get the Indicator on this zone */
1790 if (!(indi_bd = e_illume_border_indicator_get(bd->zone))) return;
1792 /* if we are fullscreen, hide the indicator...else we show it */
1793 /* NB: we could use the e_illume_border_is_fullscreen function here
1794 * but we save ourselves a function call this way */
1795 if ((bd->fullscreen) || (bd->need_fullscreen))
1797 if (indi_bd->visible)
1799 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... Hide Indicator (by win: 0x%07x)\n", __func__, __LINE__, bd->client.win);
1800 e_border_hide(indi_bd, 2);
1805 int indi_show = _policy_border_indicator_state_get(bd);
1808 if (!indi_bd->visible)
1810 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... Show Indicator (by win: 0x%07x)\n", __func__, __LINE__, bd->client.win);
1811 e_border_show(indi_bd);
1818 static void _policy_property_indicator_geometry_change (Ecore_X_Event_Window_Property *event)
1825 /* make sure this property changed on a zone */
1826 if (!(zone = e_util_zone_window_find(event->win))) return;
1828 /* get the geometry */
1829 if (!(bd = e_illume_border_indicator_get(zone))) return;
1835 /* look for conformant borders */
1836 EINA_LIST_FOREACH(e_border_client_list(), l, bd)
1839 if (bd->zone != zone) continue;
1840 if (!e_illume_border_is_conformant(bd)) continue;
1841 /* set indicator geometry on conformant window */
1842 /* NB: This is needed so that conformant apps get told about
1843 * the indicator size/position...else they have no way of
1844 * knowing that the geometry has been updated */
1845 ecore_x_e_illume_indicator_geometry_set(bd->client.win, x, y, w, h);
1849 static void _policy_property_clipboard_geometry_change (Ecore_X_Event_Window_Property *event)
1856 /* make sure this property changed on a zone */
1857 if (!(zone = e_util_zone_window_find(event->win))) return;
1859 ecore_x_e_illume_clipboard_geometry_get(zone->black_win, &x, &y, &w, &h);
1861 /* look for conformant borders */
1862 EINA_LIST_FOREACH(e_border_client_list(), l, bd)
1865 if (bd->zone != zone) continue;
1866 if (e_illume_border_is_indicator(bd)) continue;
1867 if (e_illume_border_is_keyboard(bd)) continue;
1868 if (e_illume_border_is_keyboard_sub(bd)) continue;
1869 if (e_illume_border_is_quickpanel(bd)) continue;
1870 if (e_illume_border_is_quickpanel_popup(bd)) continue;
1873 LOGD("[WM] Clipboard geometry set. win:0x%07x, geo(%d,%d,%d,%d)", bd->client.win, x, y, w, h);
1875 ecore_x_e_illume_clipboard_geometry_set(bd->client.win, x, y, w, h);
1879 static void _policy_property_clipboard_state_change (Ecore_X_Event_Window_Property *event)
1884 Ecore_X_Illume_Clipboard_State state;
1886 /* make sure this property changed on a zone */
1887 if (!(zone = e_util_zone_window_find(event->win))) return;
1889 state = ecore_x_e_illume_clipboard_state_get(zone->black_win);
1891 /* look for conformant borders */
1892 EINA_LIST_FOREACH(e_border_client_list(), l, bd)
1895 if (bd->zone != zone) continue;
1896 if (e_illume_border_is_indicator(bd)) continue;
1897 if (e_illume_border_is_keyboard(bd)) continue;
1898 if (e_illume_border_is_keyboard_sub(bd)) continue;
1899 if (e_illume_border_is_quickpanel(bd)) continue;
1900 if (e_illume_border_is_quickpanel_popup(bd)) continue;
1903 LOGD("[WM] Clipboard state set. win:0x%07x, state:%d", bd->client.win, state);
1905 ecore_x_e_illume_clipboard_state_set(bd->client.win, state);
1909 static void _policy_property_enlightenment_scale_change (Ecore_X_Event_Window_Property *event)
1914 EINA_LIST_FOREACH(e_manager_list(), ml, man)
1920 if (event->win != man->root) continue;
1921 EINA_LIST_FOREACH(man->containers, cl, con)
1927 EINA_LIST_FOREACH(con->zones, zl, zone)
1928 _policy_zone_layout_update(zone);
1933 static void _policy_property_rotate_win_angle_change (Ecore_X_Event_Window_Property *event)
1936 E_Illume_XWin_Info* xwin_info;
1938 L (LT_ANGLE, "[ILLUME2][ANGLE] %s(%d).. win:0x%07x\n", __func__, __LINE__, event->win);
1940 if (!(bd = e_border_find_by_client_window(event->win))) return;
1942 xwin_info = _policy_xwin_info_find (bd->win);
1945 if (xwin_info->visibility == E_ILLUME_VISIBILITY_UNOBSCURED)
1947 L (LT_ANGLE, "[ILLUME2][ANGLE] %s(%d).. CALL _policy_change_root_angle_by_border_angle!!! win:0x%07x\n", __func__, __LINE__, bd->client.win);
1948 _policy_change_root_angle_by_border_angle (bd);
1952 bd->changes.pos = 1;
1956 static void _policy_property_indicator_state_change (Ecore_X_Event_Window_Property *event)
1958 E_Border *bd, *indi_bd;
1960 if (!(bd = e_border_find_by_client_window(event->win))) return;
1962 indi_bd = e_illume_border_indicator_get(bd->zone);
1963 if (!indi_bd) return;
1965 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... win = 0x%07x.. Control Indicator.\n", __func__, __LINE__, bd->client.win);
1966 _policy_border_indicator_control(indi_bd);
1969 static void _policy_property_indicator_opacity_change(Ecore_X_Event_Window_Property *event)
1971 E_Border *bd, *indi_bd;
1972 Ecore_X_Window active_win;
1973 Ecore_X_Illume_Indicator_Opacity_Mode mode;
1975 if (!(bd = e_border_find_by_client_window(event->win))) return;
1977 indi_bd = e_illume_border_indicator_get(bd->zone);
1978 if (!indi_bd) return;
1980 active_win = _policy_active_window_get(bd->zone->container->manager->root);
1981 if (active_win == bd->client.win)
1983 mode = ecore_x_e_illume_indicator_opacity_get(bd->client.win);
1984 ecore_x_e_illume_indicator_opacity_send(indi_bd->client.win, mode);
1988 static void _policy_active_win_change(E_Illume_XWin_Info *xwin_info, Ecore_X_Window active_win)
1990 E_Border *active_bd = NULL;
1993 if (!xwin_info) return;
1994 if (!xwin_info->comp_vis) return;
1996 active_bd = e_border_find_by_client_window(active_win);
1998 /* for active/deactive message */
1999 if (active_win != g_active_win)
2002 active_pid = active_bd->client.netwm.pid;
2006 // 1. send deactive event to g_active_win
2007 ecore_x_client_message32_send(g_active_win, E_ILLUME_ATOM_DEACTIVATE_WINDOW,
2008 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, active_win, active_pid, g_active_win, g_active_pid, 0);
2010 // 2. send active event to active_win
2011 ecore_x_client_message32_send(active_win, E_ILLUME_ATOM_ACTIVATE_WINDOW,
2012 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, active_win, active_pid, g_active_win, g_active_pid, 0);
2015 printf ("\n=========================================================================================\n");
2018 printf ("[WM] Active window is changed. OLD(win:0x%07x,pid:%d) --> NEW(win:0x%07x,pid:%d,name:%s)\n", g_active_win, g_active_pid, active_win, active_pid, active_bd->client.netwm.name);
2020 LOGD("[WM] Active window is changed. OLD(win:0x%07x,pid:%d) --> NEW(win:0x%07x,pid:%d,name:%s)", g_active_win, g_active_pid, active_win, active_pid, active_bd->client.netwm.name);
2022 if ((E_ILLUME_BORDER_IS_IN_DESKTOP(active_bd)) ||
2023 (active_bd->client.illume.win_state.state == ECORE_X_ILLUME_WINDOW_STATE_FLOATING))
2025 e_border_raise(active_bd);
2030 printf ("[WM] Active window is changed. OLD(win:0x%07x,pid:%d) --> NEW(win:0x%07x,pid:%d,name:NULL)\n", g_active_win, g_active_pid, active_win, active_pid);
2032 LOGD("[WM] Active window is changed. OLD(win:0x%07x,pid:%d) --> NEW(win:0x%07x,pid:%d,name:NULL)", g_active_win, g_active_pid, active_win, active_pid);
2035 printf ("=========================================================================================\n\n");
2036 g_active_win = active_win;
2037 g_active_pid = active_pid;
2042 if (_e_illume_cfg->use_indicator_widget)
2044 L(LT_ANGLE, "[ILLUME2][ANGLE] %s(%d)... Control Root Angle.\n", __func__, __LINE__);
2045 _policy_border_root_angle_control(active_bd->zone);
2050 indi_bd = e_illume_border_indicator_get(active_bd->zone);
2053 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... win = 0x%07x.. Control Indicator.\n", __func__, __LINE__, active_bd->client.win);
2054 _policy_border_indicator_control(indi_bd);
2058 ILLUME2_TRACE ("[ILLUME2] ACTIVE WINDOW... (%d) active win = 0x%07x HIDE quickpanel\n", __LINE__, active_win);
2059 e_illume_quickpanel_hide(active_bd->zone, 0);
2063 static void _policy_property_active_win_change (Ecore_X_Event_Window_Property *event)
2065 Ecore_X_Window active_win;
2066 E_Border* active_bd;
2067 E_Illume_XWin_Info *xwin_info;
2069 active_win = _policy_active_window_get(event->win);
2070 active_bd = e_border_find_by_client_window(active_win);
2073 xwin_info = _policy_xwin_info_find(active_bd->win);
2077 xwin_info = _policy_xwin_info_find(active_win);
2080 _policy_active_win_change(xwin_info, active_win);
2083 static void _policy_property_win_type_change (Ecore_X_Event_Window_Property *event)
2087 E_Illume_Border_Info* bd_info = NULL;
2090 if (!(bd = e_border_find_by_client_window(event->win))) return;
2092 bd_info = _policy_get_border_info(bd);
2093 if (!bd_info) return;
2095 e_hints_window_type_get (bd);
2097 if (bd_info->win_type == bd->client.netwm.type) return;
2098 bd_info->win_type = bd->client.netwm.type;
2100 if (bd->client.netwm.type == ECORE_X_WINDOW_TYPE_NOTIFICATION)
2102 ILLUME2_TRACE ("[ILLUME2-NEW] %s(%d)... WINDOW TYPE is CHANGED to NOTIFICATION!!!!! win = 0x%07x\n", __func__, __LINE__, bd->client.win);
2103 bd_info->level = _policy_border_get_notification_level(bd->client.win);
2104 layer = _policy_notification_level_map(bd_info->level);
2105 e_border_layer_set(bd, layer);
2107 L (LT_NOTIFICATION, "[ILLUME2][NOTIFICATION] %s(%d)... win (0x%07x) is notification window... level = %d\n", __func__, __LINE__, bd->client.win, bd_info->level);
2109 indi_bd = e_illume_border_indicator_get(bd->zone);
2112 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... win = 0x%07x.. Control Indicator.\n", __func__, __LINE__, bd->client.win);
2113 _policy_border_indicator_control(indi_bd);
2116 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d).. ICONIFY win:0x%07x And UN-ICONIFY Top win...\n", __func__, __LINE__, bd->client.win);
2117 _policy_border_uniconify_top_border(bd);
2119 else if (bd->client.netwm.type == ECORE_X_WINDOW_TYPE_NORMAL)
2121 ILLUME2_TRACE ("[ILLUME2-NEW] %s(%d)... WINDOW TYPE is CHANGED to NORMAL!!!!! win = 0x%07x\n", __func__, __LINE__, bd->client.win);
2122 if (bd->layer != POL_APP_LAYER)
2124 if ( (!e_illume_border_is_quickpanel(bd)) &&
2125 (!e_illume_border_is_quickpanel_popup(bd)) &&
2126 (!e_illume_border_is_keyboard(bd)) &&
2127 (!e_illume_border_is_keyboard_sub(bd)))
2129 e_border_layer_set(bd, POL_APP_LAYER);
2133 indi_bd = e_illume_border_indicator_get(bd->zone);
2136 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... win = 0x%07x.. Control Indicator.\n", __func__, __LINE__, bd->client.win);
2137 _policy_border_indicator_control(indi_bd);
2140 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d).. ICONIFY win:0x%07x And UN-ICONIFY Top win...\n", __func__, __LINE__, bd->client.win);
2141 _policy_border_uniconify_top_border(bd);
2143 else if (bd->client.netwm.type == ECORE_X_WINDOW_TYPE_UTILITY)
2145 bd->client.icccm.request_pos = 1;
2147 if (bd->layer != POL_APP_LAYER)
2148 e_border_layer_set(bd, POL_APP_LAYER);
2153 static void _policy_property_rotate_root_angle_change (Ecore_X_Event_Window_Property *event)
2160 unsigned char *prop_data = NULL;
2163 ret = ecore_x_window_prop_property_get (event->win, ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE, ECORE_X_ATOM_CARDINAL, 32, &prop_data, &count);
2164 if( ret && prop_data )
2165 memcpy (&angle, prop_data, sizeof (int));
2167 if (prop_data) free (prop_data);
2169 L (LT_ANGLE, "[ILLUME2][ANGLE] %s(%d).. ROOT ANGLE CHANGED... angle = %d. control_win:0x%07x\n", __func__, __LINE__, angle, g_indi_control_win);
2170 bd = e_border_find_by_client_window(g_indi_control_win);
2172 if (bd) zone = bd->zone;
2173 else zone = e_util_container_zone_number_get (0, 0);
2177 // send client message to all visible windows
2178 if (g_root_angle != angle)
2180 indi_bd = e_illume_border_indicator_get(zone);
2183 _policy_indicator_angle_change (indi_bd, angle);
2189 EINA_LIST_FOREACH(e_border_client_list(), l, bd_temp)
2191 if (!bd_temp) continue;
2192 if (!bd_temp->visible && !bd_temp->iconic)
2194 if (!e_illume_border_is_keyboard(bd_temp))
2198 L (LT_ANGLE, "[ILLUME2][ANGLE] %s(%d)... win = 0x%07x.. SEND client Event with angle = %d\n", __func__, __LINE__, bd_temp->client.win, angle);
2199 ecore_x_client_message32_send (bd_temp->client.win, ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE,
2200 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, angle, g_indi_control_win, 0, 0, 0);
2203 if (_e_illume_cfg->use_indicator_widget)
2205 E_Illume_Quickpanel *qp;
2206 qp = e_illume_quickpanel_by_zone_get(zone);
2208 _policy_layout_quickpanel_rotate(qp, angle);
2211 e_illume_util_hdmi_rotation (event->win, angle);
2215 g_root_angle = angle;
2218 static void _policy_property_notification_level_change (Ecore_X_Event_Window_Property *event)
2221 0. Check if border is exist or not
2222 1. Check if a window is notification or not
2223 2. Get and Set level
2226 L (LT_NOTIFICATION, "[ILLUME2][NOTIFICATION] %s(%d)... E_ILLUME_ATOM_NOTIFICATION_LEVEL property!!! win = 0x%07x\n", __func__, __LINE__, event->win);
2230 E_Illume_Border_Info *bd_info = NULL;
2234 if (!(bd = e_border_find_by_client_window(event->win)))
2236 L (LT_NOTIFICATION, "[ILLUME2][NOTIFICATION] %s(%d)... Win (0x%07x) doesn't have border... So return..\n", __func__, __LINE__, event->win);
2240 bd_info = _policy_get_border_info(bd);
2241 if (!bd_info) return;
2244 if (!e_illume_border_is_notification (bd))
2246 L (LT_NOTIFICATION, "[ILLUME2][NOTIFICATION] %s(%d)... Win (0x%07x) gets NOTIFICATION_LEVEL notifiy... But this is NOT notification window... IGNORE!!!!!\n", __func__, __LINE__, bd->client.win);
2251 bd_info->level = _policy_border_get_notification_level(bd->client.win);
2252 layer = _policy_notification_level_map(bd_info->level);
2255 e_border_layer_set(bd, layer);
2256 L (LT_NOTIFICATION, "[ILLUME2][NOTIFICATION] %s(%d)... win (0x%07x) is notification window... level = %d\n",
2257 __func__, __LINE__, bd->client.win, bd_info->level);
2260 indi_bd = e_illume_border_indicator_get(bd->zone);
2263 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... win = 0x%07x.. Control Indicator.\n", __func__, __LINE__, bd->client.win);
2264 _policy_border_indicator_control(indi_bd);
2267 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d).. ICONIFY win:0x%07x And UN-ICONIFY Top win...\n", __func__, __LINE__, bd->client.win);
2268 _policy_border_uniconify_top_border(bd);
2271 static void _policy_property_overlay_win_change (Ecore_X_Event_Window_Property *event)
2275 unsigned char* prop_data = NULL;
2277 ret = ecore_x_window_prop_property_get (event->win, E_ILLUME_ATOM_OVERAY_WINDOW, ECORE_X_ATOM_WINDOW, 32, &prop_data, &count);
2278 if( ret && prop_data )
2279 memcpy (&_e_overlay_win, prop_data, sizeof (ECORE_X_ATOM_WINDOW));
2281 if (prop_data) free (prop_data);
2283 L (LT_XWIN, "[ILLUME2][XWIN] %s(%d)... OVERAY_WINDOW:0x%07x\n", __func__, __LINE__, _e_overlay_win);
2284 _policy_xwin_info_delete (_e_overlay_win);
2287 static int _policy_property_window_opaque_get (Ecore_X_Window win)
2292 unsigned char* prop_data = NULL;
2294 ret = ecore_x_window_prop_property_get (win, E_ILLUME_ATOM_WINDOW_OPAQUE, ECORE_X_ATOM_CARDINAL, 32, &prop_data, &count);
2295 if( ret && prop_data )
2296 memcpy (&is_opaque, prop_data, sizeof (ECORE_X_ATOM_CARDINAL));
2298 if (prop_data) free (prop_data);
2303 static void _policy_property_window_opaque_change (Ecore_X_Event_Window_Property *event)
2306 E_Illume_Border_Info* bd_info;
2308 if (!(bd = e_border_find_by_client_window(event->win))) return;
2311 bd_info = _policy_get_border_info (bd);
2312 if (!bd_info) return;
2314 // set current property
2315 bd_info->opaque = _policy_property_window_opaque_get (event->win);
2317 // visibility is changed
2318 L(LT_VISIBILITY, "[ILLUME2][VISIBILITY] %s(%d).. visibility is changed... win:0x%07x\n", __func__, __LINE__, event->win);
2319 _g_visibility_changed = EINA_TRUE;
2323 _policy_property_illume_window_state_change(Ecore_X_Event_Window_Property *event)
2327 if (!(bd = e_border_find_by_client_window(event->win))) return;
2328 if (bd->stolen) return;
2330 unsigned int state = ecore_x_e_illume_window_state_get(event->win);
2331 _policy_border_illume_window_state_change(bd, state);
2335 _policy_border_illume_window_state_change(E_Border *bd, unsigned int state)
2340 if (bd->client.illume.win_state.state == state) return;
2342 ELBF(ELBT_ILLUME, 0, bd->client.win, "SET WIN_STATE %d->%d",
2343 bd->client.illume.win_state.state, state);
2345 bd->client.illume.win_state.state = state;
2348 case ECORE_X_ILLUME_WINDOW_STATE_FLOATING:
2349 e_hints_window_state_update(bd, ECORE_X_WINDOW_STATE_ABOVE, ECORE_X_WINDOW_STATE_ACTION_ADD);
2351 if (_e_illume_cfg->use_force_iconify)
2352 _policy_border_uniconify_below_borders(bd);
2354 bd->client.icccm.request_pos = EINA_TRUE;
2355 bd->lock_user_size = 0;
2356 bd->lock_user_location = 0;
2360 e_border_unmaximize(bd, E_MAXIMIZE_BOTH);
2362 indi_bd = e_illume_border_indicator_get(bd->zone);
2365 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... win = 0x%07x.. Control Indicator.\n", __func__, __LINE__, bd->client.win);
2366 _policy_border_indicator_control(indi_bd);
2371 case ECORE_X_ILLUME_WINDOW_STATE_NORMAL:
2372 e_hints_window_state_update(bd, ECORE_X_WINDOW_STATE_ABOVE, ECORE_X_WINDOW_STATE_ACTION_REMOVE);
2374 if (E_ILLUME_BORDER_IS_IN_MOBILE(bd))
2376 bd->lock_user_size = 1;
2377 bd->lock_user_location = 1;
2379 else if (E_ILLUME_BORDER_IS_IN_DESKTOP(bd))
2384 bd->client.icccm.request_pos = EINA_FALSE;
2386 indi_bd = e_illume_border_indicator_get(bd->zone);
2389 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... win = 0x%07x.. Control Indicator.\n", __func__, __LINE__, bd->client.win);
2390 _policy_border_indicator_control(indi_bd);
2395 bd->changes.size = 1;
2396 bd->changes.pos = 1;
2401 _policy_border_illume_handlers_add(E_Illume_Border_Info *bd_info)
2403 if (!bd_info) return;
2404 if (bd_info->handlers) return;
2406 bd_info->handlers = eina_list_append(bd_info->handlers,
2407 ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP,
2408 _policy_border_cb_mouse_up, bd_info));
2409 bd_info->handlers = eina_list_append(bd_info->handlers,
2410 ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE,
2411 _policy_border_cb_mouse_move, bd_info));
2415 _policy_border_illume_handlers_remove(E_Illume_Border_Info *bd_info)
2417 Ecore_Event_Handler *hdl;
2419 if (!bd_info) return;
2420 if (!bd_info->handlers) return;
2422 EINA_LIST_FREE(bd_info->handlers, hdl)
2423 ecore_event_handler_del(hdl);
2427 _policy_border_cb_mouse_down(void *data,
2428 int type __UNUSED__,
2431 Ecore_Event_Mouse_Button *ev;
2432 E_Illume_Border_Info *bd_info;
2435 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... \n", __func__, __LINE__);
2438 bd = bd_info->border;
2440 if (ev->window != bd->event_win &&
2441 ev->event_window != bd->event_win)
2442 return ECORE_CALLBACK_PASS_ON;
2444 if (bd_info->resize_req.mouse.down)
2445 return ECORE_CALLBACK_PASS_ON;
2447 bd_info->resize_req.mouse.down = 1;
2449 bd_info->resize_req.mouse.dx = bd->x - ev->root.x;
2450 bd_info->resize_req.mouse.dy = bd->y - ev->root.y;
2452 bd_info->resize_req.mouse.x = bd->x;
2453 bd_info->resize_req.mouse.y = bd->y;
2456 ecore_x_mouse_down_send(bd->client.win, ev->x, ev->y, ev->buttons);
2458 return ECORE_CALLBACK_PASS_ON;
2462 _resize_rect_geometry_get(E_Illume_Border_Info *bd_info,
2463 Evas_Coord_Rectangle *r,
2469 int x = 0, y = 0, w = 0, h = 0;
2474 bd = bd_info->border;
2476 e_illume_border_min_get(bd, &mw, &mh);
2478 if (direction == ECORE_X_NETWM_DIRECTION_SIZE_BR)
2480 switch (bd_info->resize_req.angle)
2483 cx = bd->x; cy = bd->y;
2484 x = bd->x; y = bd->y;
2485 w = ev_x - bd->x; h = ev_y - bd->y;
2488 cx = bd->x; cy = bd->y + bd->h;
2489 x = bd->x; y = ev_y;
2490 w = ev_x - x; h = (bd->y + bd->h) - y;
2493 cx = bd->x + bd->w; cy = bd->y + bd->h;
2495 w = (bd->x + bd->w) - x; h = (bd->y + bd->h) - y;
2498 cx = bd->x + bd->w; cy = bd->y;
2499 x = ev_x; y = bd->y;
2500 w = (bd->x + bd->w) - x; h = ev_y - y;
2506 else if (direction == ECORE_X_NETWM_DIRECTION_SIZE_TL)
2508 switch (bd_info->resize_req.angle)
2511 cx = bd->x + bd->w; cy = bd->y + bd->h;
2513 w = (bd->x + bd->w) - x; h = (bd->y + bd->h) - y;
2516 cx = bd->x + bd->w; cy = bd->y;
2517 x = ev_x; y = bd->y;
2518 w = (bd->x + bd->w) - x; h = ev_y - y;
2521 cx = bd->x; cy = bd->y;
2522 x = bd->x; y = bd->y;
2523 w = ev_x - bd->x; h = ev_y - bd->y;
2526 cx = bd->x; cy = bd->y + bd->h;
2527 x = bd->x; y = ev_y;
2528 w = ev_x - x; h = (bd->y + bd->h) - y;
2534 else if (direction == ECORE_X_NETWM_DIRECTION_SIZE_TR)
2536 switch (bd_info->resize_req.angle)
2539 cx = bd->x; cy = bd->y + bd->h;
2540 x = bd->x; y = ev_y;
2541 w = ev_x - x; h = (bd->y + bd->h) - y;
2544 cx = bd->x + bd->w; cy = bd->y + bd->h;
2546 w = (bd->x + bd->w) - x; h = (bd->y + bd->h) - y;
2549 cx = bd->x + bd->w; cy = bd->y;
2550 x = ev_x; y = bd->y;
2551 w = (bd->x + bd->w) - x; h = ev_y - y;
2554 cx = bd->x; cy = bd->y;
2555 x = bd->x; y = bd->y;
2556 w = ev_x - bd->x; h = ev_y - bd->y;
2562 else if (direction == ECORE_X_NETWM_DIRECTION_SIZE_BL)
2564 switch (bd_info->resize_req.angle)
2567 cx = bd->x + bd->w; cy = bd->y;
2568 x = ev_x; y = bd->y;
2569 w = (bd->x + bd->w) - x; h = ev_y - y;
2572 cx = bd->x; cy = bd->y;
2573 x = bd->x; y = bd->y;
2574 w = ev_x - bd->x; h = ev_y - bd->y;
2577 cx = bd->x; cy = bd->y + bd->h;
2578 x = bd->x; y = ev_y;
2579 w = ev_x - x; h = (bd->y + bd->h) - y;
2582 cx = bd->x + bd->w; cy = bd->y + bd->h;
2584 w = (bd->x + bd->w) - x; h = (bd->y + bd->h) - y;
2590 else if (direction == ECORE_X_NETWM_DIRECTION_SIZE_R)
2592 switch (bd_info->resize_req.angle)
2595 cx = bd->x; cy = bd->y;
2596 x = bd->x; y = bd->y;
2597 w = ev_x - bd->x; h = bd->h;
2600 cx = bd->x; cy = bd->y + bd->h;
2601 x = bd->x; y = ev_y;
2602 w = bd->w; h = (bd->y + bd->h) - y;
2605 cx = bd->x + bd->w; cy = bd->y + bd->h;
2607 w = (bd->x + bd->w) - x; h = bd->h;
2610 cx = bd->x + bd->w; cy = bd->y;
2611 x = ev_x; y = bd->y;
2612 w = bd->w; h = ev_y - y;
2618 else if (direction == ECORE_X_NETWM_DIRECTION_SIZE_L)
2620 switch (bd_info->resize_req.angle)
2623 cx = bd->x + bd->w; cy = bd->y + bd->h;
2624 x = ev_x; y = bd->y;
2625 w = (bd->x + bd->w) - x; h = bd->h;
2628 cx = bd->x + bd->w; cy = bd->y;
2629 x = ev_x; y = bd->y;
2630 w = bd->w; h = ev_y - y;
2633 cx = bd->x; cy = bd->y;
2634 x = bd->x; y = bd->y;
2635 w = ev_x - bd->x; h = bd->h;
2638 cx = bd->x; cy = bd->y + bd->h;
2639 x = bd->x; y = ev_y;
2640 w = bd->w; h = (bd->y + bd->h) - y;
2646 else if (direction == ECORE_X_NETWM_DIRECTION_SIZE_T)
2648 switch (bd_info->resize_req.angle)
2651 cx = bd->x + bd->w; cy = bd->y + bd->h;
2652 x = bd->x; y = ev_y;
2653 w = bd->w; h = (bd->y + bd->h) - y;
2656 cx = bd->x + bd->w; cy = bd->y;
2657 x = ev_x; y = bd->y;
2658 w = (bd->x + bd->w) - x; h = bd->h;
2661 cx = bd->x; cy = bd->y;
2662 x = bd->x; y = bd->y;
2663 w = bd->w; h = ev_y - bd->y;
2666 cx = bd->x + bd->w; cy = bd->y;
2667 x = bd->x; y = bd->y;
2668 w = ev_x - bd->x; h = bd->h;
2674 else if (direction == ECORE_X_NETWM_DIRECTION_SIZE_B)
2676 switch (bd_info->resize_req.angle)
2679 cx = bd->x; cy = bd->y;
2680 x = bd->x; y = bd->y;
2681 w = bd->w; h = ev_y - bd->y;
2684 cx = bd->x + bd->w; cy = bd->y;
2685 x = bd->x; y = bd->y;
2686 w = ev_x - bd->x; h = bd->h;
2689 cx = bd->x + bd->w; cy = bd->y + bd->h;
2690 x = bd->x; y = ev_y;
2691 w = bd->w; h = (bd->y + bd->h) - y;
2694 cx = bd->x + bd->w; cy = bd->y;
2695 x = ev_x; y = bd->y;
2696 w = (bd->x + bd->w) - x; h = bd->h;
2705 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... ERROR... direction(%d) is not defined!!!\n", __func__, __LINE__, direction);
2709 if (bd->zone->w > bd->zone->h)
2710 max_size = bd->zone->h;
2712 max_size = bd->zone->w;
2716 if (w > max_size) w = max_size;
2717 if (h > max_size) h = max_size;
2719 if ((x + w) > (bd->x + w)) x = cx - w;
2720 if ((y + h) > (bd->y + h)) y = cy - h;
2722 if ((cx - x) > max_size)
2724 if ((cy - y) > max_size)
2727 x = x - bd->zone->x;
2728 y = y - bd->zone->y;
2737 _policy_border_cb_mouse_up(void *data,
2738 int type __UNUSED__,
2741 Ecore_Event_Mouse_Button *ev;
2742 E_Illume_Border_Info *bd_info;
2745 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... \n", __func__, __LINE__);
2748 bd = bd_info->border;
2750 if (ev->window != bd->event_win &&
2751 ev->event_window != bd->event_win)
2752 return ECORE_CALLBACK_PASS_ON;
2754 if (!bd_info->resize_req.mouse.down)
2755 return ECORE_CALLBACK_PASS_ON;
2757 bd->lock_user_location = 0;
2758 e_grabinput_release(bd->event_win, bd->event_win);
2760 if (bd_info->resize_req.mouse.resize)
2762 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... \n", __func__, __LINE__);
2763 Evas_Coord_Rectangle r;
2764 _resize_rect_geometry_get(bd_info, &r, ev->root.x, ev->root.y, bd_info->resize_req.direction);
2766 bd_info->resize_req.direction = ECORE_X_NETWM_DIRECTION_CANCEL;
2767 bd_info->resize_req.mouse.x = r.x + bd->zone->x;
2768 bd_info->resize_req.mouse.y = r.y + bd->zone->y;
2769 bd_info->resize_req.mouse.w = r.w;
2770 bd_info->resize_req.mouse.h = r.h;
2771 bd_info->resize_req.need_change = 1;
2772 bd->changes.pos = 1;
2773 bd->changes.size = 1;
2775 Evas_Object *o = (Evas_Object *)e_object_data_get(E_OBJECT(bd));
2779 printf("[IL2] DEL OBJ in UP\n");
2784 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... \n", __func__, __LINE__);
2785 bd_info->resize_req.mouse.x = ev->root.x + bd_info->resize_req.mouse.dx;
2786 bd_info->resize_req.mouse.y = ev->root.y + bd_info->resize_req.mouse.dy;
2789 bd_info->resize_req.mouse.down = 0;
2790 bd_info->resize_req.mouse.resize = 0;
2791 bd_info->resize_req.mouse.locked = 0;
2793 /* set property on this border to say we are done dragging */
2794 ecore_x_e_illume_drag_set(bd->client.win, 0);
2796 /* set property on zone window that a drag is finished */
2797 ecore_x_e_illume_drag_set(bd->zone->black_win, 0);
2799 ecore_x_window_raise(bd->client.shell_win);
2800 _policy_border_illume_handlers_remove(bd_info);
2802 return ECORE_CALLBACK_PASS_ON;
2806 _policy_border_cb_mouse_move(void *data,
2807 int type __UNUSED__,
2810 Ecore_Event_Mouse_Move *ev;
2811 E_Illume_Border_Info *bd_info;
2814 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... \n", __func__, __LINE__);
2817 bd = bd_info->border;
2819 if (ev->window != bd->event_win &&
2820 ev->event_window != bd->event_win)
2821 return ECORE_CALLBACK_PASS_ON;
2823 if (!bd_info->resize_req.mouse.down)
2824 return ECORE_CALLBACK_PASS_ON;
2826 if (bd_info->resize_req.mouse.resize)
2828 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... event (x:%d, y:%d, root_x:%d, root_y:%d)\n", __func__, __LINE__, ev->x, ev->y, ev->root.x, ev->root.y);
2829 Evas_Object *o = (Evas_Object *)e_object_data_get(E_OBJECT(bd));
2830 if (!o) return ECORE_CALLBACK_PASS_ON;
2832 Evas_Coord_Rectangle r;
2833 _resize_rect_geometry_get(bd_info, &r, ev->root.x, ev->root.y, bd_info->resize_req.direction);
2835 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... x:%d, y:%d, w:%d, h:%d\n", __func__, __LINE__, r.x, r.y, r.w, r.h);
2836 evas_object_move(o, r.x, r.y);
2837 evas_object_resize(o, r.w, r.h);
2841 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... \n", __func__, __LINE__);
2842 bd_info->resize_req.mouse.x = ev->root.x + bd_info->resize_req.mouse.dx;
2843 bd_info->resize_req.mouse.y = ev->root.y + bd_info->resize_req.mouse.dy;
2844 bd->changes.pos = 1;
2845 bd->changed = EINA_TRUE;
2848 return ECORE_CALLBACK_PASS_ON;
2852 _policy_property_change(Ecore_X_Event_Window_Property *event)
2854 // printf("Property Change\n");
2856 /* we are interested in state changes here */
2857 if (event->atom == ECORE_X_ATOM_NET_WM_STATE)
2859 _policy_property_window_state_change (event);
2861 else if (event->atom == ECORE_X_ATOM_E_ILLUME_INDICATOR_GEOMETRY)
2863 _policy_property_indicator_geometry_change (event);
2865 else if (event->atom == ECORE_X_ATOM_E_ILLUME_CLIPBOARD_GEOMETRY)
2867 _policy_property_clipboard_geometry_change (event);
2869 else if (event->atom == ECORE_X_ATOM_E_ILLUME_CLIPBOARD_STATE)
2871 _policy_property_clipboard_state_change (event);
2873 else if (event->atom == ATM_ENLIGHTENMENT_SCALE)
2875 _policy_property_enlightenment_scale_change (event);
2877 else if (event->atom == ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE)
2879 _policy_property_rotate_win_angle_change (event);
2881 else if (event->atom == ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE)
2883 _policy_property_indicator_state_change (event);
2885 else if (event->atom == ECORE_X_ATOM_E_ILLUME_INDICATOR_OPACITY_MODE)
2887 _policy_property_indicator_opacity_change(event);
2889 else if (event->atom == ECORE_X_ATOM_NET_ACTIVE_WINDOW)
2891 _policy_property_active_win_change (event);
2893 else if (event->atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE)
2895 _policy_property_win_type_change (event);
2897 else if (event->atom == E_ILLUME_ATOM_STACK_DISPLAY)
2899 _policy_border_list_print (event->win);
2901 else if (event->atom == ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE)
2903 _policy_property_rotate_root_angle_change (event);
2905 else if (event->atom == E_ILLUME_ATOM_NOTIFICATION_LEVEL)
2907 _policy_property_notification_level_change (event);
2909 /* for visibility */
2910 else if (event->atom == E_ILLUME_ATOM_OVERAY_WINDOW)
2912 _policy_property_overlay_win_change (event);
2914 else if (event->atom == E_ILLUME_ATOM_WINDOW_OPAQUE)
2916 _policy_property_window_opaque_change (event);
2918 else if (event->atom == ECORE_X_ATOM_E_ILLUME_WINDOW_STATE)
2920 _policy_property_illume_window_state_change(event);
2922 /* enable/disable composite module - 100320 yigl */
2923 #ifdef COMP_MODULE_CONTROL
2924 else if (event->atom == E_ILLUME_ATOM_COMP_MODULE_ENABLED)
2926 _policy_property_composite_module_change (event);
2929 else if (event->atom == E_INDICATOR_CMD_WIN)
2931 _policy_property_indicator_cmd_win_change(event);
2933 else if (event->atom == E_ACTIVE_INDICATOR_WIN)
2935 _policy_property_active_indicator_win_change(event);
2941 _policy_border_list_print (Ecore_X_Window win)
2943 Eina_List* border_list;
2946 E_Border* temp_bd = NULL;
2948 E_Illume_Print_Info info;
2949 unsigned char* prop_data = NULL;
2953 memset (info.file_name, 0, 256);
2955 ret = ecore_x_window_prop_property_get (win, E_ILLUME_ATOM_STACK_DISPLAY, ECORE_X_ATOM_CARDINAL, 32, &prop_data, &count);
2956 if( ret && prop_data )
2957 memcpy (&info, prop_data, sizeof (E_Illume_Print_Info));
2959 if (prop_data) free (prop_data);
2961 out = fopen (info.file_name, "w+");
2962 if (out == NULL) out = stderr;
2964 if ((info.type & PT_STACK) == PT_STACK)
2966 border_list = e_border_client_list();
2970 fprintf (out, "--------------------------------BORDER INFO--------------------------------------------------\n" );
2971 fprintf (out, " No Border ClientWin w h x y layer visible WinName\n" );
2972 fprintf (out, "---------------------------------------------------------------------------------------------\n" );
2974 EINA_LIST_FOREACH(border_list, l, bd)
2977 if (temp_bd == NULL) temp_bd = bd;
2979 fprintf (out, "%3i 0x%07x 0x%07x %4i %4i %6i %6i %5i %5i %-30s \n",
2980 i++, bd->win, bd->client.win, bd->w, bd->h, bd->x, bd->y, bd->layer, bd->visible, bd->client.netwm.name);
2982 fprintf (out, "---------------------------------------------------------------------------------------------\n" );
2986 E_Illume_Border_Info* bd_info;
2987 if (e_border_info_list)
2990 fprintf (out, "--------------------------------ILLUME BORDER INFO------------------------------------------------------------------\n" );
2991 fprintf (out, " No Border ClientWin w h x y isKBD layer level desk WinName\n" );
2992 fprintf (out, "--------------------------------------------------------------------------------------------------------------------\n" );
2994 EINA_LIST_FOREACH(e_border_info_list, l, bd_info)
2999 int desk_x=0, desk_y=0;
3000 if (!bd_info) continue;
3002 bd = bd_info->border;
3005 for (x = 0; x < zone->desk_x_count; x++)
3007 for (y = 0; y < zone->desk_y_count; y++)
3009 if (bd->desk == zone->desks[x + zone->desk_x_count * y])
3017 fprintf (out, "%3i 0x%07x 0x%07x %4i %4i %6i %6i %3i %5i %5i (%d,%d) %-30s \n",
3018 i++, bd_info->border->win, bd_info->border->client.win, bd_info->border->w, bd_info->border->h, bd_info->border->x, bd_info->border->y,
3019 bd_info->border->client.vkbd.vkbd, bd_info->border->layer, bd_info->level, desk_x, desk_y, bd_info->border->client.netwm.name);
3021 fprintf (out, "--------------------------------------------------------------------------------------------------------------------\n" );
3025 if (temp_bd == NULL) goto finish;
3029 fprintf (out, "-------------------------------- E17 STACK INFO--------------------------------------------\n" );
3030 fprintf (out, " No Border ClientWin w h x y layer visible WinName\n" );
3031 fprintf (out, "---------------------------------------------------------------------------------------------\n" );
3034 bl = e_container_border_list_last(temp_bd->zone->container);
3035 while ((bd = e_container_border_list_prev(bl)))
3037 fprintf (out, "%3i 0x%07x 0x%07x %4i %4i %6i %6i %5i %5i %-30s \n",
3038 i++, bd->win, bd->client.win, bd->w, bd->h, bd->x, bd->y, bd->layer, bd->visible, bd->client.netwm.name);
3040 e_container_border_list_free(bl);
3041 fprintf (out, "---------------------------------------------------------------------------------------------\n\n" );
3044 /* for visibility */
3045 if ((info.type & PT_VISIBILITY) == PT_VISIBILITY)
3047 Eina_Inlist* xwin_info_list;
3048 E_Illume_XWin_Info *xwin_info;
3050 xwin_info_list = _e_illume_xwin_info_list;
3054 fprintf (out, "--------------------------------BORDER INFO--------------------------------------------------\n" );
3055 fprintf (out, " No Win w h x y depth viewable visibility comp_vis iconify by_wm is_border(Client Win)\n" );
3056 fprintf (out, "---------------------------------------------------------------------------------------------\n" );
3058 EINA_INLIST_REVERSE_FOREACH (xwin_info_list, xwin_info)
3060 if (xwin_info->bd_info)
3062 if (xwin_info->bd_info->border)
3064 fprintf (out, "%3i 0x%07x %4i %4i %6i %6i %5i %5i %5i %5i %5i %5i yes(0x%07x)\n",
3065 i++, xwin_info->id, xwin_info->attr.w, xwin_info->attr.h, xwin_info->attr.x, xwin_info->attr.y, xwin_info->attr.depth,
3066 xwin_info->viewable, xwin_info->visibility, xwin_info->comp_vis, xwin_info->bd_info->border->iconic, xwin_info->iconify_by_wm, xwin_info->bd_info->border->client.win);
3070 fprintf (out, "%3i 0x%07x %4i %4i %6i %6i %5i %5i %5i %5i 0 %3i no(NULL)\n",
3071 i++, xwin_info->id, xwin_info->attr.w, xwin_info->attr.h, xwin_info->attr.x, xwin_info->attr.y, xwin_info->attr.depth,
3072 xwin_info->viewable, xwin_info->visibility, xwin_info->comp_vis, xwin_info->iconify_by_wm);
3077 fprintf (out, "%3i 0x%07x %4i %4i %6i %6i %5i %5i %5i %5i 0 %3i no(NULL)\n",
3078 i++, xwin_info->id, xwin_info->attr.w, xwin_info->attr.h, xwin_info->attr.x, xwin_info->attr.y, xwin_info->attr.depth,
3079 xwin_info->viewable, xwin_info->visibility, xwin_info->comp_vis, xwin_info->iconify_by_wm);
3082 fprintf (out, "---------------------------------------------------------------------------------------------\n" );
3090 fprintf (out, "--------------------------------GLOBAL INFO--------------------------------------------------\n" );
3091 fprintf (out, "g_rotated_win:0x%07x (g_root_angle:%d)\n", g_rotated_win, g_root_angle);
3092 fprintf (out, "g_active_win:0x%07x (pid:%d, angle:%d)\n", g_active_win, g_active_pid, _policy_window_rotation_angle_get(g_active_win));
3093 fprintf (out, "g_indi_control_win:0x%07x\n", g_indi_control_win);
3094 fprintf (out, "---------------------------------------------------------------------------------------------\n" );
3102 ecore_x_client_message32_send (ecore_x_window_root_first_get(), E_ILLUME_ATOM_STACK_DISPLAY_DONE,
3103 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
3109 _policy_window_rotation_angle_get(Ecore_X_Window win)
3112 int ret, size_ret = 0;
3113 unsigned long num_ret = 0, bytes = 0;
3114 unsigned char *prop_ret = NULL;
3115 Ecore_X_Display *dpy;
3118 dpy = ecore_x_display_get();
3121 win = ecore_x_window_root_first_get();
3123 ret = XGetWindowProperty(dpy, win, ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE, 0, LONG_MAX,
3124 False, ECORE_X_ATOM_CARDINAL, &type_ret, &size_ret,
3125 &num_ret, &bytes, &prop_ret);
3127 if (ret == ECORE_X_ERROR_CODE_SUCCESS)
3129 if (prop_ret && num_ret)
3131 angle = ((int *)prop_ret)[0];
3132 if (angle % 90) angle = -1;
3142 if (prop_ret) XFree(prop_ret);
3148 static Ecore_X_Window
3149 _policy_active_window_get(Ecore_X_Window root)
3154 ret = ecore_x_window_prop_xid_get(root,
3155 ECORE_X_ATOM_NET_ACTIVE_WINDOW,
3156 ECORE_X_ATOM_WINDOW,
3159 if ((ret == 1) && win)
3166 _policy_border_indicator_state_get(E_Border *bd)
3168 Ecore_X_Illume_Indicator_State state;
3171 state = ecore_x_e_illume_indicator_state_get(bd->client.win);
3172 if (state == ECORE_X_ILLUME_INDICATOR_STATE_ON)
3174 else if (state == ECORE_X_ILLUME_INDICATOR_STATE_OFF)
3182 static void _policy_layout_quickpanel_rotate (E_Illume_Quickpanel* qp, int angle)
3186 E_Illume_Quickpanel_Info *panel;
3192 // pass 1 - resize window
3193 EINA_LIST_FOREACH(qp->borders, bd_list, panel)
3195 if (!panel) continue;
3196 if (panel->angle == angle) continue;
3198 if (panel->angle > angle) diff = panel->angle - angle;
3199 else diff = angle - panel->angle;
3203 if (angle == 0 || angle == 180)
3205 if (diff == 90 || diff == 270)
3208 ILLUME2_TRACE ("[ILLUME2-QUICKPANEL] Portrait quick panel...(%d) quick win = 0x%07x old (%d, %d) new (%d, %d)\n", __LINE__, bd->client.win, bd->w, bd->h, bd->zone->w, temp);
3209 _policy_border_resize (bd, bd->zone->w, temp);
3212 ILLUME2_TRACE ("[ILLUME2-QUICKPANEL] Portrait quick panel...(%d) quick win = 0x%07x.. But size is not change\n", __LINE__, bd->client.win);
3216 if (diff == 90 || diff == 270)
3219 ILLUME2_TRACE ("[ILLUME2-QUICKPANEL] Landscape quick panel...(%d) quick win = 0x%07x old (%d, %d) new (%d, %d)\n", __LINE__, bd->client.win, bd->w, bd->h, temp, bd->zone->h);
3220 _policy_border_resize (bd, temp, bd->zone->h);
3223 ILLUME2_TRACE ("[ILLUME2-QUICKPANEL] Landscape quick panel...(%d) quick win = 0x%07x.. But size is not change\n", __LINE__, bd->client.win);
3227 // pass 2 - send client message
3228 EINA_LIST_FOREACH(qp->borders, bd_list, panel)
3230 if (!panel) continue;
3231 if (panel->angle == angle) continue;
3233 if (panel->angle > angle) diff = panel->angle - angle;
3234 else diff = angle - panel->angle;
3238 ILLUME2_TRACE ("[ILLUME2-QUICKPANEL] SEND CLIENT MESSAGE TO QUICKPANEL!!!!(%d) win:0x%07x, angle = %d\n", __LINE__, bd->client.win, angle);
3239 ecore_x_client_message32_send (bd->client.win, ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
3240 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
3243 panel->angle = angle;
3248 _policy_window_focus_in(Ecore_X_Event_Window_Focus_In *event)
3250 ILLUME2_TRACE("[ILLUME2-FOCUS] _policy_window_focus_in... win = 0x%07x\n", event->win);
3254 if (e_config->focus_policy == E_FOCUS_CLICK) return;
3256 if (!(bd = e_border_find_by_client_window(event->win))) return;
3258 if (e_illume_border_is_indicator (bd))
3264 EINA_LIST_FOREACH(e_manager_list(), ml, man)
3267 EINA_LIST_FOREACH(man->containers, cl, con)
3272 // send focus to top-level window.
3273 bl = e_container_border_list_last(con);
3274 while ((temp_bd = e_container_border_list_prev(bl)))
3276 if (temp_bd->client.icccm.accepts_focus && temp_bd->visible)
3278 /* focus the border */
3279 e_border_focus_set(temp_bd, 1, 1);
3280 e_container_border_list_free(bl);
3284 e_container_border_list_free(bl);
3291 void _policy_border_stack_change (E_Border* bd, E_Border* sibling, int stack_mode)
3293 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... win = 0x%07x, sibling = 0x%07x, stack mode = %d\n", __func__, __LINE__, bd->client.win, sibling->client.win, stack_mode);
3295 if (bd->layer != sibling->layer)
3297 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... Sibling layer is different!!! win = 0x%07x (layer = %d), sibling = 0x%07x (layer = %d)\n", __func__, __LINE__, bd->client.win, bd->layer, sibling->client.win, sibling->layer);
3301 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... Restack Window.. win = 0x%07x, sibling = 0x%07x, stack_mode = %d\n", __func__, __LINE__, bd->win, sibling->win, stack_mode);
3302 if (stack_mode == E_ILLUME_STACK_ABOVE)
3304 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... STACK CHANGE with ABOVE... win:0x%07x, above_win:0x%07x\n", __func__, __LINE__, bd->client.win, sibling->client.win);
3305 e_border_stack_above (bd, sibling);
3307 else if (stack_mode == E_ILLUME_STACK_BELOW)
3309 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... STACK CHANGE with BELOW... win:0x%07x, below_win:0x%07x\n", __func__, __LINE__, bd->client.win, sibling->client.win);
3310 e_border_stack_below (bd, sibling);
3315 int _policy_atom_init (void)
3317 /* Notification Level Atom */
3318 E_ILLUME_ATOM_NOTIFICATION_LEVEL = ecore_x_atom_get ("_E_ILLUME_NOTIFICATION_LEVEL");
3319 if (!E_ILLUME_ATOM_NOTIFICATION_LEVEL)
3321 fprintf (stderr, "[ILLUME2] Critical Error!!! Cannot create _E_ILLUME_NOTIFICATION_LEVEL Atom...\n");
3325 /* for active/deactive message */
3326 E_ILLUME_ATOM_ACTIVATE_WINDOW = ecore_x_atom_get ("_X_ILLUME_ACTIVATE_WINDOW");
3327 if (!E_ILLUME_ATOM_ACTIVATE_WINDOW)
3329 fprintf (stderr, "[ILLUME2] Critical Error!!! Cannot create _X_ILLUME_ACTIVATE_WINDOW Atom...\n");
3333 E_ILLUME_ATOM_DEACTIVATE_WINDOW = ecore_x_atom_get ("_X_ILLUME_DEACTIVATE_WINDOW");
3334 if (!E_ILLUME_ATOM_DEACTIVATE_WINDOW)
3336 fprintf (stderr, "[ILLUME2] Critical Error!!! Cannot create _X_ILLUME_DEACTIVATE_WINDOW Atom...\n");
3340 /* for visibility */
3341 E_ILLUME_ATOM_OVERAY_WINDOW = ecore_x_atom_get ("_E_COMP_OVERAY_WINDOW");
3342 if (!E_ILLUME_ATOM_OVERAY_WINDOW)
3344 fprintf (stderr, "[ILLUME2] Critical Error!!! Cannot create _E_COMP_OVERAY_WINDOW Atom...\n");
3348 E_ILLUME_ATOM_STACK_DISPLAY = ecore_x_atom_get ("_E_ILLUME_PRINT_BORDER_WIN_STACK");
3349 if (!E_ILLUME_ATOM_STACK_DISPLAY)
3351 fprintf (stderr, "[ILLUME2] Critical Error!!! Cannot create _E_ILLUME_PRINT_BORDER_WIN_STACK Atom...\n");
3355 E_ILLUME_ATOM_STACK_DISPLAY_DONE = ecore_x_atom_get ("_E_ILLUME_PRINT_BORDER_WIN_STACK_DONE");
3356 if (!E_ILLUME_ATOM_STACK_DISPLAY_DONE)
3358 fprintf (stderr, "[ILLUME2] Critical Error!!! Cannot create _E_ILLUME_PRINT_BORDER_WIN_STACK_DONE Atom...\n");
3362 E_ILLUME_ATOM_WINDOW_OPAQUE = ecore_x_atom_get ("_E_ILLUME_WINDOW_REGION_OPAQUE");
3363 if (!E_ILLUME_ATOM_WINDOW_OPAQUE)
3365 fprintf (stderr, "[ILLUME2] Critical Error!!! Cannot create _E_ILLUME_WINDOW_REGION_OPAQUE Atom...\n");
3369 #ifdef COMP_MODULE_CONTROL
3370 E_ILLUME_ATOM_COMP_MODULE_ENABLED = ecore_x_atom_get ("_E_COMP_ENABLE");
3371 if(!E_ILLUME_ATOM_COMP_MODULE_ENABLED)
3373 fprintf (stderr, "[ILLUME2] Critical Error!!! Cannot create _E_COMP_ENABLE Atom...\n");
3378 E_INDICATOR_CMD_WIN = ecore_x_atom_get("_E_INDICATOR_CMD_WIN");
3379 if (!E_INDICATOR_CMD_WIN)
3381 fprintf (stderr, "[ILLUME2] Critical Error!!! Cannot create _E_INDICATOR_CMD_WIN Atom...\n");
3385 E_ACTIVE_INDICATOR_WIN = ecore_x_atom_get("_E_ACTIVE_INDICATOR_WIN");
3386 if (!E_ACTIVE_INDICATOR_WIN)
3388 fprintf (stderr, "[ILLUME2] Critical Error!!! Cannot create _E_ACTIVE_INDICATOR_WIN Atom...\n");
3396 int _policy_init (void)
3401 /* for visibility */
3402 _e_illume_xwin_info_hash = eina_hash_string_superfast_new(NULL);
3403 EINA_LIST_FOREACH(e_manager_list(), ml, man)
3405 _policy_manage_xwins (man);
3407 dep_rot.root = man->root;
3408 dep_rot.refer.cmd_win = _policy_indicator_cmd_win_get(dep_rot.root);
3409 if (dep_rot.refer.cmd_win)
3410 dep_rot.refer.active_win = _policy_active_indicator_win_get(dep_rot.refer.cmd_win);
3414 if (!_policy_atom_init())
3416 eina_hash_free (_e_illume_xwin_info_hash);
3420 /* for visibility */
3421 _e_illume_msg_handler = e_msg_handler_add(_policy_msg_handler, NULL);
3427 void _policy_fin (void)
3429 /* for visibility */
3430 if (_e_illume_msg_handler) e_msg_handler_del(_e_illume_msg_handler);
3431 eina_hash_free (_e_illume_xwin_info_hash);
3435 _policy_compare_cb_border (E_Illume_Border_Info* data1, E_Illume_Border_Info* data2)
3439 if (data1->border == data2->border)
3447 static E_Illume_Border_Info*
3448 _policy_get_border_info (E_Border* bd)
3450 ILLUME2_TRACE ("[ILLUME2-NEW] %s(%d)... bd = %x, bd's client = 0x%07x\n", __func__, __LINE__, bd, bd->client.win);
3451 E_Illume_Border_Info tmp_win;
3452 tmp_win.border = bd;
3453 return (E_Illume_Border_Info*) eina_list_search_unsorted (
3454 e_border_info_list, EINA_COMPARE_CB(_policy_compare_cb_border), &tmp_win);
3458 static E_Illume_Border_Info* _policy_add_border_info_list (E_Border* bd)
3460 ILLUME2_TRACE ("[ILLUME2-NEW] %s(%d)... bd = %x, bd's client = 0x%07x\n", __func__, __LINE__, bd, bd->client.win);
3462 if (e_object_is_del(E_OBJECT(bd))) return NULL;
3464 E_Illume_Border_Info* bd_info = (E_Illume_Border_Info*) calloc (1, sizeof (E_Illume_Border_Info));
3467 fprintf (stderr, "[ILLUME2] Critical Error... Fail to create memory... (%s:%d)\n", __func__, __LINE__);
3470 bd_info->pid = bd->client.netwm.pid;
3471 bd_info->border = bd;
3473 bd_info->level = 50;
3475 bd_info->opaque = _policy_property_window_opaque_get(bd->client.win);
3477 // could find bd_info of ev->stack.. there is no bd_info yet...
3478 Eina_List *l = NULL;
3479 E_Illume_Border_Info *temp_bd_info = NULL;
3481 EINA_LIST_FOREACH(e_border_info_list, l, temp_bd_info)
3483 if (!temp_bd_info) continue;
3484 if (bd_info->border->layer >= temp_bd_info->border->layer)
3490 e_border_info_list = eina_list_prepend_relative(e_border_info_list, bd_info, temp_bd_info);
3491 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... changed to [ bd(win:0x%07x) -> other(win:0x%07x) ]\n", __func__, __LINE__, bd->client.win, temp_bd_info->border->client.win);
3495 e_border_info_list = eina_list_append (e_border_info_list, bd_info);
3496 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... changed to [ ---> bd(win:0x%07x) ]\n", __func__, __LINE__, bd->client.win);
3503 static void _policy_delete_border_info_list (E_Border* bd)
3505 ILLUME2_TRACE ("[ILLUME2-NEW] %s(%d)... bd = %x, bd's client = 0x%07x\n", __func__, __LINE__, bd, bd->client.win);
3506 E_Illume_Border_Info* bd_info = _policy_get_border_info (bd);
3508 if (bd_info == NULL)
3510 ILLUME2_TRACE ("[ILLUME2-NEW] %s(%d)... There is no border in the list... bd = %x, bd's client = 0x%07x\n", __func__, __LINE__, bd, bd->client.win);
3514 _policy_border_illume_handlers_remove(bd_info);
3516 e_border_info_list = eina_list_remove (e_border_info_list, bd_info);
3517 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... remove bd(win:0x%07x)\n", __func__, __LINE__, bd->client.win);
3523 _policy_zone_layout_app_layer_check (E_Border* bd)
3525 Ecore_X_Window_Type *types = NULL;
3526 E_Illume_Border_Info *bd_info;
3529 if (!bd) return POL_APP_LAYER;
3531 bd_info = _policy_get_border_info(bd);
3532 if (!bd_info) return POL_APP_LAYER;
3534 layer = POL_APP_LAYER;
3536 num = ecore_x_netwm_window_types_get(bd->client.win, &types);
3540 for (i=0; i< num; i++)
3542 if (types[i] == ECORE_X_WINDOW_TYPE_NOTIFICATION)
3543 layer = _policy_notification_level_map(bd_info->level);
3549 if (bd->client.netwm.state.stacking == E_STACKING_BELOW)
3551 ILLUME2_TRACE ("[ILLUME2-NEW] %s(%d)... WIN:0x%07x is BELOW state.. Change layer to 50\n", __func__, __LINE__, bd->client.win);
3552 layer = POL_STATE_BELOW_LAYER;
3554 else if (bd->client.netwm.state.stacking == E_STACKING_ABOVE)
3556 ILLUME2_TRACE ("[ILLUME2-NEW] %s(%d)... WIN:0x%07x is ABOVE state.. Change layer to 150\n", __func__, __LINE__, bd->client.win);
3557 layer = POL_STATE_ABOVE_LAYER;
3565 _policy_zone_layout_app_layer_set (E_Border* bd, int new_layer)
3569 /* if a window sets transient_for property, it sets same layer to parent window */
3570 if (bd->client.icccm.transient_for != 0)
3572 E_Border *bd_parent = NULL;
3573 bd_parent = e_border_find_by_client_window (bd->client.icccm.transient_for);
3576 if (bd->layer != bd_parent->layer)
3577 e_border_layer_set (bd, bd_parent->layer);
3582 if (bd->layer != new_layer)
3583 e_border_layer_set(bd, new_layer);
3588 _policy_zone_layout_app_single_new (E_Illume_Border_Info* bd_info, E_Illume_Config_Zone *cz)
3592 Eina_Bool resize = EINA_FALSE;
3593 Eina_Bool move = EINA_FALSE;
3595 ILLUME2_TRACE ("[ILLUME2-NEW] %s(%d)... LAYOUT_SINGLE... bd_info's border = %x, client win = 0x%07x\n", __func__, __LINE__, bd_info->border, bd_info->border->client.win);
3597 bd = bd_info->border;
3600 fprintf (stderr, "[ILLUME2] fatal error! (%s) There is no border!\n", __func__);
3604 if (bd->moving && !bd->client.illume.win_state.state)
3606 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... Cancel moving... win:0x%07x, bd->moving:%d\n", __func__, __LINE__, bd->client.win, bd->moving);
3607 e_border_move_cancel();
3610 if ((!bd->new_client) && (!bd->visible)) return;
3612 layer = _policy_zone_layout_app_layer_check (bd);
3614 /* check if user defined position */
3615 if (bd->client.icccm.request_pos)
3617 if (bd->client.illume.win_state.state)
3619 if (bd_info->resize_req.need_change)
3621 if ((bd->x != bd_info->resize_req.mouse.x) ||
3622 (bd->y != bd_info->resize_req.mouse.y))
3625 if ((bd->w != bd_info->resize_req.mouse.w) ||
3626 (bd->h != bd_info->resize_req.mouse.h))
3631 e_border_move_resize(bd,
3632 bd_info->resize_req.mouse.x,
3633 bd_info->resize_req.mouse.y,
3634 bd_info->resize_req.mouse.w,
3635 bd_info->resize_req.mouse.h);
3639 _policy_border_move(bd,
3640 bd_info->resize_req.mouse.x,
3641 bd_info->resize_req.mouse.y);
3645 _policy_border_resize(bd,
3646 bd_info->resize_req.mouse.w,
3647 bd_info->resize_req.mouse.h);
3650 bd_info->resize_req.need_change = 0;
3651 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... bd move resize... (%d, %d, %d, %d)\n", __func__, __LINE__, bd->x, bd->y, bd->w, bd->h);
3654 if (bd_info->resize_req.mouse.down &&
3655 bd_info->resize_req.mouse.locked)
3657 if ((bd->x != bd_info->resize_req.mouse.x) ||
3658 (bd->y != bd_info->resize_req.mouse.y))
3659 _policy_border_move(bd,
3660 bd_info->resize_req.mouse.x,
3661 bd_info->resize_req.mouse.y);
3662 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... bd move resize... (%d, %d, %d, %d)\n", __func__, __LINE__, bd->x, bd->y, bd->w, bd->h);
3666 _policy_zone_layout_app_layer_set (bd, layer);
3670 /* resize & move if needed */
3671 if (bd->client.illume.win_state.state)
3673 if (bd_info->resize_req.need_change)
3675 if ((bd->x != bd_info->resize_req.mouse.x) ||
3676 (bd->y != bd_info->resize_req.mouse.y))
3679 if ((bd->w != bd_info->resize_req.mouse.w) ||
3680 (bd->h != bd_info->resize_req.mouse.h))
3685 e_border_move_resize(bd,
3686 bd_info->resize_req.mouse.x,
3687 bd_info->resize_req.mouse.y,
3688 bd_info->resize_req.mouse.w,
3689 bd_info->resize_req.mouse.h);
3693 _policy_border_move(bd,
3694 bd_info->resize_req.mouse.x,
3695 bd_info->resize_req.mouse.y);
3699 _policy_border_resize(bd,
3700 bd_info->resize_req.mouse.w,
3701 bd_info->resize_req.mouse.h);
3704 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... bd move resize... (%d, %d, %d, %d)\n", __func__, __LINE__, bd->x, bd->y, bd->w, bd->h);
3705 bd_info->resize_req.need_change = 0;
3708 if (bd_info->resize_req.mouse.down &&
3709 bd_info->resize_req.mouse.locked)
3711 if ((bd->x != bd_info->resize_req.mouse.x) ||
3712 (bd->y != bd_info->resize_req.mouse.y))
3713 _policy_border_move(bd,
3714 bd_info->resize_req.mouse.x,
3715 bd_info->resize_req.mouse.y);
3716 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... bd move resize... (%d, %d, %d, %d)\n", __func__, __LINE__, bd->x, bd->y, bd->w, bd->h);
3721 if ((bd->w != bd->zone->w) || (bd->h != bd->zone->h))
3724 if ((bd->x != bd->zone->x) || (bd->y != bd->zone->y))
3728 e_border_move_resize(bd, bd->zone->x, bd->zone->y, bd->zone->w, bd->zone->h);
3730 _policy_border_resize(bd, bd->zone->w, bd->zone->h);
3732 _policy_border_move(bd, bd->zone->x, bd->zone->y);
3735 /* set layer if needed */
3736 _policy_zone_layout_app_layer_set (bd, layer);
3741 _policy_zone_layout_app_dual_top_new (E_Illume_Border_Info* bd_info, E_Illume_Config_Zone *cz)
3747 Eina_Bool resize = EINA_FALSE;
3748 Eina_Bool move = EINA_FALSE;
3750 ILLUME2_TRACE ("[ILLUME2-NEW] %s(%d)... LAYOUT_DUAL_TOP... bd_info's border = %x, client win = 0x%07x\n", __func__, __LINE__, bd_info->border, bd_info->border->client.win);
3752 bd = bd_info->border;
3754 if (!bd || !cz) return;
3755 if ((!bd->new_client) && (!bd->visible)) return;
3757 layer = _policy_zone_layout_app_layer_check (bd);
3759 // check if user defined position
3760 if (bd->client.icccm.request_pos)
3762 _policy_zone_layout_app_layer_set (bd, layer);
3766 /* set a default Y position */
3767 ny = (bd->zone->y + cz->indicator.size);
3768 nh = ((bd->zone->h - cz->indicator.size - cz->softkey.size) / 2);
3770 /* see if there is a border already there. if so, check placement based on
3771 * virtual keyboard usage */
3772 temp_bd = e_illume_border_at_xy_get(bd->zone, bd->zone->x, ny);
3773 if ((temp_bd) && (temp_bd != bd)) ny = temp_bd->y + nh;
3775 /* resize if needed */
3776 if ((bd->w != bd->zone->w) || (bd->h != nh))
3779 /* move to correct position (relative to zone) if needed */
3780 if ((bd->x != bd->zone->x) || (bd->y != ny))
3784 e_border_move_resize(bd, bd->zone->x, ny, bd->zone->w, nh);
3786 _policy_border_resize(bd, bd->zone->w, nh);
3788 _policy_border_move(bd, bd->zone->x, ny);
3790 /* set layer if needed */
3791 _policy_zone_layout_app_layer_set (bd, layer);
3795 _policy_zone_layout_app_dual_left_new (E_Illume_Border_Info* bd_info, E_Illume_Config_Zone *cz)
3801 Eina_Bool resize = EINA_FALSE;
3802 Eina_Bool move = EINA_FALSE;
3804 ILLUME2_TRACE ("[ILLUME2-NEW] %s(%d)... LAYOUT_DUAL_LEFT... bd_info's border = %x, client win = 0x%07x\n", __func__, __LINE__, bd_info->border, bd_info->border->client.win);
3806 bd = bd_info->border;
3808 if (!bd || !cz) return;
3809 if ((!bd->new_client) && (!bd->visible)) return;
3811 layer = _policy_zone_layout_app_layer_check (bd);
3813 // check if user defined position
3814 if (bd->client.icccm.request_pos)
3816 _policy_zone_layout_app_layer_set (bd, layer);
3820 /* set some defaults */
3822 nw = (bd->zone->w / 2);
3824 ky = bd->zone->y + cz->indicator.size;
3825 kh = bd->zone->h - cz->indicator.size - cz->softkey.size;
3827 /* see if there is a border already there. if so, place at right */
3828 temp_bd = e_illume_border_at_xy_get(bd->zone, nx, (ky + bd->zone->h / 2));
3829 if ((temp_bd) && (bd != temp_bd)) nx = temp_bd->x + nw;
3831 /* resize if needed */
3832 if ((bd->w != nw) || (bd->h != kh))
3835 /* move to correct position (relative to zone) if needed */
3836 if ((bd->x != nx) || (bd->y != ky))
3840 e_border_move_resize(bd, nx, ky, nw, kh);
3842 _policy_border_resize(bd, nw, kh);
3844 _policy_border_move(bd, nx, ky);
3846 /* set layer if needed */
3847 _policy_zone_layout_app_layer_set (bd, layer);
3852 _policy_zone_layout_app_dual_custom_new (E_Illume_Border_Info* bd_info, E_Illume_Config_Zone *cz)
3857 Eina_Bool resize = EINA_FALSE;
3858 Eina_Bool move = EINA_FALSE;
3860 ILLUME2_TRACE ("[ILLUME2-NEW] %s(%d)... LAYOUT_DUAL_CUSTOM... bd_info's border = %x, client win = 0x%07x\n", __func__, __LINE__, bd_info->border, bd_info->border->client.win);
3862 bd = bd_info->border;
3865 fprintf (stderr, "[ILLUME2] fatal error! (%s) There is no border!\n", __func__);
3869 if ((!bd->new_client) && (!bd->visible)) return;
3871 /* grab indicator position */
3872 e_illume_border_indicator_pos_get(bd->zone, NULL, &iy);
3874 /* set a default position */
3878 app = e_illume_border_at_xy_get(bd->zone, bd->zone->x, bd->zone->y);
3883 ny = (iy + cz->indicator.size);
3884 nh = ((bd->zone->y + bd->zone->h) - ny - cz->softkey.size);
3888 /* make sure it's the required width & height */
3889 if ((bd->w != bd->zone->w) || (bd->h != nh))
3892 /* move to correct position (relative to zone) if needed */
3893 if ((bd->x != bd->zone->x) || (bd->y != ny))
3897 e_border_move_resize(bd, bd->zone->x, ny, bd->zone->w, nh);
3899 _policy_border_resize(bd, bd->zone->w, nh);
3901 _policy_border_move(bd, bd->zone->x, ny);
3903 /* set layer if needed */
3904 if (bd->layer != POL_APP_LAYER)
3905 e_border_layer_set(bd, POL_APP_LAYER);
3908 static int _policy_border_get_notification_level (Ecore_X_Window win)
3913 unsigned char* prop_data = NULL;
3915 ret = ecore_x_window_prop_property_get (win, E_ILLUME_ATOM_NOTIFICATION_LEVEL, ECORE_X_ATOM_CARDINAL, 32, &prop_data, &num);
3916 if( ret && prop_data )
3917 memcpy (&level, prop_data, sizeof (int));
3919 if (prop_data) free (prop_data);
3925 _policy_notification_level_map(int level)
3929 case E_ILLUME_NOTIFICATION_LEVEL_LOW: return POL_NOTIFICATION_LAYER_LOW;
3930 case E_ILLUME_NOTIFICATION_LEVEL_NORMAL: return POL_NOTIFICATION_LAYER_NORMAL;
3931 case E_ILLUME_NOTIFICATION_LEVEL_HIGH: return POL_NOTIFICATION_LAYER_HIGH;
3932 default: return POL_NOTIFICATION_LAYER_LOW;
3936 /* find new focus window */
3938 _policy_border_focus_top_stack_set (E_Border* bd)
3941 E_Border *cur_focus;
3945 root_w = bd->zone->w;
3946 root_h = bd->zone->h;
3948 cur_focus = e_border_focused_get();
3950 bl = e_container_border_list_last(bd->zone->container);
3951 while ((temp_bd = e_container_border_list_prev(bl)))
3953 if (temp_bd == cur_focus) break;
3955 if ((temp_bd->x >= root_w) || (temp_bd->y >= root_h)) continue;
3956 if (((temp_bd->x + temp_bd->w) <= 0) || ((temp_bd->y + temp_bd->h) <= 0)) continue;
3957 if ((temp_bd != bd) &&
3958 (temp_bd->client.illume.win_state.state == ECORE_X_ILLUME_WINDOW_STATE_FLOATING)) continue;
3960 if ((!temp_bd->iconic) && (temp_bd->visible) && (temp_bd->desk == bd->desk) &&
3961 (temp_bd->client.icccm.accepts_focus || temp_bd->client.icccm.take_focus) &&
3962 (temp_bd->client.netwm.type != ECORE_X_WINDOW_TYPE_DOCK) &&
3963 (temp_bd->client.netwm.type != ECORE_X_WINDOW_TYPE_TOOLBAR) &&
3964 (temp_bd->client.netwm.type != ECORE_X_WINDOW_TYPE_MENU) &&
3965 (temp_bd->client.netwm.type != ECORE_X_WINDOW_TYPE_SPLASH) &&
3966 (temp_bd->client.netwm.type != ECORE_X_WINDOW_TYPE_DESKTOP))
3968 if (!temp_bd->focused)
3970 /* this border is the top of the latest stack */
3971 e_border_focus_set (temp_bd, 1, 1);
3976 e_container_border_list_free(bl);
3979 void _policy_border_stack (E_Event_Border_Stack *event)
3981 E_Event_Border_Stack* ev;
3982 E_Illume_Border_Info* bd_info;
3983 E_Illume_Border_Info* stack_bd_info;
3987 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... bd(win:0x%07x), stack(win:0x%07x), stack type: %d\n", __func__, __LINE__, ev->border->client.win, ev->stack ? (unsigned int)ev->stack->client.win:(unsigned int)NULL, ev->type);
3989 bd_info = _policy_get_border_info(ev->border);
3990 if (!bd_info) return;
3994 stack_bd_info = _policy_get_border_info(ev->stack);
3998 stack_bd_info = NULL;
4001 if (ev->type == E_STACKING_ABOVE)
4007 e_border_info_list = eina_list_remove (e_border_info_list, bd_info);
4008 e_border_info_list = eina_list_prepend_relative (e_border_info_list, bd_info, stack_bd_info);
4009 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... changed to [ bd(win:0x%07x) -> stack(win:0x%07x) ]\n", __func__, __LINE__, ev->border->client.win, ev->stack->client.win);
4013 // could find bd_info of ev->stack.. there is no bd_info yet...
4014 Eina_List *l = NULL;
4015 E_Illume_Border_Info *temp_bd_info;
4017 EINA_LIST_FOREACH(e_border_info_list, l, temp_bd_info)
4019 if (!temp_bd_info) continue;
4020 if (bd_info->border->layer >= temp_bd_info->border->layer)
4024 if (bd_info != temp_bd_info)
4026 e_border_info_list = eina_list_remove (e_border_info_list, bd_info);
4027 e_border_info_list = eina_list_prepend_relative(e_border_info_list, bd_info, temp_bd_info);
4028 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... changed to [ bd(win:0x%07x) -> other(win:0x%07x).. No stack(win:0x%07x) info ]\n", __func__, __LINE__, ev->border->client.win, temp_bd_info ? (unsigned int)temp_bd_info->border->client.win:(unsigned int)NULL, ev->stack->client.win);
4034 e_border_info_list = eina_list_remove (e_border_info_list, bd_info);
4035 e_border_info_list = eina_list_append (e_border_info_list, bd_info);
4036 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... changed to [ ---> bd(win:0x%07x) ]\n", __func__, __LINE__, ev->border->client.win);
4039 else if (ev->type == E_STACKING_BELOW)
4045 e_border_info_list = eina_list_remove (e_border_info_list, bd_info);
4046 e_border_info_list = eina_list_append_relative (e_border_info_list, bd_info, stack_bd_info);
4047 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... changed to [ stack(win:0x%07x) -> bd(win:0x%07x) ]\n", __func__, __LINE__, ev->stack->client.win, ev->border->client.win);
4051 // could find bd_info of ev->stack.. there is no bd_info yet...
4052 Eina_List *l = NULL;
4053 E_Illume_Border_Info *temp_bd_info;
4055 EINA_LIST_FOREACH(e_border_info_list, l, temp_bd_info)
4057 if (!temp_bd_info) continue;
4058 if (bd_info->border->layer >= temp_bd_info->border->layer)
4062 if (bd_info != temp_bd_info)
4064 e_border_info_list = eina_list_remove (e_border_info_list, bd_info);
4065 e_border_info_list = eina_list_prepend_relative(e_border_info_list, bd_info, temp_bd_info);
4066 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... changed to [ bd(win:0x%07x) -> other(win:0x%07x).. No stack(win:0x%07x) info ]\n", __func__, __LINE__, ev->border->client.win, temp_bd_info ? (unsigned int)temp_bd_info->border->client.win:(unsigned int)NULL, ev->stack->client.win);
4072 e_border_info_list = eina_list_remove (e_border_info_list, bd_info);
4073 e_border_info_list = eina_list_prepend (e_border_info_list, bd_info);
4074 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... changed to [ bd(win:0x%07x) ---> ]\n", __func__, __LINE__, ev->border->client.win);
4079 ILLUME2_TRACE ("[ILLUME2-NEW] %s(%d)... Unknown type... border (0x%07x), win (0x%07x), type = %d\n", __func__, __LINE__, ev->border, ev->border->client.win, ev->type);
4082 /* restack indicator when a active window stack is changed */
4083 if ((ev->border->client.win == g_active_win) &&
4084 (ev->border->layer == POL_NOTIFICATION_LAYER))
4087 indi_bd = e_illume_border_indicator_get(ev->border->zone);
4090 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... win = 0x%07x.. Control Indicator.\n", __func__, __LINE__, ev->border->client.win);
4091 _policy_border_indicator_control(indi_bd);
4095 ev->border->changes.pos = 1;
4096 ev->border->changed = 1;
4101 void _policy_border_zone_set(E_Event_Border_Zone_Set *event)
4103 E_Event_Border_Zone_Set* ev;
4111 ecore_x_e_illume_zone_set(bd->client.win, bd->zone->black_win);
4114 static void _policy_change_quickpanel_layer (E_Illume_Quickpanel* qp, E_Border* indi_bd, int layer, int level)
4117 E_Illume_Quickpanel_Info *panel;
4118 E_Illume_Border_Info* bd_info;
4124 bd_info = _policy_get_border_info(qp->popup->border);
4127 bd_info->level = level;
4128 e_border_stack_below (qp->popup->border, indi_bd);
4132 EINA_LIST_FOREACH(qp->hidden_mini_controllers, bd_list, panel)
4134 if (!panel) continue;
4135 if (e_object_is_del(E_OBJECT(panel->bd))) continue;
4137 bd_info = _policy_get_border_info(panel->bd);
4140 bd_info->level = level;
4141 e_border_stack_below (panel->bd, indi_bd);
4145 EINA_LIST_FOREACH(qp->borders, bd_list, panel)
4147 if (!panel) continue;
4148 if (e_object_is_del(E_OBJECT(panel->bd))) continue;
4150 bd_info = _policy_get_border_info(panel->bd);
4153 bd_info->level = level;
4154 e_border_stack_below (panel->bd, indi_bd);
4159 static void _policy_change_indicator_layer(E_Border *indi_bd, E_Border *bd, int layer, int level)
4161 // the indicator's layer is changed to layer with level
4162 E_Illume_Border_Info *indi_bd_info;
4163 E_Illume_Quickpanel *qp;
4164 int new_noti_layer = 0;
4166 indi_bd_info = _policy_get_border_info(indi_bd);
4169 indi_bd_info->level = level;
4172 if (layer == POL_NOTIFICATION_LAYER)
4174 new_noti_layer = _policy_notification_level_map(level);
4176 if (indi_bd->layer != new_noti_layer)
4177 e_border_layer_set(indi_bd, new_noti_layer);
4179 else if (indi_bd->layer != layer)
4180 e_border_layer_set(indi_bd, layer);
4185 E_Illume_Border_Info *top_bd_info;
4187 // check transient_for window
4188 top_bd = _policy_border_transient_for_border_top_get(bd);
4189 if (!top_bd) top_bd = bd;
4191 top_bd_info = _policy_get_border_info(top_bd);
4194 if ((qp = e_illume_quickpanel_by_zone_get(indi_bd->zone)))
4196 _policy_change_quickpanel_layer(qp, indi_bd, layer, level);
4201 L (LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... indicator's below win:0x%07x\n", __func__, __LINE__, top_bd->client.win);
4202 _policy_border_stack_change(indi_bd, top_bd, E_ILLUME_STACK_ABOVE);
4204 e_border_info_list = eina_list_remove(e_border_info_list, indi_bd_info);
4205 e_border_info_list = eina_list_prepend_relative(e_border_info_list, indi_bd_info, top_bd_info);
4206 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... changed to [ bd(win:0x%07x) -> other(win:0x%07x) ]\n", __func__, __LINE__, indi_bd->client.win, top_bd->client.win);
4209 if ((qp = e_illume_quickpanel_by_zone_get(indi_bd->zone)))
4211 _policy_change_quickpanel_layer(qp, indi_bd, layer, level);
4215 static Eina_Bool _policy_border_indicator_state_change(E_Border *indi_bd, E_Border *bd)
4217 E_Illume_Border_Info *bd_info;
4221 if (!indi_bd || !bd) return EINA_FALSE;
4223 indi_show = _policy_border_indicator_state_get(bd);
4226 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... Show Indicator (by win: 0x%07x)\n", __func__, __LINE__, bd->client.win);
4227 e_border_show(indi_bd);
4229 if ((e_illume_border_is_notification(bd)) ||
4230 (bd->layer == POL_NOTIFICATION_LAYER))
4232 bd_info = _policy_get_border_info(bd);
4234 level = bd_info->level;
4238 L(LT_NOTIFICATION, "[ILLUME2][NOTIFICATION] %s(%d)... Notification Win:0x%07x, Update Indicator's layer to NOTIFICATION.. level = %d\n", __func__, __LINE__, bd->client.win, level);
4239 _policy_change_indicator_layer(indi_bd, bd, POL_NOTIFICATION_LAYER, level);
4243 _policy_change_indicator_layer(indi_bd, NULL, POL_NOTIFICATION_LAYER, 50);
4248 else if (indi_show == 0)
4250 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... Hide Indicator (by win: 0x%07x)\n", __func__, __LINE__, bd->client.win);
4251 e_border_hide(indi_bd, 2);
4261 _policy_border_indicator_control(E_Border *indi_bd)
4263 Eina_Inlist *xwin_info_list;
4264 E_Illume_XWin_Info *xwin_info;
4266 Ecore_X_Illume_Indicator_Opacity_Mode mode;
4268 if (!indi_bd) return;
4271 xwin_info_list = _e_illume_xwin_info_list;
4275 EINA_INLIST_REVERSE_FOREACH (xwin_info_list, xwin_info)
4277 if (xwin_info->visibility != E_ILLUME_VISIBILITY_FULLY_OBSCURED)
4279 if (xwin_info->bd_info)
4281 bd = xwin_info->bd_info->border;
4284 if (!bd->visible) continue;
4285 if (indi_bd == bd) continue;
4286 if (indi_bd->zone != bd->zone) continue;
4287 if (e_illume_border_is_indicator(bd)) continue;
4288 if (e_illume_border_is_keyboard(bd)) continue;
4289 if (bd->client.illume.win_state.state == ECORE_X_ILLUME_WINDOW_STATE_FLOATING) continue;
4291 if (!_policy_border_indicator_state_change(indi_bd, bd))
4294 mode = ecore_x_e_illume_indicator_opacity_get(bd->client.win);
4295 ecore_x_e_illume_indicator_opacity_send(indi_bd->client.win, mode);
4297 _policy_root_angle_set(bd);
4299 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... indicator_control_win = 0x%07x...\n", __func__, __LINE__, bd->client.win);
4300 g_indi_control_win = bd->client.win;
4308 /* for visibility */
4310 _policy_send_visibility_notify (Ecore_X_Window win, int visibility)
4314 event.type = VisibilityNotify;
4315 event.xvisibility.display = ecore_x_display_get();
4316 event.xvisibility.send_event = EINA_TRUE;
4317 event.xvisibility.state = visibility;
4318 event.xvisibility.window = win;
4320 XSendEvent(event.xvisibility.display
4321 , event.xvisibility.window
4323 , VisibilityChangeMask, &event);
4327 _policy_check_transient_child_visible(E_Border *bd)
4329 Eina_Bool ret = EINA_FALSE;
4330 E_Illume_XWin_Info *child_xwin_info = NULL;
4332 E_Border *child = NULL;
4334 EINA_LIST_FOREACH(bd->transients, l, child)
4336 if (!child) continue;
4337 if (ret) return ret;
4339 child_xwin_info = _policy_xwin_info_find(child->win);
4340 if ((child_xwin_info) &&
4341 (child_xwin_info->visibility == E_ILLUME_VISIBILITY_UNOBSCURED))
4346 ret = _policy_check_transient_child_visible(child);
4353 _policy_calculate_visibility(void)
4355 // 1. CALCULATES window's region and decide it's visibility.
4356 // 2. DO (UN)ICONIFY if it's needed.
4357 // 3. SEND notify about visibility.
4359 E_Zone *zone = NULL;
4360 E_Border *bd = NULL, *indi_bd = NULL;
4361 Eina_Inlist *xwin_info_list = NULL;
4362 E_Illume_XWin_Info *xwin_info = NULL;
4363 E_Illume_Border_Info *bd_info = NULL;
4364 Ecore_X_XRegion *visible_region = NULL;
4365 Ecore_X_XRegion *win_region = NULL;
4366 Ecore_X_Rectangle visible_rect, win_rect;
4367 Eina_Bool is_fully_obscured = EINA_FALSE;
4368 Eina_Bool obscured_by_special_bd = EINA_FALSE;
4369 Eina_Bool is_opaque_win = EINA_FALSE;
4370 Eina_Bool do_not_iconify = EINA_FALSE;
4372 int set_root_angle = 0;
4373 int control_indi = 0;
4375 if (!_g_visibility_changed) return;
4376 _g_visibility_changed = EINA_FALSE;
4378 L(LT_VISIBILITY, "[ILLUME2][VISIBILITY] %s(%d).. BEGIN calculate visibility ...\n", __func__, __LINE__);
4379 xwin_info_list = _e_illume_xwin_info_list;
4380 if (!xwin_info_list) return;
4382 // set the entire visible region as a root geometry
4385 visible_rect.width = _g_root_width;
4386 visible_rect.height = _g_root_height;
4388 visible_region = ecore_x_xregion_new();
4389 if (!visible_region)
4391 L (LT_VISIBILITY_DETAIL,
4392 "[ILLUME2][VISIBILITY] BAD.... Creating visible region is failed.\n");
4396 ecore_x_xregion_union_rect(visible_region, visible_region, &visible_rect);
4398 EINA_INLIST_REVERSE_FOREACH (xwin_info_list, xwin_info)
4400 // skip "input only" window
4401 if (xwin_info->attr.input_only) continue;
4403 // skip "unmap" window
4404 if ((xwin_info->viewable == 0) &&
4405 (xwin_info->iconify_by_wm == 0)) continue;
4407 if (!xwin_info->is_drawed) continue;
4409 // initializing variable
4412 is_opaque_win = EINA_TRUE;
4413 do_not_iconify = EINA_FALSE;
4414 old_vis = xwin_info->visibility;
4416 bd_info = xwin_info->bd_info;
4417 if (bd_info) bd = bd_info->border;
4419 // 1. calculates window's region and decide it's visibility.
4420 if (is_fully_obscured == EINA_FALSE)
4422 win_rect.x = xwin_info->attr.x;
4423 win_rect.y = xwin_info->attr.y;
4424 win_rect.width = xwin_info->attr.w;
4425 win_rect.height = xwin_info->attr.h;
4427 // if it stick out or is bigger than the entire visible region,
4428 // clip it by the entire visible's geometry.
4429 E_RECTS_CLIP_TO_RECT(win_rect.x, win_rect.y,
4430 win_rect.width, win_rect.height,
4431 visible_rect.x, visible_rect.y,
4432 (int)(visible_rect.width), (int)(visible_rect.height));
4434 if (ecore_x_xregion_rect_contain(visible_region, &win_rect))
4436 xwin_info->visibility = obscured_by_special_bd ?
4437 E_ILLUME_VISIBILITY_FULLY_OBSCURED :
4438 E_ILLUME_VISIBILITY_UNOBSCURED;
4442 if (e_illume_border_is_lock_screen(bd))
4444 obscured_by_special_bd = EINA_TRUE;
4445 is_opaque_win = EINA_FALSE;
4447 else if ((bd->client.illume.win_state.state ==
4448 ECORE_X_ILLUME_WINDOW_STATE_FLOATING) ||
4449 ((bd_info->opaque == 0) && (bd->client.argb)))
4450 is_opaque_win = EINA_FALSE;
4454 if (xwin_info->argb)
4455 is_opaque_win = EINA_FALSE;
4460 win_region = ecore_x_xregion_new();
4463 ecore_x_xregion_union_rect(win_region, win_region, &win_rect);
4464 ecore_x_xregion_subtract(visible_region, visible_region, win_region);
4465 ecore_x_xregion_free(win_region);
4468 if (ecore_x_xregion_is_empty(visible_region))
4470 is_fully_obscured = EINA_TRUE;
4477 xwin_info->visibility = E_ILLUME_VISIBILITY_FULLY_OBSCURED;
4482 xwin_info->visibility = E_ILLUME_VISIBILITY_FULLY_OBSCURED;
4483 obscured_by_special_bd = EINA_FALSE;
4487 if (!E_ILLUME_BORDER_IS_IN_MOBILE(bd)) continue;
4489 // decide if it's the border that DO NOT iconify.
4490 if (obscured_by_special_bd)
4492 do_not_iconify = EINA_TRUE;
4494 // when this border has transient windows,
4495 // check out this child's visibility.
4496 // if there is any child window that is UNOBSCURED,
4497 // DO NOT iconify this border.
4498 else if (bd->transients)
4500 do_not_iconify = _policy_check_transient_child_visible(bd);
4503 // 2. DO (UN)ICONIFY and send visibility notify if it's needed.
4504 if (old_vis != xwin_info->visibility)
4507 LOGD("[WM] SEND VISIBILITY. win:0x%07x (old:%d -> new:%d)", xwin_info->bd_info->border->client.win, old_vis, xwin_info->visibility);
4509 L(LT_VISIBILITY, "[ILLUME2][VISIBILITY] SEND VISIBILITY NOTIFY (Line:%d)... win:0x%07x (old:%d -> new:%d)\n", __LINE__, bd->client.win, old_vis, xwin_info->visibility);
4510 _policy_send_visibility_notify(bd->client.win, xwin_info->visibility);
4512 if (xwin_info->visibility == E_ILLUME_VISIBILITY_UNOBSCURED)
4514 L (LT_ANGLE, "[ILLUME2][ANGLE] %s(%d).. CALL _policy_change_root_angle_b y_border_angle!!! win:0x%07x\n", __func__, __LINE__, xwin_info->bd_info->border->client.win);
4517 if (_e_illume_cfg->use_force_iconify)
4521 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d).. Uniconify by illume.. win:0x%07x (parent:0x%07x)\n", __func__, __LINE__, xwin_info->bd_info->border->client.win, xwin_info->bd_info->border->parent ? xwin_info->bd_info->border->parent->client.win:(unsigned int)NULL);
4522 _policy_border_force_uniconify(bd);
4526 else if (xwin_info->visibility == E_ILLUME_VISIBILITY_FULLY_OBSCURED)
4528 if (bd->client.win == g_rotated_win)
4530 L(LT_ANGLE, "[ILLUME2][ANGLE] %s(%d).. g_rotated_win(0x%07x) is obscured.\n", __func__, __LINE__, xwin_info->bd_info->border->client.win);
4534 if (_e_illume_cfg->use_force_iconify)
4536 if ((!bd->iconic) && (!do_not_iconify))
4538 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d).. Iconify by illume.. win:0x%07x (parent:0x%07x)\n", __func__, __LINE__, xwin_info->bd_info->border->client.win, xwin_info->bd_info->border->parent ? xwin_info->bd_info->border->parent->client.win:(unsigned int)NULL);
4539 _policy_border_iconify_by_illume(xwin_info);
4545 zone = xwin_info->bd_info->border->zone;
4549 if (xwin_info->visibility == E_ILLUME_VISIBILITY_FULLY_OBSCURED)
4551 if (_e_illume_cfg->use_force_iconify)
4553 if (bd->parent && bd->parent->iconic)
4555 if ((!bd->iconic) && (!do_not_iconify))
4557 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d).. Iconify by illume.. win:0x%07x (parent:0x%07x)\n", __func__, __LINE__, xwin_info->bd_info->border->client.win, xwin_info->bd_info->border->parent ? xwin_info->bd_info->border->parent->client.win:(unsigned int)NULL);
4558 _policy_border_iconify_by_illume(xwin_info);
4568 if (_e_illume_cfg->use_indicator_widget)
4570 L(LT_ANGLE, "[ILLUME2][ANGLE] %s(%d)... Control Root Angle.\n", __func__, __LINE__);
4571 _policy_border_root_angle_control(zone);
4575 indi_bd = e_illume_border_indicator_get(zone);
4578 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... Control Indicator.\n", __func__, __LINE__);
4579 _policy_border_indicator_control(indi_bd);
4584 L(LT_VISIBILITY, "[ILLUME2][VISIBILITY] %s(%d).. END calculate visibility ...\n", __func__, __LINE__);
4586 if (visible_region) ecore_x_xregion_free(visible_region);
4589 static E_Illume_XWin_Info*
4590 _policy_xwin_info_find (Ecore_X_Window win)
4592 return eina_hash_find(_e_illume_xwin_info_hash, e_util_winid_str_get(win));
4597 _policy_manage_xwins (E_Manager* man)
4599 Ecore_X_Window *windows;
4603 windows = ecore_x_window_children_get(man->root, &wnum);
4606 for (i = 0; i < wnum; i++)
4607 _policy_xwin_info_add(windows[i]);
4612 ecore_x_window_size_get (man->root, &_g_root_width, &_g_root_height);
4617 _policy_xwin_info_add (Ecore_X_Window win)
4621 if (win == _e_overlay_win) return EINA_FALSE;
4623 E_Illume_XWin_Info* xwin_info = _policy_xwin_info_find (win);
4626 L (LT_XWIN, "[ILLUME2][XWIN] %s(%d).. win:0x%07x EXIST in the list...\n", __func__, __LINE__, win);
4630 xwin_info = (E_Illume_XWin_Info*) calloc (1, sizeof (E_Illume_XWin_Info));
4633 L (LT_XWIN, "[ILLUME2][XWIN] (%s:%d).. Critical Error... Fail to create memory... \n", __func__, __LINE__);
4637 xwin_info->id = win;
4638 xwin_info->visibility = E_ILLUME_VISIBILITY_FULLY_OBSCURED;
4640 if (!ecore_x_window_attributes_get(win, &xwin_info->attr))
4646 xwin_info->viewable = xwin_info->attr.viewable;
4648 bd = e_border_find_by_window (win);
4649 xwin_info->bd_info = _policy_get_border_info(bd);
4650 xwin_info->argb = ecore_x_window_argb_get (win);
4652 if (_e_use_comp) xwin_info->comp_vis = 0;
4653 else xwin_info->comp_vis = 1;
4655 eina_hash_add(_e_illume_xwin_info_hash, e_util_winid_str_get(xwin_info->id), xwin_info);
4656 _e_illume_xwin_info_list = eina_inlist_append(_e_illume_xwin_info_list, EINA_INLIST_GET(xwin_info));
4663 _policy_xwin_info_delete (Ecore_X_Window win)
4665 E_Illume_XWin_Info* xwin_info = _policy_xwin_info_find (win);
4666 if (xwin_info == NULL)
4668 L (LT_XWIN, "[ILLUME2][XWIN] %s(%d).. No win:0x%07x in the list...\n", __func__, __LINE__, win);
4672 _e_illume_xwin_info_list = eina_inlist_remove(_e_illume_xwin_info_list, EINA_INLIST_GET(xwin_info));
4673 eina_hash_del(_e_illume_xwin_info_hash, e_util_winid_str_get(xwin_info->id), xwin_info);
4681 void _policy_window_create (Ecore_X_Event_Window_Create *event)
4683 Ecore_X_Window parent;
4685 parent = ecore_x_window_parent_get(event->win);
4686 if (parent != ecore_x_window_root_get(event->win))
4689 L (LT_XWIN, "[ILLUME2][XWIN] %s(%d).. win:0x%07x...\n", __func__, __LINE__, event->win);
4691 _policy_xwin_info_add (event->win);
4695 void _policy_window_destroy (Ecore_X_Event_Window_Destroy *event)
4697 L (LT_XWIN, "[ILLUME2][XWIN] %s(%d).. win:0x%07x...\n", __func__, __LINE__, event->win);
4699 _policy_xwin_info_delete (event->win);
4703 void _policy_window_reparent (Ecore_X_Event_Window_Reparent *event)
4705 L (LT_XWIN, "[ILLUME2][XWIN] %s(%d).. win:0x%07x...\n", __func__, __LINE__, event->win);
4707 if (event->parent == ecore_x_window_root_first_get())
4708 _policy_xwin_info_add (event->win);
4710 _policy_xwin_info_delete (event->win);
4714 void _policy_window_show (Ecore_X_Event_Window_Show *event)
4716 L (LT_XWIN, "[ILLUME2][XWIN] %s(%d).. win:0x%07x...\n", __func__, __LINE__, event->win);
4718 E_Illume_XWin_Info* xwin_info = _policy_xwin_info_find (event->win);
4719 if (xwin_info == NULL)
4721 L (LT_XWIN, "[ILLUME2][XWIN] %s(%d).. No win:0x%07x in the list...\n", __func__, __LINE__, event->win);
4725 xwin_info->viewable = EINA_TRUE;
4727 if (xwin_info->comp_vis)
4729 L(LT_VISIBILITY, "[ILLUME2][VISIBILITY] %s(%d).. visibility is changed... win:0x%07x\n", __func__, __LINE__, event->win);
4730 _g_visibility_changed = EINA_TRUE;
4735 void _policy_window_hide (Ecore_X_Event_Window_Hide *event)
4737 L (LT_XWIN, "[ILLUME2][XWIN] %s(%d).. win:0x%07x...\n", __func__, __LINE__, event->win);
4739 E_Illume_XWin_Info* xwin_info = _policy_xwin_info_find (event->win);
4740 if (xwin_info == NULL)
4742 L (LT_XWIN, "[ILLUME2][XWIN] %s(%d).. No win:0x%07x in the list...\n", __func__, __LINE__, event->win);
4746 xwin_info->viewable = EINA_FALSE;
4748 L(LT_VISIBILITY, "[ILLUME2][VISIBILITY] %s(%d).. visibility is changed... win:0x%07x\n", __func__, __LINE__, event->win);
4749 _g_visibility_changed = EINA_TRUE;
4753 void _policy_window_configure (Ecore_X_Event_Window_Configure *event)
4756 E_Illume_XWin_Info* xwin_info;
4757 E_Illume_XWin_Info* old_above_xwin_info;
4758 E_Illume_XWin_Info* new_above_xwin_info;
4759 E_Illume_XWin_Info* temp_xwin_info;
4760 E_Illume_XWin_Info* target_xwin_info;
4761 int check_visibility;
4763 Ecore_X_Window target_win;
4765 L (LT_XWIN, "[ILLUME2][XWIN] %s(%d).. win:0x%07x...\n", __func__, __LINE__, event->win);
4768 old_above_xwin_info = NULL;
4769 new_above_xwin_info = NULL;
4770 check_visibility = 0;
4772 target_win = event->win;
4774 xwin_info = _policy_xwin_info_find (event->win);
4775 if (xwin_info == NULL)
4777 L (LT_XWIN, "[ILLUME2][XWIN] %s(%d).. No win:0x%07x in the list...\n", __func__, __LINE__, event->win);
4780 target_xwin_info = xwin_info;
4782 if ((xwin_info->attr.x != event->x) ||
4783 (xwin_info->attr.y != event->y))
4785 check_visibility = 1;
4788 if ((xwin_info->attr.w != event->w) ||
4789 (xwin_info->attr.h != event->h))
4792 check_visibility = 1;
4795 xwin_info->attr.x = event->x;
4796 xwin_info->attr.y = event->y;
4797 xwin_info->attr.w = event->w;
4798 xwin_info->attr.h = event->h;
4800 if ((l = EINA_INLIST_GET(xwin_info)->prev) != NULL)
4802 old_above_xwin_info = EINA_INLIST_CONTAINER_GET (l, E_Illume_XWin_Info);
4805 new_above_xwin_info = _policy_xwin_info_find (event->abovewin);
4807 if (old_above_xwin_info != new_above_xwin_info)
4810 if (old_above_xwin_info)
4812 temp_xwin_info = old_above_xwin_info;
4813 for (; temp_xwin_info; temp_xwin_info = (EINA_INLIST_GET(temp_xwin_info)->prev ? _EINA_INLIST_CONTAINER(temp_xwin_info, EINA_INLIST_GET(temp_xwin_info)->prev) : NULL))
4815 if (temp_xwin_info == new_above_xwin_info)
4817 target_win = old_above_xwin_info->id;
4818 target_xwin_info = old_above_xwin_info;
4823 check_visibility = 1;
4826 _e_illume_xwin_info_list = eina_inlist_remove (_e_illume_xwin_info_list, EINA_INLIST_GET(xwin_info));
4827 if (new_above_xwin_info)
4828 _e_illume_xwin_info_list = eina_inlist_append_relative (_e_illume_xwin_info_list, EINA_INLIST_GET(xwin_info), EINA_INLIST_GET(new_above_xwin_info));
4830 _e_illume_xwin_info_list = eina_inlist_prepend (_e_illume_xwin_info_list, EINA_INLIST_GET(xwin_info));
4832 if (check_visibility == 1)
4834 if (target_xwin_info->viewable)
4836 if (target_xwin_info->comp_vis)
4840 L(LT_VISIBILITY, "[ILLUME2][VISIBILITY] %s(%d).. SIZE is changed... target win:0x%07x\n", __func__, __LINE__, target_xwin_info->id);
4841 target_xwin_info->is_drawed = EINA_FALSE;
4845 L(LT_VISIBILITY, "[ILLUME2][VISIBILITY] %s(%d).. visibility is changed... win:0x%07x\n", __func__, __LINE__, event->win);
4846 _g_visibility_changed = EINA_TRUE;
4848 else if (target_xwin_info->iconify_by_wm)
4850 L(LT_VISIBILITY, "[ILLUME2][VISIBILITY] %s(%d).. visibility is changed... win:0x%07x\n", __func__, __LINE__, event->win);
4851 _g_visibility_changed = EINA_TRUE;
4858 void _policy_window_configure_request (Ecore_X_Event_Window_Configure_Request *event)
4861 Ecore_X_Event_Window_Configure_Request *e;
4864 bd = e_border_find_by_client_window(e->win);
4867 if (!bd->lock_client_stacking)
4869 if ((e->value_mask & ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE) &&
4870 (e->value_mask & ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING))
4872 if (e_config->focus_setting == E_FOCUS_NEW_WINDOW_IF_TOP_STACK)
4874 if (bd->visible && (bd->client.icccm.accepts_focus || bd->client.icccm.take_focus))
4875 _policy_border_focus_top_stack_set (bd);
4878 else if (e->value_mask & ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE)
4880 if (_e_illume_cfg->use_force_iconify)
4882 if (e->detail == ECORE_X_WINDOW_STACK_BELOW && !e->abovewin)
4884 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d).. Request Lower window... win:0x%07x\n", __func__, __LINE__, e->win);
4885 E_Illume_XWin_Info *xwin_info = _policy_xwin_info_find(bd->win);
4888 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d).. ICONIFY win:0x%07x And UN-ICONIFY Top win...\n", __func__, __LINE__, bd->client.win);
4889 _policy_border_uniconify_top_border(bd);
4894 if (e_config->focus_setting == E_FOCUS_NEW_WINDOW_IF_TOP_STACK)
4896 if (bd->visible && (bd->client.icccm.accepts_focus || bd->client.icccm.take_focus))
4897 _policy_border_focus_top_stack_set(bd);
4903 void _policy_window_sync_draw_done(Ecore_X_Event_Client_Message* event)
4906 E_Illume_XWin_Info *xwin_info;
4909 win = event->data.l[0];
4910 bd = e_border_find_by_client_window(win);
4913 xwin_info = _policy_xwin_info_find(bd->win);
4914 if (!xwin_info) return;
4916 if (!xwin_info->is_drawed)
4918 if (xwin_info->comp_vis)
4920 xwin_info->is_drawed = EINA_TRUE;
4921 L(LT_VISIBILITY, "[ILLUME2][VISIBILITY] %s(%d).. visibility is changed... win:0x%07x\n", __func__, __LINE__, event->win);
4922 _g_visibility_changed = EINA_TRUE;
4924 else if (xwin_info->iconify_by_wm)
4926 xwin_info->is_drawed = EINA_TRUE;
4927 L(LT_VISIBILITY, "[ILLUME2][VISIBILITY] %s(%d).. visibility is changed... win:0x%07x\n", __func__, __LINE__, event->win);
4928 _g_visibility_changed = EINA_TRUE;
4933 /* Setting window mode requires window stack change and window geometry
4934 * change. But now, the WM can't control these sequential operations
4935 * using x property set API which whould be able to overwrite previous
4936 * value before getting x property by the WM.
4937 * So we changed ecore_x_e_illume_window_state_set function to use x send
4938 * message and x sync counter. When the WM receives this message,
4939 * the WM sets window mode and then increases x sync counter.
4941 * TODO: We need to make a new protocol to set the window mode!!
4943 void _policy_illume_win_state_change_request (Ecore_X_Event_Client_Message *event)
4945 E_Border *bd = NULL;
4946 Ecore_X_Atom atom = 0, set = 0;
4947 unsigned int state = 0;
4948 Ecore_X_Sync_Counter counter = 0;
4953 bd = e_border_find_by_client_window(event->win);
4954 atom = event->data.l[0];
4955 counter = event->data.l[1];
4956 val = event->data.l[2];
4958 if (atom == ECORE_X_ATOM_E_ILLUME_WINDOW_STATE_NORMAL)
4960 state = ECORE_X_ILLUME_WINDOW_STATE_NORMAL;
4963 else if (atom == ECORE_X_ATOM_E_ILLUME_WINDOW_STATE_FLOATING)
4965 state = ECORE_X_ILLUME_WINDOW_STATE_FLOATING;
4969 ELBF(ELBT_ILLUME, 0, event->win,
4970 "GET WIN_STATE_CHANGE_REQ bd:0x%08x(%d->%d) counter:0x%08x val:%d",
4971 bd ? bd->client.win : (unsigned int)NULL,
4972 bd ? bd->client.illume.win_state.state : 0,
4977 _policy_border_illume_window_state_change(bd, state);
4981 ecore_x_window_prop_atom_set(event->win, ECORE_X_ATOM_E_ILLUME_WINDOW_STATE,
4983 ELB(ELBT_ILLUME, "SET WIN_STATE", event->win);
4986 if (counter) ecore_x_sync_counter_inc(counter, 1);
4989 void _policy_quickpanel_state_change (Ecore_X_Event_Client_Message* event)
4992 E_Illume_Quickpanel *qp;
4994 if ((zone = e_util_zone_window_find(event->win)))
4996 if ((qp = e_illume_quickpanel_by_zone_get(zone)))
4998 if (event->data.l[0] == (int)ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON)
5000 _policy_layout_quickpanel_rotate (qp, g_root_angle);
5007 _policy_root_angle_set(E_Border *bd)
5010 Ecore_X_Window root;
5014 angle = _policy_window_rotation_angle_get(bd->client.win);
5015 if (angle == -1) return EINA_FALSE;
5016 if (!(((bd->w == bd->zone->w) && (bd->h == bd->zone->h)) ||
5017 ((bd->w == bd->zone->h) && (bd->h == bd->zone->w))))
5020 g_rotated_win = bd->client.win;
5021 root = bd->zone->container->manager->root;
5025 angle = g_root_angle;
5030 if (_e_illume_cfg->use_indicator_widget)
5032 L(LT_INDICATOR, "[ILLUME2][INDICATOR] %s(%d)... indicator_control_win = 0x%07x...\n", __func__, __LINE__, g_rotated_win);
5033 g_indi_control_win = g_rotated_win;
5036 L (LT_ANGLE, "[ILLUME2][ANGLE] %s(%d).. new_win:0x%07x, old angle:%d -> new_angle:%d\n", __func__, __LINE__, g_rotated_win, g_root_angle, angle);
5037 L (LT_ANGLE, "[ILLUME2][ANGLE] %s(%d).. SET ROOT ANGLE... angle:%d\n\n", __func__, __LINE__, angle);
5038 // set root window property
5039 ecore_x_window_prop_property_set(root, ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE, ECORE_X_ATOM_CARDINAL, 32, &angle, 1);
5045 e_illume_border_is_camera(E_Border *bd)
5047 const char *name = NULL;
5048 const char *clas = NULL;
5050 if (!bd) return EINA_FALSE;
5052 name = bd->client.icccm.name;
5053 clas = bd->client.icccm.class;
5055 if (clas == NULL) return EINA_FALSE;
5056 if (strncmp(clas,"camera",strlen("camera"))!= 0) return EINA_FALSE;
5057 if (name == NULL) return EINA_FALSE;
5058 if (strncmp(name,"camera",strlen("camera"))!= 0) return EINA_FALSE;
5064 _policy_change_root_angle_by_border_angle (E_Border* bd)
5066 L (LT_ANGLE, "[ILLUME2][ANGLE] %s(%d)... win:0x%07x\n", __func__, __LINE__, bd ? (unsigned int)bd->client.win:(unsigned int)NULL);
5069 // ignore the angle of special borders - like indicator, keyboard, quickpanel, etc.
5070 if (e_illume_border_is_indicator(bd)) return;
5071 if (e_illume_border_is_keyboard(bd)) return;
5072 if (e_illume_border_is_quickpanel(bd)) return;
5073 if (e_illume_border_is_quickpanel_popup(bd)) return;
5075 if (e_illume_border_is_camera(bd))
5077 if (dep_rot.refer.active_win == bd->client.win)
5079 // make rotation request for the dependent windows such as quickpanel
5080 int ang = _policy_window_rotation_angle_get(bd->client.win);
5081 if (ang == -1) ang = 0;
5083 if (dep_rot.ang != ang)
5085 int prev_ang = dep_rot.ang;
5088 Eina_List *nl = NULL, *l;
5089 E_Border *dep_bd = NULL;
5091 EINA_LIST_FOREACH(dep_rot.list, l, dep_bd)
5093 dep_bd->client.e.state.rot.prev = bd->client.e.state.rot.curr;
5094 dep_bd->client.e.state.rot.curr = ang;
5095 dep_bd->client.e.state.rot.wait_for_done = 1;
5096 nl = eina_list_append(nl, dep_bd);
5101 ELBF(ELBT_ROT, 0, bd->client.win,
5102 "ADD & REQUEST ROT(dependent) curr:%d != prev:%d", dep_rot.ang, prev_ang);
5103 e_border_rotation_list_add_change_req(bd->zone, nl);
5110 L (LT_ANGLE, "[ILLUME2][ANGLE] %s(%d)... CALL _policy_root_angle_set.. win:0x%07x\n", __func__, __LINE__, bd->client.win);
5111 _policy_root_angle_set(bd);
5115 _policy_indicator_angle_change (E_Border* indi_bd, int angle)
5117 L (LT_ANGLE, "[ILLUME2][ANGLE] %s(%d)... indicator:0x%07x\n", __func__, __LINE__, indi_bd ? (unsigned int)indi_bd->client.win:(unsigned int)NULL);
5118 if (!indi_bd) return;
5120 int old_angle = _policy_window_rotation_angle_get (indi_bd->client.win);
5121 if(old_angle == -1) return;
5123 L (LT_ANGLE, "[ILLUME2][ANGLE] %s(%d)... old_angle:%d, new_angle:%d\n", __func__, __LINE__, old_angle, angle);
5124 if (old_angle != angle)
5128 angles[1] = old_angle;
5129 ecore_x_window_prop_property_set(indi_bd->client.win,
5130 ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
5131 ECORE_X_ATOM_CARDINAL,
5136 ecore_x_client_message32_send (indi_bd->client.win, ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
5137 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
5140 E_Illume_Quickpanel *qp;
5141 qp = e_illume_quickpanel_by_zone_get (indi_bd->zone);
5144 _policy_layout_quickpanel_rotate (qp, angle);
5150 _policy_border_transient_for_group_make(E_Border *bd,
5159 E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE);
5161 if (e_config->transient.raise)
5163 EINA_LIST_FOREACH(bd->transients, l, child)
5165 if (!child) continue;
5168 *list = eina_list_prepend(*list, child);
5169 _policy_border_transient_for_group_make(child, list);
5176 _policy_border_transient_for_border_top_get(E_Border *bd)
5178 E_Border *top_border = NULL;
5179 Eina_List *transient_list = NULL;
5181 _policy_border_transient_for_group_make(bd, &transient_list);
5185 Eina_List *l = NULL;
5190 bl = e_container_border_list_last(bd->zone->container);
5191 while ((temp_bd = e_container_border_list_prev(bl)))
5193 if (top_border) break;
5194 if (temp_bd == bd) break;
5196 EINA_LIST_FOREACH(transient_list, l, temp_bd2)
5198 if (temp_bd == temp_bd2)
5200 top_border = temp_bd2;
5205 e_container_border_list_free(bl);
5208 L (LT_TRANSIENT_FOR, "[ILLUME2][TRANSIENT] %s(%d).. win:0x%07x, transient_for_top_win:0x%07x\n", __func__, __LINE__, bd->client.win, top_border ? (unsigned int)top_border->client.win:(unsigned int)NULL);
5210 eina_list_free(transient_list);
5216 _policy_border_transient_for_layer_set(E_Border *bd,
5217 E_Border *parent_bd,
5221 E_Border *top_border;
5224 E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE);
5226 L (LT_TRANSIENT_FOR, "[ILLUME2][TRANSIENT] %s(%d).. win:0x%07x, transient_for:0x%07x, layer:%d\n", __func__, __LINE__, bd->client.win, parent_bd ? (unsigned int)parent_bd->client.win:(unsigned int)NULL, layer);
5228 ecore_x_window_shadow_tree_flush();
5230 raise = e_config->transient.raise;
5232 bd->saved.layer = bd->layer;
5234 if (e_config->transient.layer)
5239 /* We need to set raise to one, else the child wont
5240 * follow to the new layer. It should be like this,
5241 * even if the user usually doesn't want to raise
5244 e_config->transient.raise = 1;
5245 EINA_LIST_FOREACH(bd->transients, l, child)
5247 if (!child) continue;
5248 child->layer = layer;
5252 top_border = _policy_border_transient_for_border_top_get(parent_bd);
5255 if (top_border != bd)
5257 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... STACK CHANGE with ABOVE... win:0x%07x, above_win:0x%07x\n", __func__, __LINE__, bd->client.win, top_border->client.win);
5258 e_border_stack_above(bd, top_border);
5263 L (LT_STACK, "[ILLUME2][STACK] %s(%d)... STACK CHANGE with ABOVE... win:0x%07x, above_win:0x%07x\n", __func__, __LINE__, bd->client.win, parent_bd->client.win);
5264 e_border_stack_above(bd, parent_bd);
5267 e_config->transient.raise = raise;
5270 /* for desktop mode */
5272 _policy_zone_layout_app_single_monitor(E_Illume_Border_Info* bd_info, E_Illume_Config_Zone *cz)
5276 Eina_Bool resize = EINA_FALSE;
5277 Eina_Bool move = EINA_FALSE;
5279 bd = bd_info->border;
5282 fprintf(stderr, "[ILLUME2] fatal error! (%s) There is no border!\n", __func__);
5286 if ((!bd->new_client) && (!bd->visible)) return;
5288 layer = _policy_zone_layout_app_layer_check(bd);
5292 int zx = 0, zy = 0, zw = 0, zh = 0;
5293 int new_x, new_y, new_w, new_h;
5295 if (!bd->client.icccm.request_pos)
5298 Eina_List *skiplist = NULL;
5301 e_zone_useful_geometry_get(bd->zone, &zx, &zy, &zw, &zh);
5303 // calculate width & height
5309 delta = delta * 0.66;
5311 new_w = delta * 9.0;
5312 new_h = delta * 16.0;
5315 new_x = zx + (rand() % (zw - new_w));
5319 new_y = zy + (rand() % (zh - new_h));
5323 skiplist = eina_list_append(skiplist, bd);
5325 e_place_zone_region_smart(bd->zone, skiplist,
5326 bd->x, bd->y, new_w, new_h,
5329 eina_list_free(skiplist);
5334 e_zone_useful_geometry_get(bd->zone, &zx, &zy, &zw, &zh);
5336 if (zx > bd->x) new_x = zx;
5339 if (zy > bd->y) new_y = zy;
5342 if (zw < bd->w) new_w = zw;
5345 if (zh < bd->h) new_h = zh;
5349 if ((bd->x != new_x) || (bd->y != new_y))
5352 if ((bd->w != new_w) || (bd->h != new_h))
5356 e_border_move_resize(bd, new_x, new_y, new_w, new_h);
5358 _policy_border_move(bd, new_x, new_y);
5360 _policy_border_resize(bd, new_w, new_h);
5364 /* check if user defined position */
5365 if (bd->client.icccm.request_pos)
5367 if (bd->client.illume.win_state.state)
5369 if (bd_info->resize_req.need_change)
5371 if ((bd->x != bd_info->resize_req.mouse.x) ||
5372 (bd->y != bd_info->resize_req.mouse.y))
5375 if ((bd->w != bd_info->resize_req.mouse.w) ||
5376 (bd->h != bd_info->resize_req.mouse.h))
5381 e_border_move_resize(bd,
5382 bd_info->resize_req.mouse.x,
5383 bd_info->resize_req.mouse.y,
5384 bd_info->resize_req.mouse.w,
5385 bd_info->resize_req.mouse.h);
5389 _policy_border_move(bd,
5390 bd_info->resize_req.mouse.x,
5391 bd_info->resize_req.mouse.y);
5395 _policy_border_resize(bd,
5396 bd_info->resize_req.mouse.w,
5397 bd_info->resize_req.mouse.h);
5400 bd_info->resize_req.need_change = 0;
5401 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... bd move resize... (%d, %d, %d, %d)\n", __func__, __LINE__, bd->x, bd->y, bd->w, bd->h);
5404 if (bd_info->resize_req.mouse.down &&
5405 bd_info->resize_req.mouse.locked)
5407 if ((bd->x != bd_info->resize_req.mouse.x) ||
5408 (bd->y != bd_info->resize_req.mouse.y))
5409 _policy_border_move(bd,
5410 bd_info->resize_req.mouse.x,
5411 bd_info->resize_req.mouse.y);
5412 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... bd move resize... (%d, %d, %d, %d)\n", __func__, __LINE__, bd->x, bd->y, bd->w, bd->h);
5415 _policy_zone_layout_app_layer_set(bd, layer);
5419 /* resize & move if needed */
5420 if (bd->client.illume.win_state.state)
5422 if (bd_info->resize_req.need_change)
5424 if ((bd->x != bd_info->resize_req.mouse.x) ||
5425 (bd->y != bd_info->resize_req.mouse.y))
5428 if ((bd->w != bd_info->resize_req.mouse.w) ||
5429 (bd->h != bd_info->resize_req.mouse.h))
5434 e_border_move_resize(bd,
5435 bd_info->resize_req.mouse.x,
5436 bd_info->resize_req.mouse.y,
5437 bd_info->resize_req.mouse.w,
5438 bd_info->resize_req.mouse.h);
5442 _policy_border_move(bd,
5443 bd_info->resize_req.mouse.x,
5444 bd_info->resize_req.mouse.y);
5448 _policy_border_resize(bd,
5449 bd_info->resize_req.mouse.w,
5450 bd_info->resize_req.mouse.h);
5453 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... bd move resize... (%d, %d, %d, %d)\n", __func__, __LINE__, bd->x, bd->y, bd->w, bd->h);
5454 bd_info->resize_req.need_change = 0;
5457 if (bd_info->resize_req.mouse.down &&
5458 bd_info->resize_req.mouse.locked)
5460 if ((bd->x != bd_info->resize_req.mouse.x) ||
5461 (bd->y != bd_info->resize_req.mouse.y))
5462 _policy_border_move(bd,
5463 bd_info->resize_req.mouse.x,
5464 bd_info->resize_req.mouse.y);
5465 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... bd move resize... (%d, %d, %d, %d)\n", __func__, __LINE__, bd->x, bd->y, bd->w, bd->h);
5470 /* set layer if needed */
5471 _policy_zone_layout_app_layer_set(bd, layer);
5474 void _policy_window_move_resize_request(Ecore_X_Event_Window_Move_Resize_Request *event)
5477 E_Illume_Border_Info *bd_info;
5478 Ecore_X_Event_Window_Move_Resize_Request *e;
5481 bd = e_border_find_by_client_window(e->win);
5483 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... win:0x%07x, x:%d, y:%d, direction:%d, button:%d, source:%d\n", __func__, __LINE__, e->win, e->x, e->y, e->direction, e->button, e->source);
5485 if (e->direction == ECORE_X_NETWM_DIRECTION_MOVE ||
5486 e->direction == ECORE_X_NETWM_DIRECTION_CANCEL)
5489 if (bd->client.illume.win_state.state != ECORE_X_ILLUME_WINDOW_STATE_FLOATING)
5492 bd_info = _policy_get_border_info(bd);
5493 if (!bd_info) return;
5495 e_border_resize_cancel();
5497 if (bd_info->resize_req.mouse.down)
5500 L(LT_AIA, "[ILLUME2][AIA] %s(%d)... \n", __func__, __LINE__);
5502 bd_info->resize_req.mouse.down = 1;
5503 bd_info->resize_req.mouse.dx = bd->x - e->x;
5504 bd_info->resize_req.mouse.dy = bd->y - e->y;
5505 bd_info->resize_req.mouse.x = bd->x;
5506 bd_info->resize_req.mouse.y = bd->y;
5508 bd->lock_user_location = 1;
5510 _policy_border_illume_handlers_add(bd_info);
5511 ecore_x_window_raise(bd->event_win);
5512 e_grabinput_get(bd->event_win, 0, bd->event_win);
5514 bd_info->resize_req.direction = e->direction;
5515 _policy_resize_start(bd_info);
5518 void _policy_window_state_request(Ecore_X_Event_Window_State_Request *event)
5521 Ecore_X_Event_Window_State_Request *e;
5523 E_Maximize maximize = 0;
5526 bd = e_border_find_by_client_window(e->win);
5529 for (i = 0; i < 2; i++)
5531 switch (e->state[i])
5533 case ECORE_X_WINDOW_STATE_MAXIMIZED_VERT:
5534 if (bd->lock_client_maximize) break;
5535 maximize |= E_MAXIMIZE_VERTICAL;
5538 case ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ:
5539 if (bd->lock_client_maximize) break;
5540 maximize |= E_MAXIMIZE_HORIZONTAL;
5548 if (maximize &= E_MAXIMIZE_BOTH)
5550 if (e->action == ECORE_X_WINDOW_STATE_ACTION_ADD)
5552 if (bd->pointer && bd->pointer->type)
5553 e_pointer_type_pop(bd->pointer, bd, bd->pointer->type);
5558 static void _policy_border_root_angle_control(E_Zone *zone)
5560 Eina_Inlist *xwin_info_list;
5561 E_Illume_XWin_Info *xwin_info;
5565 xwin_info_list = _e_illume_xwin_info_list;
5569 EINA_INLIST_REVERSE_FOREACH (xwin_info_list, xwin_info)
5571 if (xwin_info->visibility != E_ILLUME_VISIBILITY_FULLY_OBSCURED)
5573 if (xwin_info->bd_info)
5575 bd = xwin_info->bd_info->border;
5578 if (!bd->visible) continue;
5579 if (bd->zone != zone) continue;
5580 if (e_illume_border_is_indicator(bd)) continue;
5581 if (e_illume_border_is_keyboard(bd)) continue;
5582 if (e_illume_border_is_quickpanel(bd)) continue;
5583 if (e_illume_border_is_quickpanel_popup(bd)) continue;
5584 if (bd->client.illume.win_state.state == ECORE_X_ILLUME_WINDOW_STATE_FLOATING) continue;
5586 if (_policy_root_angle_set(bd)) break;
5593 static int _policy_border_layer_map(int layer)
5597 if (layer < 0) layer = 0;
5598 pos = 1 + (layer / 50);
5599 if (pos > POL_NUM_OF_LAYER) pos = POL_NUM_OF_LAYER;
5604 _policy_msg_handler(void *data, const char *name, const char *info, int val, E_Object *obj, void *msgdata)
5606 E_Manager *man = (E_Manager *)obj;
5607 E_Manager_Comp_Source *src = (E_Manager_Comp_Source *)msgdata;
5609 // handle only comp.manager msg
5610 if (strncmp(name, "comp.manager", sizeof("comp.manager"))) return;
5612 if (!strncmp(info, "visibility.src", sizeof("visibility.src")))
5614 E_Illume_XWin_Info *xwin_info;
5616 Ecore_X_Window active_win;
5617 Ecore_X_Window client_win;
5620 win = e_manager_comp_src_window_get(man, src);
5622 xwin_info = _policy_xwin_info_find(win);
5623 if (!xwin_info) return;
5625 visible = e_manager_comp_src_visible_get(man, src);
5628 xwin_info->is_drawed = EINA_TRUE;
5629 xwin_info->comp_vis = 1;
5630 L(LT_VISIBILITY, "[ILLUME2][VISIBILITY] %s(%d).. visibility is changed... win:0x%07x\n", __func__, __LINE__, win);
5631 _g_visibility_changed = EINA_TRUE;
5633 if (xwin_info->bd_info && xwin_info->bd_info->border)
5634 client_win = xwin_info->bd_info->border->client.win;
5638 active_win = _policy_active_window_get(ecore_x_window_root_get(win));
5639 if (active_win == client_win)
5641 _policy_active_win_change(xwin_info, active_win);
5646 xwin_info->comp_vis = 0;
5651 void _policy_module_update(E_Event_Module_Update *event)
5653 if ((!strncmp(event->name, "comp-tizen", sizeof("comp-tizen"))) ||
5654 (!strncmp(event->name, "comp", sizeof("comp"))))
5659 _e_use_comp = EINA_TRUE;
5664 _e_use_comp = EINA_FALSE;
5666 // change all variable to 1
5667 Eina_Inlist* xwin_info_list;
5668 E_Illume_XWin_Info *xwin_info;
5670 xwin_info_list = _e_illume_xwin_info_list;
5673 EINA_INLIST_REVERSE_FOREACH (xwin_info_list, xwin_info)
5675 xwin_info->comp_vis = EINA_TRUE;
5682 void _policy_border_iconify_cb(E_Border *bd)
5684 if (!_e_illume_cfg->use_force_iconify) return;
5687 if (e_object_is_del(E_OBJECT(bd))) return;
5689 E_Illume_XWin_Info* xwin_info = _policy_xwin_info_find(bd->win);
5690 if (xwin_info == NULL) return;
5692 _policy_border_uniconify_below_borders_by_illume(xwin_info);
5694 if (xwin_info->visibility != E_ILLUME_VISIBILITY_FULLY_OBSCURED)
5696 int old_vis = xwin_info->visibility;
5697 xwin_info->visibility = E_ILLUME_VISIBILITY_FULLY_OBSCURED;
5698 L (LT_VISIBILITY, "[ILLUME2][VISIBILITY] SEND VISIBILITY NOTIFY (Line:%d)... win:0x%07x (old:%d -> new:%d)\n", __LINE__, xwin_info->bd_info->border->client.win, old_vis, xwin_info->visibility);
5700 LOGD("[WM] SEND VISIBILITY. win:0x%07x (old:%d -> new:%d)", xwin_info->bd_info->border->client.win, old_vis, xwin_info->visibility);
5702 _policy_send_visibility_notify (xwin_info->bd_info->border->client.win, xwin_info->visibility);
5705 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d)... ICONFIY win:0x%07x (iconify_by_wm:%d)\n", __func__, __LINE__, bd->client.win, xwin_info->iconify_by_wm);
5706 L(LT_VISIBILITY, "[ILLUME2][VISIBILITY] %s(%d).. visibility is changed... win:0x%07x\n", __func__, __LINE__, bd->client.win);
5707 _g_visibility_changed = EINA_TRUE;
5709 xwin_info->attr.visible = 0;
5711 _policy_border_focus_top_stack_set(bd);
5714 void _policy_border_uniconify_cb(E_Border *bd)
5716 if (!_e_illume_cfg->use_force_iconify) return;
5719 if (e_object_is_del(E_OBJECT(bd))) return;
5721 E_Illume_XWin_Info* xwin_info = _policy_xwin_info_find(bd->win);
5722 if (xwin_info == NULL) return;
5724 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d)... UNICONIFY win:0x%07x (iconify_by_wm:%d)\n", __func__, __LINE__, bd->client.win, xwin_info->iconify_by_wm);
5726 xwin_info->iconify_by_wm = 0;
5727 xwin_info->attr.visible = 1;
5729 L(LT_VISIBILITY, "[ILLUME2][VISIBILITY] %s(%d).. visibility is changed... win:0x%07x\n", __func__, __LINE__, bd->client.win);
5730 _g_visibility_changed = EINA_TRUE;
5732 _policy_border_focus_top_stack_set(bd);
5736 _policy_border_event_border_iconify_free(void *data __UNUSED__,
5739 E_Event_Border_Iconify *e;
5742 // e_object_breadcrumb_del(E_OBJECT(e->border), "border_iconify_event");
5743 e_object_unref(E_OBJECT(e->border));
5749 _policy_border_force_iconify(E_Border *bd)
5751 E_Event_Border_Iconify *ev;
5752 unsigned int iconic;
5753 E_Illume_XWin_Info* xwin_info;
5756 E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE);
5757 if (bd->shading) return;
5758 ecore_x_window_shadow_tree_flush();
5762 e_border_hide(bd, 0);
5763 if (bd->fullscreen) bd->desk->fullscreen_borders--;
5764 edje_object_signal_emit(bd->bg_object, "e,action,iconify", "e");
5767 e_hints_window_iconic_set(bd);
5768 ecore_x_window_prop_card32_set(bd->client.win, E_ATOM_MAPPED, &iconic, 1);
5770 ev = E_NEW(E_Event_Border_Iconify, 1);
5772 e_object_ref(E_OBJECT(bd));
5773 // e_object_breadcrumb_add(E_OBJECT(bd), "border_iconify_event");
5774 ecore_event_add(E_EVENT_BORDER_ICONIFY, ev, _policy_border_event_border_iconify_free, NULL);
5776 xwin_info = _policy_xwin_info_find(bd->win);
5779 xwin_info->iconify_by_wm = 1;
5782 if (e_config->transient.iconify)
5786 E_Illume_XWin_Info* child_xwin_info;
5788 EINA_LIST_FOREACH(bd->transients, l, child)
5790 if (!e_object_is_del(E_OBJECT(child)))
5794 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d)... Iconify by illume.. child:0x%07x\n", __func__, __LINE__, child->client.win);
5795 child_xwin_info = _policy_xwin_info_find(child->win);
5796 if (child_xwin_info)
5798 _policy_border_iconify_by_illume(child_xwin_info);
5804 e_remember_update(bd);
5808 _policy_border_iconify_by_illume(E_Illume_XWin_Info *xwin_info)
5812 if (!xwin_info) return;
5813 if (!xwin_info->bd_info) return;
5814 if (!xwin_info->bd_info->border) return;
5816 bd = xwin_info->bd_info->border;
5817 if (!E_ILLUME_BORDER_IS_IN_MOBILE(bd)) return;
5818 if (e_object_is_del(E_OBJECT(bd))) return;
5820 if (bd->parent && (!bd->parent->iconic)) return;
5822 if (e_illume_border_is_indicator(bd)) return;
5823 if (e_illume_border_is_keyboard(bd)) return;
5824 if (e_illume_border_is_keyboard_sub(bd)) return;
5825 if (e_illume_border_is_quickpanel(bd)) return;
5826 if (e_illume_border_is_quickpanel_popup(bd)) return;
5827 if (e_illume_border_is_clipboard(bd)) return;
5828 if (e_illume_border_is_app_tray(bd)) return;
5829 if (e_illume_border_is_miniapp_tray(bd)) return;
5830 // if (bd->client.illume.win_state.state == ECORE_X_ILLUME_WINDOW_STATE_FLOATING) return;
5832 xwin_info->iconify_by_wm = 1;
5836 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d)... FORCE_ICONIFY win:0x%07x\n", __func__, __LINE__, bd->client.win);
5837 _policy_border_force_iconify(bd);
5842 _policy_border_event_border_uniconify_free(void *data, void *ev)
5844 E_Event_Border_Uniconify *e;
5847 // e_object_breadcrumb_del(E_OBJECT(e->border), "border_uniconify_event");
5848 e_object_unref(E_OBJECT(e->border));
5852 static void _policy_border_force_uniconify(E_Border *bd)
5855 E_Event_Border_Uniconify *ev;
5856 unsigned int iconic;
5857 E_Illume_XWin_Info* xwin_info;
5860 E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE);
5862 xwin_info = _policy_xwin_info_find(bd->win);
5863 if (!(xwin_info && xwin_info->iconify_by_wm)) return;
5865 if (bd->shading) return;
5866 ecore_x_window_shadow_tree_flush();
5871 if (bd->fullscreen) bd->desk->fullscreen_borders++;
5872 if (e_manager_comp_evas_get(bd->zone->container->manager))
5874 if (bd->await_hide_event > 0)
5875 bd->await_hide_event--;
5877 desk = e_desk_current_get(bd->desk->zone);
5878 e_border_desk_set(bd, desk);
5879 edje_object_signal_emit(bd->bg_object, "e,action,uniconify", "e");
5882 ecore_x_window_prop_card32_set(bd->client.win, E_ATOM_MAPPED, &iconic, 1);
5884 ev = E_NEW(E_Event_Border_Uniconify, 1);
5886 e_object_ref(E_OBJECT(bd));
5887 // e_object_breadcrumb_add(E_OBJECT(bd), "border_uniconify_event");
5888 ecore_event_add(E_EVENT_BORDER_UNICONIFY, ev, _policy_border_event_border_uniconify_free, NULL);
5890 if (e_config->transient.iconify)
5894 E_Illume_XWin_Info* child_xwin_info;
5896 EINA_LIST_FOREACH(bd->transients, l, child)
5898 if (!e_object_is_del(E_OBJECT(child)))
5902 child_xwin_info = _policy_xwin_info_find(child->win);
5903 if (child_xwin_info) child_xwin_info->iconify_by_wm = 1;
5905 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d).. FORCE UNICONIFY... win:0x%07x\n", __func__, __LINE__, child->client.win);
5906 _policy_border_force_uniconify(child);
5911 e_remember_update(bd);
5915 _policy_border_uniconify_below_borders_by_illume(E_Illume_XWin_Info *xwin_info)
5919 if (!xwin_info) return;
5920 if (!xwin_info->bd_info) return;
5922 bd = xwin_info->bd_info->border;
5924 // 1. check if iconify is caused by visibility change or not
5925 if (xwin_info->iconify_by_wm) return;
5927 // 2. check if current bd's visibility is fully-obscured or not
5928 if (xwin_info->visibility == E_ILLUME_VISIBILITY_FULLY_OBSCURED) return;
5930 // 3-1. find bd's below window and un-iconify it
5931 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d)... UNICONIFY Below Windows of win:0x%07x\n", __func__, __LINE__, bd->client.win);
5932 _policy_border_uniconify_below_borders(bd);
5934 if (!e_object_is_del(E_OBJECT(bd)))
5940 static E_Border* _policy_border_find_below(E_Border *bd)
5945 E_Illume_XWin_Info* xwin_info;
5947 passed = EINA_FALSE;
5949 /* determine layering position */
5950 pos = _policy_border_layer_map(bd->layer);
5952 /* Find the windows below this one */
5953 for (i = pos; i >= 2; i--)
5957 EINA_LIST_REVERSE_FOREACH(bd->zone->container->layers[i].clients, l, b)
5961 /* skip if it's the same border */
5968 if ((b->x == b->zone->x) &&
5969 (b->y == b->zone->y) &&
5970 (b->w == b->zone->w) &&
5971 (b->h == b->zone->h) &&
5972 (b->h == b->zone->h) &&
5973 (b->client.illume.win_state.state != ECORE_X_ILLUME_WINDOW_STATE_FLOATING) &&
5976 xwin_info = _policy_xwin_info_find(b->win);
5979 if ((!xwin_info->argb) ||
5980 (xwin_info->argb && xwin_info->bd_info->opaque))
5982 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d)... win:0x%07x, ALREADY FULLY-OBSCURED... by win:0x%07x visible:%d (visibility:%d)\n", __func__, __LINE__, bd->client.win, b->client.win, b->visible, xwin_info->visibility);
5988 if (!passed) continue;
5990 /* skip if it's not on this zone */
5991 if (b->zone != bd->zone) continue;
5993 /* skip special borders */
5994 if (e_illume_border_is_indicator(b)) continue;
5995 if (e_illume_border_is_keyboard(b)) continue;
5996 if (e_illume_border_is_keyboard_sub(b)) continue;
5997 if (e_illume_border_is_quickpanel(b)) continue;
5998 if (e_illume_border_is_quickpanel_popup(b)) continue;
5999 if (e_illume_border_is_clipboard(b)) continue;
6000 if (e_illume_border_is_app_tray(b)) continue;
6001 if (e_illume_border_is_miniapp_tray(b)) continue;
6010 static void _policy_border_uniconify_below_borders(E_Border *bd)
6014 below_bd = _policy_border_find_below(bd);
6015 if (!below_bd) return;
6017 E_Illume_XWin_Info* below_xwin_info = _policy_xwin_info_find(below_bd->win);
6018 if (below_xwin_info == NULL) return;
6020 if ((below_bd->w != below_bd->zone->w) ||
6021 (below_bd->h != below_bd->zone->h) ||
6022 (below_xwin_info->argb))
6024 if (!(below_xwin_info->bd_info && below_xwin_info->bd_info->opaque))
6025 _policy_border_uniconify_below_borders(below_bd);
6029 if (below_bd->iconic)
6031 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d).. FORCE UNICONIFY... win:0x%07x\n", __func__, __LINE__, below_bd->client.win);
6032 _policy_border_force_uniconify(below_bd);
6036 static void _policy_border_uniconify_top_border(E_Border *bd)
6041 E_Illume_XWin_Info* xwin_info;
6043 if (!_e_illume_cfg->use_force_iconify) return;
6045 zone_w = bd->zone->w;
6046 zone_h = bd->zone->h;
6047 /* determine layering position */
6049 /* Find the windows below this one */
6050 for (i = POL_NUM_OF_LAYER; i >= 2; i--)
6054 EINA_LIST_REVERSE_FOREACH(bd->zone->container->layers[i].clients, l, b)
6058 if ((b->x >= zone_w) || (b->y >= zone_h)) continue;
6059 if (((b->x + b->w) <= 0) || ((b->y + b->h) <= 0)) continue;
6061 /* skip if it's not on this zone */
6062 if (b->zone != bd->zone) continue;
6064 /* skip special borders */
6065 if (e_illume_border_is_indicator(b)) continue;
6066 if (e_illume_border_is_keyboard(b)) continue;
6067 if (e_illume_border_is_keyboard_sub(b)) continue;
6068 if (e_illume_border_is_quickpanel(b)) continue;
6069 if (e_illume_border_is_quickpanel_popup(b)) continue;
6070 if (e_illume_border_is_clipboard(b)) continue;
6071 if (e_illume_border_is_app_tray(b)) continue;
6072 if (e_illume_border_is_miniapp_tray(b)) continue;
6076 L(LT_ICONIFY, "[ILLUME2][ICONIFY] %s(%d).. FORCE UNICONIFY... win:0x%07x\n", __func__, __LINE__, b->client.win);
6077 _policy_border_force_uniconify(b);
6080 if ((b->x == b->zone->x) &&
6081 (b->y == b->zone->y) &&
6082 (b->w == b->zone->w) &&
6083 (b->h == b->zone->h))
6085 xwin_info = _policy_xwin_info_find(b->win);
6088 if (xwin_info->argb && !xwin_info->bd_info->opaque)
6103 /* change the desk of window for popsync.
6104 * if there is no window in data read from ev->l[0],
6105 * window that is latest above stack will be changed.
6106 * - event->data.l[0] : window ID
6107 * - event->data.l[1]
6108 * 1(default): mobile
6112 _policy_window_desk_set(Ecore_X_Event_Client_Message *event)
6114 Ecore_X_Event_Client_Message *ev = event;
6118 E_Desk *desk = NULL;
6121 Eina_Bool one_time = EINA_FALSE;
6122 char *profile = NULL, *new_profile = NULL;
6123 unsigned int desk_num;
6127 EINA_SAFETY_ON_NULL_RETURN(ev);
6129 win = ev->data.l[0];
6130 desk_num = ev->data.l[1];
6131 if (win) one_time = EINA_TRUE;
6133 // decide new desk's profile from received data.
6137 new_profile = _e_illume_cfg->display_name.popsync;
6141 new_profile = _e_illume_cfg->display_name.mobile;
6145 con = e_container_current_get(e_manager_current_get());
6146 bl = e_container_border_list_last(con);
6148 // if there exists a ID of window read from data ev->data.l[0],
6149 // find and set this window's border window, or set latest above border.
6150 bd = win ? e_border_find_by_client_window(win) :
6151 e_container_border_list_prev(bl);
6152 if (!bd) bd = e_border_find_by_window(win);
6157 // skip special window.
6158 if ((e_illume_border_is_indicator(bd)) ||
6159 (e_illume_border_is_keyboard(bd)) ||
6160 (e_illume_border_is_keyboard_sub(bd)) ||
6161 (e_illume_border_is_quickpanel(bd)) ||
6162 (e_illume_border_is_quickpanel_popup(bd)) ||
6163 (e_illume_border_is_clipboard(bd)))
6165 if (one_time) goto fin;
6169 if ((bd->client.icccm.accepts_focus || bd->client.icccm.take_focus) &&
6170 (bd->client.netwm.type != ECORE_X_WINDOW_TYPE_DOCK) &&
6171 (bd->client.netwm.type != ECORE_X_WINDOW_TYPE_TOOLBAR) &&
6172 (bd->client.netwm.type != ECORE_X_WINDOW_TYPE_MENU) &&
6173 (bd->client.netwm.type != ECORE_X_WINDOW_TYPE_SPLASH) &&
6174 (bd->client.netwm.type != ECORE_X_WINDOW_TYPE_DESKTOP) &&
6175 (bd->client.netwm.type != ECORE_X_WINDOW_TYPE_NOTIFICATION))
6180 // terminated this function if there is only one desk.
6181 if ((zone->desk_x_count < 2) && (zone->desk_y_count < 2))
6185 // find the corresponsive desk.
6186 for (x = 0; x < zone->desk_x_count; x++)
6188 for (y = 0; y < zone->desk_y_count; y++)
6190 int index = x + (y * zone->desk_x_count);
6191 profile = zone->desks[index]->window_profile;
6193 if (!strcmp(new_profile, profile))
6194 desk = zone->desks[index];
6198 if (!desk) goto fin;
6200 e_border_desk_set(bd, desk);
6202 // we have to receive the DAMAGE notify from this window.
6203 // for this, the window has to have visible state as a its property.
6204 // if not, can not receive DAMAGE notify.
6205 e_hints_window_visible_set(bd);
6206 e_hints_window_desktop_set(bd);
6207 _policy_border_uniconify_below_borders(bd);
6210 } while((!one_time) && (bd = e_container_border_list_prev(bl)));
6213 e_container_border_list_free(bl);
6217 "[POPSYNC] ERROR: ");
6221 fprintf(stderr, "Couldn't find border.\n");
6224 fprintf(stderr, "Couldn't change desk. No border, or special window.\n");
6227 fprintf(stderr, "NO desk to change \n");
6230 fprintf(stderr, "Couldn't find desk such a profile.\n");
6233 fprintf(stderr, "Non-defined error\n");
6239 /* for supporting rotation */
6241 _policy_border_hook_rotation_list_add(E_Border *bd)
6243 Eina_List *list = NULL;
6244 int prev_ang = dep_rot.ang;
6248 list = _policy_dependent_rotation_list_make(bd);
6251 dep_rot.ang = bd->client.e.state.rot.curr;
6252 ELBF(ELBT_ROT, 0, bd->client.win,
6253 "ADD ROT_LIST(dependent) curr:%d != prev:%d", dep_rot.ang, prev_ang);
6254 e_border_rotation_list_add(list);
6255 eina_list_free(list);
6260 _policy_border_dependent_rotation(E_Border *bd)
6262 Eina_List *list = NULL;
6263 E_Zone *zone = bd->zone;
6264 int prev_ang = dep_rot.ang;
6266 list = _policy_dependent_rotation_list_make(bd);
6269 dep_rot.ang = bd->client.e.state.rot.curr;
6270 ELBF(ELBT_ROT, 0, bd->client.win,
6271 "ADD & REQUEST ROT(dependent) curr:%d != prev:%d", dep_rot.ang, prev_ang);
6272 e_border_rotation_list_add_change_req(zone, list);
6273 eina_list_free(list);
6278 _policy_dependent_rotation_list_make(E_Border *bd)
6280 Eina_List *nl = NULL, *l;
6281 E_Border *dep_bd = NULL;
6284 if (!bd) return NULL;
6285 if (dep_rot.refer.active_win != bd->client.win) return NULL;
6286 if (dep_rot.ang == bd->client.e.state.rot.curr) return NULL;
6287 if (eina_list_data_find(dep_rot.list, bd) == bd) return NULL;
6289 ang = bd->client.e.state.rot.curr;
6290 EINA_LIST_FOREACH(dep_rot.list, l, dep_bd)
6292 dep_bd->client.e.state.rot.prev = dep_bd->client.e.state.rot.curr;
6293 dep_bd->client.e.state.rot.curr = ang;
6294 dep_bd->client.e.state.rot.wait_for_done = 1;
6295 nl = eina_list_append(nl, dep_bd);
6302 _policy_property_indicator_cmd_win_change(Ecore_X_Event_Window_Property *event)
6304 Ecore_X_Window cmd_win;
6306 cmd_win = _policy_indicator_cmd_win_get(event->win);
6310 ELB(ELBT_ROT, "ERR! NO INDI_CMD_WIN", event->win);
6314 if (dep_rot.refer.cmd_win != cmd_win)
6316 ELBF(ELBT_ROT, 0, cmd_win,
6317 "INDICATOR COMMAND WIN: [0x%08x -> 0x%08x]",
6318 dep_rot.refer.cmd_win, cmd_win);
6319 dep_rot.refer.cmd_win = cmd_win;
6324 _policy_property_active_indicator_win_change(Ecore_X_Event_Window_Property *event)
6326 Ecore_X_Window active_win = 0;
6327 E_Border *bd = NULL;
6331 active_win = _policy_active_indicator_win_get(event->win);
6334 ELB(ELBT_ROT, "ERR! NO ACTIVE_INDI_WIN", event->win);
6338 if (dep_rot.refer.active_win != active_win)
6340 bd = e_border_find_by_client_window(active_win);
6343 ELB(ELBT_ROT, "ERR! NO BD ACTIVE_INDI_WIN", active_win);
6347 /* The normal application window is ok to rotate dependent rotation windows.
6348 * But if the notification window which doesn't have accepts_focus such as volume popup
6349 * is the active window, then the illume doesn't rotate dependent windows.
6351 Eina_Bool rot = EINA_FALSE;
6352 if (e_illume_border_is_notification(bd))
6354 if ((bd->client.icccm.accepts_focus) || (bd->client.icccm.take_focus))
6364 ELBF(ELBT_ROT, 0, bd->client.win,
6365 "ROT:%d NOTI:%d ACCEPT_FOCUS:%d TAKE_FOCUS:%d",
6367 e_illume_border_is_notification(bd),
6368 bd->client.icccm.accepts_focus,
6369 bd->client.icccm.take_focus);
6373 E_Border *prev_bd = e_border_find_by_client_window(dep_rot.refer.active_win);
6374 ELBF(ELBT_ROT, 0, active_win,
6375 "INDICATOR ACTIVE WIN: [%s(0x%08x) -> %s(0x%08x)]",
6376 prev_bd ? (prev_bd->client.icccm.name ? prev_bd->client.icccm.name : "") : "",
6377 dep_rot.refer.active_win,
6378 bd->client.icccm.name ? bd->client.icccm.name : "",
6380 dep_rot.refer.active_win = active_win;
6381 _policy_border_dependent_rotation(bd);
6386 static Ecore_X_Window
6387 _policy_indicator_cmd_win_get(Ecore_X_Window win)
6389 Ecore_X_Window cmd_win = NULL;
6390 unsigned char* prop_data = NULL;
6391 int ret = 0, count = 0;
6393 if (win != dep_rot.root) return NULL;
6395 ret = ecore_x_window_prop_property_get(win, E_INDICATOR_CMD_WIN,
6396 ECORE_X_ATOM_WINDOW, 32,
6397 &prop_data, &count);
6399 memcpy (&cmd_win, prop_data, sizeof(ECORE_X_ATOM_WINDOW));
6401 if (prop_data) free(prop_data);
6406 static Ecore_X_Window
6407 _policy_active_indicator_win_get(Ecore_X_Window win)
6409 Ecore_X_Window active_win = NULL;
6410 unsigned char* prop_data = NULL;
6411 int ret = 0, count = 0;
6413 if (win != dep_rot.refer.cmd_win) return NULL;
6415 ret = ecore_x_window_prop_property_get(win, E_ACTIVE_INDICATOR_WIN,
6416 ECORE_X_ATOM_WINDOW, 32,
6417 &prop_data, &count);
6419 memcpy (&active_win, prop_data, sizeof(ECORE_X_ATOM_WINDOW));
6421 if (prop_data) free(prop_data);
6427 _policy_idle_enterer(void)
6429 _policy_calculate_visibility();