54
54
#include <X11/extensions/shape.h>
57
#define AUTO_MAXIMIZE_MINIMUM_COVERAGE 0.75
59
57
static int destroying_windows_disallowed = 0;
61
60
static void update_sm_hints (MetaWindow *window);
62
61
static void update_net_frame_extents (MetaWindow *window);
63
62
static void restack_window (MetaWindow *window,
978
save_pixmap_for_window(MetaWindow *window)
980
MetaDisplay *display = meta_window_get_display(window);
984
MetaCompositor *compositor = meta_display_get_compositor(display);
985
if (compositor != NULL) {
986
Pixmap pixmap = meta_compositor_get_window_pixmap(compositor, window);
990
Window xwindow = meta_window_get_xwindow(window);
991
meta_error_trap_push (display);
992
int success = XChangeProperty (meta_display_get_xdisplay(display),
994
display->atom__METACITY_WINDOW_CAPTURE,
996
32, PropModeReplace, (guchar*) &pixmap, 1);
997
meta_error_trap_pop (display, FALSE);
999
meta_warning("Failed to save capture property on window %lu\n", xwindow);
1004
remove_pixmap_for_window(MetaWindow *window)
1006
MetaDisplay *display = meta_window_get_display(window);
1007
if (display == NULL)
1010
Window xwindow = meta_window_get_xwindow(window);
1011
meta_error_trap_push (display);
1012
XDeleteProperty(meta_display_get_xdisplay(display),
1014
display->atom__METACITY_WINDOW_CAPTURE);
1015
meta_error_trap_pop (display, FALSE);
1019
977
meta_window_free (MetaWindow *window,
1020
978
guint32 timestamp)
1024
982
meta_verbose ("Unmanaging 0x%lx\n", window->xwindow);
1026
/* As a precaution remove the property holding the id of the
1027
captured pixmap first, so it can't be accessed anymore. */
1028
remove_pixmap_for_window(window);
1030
984
if (window->display->compositor)
1031
985
meta_compositor_free_window (window->display->compositor, window);
1527
1481
gboolean on_workspace;
1529
if (!showing && meta_prefs_get_capture_before_unmap())
1530
save_pixmap_for_window(window);
1532
1483
on_workspace = meta_window_located_on_workspace (window,
1533
1484
window->screen->active_workspace);
1576
/* Remove the property with the captured pixmap id before
1577
we actually proceed to show the window, as the pixmap will
1578
be destroyed by the compositor as soon as the window is
1579
mapped. This will leave a small gap in which neither the
1580
actual window pixmap nor the property holding the captured
1581
pixmap are available, but it's safer than having the
1582
property reference a pixmap that doesn't exist anymore. */
1583
remove_pixmap_for_window(window);
1585
1527
meta_window_show (window);
1725
1667
tmp = tmp->next;
1728
if (meta_prefs_get_focus_mode () != META_FOCUS_MODE_CLICK)
1670
if (meta_prefs_get_focus_mode () != G_DESKTOP_FOCUS_MODE_CLICK)
1730
1672
/* When display->mouse_mode is false, we want to ignore
1731
1673
* EnterNotify events unless they come from mouse motion. To do
2062
2004
* approximation to enforce so we do that.
2064
2006
if (*takes_focus &&
2065
meta_prefs_get_focus_new_windows () == META_FOCUS_NEW_WINDOWS_STRICT &&
2007
meta_prefs_get_focus_new_windows () == G_DESKTOP_FOCUS_NEW_WINDOWS_STRICT &&
2066
2008
!window->display->allow_terminal_deactivation &&
2067
2009
__window_is_terminal (window->display->focus_window) &&
2068
2010
!meta_window_is_ancestor_of_transient (window->display->focus_window,
2103
2045
windows_overlap (const MetaWindow *w1, const MetaWindow *w2)
2105
2047
MetaRectangle w1rect, w2rect;
2049
if (w1->minimized || w2->minimized)
2106
2052
meta_window_get_outer_rect (w1, &w1rect);
2107
2053
meta_window_get_outer_rect (w2, &w2rect);
2108
2054
return meta_rectangle_overlap (&w1rect, &w2rect);
2157
2103
gboolean takes_focus_on_map;
2158
2104
gboolean place_on_top_on_map;
2159
2105
gboolean needs_stacking_adjustment;
2106
gboolean will_be_covered;
2160
2107
MetaWindow *focus_window;
2161
2108
guint32 timestamp;
2174
2121
did_show = FALSE;
2175
2122
window_state_on_map (window, &takes_focus_on_map, &place_on_top_on_map);
2176
2123
needs_stacking_adjustment = FALSE;
2124
will_be_covered = window_would_be_covered (window);
2178
2126
meta_topic (META_DEBUG_WINDOW_STATE,
2179
2127
"Window %s %s focus on map, and %s place on top on map.\n",
2195
2143
if ( focus_window != NULL && window->showing_for_first_time &&
2196
2144
( (!place_on_top_on_map && !takes_focus_on_map) ||
2197
window_would_be_covered (window) )
2199
2147
if (meta_window_is_ancestor_of_transient (focus_window, window))
2278
2226
* in the stack when it doesn't overlap it confusingly places
2279
2227
* that new window below a lot of other windows.
2282
(meta_prefs_get_focus_mode () == META_FOCUS_MODE_CLICK &&
2283
meta_prefs_get_raise_on_click ()))
2229
if (!will_be_covered && (overlap ||
2230
(meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK &&
2231
meta_prefs_get_raise_on_click ())))
2284
2232
meta_window_stack_just_below (window, focus_window);
2286
/* If the window will be obscured by the focus window, then the
2287
* user might not notice the window appearing so set the
2288
* demands attention hint.
2234
/* If the window will be obscured by the focus window or a window set to
2235
* always on top, then the user might not notice the window appearing so
2236
* set the demands attention hint.
2290
2238
* We set the hint ourselves rather than calling
2291
2239
* meta_window_set_demands_attention() because that would cause
2292
2240
* a recalculation of overlap, and a call to set_net_wm_state()
2293
2241
* which we are going to call ourselves here a few lines down.
2243
if (overlap || will_be_covered)
2296
2244
window->wm_state_demands_attention = TRUE;
2374
2322
if (window->showing_for_first_time)
2376
2324
window->showing_for_first_time = FALSE;
2377
if (takes_focus_on_map && meta_prefs_get_focus_mode () != META_FOCUS_MODE_STRICT)
2325
if (takes_focus_on_map)
2379
2327
meta_window_focus (window, timestamp);
2703
meta_window_auto_maximize (MetaWindow *window)
2705
const MetaXineramaScreenInfo* info;
2706
int screen_surface, window_surface;
2709
if (window->type != META_WINDOW_NORMAL || !window->has_maximize_func)
2712
if (window->maximized_horizontally || window->maximized_vertically)
2715
info = meta_screen_get_xinerama_for_window (window->display->active_screen, window);
2716
g_return_if_fail (info);
2717
screen_surface = info->rect.width * info->rect.height;
2718
g_return_if_fail (screen_surface != 0);
2719
window_surface = window->rect.width * window->rect.height;
2720
coverage = (double)(window_surface) / screen_surface;
2722
if (coverage > AUTO_MAXIMIZE_MINIMUM_COVERAGE && coverage <= 1.0)
2723
meta_window_maximize (window, META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
2727
2651
unmaximize_window_before_freeing (MetaWindow *window)
5530
5454
* There is dicussion in bugs 102209, 115072, and 461577
5532
if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_CLICK ||
5456
if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK ||
5533
5457
!meta_prefs_get_raise_on_click())
5534
5458
meta_display_ungrab_focus_window_button (window->display, window);
5573
5497
meta_window_update_layer (window);
5575
5499
/* Re-grab for click to focus and raise-on-click, if necessary */
5576
if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_CLICK ||
5500
if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK ||
5577
5501
!meta_prefs_get_raise_on_click ())
5578
5502
meta_display_grab_focus_window_button (window->display, window);
8220
8144
* doesn't want to have focus transferred for now due to new windows.
8222
8146
if (meta_prefs_get_focus_new_windows () ==
8223
META_FOCUS_NEW_WINDOWS_STRICT &&
8147
G_DESKTOP_FOCUS_NEW_WINDOWS_STRICT &&
8224
8148
__window_is_terminal (window))
8225
8149
window->display->allow_terminal_deactivation = FALSE;