1 
2 /**
3  * Move window to coordinates that do not account client decorations yet.
4  *
5  * This call will consider given position does not account client
6  * decoration, so these values (e_comp_object_frame) will be
7  * accounted automatically. This is specially useful when it is a new
8  * client and has not be evaluated yet, in this case
9  * the frame will be zeroed and no information is known. It
10  * will mark pending requests so client will be accounted on
11  * evalutation phase.
12  *
13  * @parm x horizontal position to place window.
14  * @parm y vertical position to place window.
15  *
16  * @see e_client_move()
17  */
18 static inline void
e_client_util_move_without_frame(E_Client * ec,int x,int y)19 e_client_util_move_without_frame(E_Client *ec, int x, int y)
20 {
21    if (!ec) return;
22    e_comp_object_frame_xy_adjust(ec->frame, x, y, &x, &y);
23    evas_object_move(ec->frame, x, y);
24 }
25 
26 /**
27  * Resize window to values that do not account client decorations yet.
28  *
29  * This call will consider given size and does not for account client
30  * decoration, so these values (e_comp_object_frame) will be
31  * accounted for automatically. This is specially useful when it is a new
32  * client and has not been evaluated yet, in this case
33  * e_comp_object_frame will be zeroed and no information is known. It
34  * will mark pending requests so the client will be accounted for on
35  * evalutation phase.
36  *
37  * @parm w horizontal window size.
38  * @parm h vertical window size.
39  *
40  * @see e_client_resize()
41  */
42 static inline void
e_client_util_resize_without_frame(E_Client * ec,int w,int h)43 e_client_util_resize_without_frame(E_Client *ec, int w, int h)
44 {
45    if (!ec) return;
46    e_comp_object_frame_wh_adjust(ec->frame, w, h, &w, &h);
47    evas_object_resize(ec->frame, w, h);
48 }
49 
50 /**
51  * Move and resize window to values that do not account for client decorations yet.
52  *
53  * This call will consider given values already accounts client
54  * decorations, so it will not be considered later. This will just
55  * work properly with clients that have being evaluated and client
56  * decorations are known (e_comp_object_frame).
57  *
58  * @parm x horizontal position to place window.
59  * @parm y vertical position to place window.
60  * @parm w horizontal window size.
61  * @parm h vertical window size.
62  *
63  * @see e_client_move_resize()
64  */
65 static inline void
e_client_util_move_resize_without_frame(E_Client * ec,int x,int y,int w,int h)66 e_client_util_move_resize_without_frame(E_Client *ec, int x, int y, int w, int h)
67 {
68    e_client_util_move_without_frame(ec, x, y);
69    e_client_util_resize_without_frame(ec, w, h);
70 }
71 
72 static inline Eina_Bool
e_client_util_ignored_get(const E_Client * ec)73 e_client_util_ignored_get(const E_Client *ec)
74 {
75    if (!ec) return EINA_TRUE;
76    return ec->override || ec->input_only || ec->ignored;
77 }
78 
79 static inline Eina_Bool
e_client_util_is_popup(const E_Client * ec)80 e_client_util_is_popup(const E_Client *ec)
81 {
82    if (!ec) return EINA_FALSE;
83    switch (ec->netwm.type)
84      {
85       case E_WINDOW_TYPE_MENU:
86       case E_WINDOW_TYPE_SPLASH:
87       case E_WINDOW_TYPE_DROPDOWN_MENU:
88       case E_WINDOW_TYPE_POPUP_MENU:
89       case E_WINDOW_TYPE_TOOLTIP:
90       case E_WINDOW_TYPE_NOTIFICATION:
91       case E_WINDOW_TYPE_COMBO:
92       case E_WINDOW_TYPE_DND:
93         return EINA_TRUE;
94       default: break;
95      }
96    return EINA_FALSE;
97 }
98 
99 static inline Eina_Bool
e_client_util_desk_visible(const E_Client * ec,const E_Desk * desk)100 e_client_util_desk_visible(const E_Client *ec, const E_Desk *desk)
101 {
102    if (!ec) return EINA_FALSE;
103    return !ec->desk || ec->sticky || (ec->desk == desk);
104 }
105 
106 static inline Ecore_Window
e_client_util_pwin_get(const E_Client * ec)107 e_client_util_pwin_get(const E_Client *ec)
108 {
109    if (!ec->pixmap) return 0;
110 #if defined(HAVE_WAYLAND) && !defined(HAVE_WAYLAND_ONLY)
111    return e_pixmap_parent_window_get(e_comp_x_client_pixmap_get(ec));
112 #else
113    return e_pixmap_parent_window_get(ec->pixmap);
114 #endif
115 }
116 
117 static inline Ecore_Window
e_client_util_win_get(const E_Client * ec)118 e_client_util_win_get(const E_Client *ec)
119 {
120    if (!ec->pixmap) return 0;
121 #if defined(HAVE_WAYLAND) && !defined(HAVE_WAYLAND_ONLY)
122    return e_pixmap_window_get(e_comp_x_client_pixmap_get(ec));
123 #else
124    return e_pixmap_window_get(ec->pixmap);
125 #endif
126 }
127 
128 static inline Eina_Bool
e_client_util_resizing_get(const E_Client * ec)129 e_client_util_resizing_get(const E_Client *ec)
130 {
131    if (!ec) return EINA_FALSE;
132    return (ec->resize_mode != E_POINTER_RESIZE_NONE);
133 }
134 
135 static inline Eina_Bool
e_client_util_borderless(const E_Client * ec)136 e_client_util_borderless(const E_Client *ec)
137 {
138    if (!ec) return EINA_FALSE;
139    return (ec->borderless || ec->mwm.borderless || (!ec->border.name) || (!strcmp(ec->border.name, "borderless")));
140 }
141 
142 static inline Eina_Bool
e_client_util_shadow_state_get(const E_Client * ec)143 e_client_util_shadow_state_get(const E_Client *ec)
144 {
145    Eina_Bool on;
146    if (ec->shaped) return EINA_FALSE;
147    if (ec->argb)
148      {
149         return (!ec->borderless) && (ec->bordername || (ec->border.name && strcmp(ec->border.name, "borderless")));
150      }
151    on = !ec->e.state.video;
152    if (on)
153      on = !ec->fullscreen;
154    return on;
155 }
156 
157 static inline Eina_Stringshare *
e_client_util_name_get(const E_Client * ec)158 e_client_util_name_get(const E_Client *ec)
159 {
160    if (!ec) return NULL;
161    if (ec->netwm.name)
162      return ec->netwm.name;
163    else if (ec->icccm.title)
164      return ec->icccm.title;
165    return NULL;
166 }
167 
168 static inline E_Client *
e_client_util_top_parent_get(const E_Client * ec)169 e_client_util_top_parent_get(const E_Client *ec)
170 {
171    E_Client *parent = ec->parent;
172 
173    while (parent->parent) parent = parent->parent;
174    return parent;
175 }
176