~ubuntu-branches/ubuntu/raring/metacity/raring

« back to all changes in this revision

Viewing changes to .pc/103_struts_in_the_middle.patch/src/core/window.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-08-23 11:12:43 UTC
  • mfrom: (1.2.64) (2.1.13 quantal-proposed)
  • Revision ID: package-import@ubuntu.com-20120823111243-v2ome3yisozc1dhw
* Resync with Debian & refresh patches. (LP: #1032120, LP: #1035261)
  Remaining changes:
* debian/control:
  - Suggest gnome-themes-standard instead of recommend
  - Add Vcs-Bzr link
* debian/metacity-common.gsettings-override:
  - Set Ubuntu default button layout order for Classic session
  - Drop previous gconf overrides as obsolete
* debian/patches/04_support_drag_drop_with_alt_tab.patch:
  - Support alt-tab during drag and drop.
* debian/patches/05_raise_on_click_for_click_mode.patch:
  - Use raise on click option.
* debian/patches/06_Add_UXD_shadows_and_borders.patch:
  - patch for a new key in the ubuntu theme for shows and borders
* debian/patches/10_no-ws-switcher.patch:
  - Don't show the workspace switcher if we only have one.
* debian/patches/12_dont-show-as-user.patch:
  - Don't show "as user" in title bar.
* debian/patches/13_better_support_for_button_layout.patch:
  - Corrected support for buttons backgrounds with transparency
* debian/patches/14_wrong_colormap.patch:
  - Use correct colormap to avoid crash with client side decorations
* debian/patches/20_do-not-place-windows-over-the-launcher.patch:
  - Try to avoid an already visible launcher in intellihide mode when
    initially positioning new windows.
* debian/patches/21_fix_compositing_startup.patch:
  Fix some weird rendering effect at startup with compositing activated
* debian/patches/100_fade_on_long_title.patch:
  - Fade on the end if the title is too long.
* debian/patches/102_workarea.patch,
  debian/patches/103_struts_in_the_middle.patch,
  debian/patches/104_workarea_union.patch:
  - Add barriers and multimonitor strut support for unity-2d
* debian/patches/104_workarea_union.patch:
  - Ensure each screen_region generated by
    meta_rectangle_get_minimal_spanning_set_for_region is not outside
    the xinerama screens
* Dropped patch:
  - 11_hide_tooltip_on_decorator.patch: Obsolete
* debian/patches/03_strict_focus.patch:
  - Disabled. This needs gsettings-desktop-schemas to be patched if
    we want to bring this back
* Disabled Unity 2D-related patches that need porting to gsettings:
  - 15_show_maximized_titlebars.patch
  - 16-capture-before-unmap.patch
  - 17-workspace-switcher-cycle.patch
  - 18-auto-maximize-windows.patch
  - 19_add_unity_hud_configuration.patch
  - 101_override_gconf_settings.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
#include <X11/extensions/shape.h>
55
55
#endif
56
56
 
57
 
#define AUTO_MAXIMIZE_MINIMUM_COVERAGE 0.75
58
 
 
59
57
static int destroying_windows_disallowed = 0;
60
58
 
 
59
 
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,
974
973
    }
975
974
}
976
975
 
977
 
static void
978
 
save_pixmap_for_window(MetaWindow *window)
979
 
{
980
 
    MetaDisplay *display = meta_window_get_display(window);
981
 
    if (display == NULL)
982
 
      return;
983
 
 
984
 
    MetaCompositor *compositor = meta_display_get_compositor(display);
985
 
    if (compositor != NULL) {
986
 
      Pixmap pixmap = meta_compositor_get_window_pixmap(compositor, window);
987
 
      if (pixmap == None)
988
 
        return;
989
 
 
990
 
      Window xwindow = meta_window_get_xwindow(window);
991
 
      meta_error_trap_push (display);
992
 
      int success = XChangeProperty (meta_display_get_xdisplay(display),
993
 
                                     xwindow,
994
 
                                     display->atom__METACITY_WINDOW_CAPTURE,
995
 
                                     XA_PIXMAP,
996
 
                                     32, PropModeReplace, (guchar*) &pixmap, 1);
997
 
      meta_error_trap_pop (display, FALSE);
998
 
      if (!success)
999
 
        meta_warning("Failed to save capture property on window %lu\n", xwindow);
1000
 
    }
1001
 
}
1002
 
 
1003
 
static void
1004
 
remove_pixmap_for_window(MetaWindow *window)
1005
 
{
1006
 
    MetaDisplay *display = meta_window_get_display(window);
1007
 
    if (display == NULL)
1008
 
      return;
1009
 
 
1010
 
    Window xwindow = meta_window_get_xwindow(window);
1011
 
    meta_error_trap_push (display);
1012
 
    XDeleteProperty(meta_display_get_xdisplay(display),
1013
 
                    xwindow,
1014
 
                    display->atom__METACITY_WINDOW_CAPTURE);
1015
 
    meta_error_trap_pop (display, FALSE);
1016
 
}
1017
 
 
1018
976
void
1019
977
meta_window_free (MetaWindow  *window,
1020
978
                  guint32      timestamp)
1023
981
  
1024
982
  meta_verbose ("Unmanaging 0x%lx\n", window->xwindow);
1025
983
 
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);
1029
 
 
1030
984
  if (window->display->compositor)
1031
985
    meta_compositor_free_window (window->display->compositor, window);
1032
986
  
1526
1480
    {
1527
1481
      gboolean on_workspace;
1528
1482
 
1529
 
      if (!showing && meta_prefs_get_capture_before_unmap())
1530
 
        save_pixmap_for_window(window);
1531
 
      
1532
1483
      on_workspace = meta_window_located_on_workspace (window, 
1533
1484
                                                       window->screen->active_workspace);
1534
1485
      
1573
1524
    }
1574
1525
  else
1575
1526
    {
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);
1584
 
 
1585
1527
      meta_window_show (window);
1586
1528
    }
1587
1529
}
1725
1667
      tmp = tmp->next;
1726
1668
    }
1727
1669
 
1728
 
  if (meta_prefs_get_focus_mode () != META_FOCUS_MODE_CLICK)
 
1670
  if (meta_prefs_get_focus_mode () != G_DESKTOP_FOCUS_MODE_CLICK)
1729
1671
    {
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.
2063
2005
   */
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)
2104
2046
{
2105
2047
  MetaRectangle w1rect, w2rect;
 
2048
 
 
2049
  if (w1->minimized || w2->minimized)
 
2050
    return FALSE;
 
2051
 
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;
2162
2109
 
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);
2177
2125
 
2178
2126
  meta_topic (META_DEBUG_WINDOW_STATE,
2179
2127
              "Window %s %s focus on map, and %s place on top on map.\n",
2194
2142
 
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) )
 
2145
      will_be_covered )
2198
2146
    ) {
2199
2147
      if (meta_window_is_ancestor_of_transient (focus_window, window))
2200
2148
        {
2278
2226
       * in the stack when it doesn't overlap it confusingly places
2279
2227
       * that new window below a lot of other windows.
2280
2228
       */
2281
 
      if (overlap || 
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);
2285
2233
 
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.
2289
2237
       *
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.
2294
2242
       */
2295
 
      if (overlap)
 
2243
      if (overlap || will_be_covered)
2296
2244
        window->wm_state_demands_attention = TRUE;
2297
2245
    } 
2298
2246
 
2374
2322
  if (window->showing_for_first_time)
2375
2323
    {
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)
2378
2326
        {                
2379
2327
          meta_window_focus (window, timestamp);
2380
2328
        }
2699
2647
    }
2700
2648
}
2701
2649
 
2702
 
void
2703
 
meta_window_auto_maximize (MetaWindow *window)
2704
 
{
2705
 
  const MetaXineramaScreenInfo* info;
2706
 
  int screen_surface, window_surface;
2707
 
  double coverage;
2708
 
 
2709
 
  if (window->type != META_WINDOW_NORMAL || !window->has_maximize_func)
2710
 
    return;
2711
 
 
2712
 
  if (window->maximized_horizontally || window->maximized_vertically)
2713
 
    return;
2714
 
 
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;
2721
 
 
2722
 
  if (coverage > AUTO_MAXIMIZE_MINIMUM_COVERAGE && coverage <= 1.0)
2723
 
    meta_window_maximize (window, META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
2724
 
}
2725
 
 
2726
2650
static void
2727
2651
unmaximize_window_before_freeing (MetaWindow        *window)
2728
2652
{
5529
5453
           *
5530
5454
           * There is dicussion in bugs 102209, 115072, and 461577
5531
5455
           */
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);
5535
5459
        }
5573
5497
          meta_window_update_layer (window);
5574
5498
 
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);
5579
5503
       }
8220
8144
       * doesn't want to have focus transferred for now due to new windows.
8221
8145
       */
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;
8226
8150
    }