3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 oroborus - (c) 2001 Ken Lynch
18 xfwm4 - (c) 2002-2007 Olivier Fourdan
34 #include <X11/Xutil.h>
36 #include <X11/cursorfont.h>
37 #include <X11/extensions/shape.h>
58 #define PLACEMENT_MOUSE 0
59 #define PLACEMENT_ROOT 1
62 #define CFG_CONSTRAINED (1<<0)
63 #define CFG_REQUEST (1<<1)
64 #define CFG_NOTIFY (1<<2)
65 #define CFG_FORCE_REDRAW (1<<3)
67 #define INCLUDE_HIDDEN (1<<0)
68 #define INCLUDE_SHADED (1<<1)
69 #define INCLUDE_ALL_WORKSPACES (1<<2)
70 #define INCLUDE_SKIP_FOCUS (1<<3)
71 #define INCLUDE_SKIP_PAGER (1<<4)
72 #define INCLUDE_SKIP_TASKBAR (1<<5)
74 #define NO_UPDATE_FLAG 0
75 #define UPDATE_BUTTON_GRABS (1<<0)
76 #define UPDATE_FRAME (1<<1)
77 #define UPDATE_GRAVITY (1<<2)
78 #define UPDATE_MAXIMIZE (1<<3)
79 #define UPDATE_CACHE (1<<4)
80 #define UPDATE_ALL (UPDATE_BUTTON_GRABS | \
86 #define CLIENT_FILL_VERT (1L<<0)
87 #define CLIENT_FILL_HORIZ (1L<<1)
88 #define CLIENT_FILL (CLIENT_FILL_VERT | \
92 #define STRUTS_SIZE 12
94 #ifndef CLIENT_MIN_VISIBLE
95 #define CLIENT_MIN_VISIBLE 15
98 #ifndef CLIENT_XSYNC_TIMEOUT
99 #define CLIENT_XSYNC_TIMEOUT 1000 /* ms */
102 #ifndef CLIENT_BLINK_TIMEOUT
103 #define CLIENT_BLINK_TIMEOUT 500 /* ms */
106 #define XFWM_FLAG_HAS_BORDER (1L<<0)
107 #define XFWM_FLAG_HAS_MENU (1L<<1)
108 #define XFWM_FLAG_HAS_MAXIMIZE (1L<<2)
109 #define XFWM_FLAG_HAS_CLOSE (1L<<3)
110 #define XFWM_FLAG_HAS_HIDE (1L<<4)
111 #define XFWM_FLAG_HAS_MOVE (1L<<5)
112 #define XFWM_FLAG_HAS_RESIZE (1L<<6)
113 #define XFWM_FLAG_HAS_STICK (1L<<7)
114 #define XFWM_FLAG_FOCUS (1L<<8)
115 #define XFWM_FLAG_IS_RESIZABLE (1L<<9)
116 #define XFWM_FLAG_MAP_PENDING (1L<<10)
117 #define XFWM_FLAG_VISIBLE (1L<<11)
118 #define XFWM_FLAG_MANAGED (1L<<13)
119 #define XFWM_FLAG_SESSION_MANAGED (1L<<14)
120 #define XFWM_FLAG_WORKSPACE_SET (1L<<15)
121 #define XFWM_FLAG_WAS_SHOWN (1L<<16)
122 #define XFWM_FLAG_DRAW_ACTIVE (1L<<17)
123 #define XFWM_FLAG_SEEN_ACTIVE (1L<<18)
124 #define XFWM_FLAG_FIRST_MAP (1L<<19)
125 #define XFWM_FLAG_LEGACY_FULLSCREEN (1L<<20)
126 #define XFWM_FLAG_MOVING_RESIZING (1L<<21)
128 #define CLIENT_FLAG_HAS_STRUT (1L<<0)
129 #define CLIENT_FLAG_HAS_STRUT_PARTIAL (1L<<1)
130 #define CLIENT_FLAG_HAS_USER_TIME (1L<<2)
131 #define CLIENT_FLAG_HAS_STARTUP_TIME (1L<<3)
132 #define CLIENT_FLAG_ABOVE (1L<<4)
133 #define CLIENT_FLAG_BELOW (1L<<5)
134 #define CLIENT_FLAG_FULLSCREEN (1L<<6)
135 #define CLIENT_FLAG_ICONIFIED (1L<<7)
136 #define CLIENT_FLAG_MAXIMIZED_VERT (1L<<8)
137 #define CLIENT_FLAG_MAXIMIZED_HORIZ (1L<<9)
138 #define CLIENT_FLAG_MAXIMIZED (CLIENT_FLAG_MAXIMIZED_VERT | \
139 CLIENT_FLAG_MAXIMIZED_HORIZ)
140 #define CLIENT_FLAG_SHADED (1L<<10)
141 #define CLIENT_FLAG_SKIP_PAGER (1L<<11)
142 #define CLIENT_FLAG_SKIP_TASKBAR (1L<<12)
143 #define CLIENT_FLAG_STATE_MODAL (1L<<13)
144 #define CLIENT_FLAG_STICKY (1L<<15)
145 #define CLIENT_FLAG_NAME_CHANGED (1L<<16)
146 #define CLIENT_FLAG_DEMANDS_ATTENTION (1L<<17)
147 #define CLIENT_FLAG_HAS_SHAPE (1L<<18)
149 #define WM_FLAG_DELETE (1L<<0)
150 #define WM_FLAG_INPUT (1L<<1)
151 #define WM_FLAG_TAKEFOCUS (1L<<2)
152 #define WM_FLAG_CONTEXT_HELP (1L<<3)
153 #define WM_FLAG_URGENT (1L<<4)
155 #define CLIENT_FLAG_INITIAL_VALUES XFWM_FLAG_HAS_BORDER | \
156 XFWM_FLAG_HAS_MENU | \
157 XFWM_FLAG_HAS_MAXIMIZE | \
158 XFWM_FLAG_HAS_STICK | \
159 XFWM_FLAG_HAS_HIDE | \
160 XFWM_FLAG_HAS_CLOSE | \
161 XFWM_FLAG_HAS_MOVE | \
162 XFWM_FLAG_HAS_RESIZE | \
165 #define ALL_WORKSPACES (int) 0xFFFFFFFF
167 #define CONSTRAINED_WINDOW(c) ((c->win_layer > WIN_LAYER_DESKTOP) && \
168 !(c->type & (WINDOW_DESKTOP | WINDOW_DOCK)) && \
169 !FLAG_TEST(c->xfwm_flags, XFWM_FLAG_LEGACY_FULLSCREEN))
171 #define WINDOW_TYPE_DIALOG (WINDOW_DIALOG | \
173 #define WINDOW_TYPE_DONT_PLACE (WINDOW_DESKTOP | \
177 #define WINDOW_REGULAR_FOCUSABLE (WINDOW_NORMAL | \
180 #define WINDOW_TYPE_DONT_FOCUS (WINDOW_SPLASHSCREEN | \
183 /* Which bits of opacity are applied */
184 #define OPACITY_MOVE (1<<0)
185 #define OPACITY_RESIZE (1<<1)
186 #define OPACITY_INACTIVE (1<<2)
188 /* Convenient macros */
189 #define FLAG_TEST(flag,bits) (flag & (bits))
190 #define FLAG_TEST_ALL(flag,bits) ((flag & (bits)) == (bits))
191 #define FLAG_TEST_AND_NOT(flag,bits1,bits2) ((flag & (bits1 | bits2)) == (bits1))
192 #define FLAG_SET(flag,bits) (flag |= (bits))
193 #define FLAG_UNSET(flag,bits) (flag &= ~(bits))
194 #define FLAG_TOGGLE(flag,bits) (flag ^= (bits))
196 #define CLIENT_CAN_HIDE_WINDOW(c) (!(c->transient_for) && \
197 FLAG_TEST(c->xfwm_flags, XFWM_FLAG_HAS_HIDE) && \
198 !FLAG_TEST(c->flags, CLIENT_FLAG_SKIP_TASKBAR))
199 #define CLIENT_CAN_MAXIMIZE_WINDOW(c) (FLAG_TEST_AND_NOT(c->xfwm_flags, XFWM_FLAG_HAS_MAXIMIZE | \
200 XFWM_FLAG_HAS_RESIZE | \
201 XFWM_FLAG_IS_RESIZABLE, \
202 XFWM_FLAG_LEGACY_FULLSCREEN) && \
203 !FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN))
204 #define CLIENT_CAN_FILL_WINDOW(c) (FLAG_TEST_AND_NOT(c->xfwm_flags, XFWM_FLAG_HAS_RESIZE | \
205 XFWM_FLAG_IS_RESIZABLE, \
206 XFWM_FLAG_LEGACY_FULLSCREEN) && \
207 !FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN | CLIENT_FLAG_MAXIMIZED))
209 #define CLIENT_CAN_STICK_WINDOW(c) (!(c->transient_for) && \
210 FLAG_TEST(c->xfwm_flags, XFWM_FLAG_HAS_STICK))
215 WINDOW_NORMAL
= (1 << 0),
216 WINDOW_DESKTOP
= (1 << 1),
217 WINDOW_DOCK
= (1 << 2),
218 WINDOW_DIALOG
= (1 << 3),
219 WINDOW_MODAL_DIALOG
= (1 << 4),
220 WINDOW_TOOLBAR
= (1 << 5),
221 WINDOW_MENU
= (1 << 6),
222 WINDOW_UTILITY
= (1 << 7),
223 WINDOW_SPLASHSCREEN
= (1 << 8)
229 /* Reference to our screen structure */
230 ScreenInfo
*screen_info
;
234 Window transient_for
;
235 Window
*cmap_windows
;
237 xfwmWindow sides
[SIDE_COUNT
];
238 xfwmWindow corners
[CORNER_COUNT
];
239 xfwmWindow buttons
[BUTTON_COUNT
];
240 Window client_leader
;
242 xfwmPixmap appmenu
[STATE_TOGGLED
];
244 unsigned long win_hints
;
245 unsigned long win_state
;
246 unsigned long win_layer
;
247 unsigned long serial
;
264 unsigned int ignore_unmap
;
269 int fullscreen_old_x
;
270 int fullscreen_old_y
;
271 int fullscreen_old_width
;
272 int fullscreen_old_height
;
273 int fullscreen_old_layer
;
278 int button_status
[BUTTON_COUNT
];
279 int struts
[STRUTS_SIZE
];
283 unsigned long wm_flags
;
284 unsigned long xfwm_flags
;
285 /* Timout for asynchronous icon update */
286 guint icon_timeout_id
;
287 /* Timout for asynchronous frame update */
288 guint frame_timeout_id
;
289 /* Timout to manage blinking decorations for urgent windows */
290 guint blink_timeout_id
;
291 /* Opacity for the compositor */
293 guint opacity_applied
;
295 gboolean opacity_locked
;
297 #ifdef HAVE_LIBSTARTUP_NOTIFICATION
298 /* Startup notification */
300 #endif /* HAVE_LIBSTARTUP_NOTIFICATION */
303 XSyncAlarm xsync_alarm
;
304 XSyncCounter xsync_counter
;
305 XSyncValue xsync_value
;
306 guint xsync_timeout_id
;
307 gboolean xsync_waiting
;
308 gboolean xsync_enabled
;
309 #endif /* HAVE_XSYNC */
312 extern Client
*clients
;
313 extern unsigned int client_count
;
315 Display
*clientGetXDisplay (Client
*);
316 void clientClearLastOpTime (Client
*);
317 void clientUpdateWinState (Client
*,
318 XClientMessageEvent
*);
319 void clientUpdateUrgency (Client
*);
320 void clientCoordGravitate (Client
*,
324 void clientGravitate (Client
*,
326 void clientConfigure (Client
*,
330 void clientGetMWMHints (Client
*,
332 void clientGetWMNormalHints (Client
*,
334 void clientGetWMProtocols (Client
*);
335 void clientUpdateIcon (Client
* c
);
336 Client
*clientFrame (DisplayInfo
*,
339 void clientUnframe (Client
*,
341 void clientFrameAll (ScreenInfo
*);
342 void clientUnframeAll (ScreenInfo
*);
343 void clientInstallColormaps (Client
*);
344 void clientUpdateColormaps (Client
*);
345 void clientUpdateName (Client
*);
346 void clientUpdateAllFrames (ScreenInfo
*,
348 void clientGrabButtons (Client
*);
349 void clientUngrabButtons (Client
*);
350 Client
*clientGetFromWindow (Client
*,
353 void clientShow (Client
*,
355 void clientHide (Client
*,
358 void clientHideAll (Client
*,
360 void clientClearAllShowDesktop (ScreenInfo
*);
361 void clientToggleShowDesktop (ScreenInfo
*);
362 void clientActivate (Client
*,
364 void clientClose (Client
*);
365 void clientKill (Client
*);
366 void clientEnterContextMenuState (Client
*);
367 void clientSetLayer (Client
*,
369 void clientSetWorkspace (Client
*,
372 void clientShade (Client
*);
373 void clientUnshade (Client
*);
374 void clientToggleShaded (Client
*);
375 void clientStick (Client
*,
377 void clientUnstick (Client
*,
379 void clientToggleSticky (Client
*,
381 void clientToggleFullscreen (Client
*);
382 void clientToggleAbove (Client
*);
383 void clientToggleBelow (Client
*);
384 void clientRemoveMaximizeFlag (Client
*);
385 void clientToggleMaximized (Client
*,
388 void clientFill (Client
*,
390 void clientUpdateOpacity (ScreenInfo
*,
392 void clientSetOpacity (Client
*,
395 void clientIncOpacity (Client
*);
396 void clientDecOpacity (Client
*);
397 void clientScreenResize (ScreenInfo
*);
398 void clientMove (Client
*,
400 void clientResize (Client
*,
403 void clientCycle (Client
*,
405 void clientButtonPress (Client
*,
408 xfwmPixmap
* clientGetButtonPixmap (Client
*,
411 int clientGetButtonState (Client
*,
414 Client
*clientGetLeader (Client
*);
415 #ifdef HAVE_LIBSTARTUP_NOTIFICATION
416 char *clientGetStartupId (Client
*);
417 #endif /* HAVE_LIBSTARTUP_NOTIFICATION */
419 void clientXSyncRequest (Client
*);
420 #endif /* HAVE_XSYNC */
422 #endif /* INC_CLIENT_H */