1
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
4
* \file window-private.h Windows which Metacity manages
7
* This file contains methods on this class which are available to
8
* routines in core but not outside it. (See window.h for the routines
9
* which the rest of the world is allowed to use.)
13
* Copyright (C) 2001 Havoc Pennington
14
* Copyright (C) 2002 Red Hat, Inc.
15
* Copyright (C) 2003, 2004 Rob Adams
16
* Copyright (C) 2004-2006 Elijah Newren
18
* This program is free software; you can redistribute it and/or
19
* modify it under the terms of the GNU General Public License as
20
* published by the Free Software Foundation; either version 2 of the
21
* License, or (at your option) any later version.
23
* This program is distributed in the hope that it will be useful, but
24
* WITHOUT ANY WARRANTY; without even the implied warranty of
25
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26
* General Public License for more details.
28
* You should have received a copy of the GNU General Public License
29
* along with this program; if not, write to the Free Software
30
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
34
#ifndef META_WINDOW_PRIVATE_H
35
#define META_WINDOW_PRIVATE_H
39
#include "screen-private.h"
42
#include "iconcache.h"
43
#include <X11/Xutil.h>
44
#include <gdk-pixbuf/gdk-pixbuf.h>
46
typedef struct _MetaGroup MetaGroup;
47
typedef struct _MetaWindowQueue MetaWindowQueue;
49
typedef gboolean (*MetaWindowForeachFunc) (MetaWindow *window,
58
META_WINDOW_MODAL_DIALOG,
62
META_WINDOW_SPLASHSCREEN
67
META_MAXIMIZE_HORIZONTAL = 1 << 0,
68
META_MAXIMIZE_VERTICAL = 1 << 1
72
META_CLIENT_TYPE_UNKNOWN = 0,
73
META_CLIENT_TYPE_APPLICATION = 1,
74
META_CLIENT_TYPE_PAGER = 2,
75
META_CLIENT_TYPE_MAX_RECOGNIZED = 2
79
META_QUEUE_CALC_SHOWING = 1 << 0,
80
META_QUEUE_MOVE_RESIZE = 1 << 1,
81
META_QUEUE_UPDATE_ICON = 1 << 2,
84
#define NUMBER_OF_QUEUES 3
90
MetaWorkspace *workspace;
92
/* may be NULL! not all windows get decorated */
97
char *desc; /* used in debug spew */
102
GdkPixbuf *mini_icon;
103
MetaIconCache icon_cache;
104
Pixmap wm_hints_pixmap;
105
Pixmap wm_hints_mask;
110
/* NOTE these five are not in UTF-8, we just treat them as random
117
char *wm_client_machine;
122
Window xtransient_for;
123
Window xgroup_leader;
124
Window xclient_leader;
126
/* Initial workspace property */
127
int initial_workspace;
129
/* Initial timestamp property */
130
guint32 initial_timestamp;
132
/* Whether we're maximized */
133
guint maximized_horizontally : 1;
134
guint maximized_vertically : 1;
136
/* Whether we have to maximize/minimize after placement */
137
guint maximize_horizontally_after_placement : 1;
138
guint maximize_vertically_after_placement : 1;
139
guint minimize_after_placement : 1;
141
/* Whether we're shaded */
144
/* Whether we're fullscreen */
145
guint fullscreen : 1;
147
/* Whether we have to fullscreen after placement */
148
guint fullscreen_after_placement : 1;
150
/* Area to cover when in fullscreen mode. If _NET_WM_FULLSCREEN_MONITORS has
151
* been overridden (via a client message), the window will cover the union of
152
* these monitors. If not, this is the single monitor which the window's
154
long fullscreen_monitors[4];
156
/* Whether we're trying to constrain the window to be fully onscreen */
157
guint require_fully_onscreen : 1;
159
/* Whether we're trying to constrain the window to be on a single xinerama */
160
guint require_on_single_xinerama : 1;
162
/* Whether we're trying to constrain the window's titlebar to be onscreen */
163
guint require_titlebar_visible : 1;
165
/* Whether we're sticky in the multi-workspace sense
166
* (vs. the not-scroll-with-viewport sense, we don't
167
* have no stupid viewports)
169
guint on_all_workspaces : 1;
171
/* Minimize is the state controlled by the minimize button */
173
guint was_minimized : 1;
174
guint tab_unminimized : 1;
176
/* Whether the window is mapped; actual server-side state
177
* see also unmaps_pending
181
/* Iconic is the state in WM_STATE; happens for workspaces/shading
182
* in addition to minimize
185
/* initially_iconic is the WM_HINTS setting when we first manage
186
* the window. It's taken to mean initially minimized.
188
guint initially_iconic : 1;
190
/* whether an initial workspace was explicitly set */
191
guint initial_workspace_set : 1;
193
/* whether an initial timestamp was explicitly set */
194
guint initial_timestamp_set : 1;
196
/* whether net_wm_user_time has been set yet */
197
guint net_wm_user_time_set : 1;
199
/* These are the flags from WM_PROTOCOLS */
200
guint take_focus : 1;
201
guint delete_window : 1;
202
guint net_wm_ping : 1;
203
/* Globally active / No input */
206
/* MWM hints about features of window */
207
guint mwm_decorated : 1;
208
guint mwm_border_only : 1;
209
guint mwm_has_close_func : 1;
210
guint mwm_has_minimize_func : 1;
211
guint mwm_has_maximize_func : 1;
212
guint mwm_has_move_func : 1;
213
guint mwm_has_resize_func : 1;
215
/* Computed features of window */
217
guint border_only : 1;
218
guint always_sticky : 1;
219
guint has_close_func : 1;
220
guint has_minimize_func : 1;
221
guint has_maximize_func : 1;
222
guint has_shade_func : 1;
223
guint has_move_func : 1;
224
guint has_resize_func : 1;
225
guint has_fullscreen_func : 1;
227
/* Weird "_NET_WM_STATE_MODAL" flag */
228
guint wm_state_modal : 1;
230
/* TRUE if the client forced these on */
231
guint wm_state_skip_taskbar : 1;
232
guint wm_state_skip_pager : 1;
234
/* Computed whether to skip taskbar or not */
235
guint skip_taskbar : 1;
236
guint skip_pager : 1;
238
/* TRUE if client set these */
239
guint wm_state_above : 1;
240
guint wm_state_below : 1;
242
/* EWHH demands attention flag */
243
guint wm_state_demands_attention : 1;
245
/* this flag tracks receipt of focus_in focus_out and
246
* determines whether we draw the focus
250
/* Have we placed this window? */
253
/* Must we force_save_user_window_placement? */
254
guint force_save_user_rect : 1;
256
/* Is this not a transient of the focus window which is being denied focus? */
257
guint denied_focus_and_not_transient : 1;
259
/* Has this window not ever been shown yet? */
260
guint showing_for_first_time : 1;
262
/* Are we in meta_window_free()? */
263
guint unmanaging : 1;
265
/* Are we in meta_window_new()? */
266
guint constructing : 1;
268
/* Are we in the various queues? (Bitfield: see META_WINDOW_IS_IN_QUEUE) */
269
guint is_in_queues : NUMBER_OF_QUEUES;
271
/* Used by keybindings.c */
272
guint keys_grabbed : 1; /* normal keybindings grabbed */
273
guint grab_on_frame : 1; /* grabs are on the frame */
274
guint all_keys_grabbed : 1; /* AnyKey grabbed */
276
/* Set if the reason for unmanaging the window is that
281
/* TRUE if constrain_position should calc placement.
282
* only relevant if !window->placed
284
guint calc_placement : 1;
286
/* Transient parent is a root window */
287
guint transient_parent_is_root_window : 1;
289
/* Info on which props we got our attributes from */
290
guint using_net_wm_name : 1; /* vs. plain wm_name */
291
guint using_net_wm_visible_name : 1; /* tracked so we can clear it */
292
guint using_net_wm_icon_name : 1; /* vs. plain wm_icon_name */
293
guint using_net_wm_visible_icon_name : 1; /* tracked so we can clear it */
295
/* has a shape mask */
298
/* icon props have changed */
299
guint need_reread_icon : 1;
301
/* if TRUE, window was maximized at start of current grab op */
302
guint shaken_loose : 1;
304
/* if TRUE we have a grab on the focus click buttons */
305
guint have_focus_click_grab : 1;
307
/* if TRUE, application is buggy and SYNC resizing is turned off */
308
guint disable_sync : 1;
310
/* Note: can be NULL */
314
/* XSync update counter */
315
XSyncCounter sync_request_counter;
316
guint sync_request_serial;
317
GTimeVal sync_request_time;
320
/* Number of UnmapNotify that are caused by us, if
321
* we get UnmapNotify with none pending then the client
322
* is withdrawing the window.
326
/* set to the most recent user-interaction event timestamp that we
327
know about for this window */
328
guint32 net_wm_user_time;
330
/* window that gets updated net_wm_user_time values */
331
Window user_time_window;
333
/* The size we set the window to last (i.e. what we believe
334
* to be its actual size on the server). The x, y are
335
* the actual server-side x,y so are relative to the frame
336
* (meaning that they just hold the frame width and height)
337
* or the root window (meaning they specify the location
338
* of the top left of the inner window) as appropriate.
342
/* The geometry to restore when we unmaximize. The position is in
343
* root window coords, even if there's a frame, which contrasts with
344
* window->rect above. Note that this gives the position and size
345
* of the client window (i.e. ignoring the frame).
347
MetaRectangle saved_rect;
349
/* This is the geometry the window had after the last user-initiated
350
* move/resize operations. We use this whenever we are moving the
351
* implicitly (for example, if we move to avoid a panel, we can snap
352
* back to this position if the panel moves again). Note that this
353
* gives the position and size of the client window (i.e. ignoring
356
* Position valid if user_has_moved, size valid if user_has_resized
358
* Position always in root coords, unlike window->rect.
360
MetaRectangle user_rect;
362
/* Requested geometry */
364
/* x/y/w/h here get filled with ConfigureRequest values */
365
XSizeHints size_hints;
367
/* Managed by stack.c */
368
MetaStackLayer layer;
369
int stack_position; /* see comment in stack.h */
371
/* Current dialog open for this window */
374
/* maintained by group.c */
378
/* These differ from window->has_foo_func in that they consider
379
* the dynamic window state such as "maximized", not just the
382
#define META_WINDOW_MAXIMIZED(w) ((w)->maximized_horizontally && \
383
(w)->maximized_vertically)
384
#define META_WINDOW_MAXIMIZED_VERTICALLY(w) ((w)->maximized_vertically)
385
#define META_WINDOW_MAXIMIZED_HORIZONTALLY(w) ((w)->maximized_horizontally)
386
#define META_WINDOW_ALLOWS_MOVE(w) ((w)->has_move_func && !(w)->fullscreen)
387
#define META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS(w) ((w)->has_resize_func && !META_WINDOW_MAXIMIZED (w) && !(w)->fullscreen && !(w)->shaded)
388
#define META_WINDOW_ALLOWS_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) && \
389
(((w)->size_hints.min_width < (w)->size_hints.max_width) || \
390
((w)->size_hints.min_height < (w)->size_hints.max_height)))
391
#define META_WINDOW_ALLOWS_HORIZONTAL_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) && (w)->size_hints.min_width < (w)->size_hints.max_width)
392
#define META_WINDOW_ALLOWS_VERTICAL_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) && (w)->size_hints.min_height < (w)->size_hints.max_height)
394
MetaWindow* meta_window_new (MetaDisplay *display,
396
gboolean must_be_viewable);
397
MetaWindow* meta_window_new_with_attrs (MetaDisplay *display,
399
gboolean must_be_viewable,
400
XWindowAttributes *attrs);
401
void meta_window_free (MetaWindow *window,
403
void meta_window_calc_showing (MetaWindow *window);
404
void meta_window_queue (MetaWindow *window,
406
void meta_window_minimize (MetaWindow *window);
407
void meta_window_unminimize (MetaWindow *window);
408
void meta_window_maximize (MetaWindow *window,
409
MetaMaximizeFlags directions);
410
void meta_window_maximize_internal (MetaWindow *window,
411
MetaMaximizeFlags directions,
412
MetaRectangle *saved_rect);
413
void meta_window_unmaximize (MetaWindow *window,
414
MetaMaximizeFlags directions);
415
void meta_window_make_above (MetaWindow *window);
416
void meta_window_unmake_above (MetaWindow *window);
417
void meta_window_shade (MetaWindow *window,
419
void meta_window_unshade (MetaWindow *window,
421
void meta_window_change_workspace (MetaWindow *window,
422
MetaWorkspace *workspace);
423
void meta_window_stick (MetaWindow *window);
424
void meta_window_unstick (MetaWindow *window);
426
void meta_window_activate (MetaWindow *window,
427
guint32 current_time);
428
void meta_window_activate_with_workspace (MetaWindow *window,
429
guint32 current_time,
430
MetaWorkspace *workspace);
431
void meta_window_make_fullscreen_internal (MetaWindow *window);
432
void meta_window_make_fullscreen (MetaWindow *window);
433
void meta_window_unmake_fullscreen (MetaWindow *window);
434
void meta_window_update_fullscreen_monitors (MetaWindow *window,
436
unsigned long bottom,
438
unsigned long right);
440
/* args to move are window pos, not frame pos */
441
void meta_window_move (MetaWindow *window,
445
void meta_window_resize (MetaWindow *window,
449
void meta_window_move_resize (MetaWindow *window,
455
void meta_window_resize_with_gravity (MetaWindow *window,
462
/* Return whether the window would be showing if we were on its workspace */
463
gboolean meta_window_showing_on_its_workspace (MetaWindow *window);
465
/* Return whether the window should be currently mapped */
466
gboolean meta_window_should_be_showing (MetaWindow *window);
468
/* See warning in window.c about this function */
469
gboolean __window_is_terminal (MetaWindow *window);
471
void meta_window_update_struts (MetaWindow *window);
473
/* this gets root coords */
474
void meta_window_get_position (MetaWindow *window,
478
/* Gets root coords for x, y, width & height of client window; uses
479
* meta_window_get_position for x & y.
481
void meta_window_get_client_root_coords (MetaWindow *window,
482
MetaRectangle *rect);
484
/* gets position we need to set to stay in current position,
485
* assuming position will be gravity-compensated. i.e.
486
* this is the position a client would send in a configure
489
void meta_window_get_gravity_position (MetaWindow *window,
493
/* Get geometry for saving in the session; x/y are gravity
494
* position, and w/h are in resize inc above the base size.
496
void meta_window_get_geometry (MetaWindow *window,
501
void meta_window_get_outer_rect (const MetaWindow *window,
502
MetaRectangle *rect);
503
void meta_window_get_xor_rect (MetaWindow *window,
504
const MetaRectangle *grab_wireframe_rect,
505
MetaRectangle *xor_rect);
506
void meta_window_begin_wireframe (MetaWindow *window);
507
void meta_window_update_wireframe (MetaWindow *window,
512
void meta_window_end_wireframe (MetaWindow *window);
514
void meta_window_delete (MetaWindow *window,
516
void meta_window_kill (MetaWindow *window);
517
void meta_window_focus (MetaWindow *window,
519
void meta_window_raise (MetaWindow *window);
520
void meta_window_lower (MetaWindow *window);
522
void meta_window_update_unfocused_button_grabs (MetaWindow *window);
524
/* Sends a client message */
525
void meta_window_send_icccm_message (MetaWindow *window,
530
void meta_window_move_resize_request(MetaWindow *window,
537
gboolean meta_window_configure_request (MetaWindow *window,
539
gboolean meta_window_property_notify (MetaWindow *window,
541
gboolean meta_window_client_message (MetaWindow *window,
543
gboolean meta_window_notify_focus (MetaWindow *window,
546
void meta_window_set_current_workspace_hint (MetaWindow *window);
548
unsigned long meta_window_get_net_wm_desktop (MetaWindow *window);
550
void meta_window_show_menu (MetaWindow *window,
556
gboolean meta_window_titlebar_is_onscreen (MetaWindow *window);
557
void meta_window_shove_titlebar_onscreen (MetaWindow *window);
559
void meta_window_set_gravity (MetaWindow *window,
562
void meta_window_handle_mouse_grab_op_event (MetaWindow *window,
565
GList* meta_window_get_workspaces (MetaWindow *window);
567
gboolean meta_window_located_on_workspace (MetaWindow *window,
568
MetaWorkspace *workspace);
570
void meta_window_get_work_area_current_xinerama (MetaWindow *window,
571
MetaRectangle *area);
572
void meta_window_get_work_area_for_xinerama (MetaWindow *window,
574
MetaRectangle *area);
575
void meta_window_get_work_area_all_xineramas (MetaWindow *window,
576
MetaRectangle *area);
579
gboolean meta_window_same_application (MetaWindow *window,
580
MetaWindow *other_window);
582
#define META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE(w) \
583
((w)->type != META_WINDOW_DOCK && (w)->type != META_WINDOW_DESKTOP)
584
#define META_WINDOW_IN_NORMAL_TAB_CHAIN(w) \
585
(((w)->input || (w)->take_focus ) && META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE (w) && (!(w)->skip_taskbar))
586
#define META_WINDOW_IN_DOCK_TAB_CHAIN(w) \
587
(((w)->input || (w)->take_focus) && (! META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE (w) || (w)->skip_taskbar))
588
#define META_WINDOW_IN_GROUP_TAB_CHAIN(w, g) \
589
(((w)->input || (w)->take_focus) && (!g || meta_window_get_group(w)==g))
591
void meta_window_refresh_resize_popup (MetaWindow *window);
593
void meta_window_free_delete_dialog (MetaWindow *window);
595
void meta_window_foreach_transient (MetaWindow *window,
596
MetaWindowForeachFunc func,
598
gboolean meta_window_is_ancestor_of_transient (MetaWindow *window,
599
MetaWindow *transient);
600
void meta_window_foreach_ancestor (MetaWindow *window,
601
MetaWindowForeachFunc func,
603
MetaWindow* meta_window_find_root_ancestor (MetaWindow *window);
606
void meta_window_begin_grab_op (MetaWindow *window,
608
gboolean frame_action,
611
void meta_window_update_keyboard_resize (MetaWindow *window,
612
gboolean update_cursor);
613
void meta_window_update_keyboard_move (MetaWindow *window);
615
void meta_window_update_layer (MetaWindow *window);
617
gboolean meta_window_get_icon_geometry (MetaWindow *window,
618
MetaRectangle *rect);
620
const char* meta_window_get_startup_id (MetaWindow *window);
622
void meta_window_recalc_features (MetaWindow *window);
623
void meta_window_recalc_window_type (MetaWindow *window);
625
void meta_window_stack_just_above (MetaWindow *window,
626
MetaWindow *above_this_one);
627
void meta_window_stack_just_below (MetaWindow *window,
628
MetaWindow *below_this_one);
630
void meta_window_set_user_time (MetaWindow *window,
633
void meta_window_set_demands_attention (MetaWindow *window);
635
void meta_window_unset_demands_attention (MetaWindow *window);
637
void meta_window_update_icon_now (MetaWindow *window);
639
void meta_window_update_role (MetaWindow *window);
640
void meta_window_update_net_wm_type (MetaWindow *window);