2006-10-01 18:30:10 -04:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
Comprehensively rename to Mutter
Code:
All references in the code not related to themes, keybindings, or
GConf were changed from 'metacity' to 'mutter'. This includes, among other
things, strings, comments, the atoms used in the message protocol, and
the envvars used for debugging. The GConf schema file was reduced to
the 3 settings new to mutter.
The overall version was brought up to 2.27 to match current gnome.
Structure:
All files named '*metacity*' were renamed '*mutter*' with appropriate
changes in the automake system. Files removed are
doc/creating_themes, src/themes, doc/metacity-theme.dtd,
metacity.doap. These files will eventually end up in an external
gnome-wm-data module.
Installation location:
On the filesystem the mutter-plugindir was change from
$(libdir)/metacity/plugins/clutter to just $(libdir)/mutter/plugins.
The mutter-plugins.pc.in reflects these changes.
Note:
mutter.desktop.in and mutter-wm.desktop both continue to have
X-GNOME-WMSettingsModule=metacity set. This allows
gnome-control-center to continue using libmetacity.so for
configuration. This is fine since most the general keybindings and wm
settings are being read from /apps/metacity/* in gconf.
2009-06-10 06:29:20 -04:00
|
|
|
/* Mutter window placement */
|
2001-06-24 02:47:54 -04:00
|
|
|
|
2014-05-02 09:34:02 -04:00
|
|
|
/*
|
2001-06-24 02:47:54 -04:00
|
|
|
* Copyright (C) 2001 Havoc Pennington
|
2003-02-23 12:09:46 -05:00
|
|
|
* Copyright (C) 2002, 2003 Red Hat, Inc.
|
|
|
|
* Copyright (C) 2003 Rob Adams
|
2005-10-08 15:38:54 -04:00
|
|
|
* Copyright (C) 2005 Elijah Newren
|
2014-05-02 09:34:02 -04:00
|
|
|
*
|
2001-06-24 02:47:54 -04:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
2014-05-02 09:34:02 -04:00
|
|
|
*
|
2001-06-24 02:47:54 -04:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-11 20:42:06 -05:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2001-06-24 02:47:54 -04:00
|
|
|
*/
|
|
|
|
|
2002-05-12 20:03:17 -04:00
|
|
|
#include <config.h>
|
|
|
|
|
2010-10-18 14:34:14 -04:00
|
|
|
#include "boxes-private.h"
|
2001-06-24 02:47:54 -04:00
|
|
|
#include "place.h"
|
2011-03-05 19:29:12 -05:00
|
|
|
#include <meta/workspace.h>
|
|
|
|
#include <meta/prefs.h>
|
2008-11-11 22:43:51 -05:00
|
|
|
#include <gdk/gdk.h>
|
2001-06-24 04:09:10 -04:00
|
|
|
#include <math.h>
|
2001-07-12 01:53:56 -04:00
|
|
|
#include <stdlib.h>
|
2001-06-24 04:09:10 -04:00
|
|
|
|
2005-02-11 14:20:44 -05:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
META_LEFT,
|
|
|
|
META_RIGHT,
|
|
|
|
META_TOP,
|
|
|
|
META_BOTTOM
|
|
|
|
} MetaWindowDirection;
|
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
static gint
|
|
|
|
northwestcmp (gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
MetaWindow *aw = (gpointer) a;
|
|
|
|
MetaWindow *bw = (gpointer) b;
|
2013-11-15 16:11:20 -05:00
|
|
|
MetaRectangle a_frame;
|
|
|
|
MetaRectangle b_frame;
|
2001-06-24 04:09:10 -04:00
|
|
|
int from_origin_a;
|
|
|
|
int from_origin_b;
|
|
|
|
int ax, ay, bx, by;
|
|
|
|
|
2013-11-19 12:24:45 -05:00
|
|
|
meta_window_get_frame_rect (aw, &a_frame);
|
|
|
|
meta_window_get_frame_rect (bw, &b_frame);
|
2013-11-15 16:11:20 -05:00
|
|
|
ax = a_frame.x;
|
|
|
|
ay = a_frame.y;
|
|
|
|
bx = b_frame.x;
|
|
|
|
by = b_frame.y;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
/* probably there's a fast good-enough-guess we could use here. */
|
|
|
|
from_origin_a = sqrt (ax * ax + ay * ay);
|
|
|
|
from_origin_b = sqrt (bx * bx + by * by);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
if (from_origin_a < from_origin_b)
|
|
|
|
return -1;
|
|
|
|
else if (from_origin_a > from_origin_b)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
2008-02-26 23:39:10 -05:00
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
static void
|
|
|
|
find_next_cascade (MetaWindow *window,
|
|
|
|
/* visible windows on relevant workspaces */
|
|
|
|
GList *windows,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int *new_x,
|
|
|
|
int *new_y)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
GList *sorted;
|
|
|
|
int cascade_x, cascade_y;
|
2014-05-22 16:48:58 -04:00
|
|
|
MetaRectangle titlebar_rect;
|
2001-06-24 04:09:10 -04:00
|
|
|
int x_threshold, y_threshold;
|
2013-11-15 16:11:20 -05:00
|
|
|
MetaRectangle frame_rect;
|
2002-10-01 22:42:24 -04:00
|
|
|
int window_width, window_height;
|
|
|
|
int cascade_stage;
|
2003-04-06 23:33:45 -04:00
|
|
|
MetaRectangle work_area;
|
2012-06-11 10:12:39 -04:00
|
|
|
int current;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
sorted = g_list_copy (windows);
|
|
|
|
sorted = g_list_sort (sorted, northwestcmp);
|
|
|
|
|
2014-05-02 09:34:02 -04:00
|
|
|
/* This is a "fuzzy" cascade algorithm.
|
2001-06-24 04:09:10 -04:00
|
|
|
* For each window in the list, we find where we'd cascade a
|
|
|
|
* new window after it. If a window is already nearly at that
|
|
|
|
* position, we move on.
|
|
|
|
*/
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-01 22:42:24 -04:00
|
|
|
/* arbitrary-ish threshold, honors user attempts to
|
|
|
|
* manually cascade.
|
|
|
|
*/
|
|
|
|
#define CASCADE_FUZZ 15
|
2014-05-22 16:48:58 -04:00
|
|
|
meta_window_get_titlebar_rect (window, &titlebar_rect);
|
|
|
|
x_threshold = MAX (titlebar_rect.x, CASCADE_FUZZ);
|
|
|
|
y_threshold = MAX (titlebar_rect.y, CASCADE_FUZZ);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
/* Find furthest-SE origin of all workspaces.
|
|
|
|
* cascade_x, cascade_y are the target position
|
|
|
|
* of NW corner of window frame.
|
|
|
|
*/
|
2003-02-23 12:09:46 -05:00
|
|
|
|
2009-08-31 09:52:16 -04:00
|
|
|
current = meta_screen_get_current_monitor (window->screen);
|
2012-06-08 04:21:10 -04:00
|
|
|
meta_window_get_work_area_for_monitor (window, current, &work_area);
|
2003-02-23 12:09:46 -05:00
|
|
|
|
2002-01-10 01:31:31 -05:00
|
|
|
cascade_x = MAX (0, work_area.x);
|
|
|
|
cascade_y = MAX (0, work_area.y);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
/* Find first cascade position that's not used. */
|
2013-11-15 16:11:20 -05:00
|
|
|
|
2013-11-19 12:24:45 -05:00
|
|
|
meta_window_get_frame_rect (window, &frame_rect);
|
2013-11-15 16:11:20 -05:00
|
|
|
window_width = frame_rect.width;
|
|
|
|
window_height = frame_rect.height;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-01 22:42:24 -04:00
|
|
|
cascade_stage = 0;
|
2001-06-24 04:09:10 -04:00
|
|
|
tmp = sorted;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
MetaWindow *w;
|
2013-11-15 16:11:20 -05:00
|
|
|
MetaRectangle w_frame_rect;
|
2001-06-24 04:09:10 -04:00
|
|
|
int wx, wy;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
w = tmp->data;
|
|
|
|
|
|
|
|
/* we want frame position, not window position */
|
2013-11-19 12:24:45 -05:00
|
|
|
meta_window_get_frame_rect (w, &w_frame_rect);
|
2013-11-15 16:11:20 -05:00
|
|
|
wx = w_frame_rect.x;
|
|
|
|
wy = w_frame_rect.y;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
if (ABS (wx - cascade_x) < x_threshold &&
|
|
|
|
ABS (wy - cascade_y) < y_threshold)
|
|
|
|
{
|
2014-05-22 16:48:58 -04:00
|
|
|
meta_window_get_titlebar_rect (w, &titlebar_rect);
|
|
|
|
|
|
|
|
/* Cascade the window evenly by the titlebar height; this isn't a typo. */
|
|
|
|
cascade_x = wx + titlebar_rect.height;
|
|
|
|
cascade_y = wy + titlebar_rect.height;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-01 22:42:24 -04:00
|
|
|
/* If we go off the screen, start over with a new cascade */
|
|
|
|
if (((cascade_x + window_width) >
|
|
|
|
(work_area.x + work_area.width)) ||
|
|
|
|
((cascade_y + window_height) >
|
|
|
|
(work_area.y + work_area.height)))
|
|
|
|
{
|
|
|
|
cascade_x = MAX (0, work_area.x);
|
|
|
|
cascade_y = MAX (0, work_area.y);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-01 22:42:24 -04:00
|
|
|
#define CASCADE_INTERVAL 50 /* space between top-left corners of cascades */
|
|
|
|
cascade_stage += 1;
|
|
|
|
cascade_x += CASCADE_INTERVAL * cascade_stage;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-01 22:42:24 -04:00
|
|
|
/* start over with a new cascade translated to the right, unless
|
|
|
|
* we are out of space
|
|
|
|
*/
|
|
|
|
if ((cascade_x + window_width) <
|
|
|
|
(work_area.x + work_area.width))
|
|
|
|
{
|
|
|
|
tmp = sorted;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* All out of space, this cascade_x won't work */
|
|
|
|
cascade_x = MAX (0, work_area.x);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-06-24 04:09:10 -04:00
|
|
|
}
|
|
|
|
else
|
2002-07-12 19:03:40 -04:00
|
|
|
{
|
|
|
|
/* Keep searching for a further-down-the-diagonal window. */
|
|
|
|
}
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
|
2002-07-12 19:03:40 -04:00
|
|
|
/* cascade_x and cascade_y will match the last window in the list
|
|
|
|
* that was "in the way" (in the approximate cascade diagonal)
|
|
|
|
*/
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
g_list_free (sorted);
|
|
|
|
|
2013-11-15 16:11:20 -05:00
|
|
|
*new_x = cascade_x;
|
|
|
|
*new_y = cascade_y;
|
2001-06-24 04:09:10 -04:00
|
|
|
}
|
|
|
|
|
2005-02-11 14:20:44 -05:00
|
|
|
static void
|
|
|
|
find_most_freespace (MetaWindow *window,
|
|
|
|
/* visible windows on relevant workspaces */
|
|
|
|
MetaWindow *focus_window,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int *new_x,
|
|
|
|
int *new_y)
|
|
|
|
{
|
|
|
|
MetaWindowDirection side;
|
|
|
|
int max_area;
|
|
|
|
int max_width, max_height, left, right, top, bottom;
|
2005-07-24 22:12:58 -04:00
|
|
|
int left_space, right_space, top_space, bottom_space;
|
2005-02-11 14:20:44 -05:00
|
|
|
MetaRectangle work_area;
|
|
|
|
MetaRectangle avoid;
|
2013-11-19 12:24:45 -05:00
|
|
|
MetaRectangle frame_rect;
|
2005-02-11 14:20:44 -05:00
|
|
|
|
2009-08-31 09:52:16 -04:00
|
|
|
meta_window_get_work_area_current_monitor (focus_window, &work_area);
|
2013-11-19 12:24:45 -05:00
|
|
|
meta_window_get_frame_rect (focus_window, &avoid);
|
|
|
|
meta_window_get_frame_rect (window, &frame_rect);
|
2005-02-11 14:20:44 -05:00
|
|
|
|
|
|
|
/* Find the areas of choosing the various sides of the focus window */
|
2013-11-19 12:24:45 -05:00
|
|
|
max_width = MIN (avoid.width, frame_rect.width);
|
|
|
|
max_height = MIN (avoid.height, frame_rect.height);
|
2005-07-24 22:12:58 -04:00
|
|
|
left_space = avoid.x - work_area.x;
|
|
|
|
right_space = work_area.width - (avoid.x + avoid.width - work_area.x);
|
|
|
|
top_space = avoid.y - work_area.y;
|
|
|
|
bottom_space = work_area.height - (avoid.y + avoid.height - work_area.y);
|
2013-11-19 12:24:45 -05:00
|
|
|
left = MIN (left_space, frame_rect.width);
|
|
|
|
right = MIN (right_space, frame_rect.width);
|
|
|
|
top = MIN (top_space, frame_rect.height);
|
|
|
|
bottom = MIN (bottom_space, frame_rect.height);
|
2005-02-11 14:20:44 -05:00
|
|
|
|
|
|
|
/* Find out which side of the focus_window can show the most of the window */
|
|
|
|
side = META_LEFT;
|
|
|
|
max_area = left*max_height;
|
|
|
|
if (right*max_height > max_area)
|
|
|
|
{
|
|
|
|
side = META_RIGHT;
|
|
|
|
max_area = right*max_height;
|
|
|
|
}
|
|
|
|
if (top*max_width > max_area)
|
|
|
|
{
|
|
|
|
side = META_TOP;
|
|
|
|
max_area = top*max_width;
|
|
|
|
}
|
|
|
|
if (bottom*max_width > max_area)
|
2005-07-24 22:12:58 -04:00
|
|
|
{
|
|
|
|
side = META_BOTTOM;
|
|
|
|
max_area = bottom*max_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Give up if there's no where to put it (i.e. focus window is maximized) */
|
|
|
|
if (max_area == 0)
|
|
|
|
return;
|
2005-02-11 14:20:44 -05:00
|
|
|
|
2005-07-24 22:12:58 -04:00
|
|
|
/* Place the window on the relevant side; if the whole window fits,
|
|
|
|
* make it adjacent to the focus window; if not, make sure the
|
|
|
|
* window doesn't go off the edge of the screen.
|
2005-02-11 14:20:44 -05:00
|
|
|
*/
|
|
|
|
switch (side)
|
|
|
|
{
|
|
|
|
case META_LEFT:
|
2013-11-15 16:11:20 -05:00
|
|
|
*new_y = avoid.y;
|
2013-11-19 12:24:45 -05:00
|
|
|
if (left_space > frame_rect.width)
|
|
|
|
*new_x = avoid.x - frame_rect.width;
|
2005-07-24 22:12:58 -04:00
|
|
|
else
|
2013-11-15 16:11:20 -05:00
|
|
|
*new_x = work_area.x;
|
2005-02-11 14:20:44 -05:00
|
|
|
break;
|
|
|
|
case META_RIGHT:
|
2013-11-15 16:11:20 -05:00
|
|
|
*new_y = avoid.y;
|
2013-11-19 12:24:45 -05:00
|
|
|
if (right_space > frame_rect.width)
|
2013-11-15 16:11:20 -05:00
|
|
|
*new_x = avoid.x + avoid.width;
|
2005-07-24 22:12:58 -04:00
|
|
|
else
|
2013-11-19 12:24:45 -05:00
|
|
|
*new_x = work_area.x + work_area.width - frame_rect.width;
|
2005-02-11 14:20:44 -05:00
|
|
|
break;
|
|
|
|
case META_TOP:
|
2013-11-15 16:11:20 -05:00
|
|
|
*new_x = avoid.x;
|
2013-11-19 12:24:45 -05:00
|
|
|
if (top_space > frame_rect.height)
|
|
|
|
*new_y = avoid.y - frame_rect.height;
|
2005-07-24 22:12:58 -04:00
|
|
|
else
|
2013-11-15 16:11:20 -05:00
|
|
|
*new_y = work_area.y;
|
2005-02-11 14:20:44 -05:00
|
|
|
break;
|
|
|
|
case META_BOTTOM:
|
2013-11-15 16:11:20 -05:00
|
|
|
*new_x = avoid.x;
|
2013-11-19 12:24:45 -05:00
|
|
|
if (bottom_space > frame_rect.height)
|
2013-11-15 16:11:20 -05:00
|
|
|
*new_y = avoid.y + avoid.height;
|
2005-07-24 22:12:58 -04:00
|
|
|
else
|
2013-11-19 12:24:45 -05:00
|
|
|
*new_y = work_area.y + work_area.height - frame_rect.height;
|
2005-02-11 14:20:44 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-15 16:11:20 -05:00
|
|
|
static gboolean
|
|
|
|
window_overlaps_focus_window (MetaWindow *window)
|
|
|
|
{
|
|
|
|
MetaWindow *focus_window;
|
|
|
|
MetaRectangle window_frame, focus_frame, overlap;
|
|
|
|
|
|
|
|
focus_window = window->display->focus_window;
|
|
|
|
if (focus_window == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2013-11-19 12:24:45 -05:00
|
|
|
meta_window_get_frame_rect (window, &window_frame);
|
|
|
|
meta_window_get_frame_rect (focus_window, &focus_frame);
|
2013-11-15 16:11:20 -05:00
|
|
|
|
|
|
|
return meta_rectangle_intersect (&window_frame,
|
|
|
|
&focus_frame,
|
|
|
|
&overlap);
|
|
|
|
}
|
|
|
|
|
2014-04-25 09:26:24 -04:00
|
|
|
static gboolean
|
|
|
|
window_place_centered (MetaWindow *window)
|
|
|
|
{
|
|
|
|
MetaWindowType type;
|
|
|
|
|
|
|
|
type = window->type;
|
|
|
|
|
|
|
|
return (type == META_WINDOW_DIALOG ||
|
|
|
|
type == META_WINDOW_MODAL_DIALOG ||
|
|
|
|
type == META_WINDOW_SPLASHSCREEN ||
|
|
|
|
(type == META_WINDOW_NORMAL && meta_prefs_get_center_new_windows ()));
|
|
|
|
}
|
|
|
|
|
2005-07-24 22:12:58 -04:00
|
|
|
static void
|
|
|
|
avoid_being_obscured_as_second_modal_dialog (MetaWindow *window,
|
|
|
|
int *x,
|
|
|
|
int *y)
|
|
|
|
{
|
|
|
|
/* We can't center this dialog if it was denied focus and it
|
|
|
|
* overlaps with the focus window and this dialog is modal and this
|
|
|
|
* dialog is in the same app as the focus window (*phew*...please
|
|
|
|
* don't make me say that ten times fast). See bug 307875 comment 11
|
|
|
|
* and 12 for details, but basically it means this is probably a
|
|
|
|
* second modal dialog for some app while the focus window is the
|
|
|
|
* first modal dialog. We should probably make them simultaneously
|
|
|
|
* visible in general, but it becomes mandatory to do so due to
|
|
|
|
* buggy apps (e.g. those using gtk+ *sigh*) because in those cases
|
|
|
|
* this second modal dialog also happens to be modal to the first
|
|
|
|
* dialog in addition to the main window, while it has only let us
|
|
|
|
* know about the modal-to-the-main-window part.
|
|
|
|
*/
|
|
|
|
|
|
|
|
MetaWindow *focus_window;
|
|
|
|
|
|
|
|
focus_window = window->display->focus_window;
|
|
|
|
|
2013-11-15 16:11:20 -05:00
|
|
|
/* denied_focus_and_not_transient is only set when focus_window != NULL */
|
|
|
|
|
2005-07-24 22:12:58 -04:00
|
|
|
if (window->denied_focus_and_not_transient &&
|
2014-03-18 10:58:26 -04:00
|
|
|
window->type == META_WINDOW_MODAL_DIALOG &&
|
2005-07-24 22:12:58 -04:00
|
|
|
meta_window_same_application (window, focus_window) &&
|
2013-11-15 16:11:20 -05:00
|
|
|
window_overlaps_focus_window (window))
|
2005-07-24 22:12:58 -04:00
|
|
|
{
|
2013-11-15 18:03:50 -05:00
|
|
|
find_most_freespace (window, focus_window, *x, *y, x, y);
|
2005-07-24 22:12:58 -04:00
|
|
|
meta_topic (META_DEBUG_PLACEMENT,
|
|
|
|
"Dialog window %s was denied focus but may be modal "
|
|
|
|
"to the focus window; had to move it to avoid the "
|
|
|
|
"focus window\n",
|
|
|
|
window->desc);
|
|
|
|
}
|
|
|
|
}
|
2005-02-11 14:20:44 -05:00
|
|
|
|
2002-06-17 23:06:07 -04:00
|
|
|
static gboolean
|
|
|
|
rectangle_overlaps_some_window (MetaRectangle *rect,
|
|
|
|
GList *windows)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
MetaRectangle dest;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-06-17 23:06:07 -04:00
|
|
|
tmp = windows;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
MetaWindow *other = tmp->data;
|
2014-05-02 09:34:02 -04:00
|
|
|
MetaRectangle other_rect;
|
2002-06-17 23:06:07 -04:00
|
|
|
|
|
|
|
switch (other->type)
|
|
|
|
{
|
|
|
|
case META_WINDOW_DOCK:
|
|
|
|
case META_WINDOW_SPLASHSCREEN:
|
|
|
|
case META_WINDOW_DESKTOP:
|
|
|
|
case META_WINDOW_DIALOG:
|
|
|
|
case META_WINDOW_MODAL_DIALOG:
|
2008-11-23 14:28:40 -05:00
|
|
|
/* override redirect window types: */
|
|
|
|
case META_WINDOW_DROPDOWN_MENU:
|
|
|
|
case META_WINDOW_POPUP_MENU:
|
|
|
|
case META_WINDOW_TOOLTIP:
|
|
|
|
case META_WINDOW_NOTIFICATION:
|
|
|
|
case META_WINDOW_COMBO:
|
|
|
|
case META_WINDOW_DND:
|
|
|
|
case META_WINDOW_OVERRIDE_OTHER:
|
2002-06-17 23:06:07 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case META_WINDOW_NORMAL:
|
|
|
|
case META_WINDOW_UTILITY:
|
|
|
|
case META_WINDOW_TOOLBAR:
|
|
|
|
case META_WINDOW_MENU:
|
2013-11-19 12:24:45 -05:00
|
|
|
meta_window_get_frame_rect (other, &other_rect);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-06-17 23:06:07 -04:00
|
|
|
if (meta_rectangle_intersect (rect, &other_rect, &dest))
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-06-17 23:06:07 -04:00
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
leftmost_cmp (gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
MetaWindow *aw = (gpointer) a;
|
|
|
|
MetaWindow *bw = (gpointer) b;
|
2013-11-15 16:11:20 -05:00
|
|
|
MetaRectangle a_frame;
|
|
|
|
MetaRectangle b_frame;
|
2002-06-17 23:06:07 -04:00
|
|
|
int ax, bx;
|
|
|
|
|
2013-11-19 12:24:45 -05:00
|
|
|
meta_window_get_frame_rect (aw, &a_frame);
|
|
|
|
meta_window_get_frame_rect (bw, &b_frame);
|
2013-11-15 16:11:20 -05:00
|
|
|
ax = a_frame.x;
|
|
|
|
bx = b_frame.x;
|
2002-06-17 23:06:07 -04:00
|
|
|
|
|
|
|
if (ax < bx)
|
|
|
|
return -1;
|
|
|
|
else if (ax > bx)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
topmost_cmp (gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
MetaWindow *aw = (gpointer) a;
|
|
|
|
MetaWindow *bw = (gpointer) b;
|
2013-11-15 16:11:20 -05:00
|
|
|
MetaRectangle a_frame;
|
|
|
|
MetaRectangle b_frame;
|
2002-06-17 23:06:07 -04:00
|
|
|
int ay, by;
|
|
|
|
|
2013-11-19 12:24:45 -05:00
|
|
|
meta_window_get_frame_rect (aw, &a_frame);
|
|
|
|
meta_window_get_frame_rect (bw, &b_frame);
|
2013-11-15 16:11:20 -05:00
|
|
|
ay = a_frame.y;
|
|
|
|
by = b_frame.y;
|
2002-06-17 23:06:07 -04:00
|
|
|
|
|
|
|
if (ay < by)
|
|
|
|
return -1;
|
|
|
|
else if (ay > by)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-02-23 12:09:46 -05:00
|
|
|
static void
|
|
|
|
center_tile_rect_in_area (MetaRectangle *rect,
|
|
|
|
MetaRectangle *work_area)
|
|
|
|
{
|
|
|
|
int fluff;
|
|
|
|
|
|
|
|
/* The point here is to tile a window such that "extra"
|
|
|
|
* space is equal on either side (i.e. so a full screen
|
|
|
|
* of windows tiled this way would center the windows
|
|
|
|
* as a group)
|
|
|
|
*/
|
2003-04-05 20:22:56 -05:00
|
|
|
|
|
|
|
fluff = (work_area->width % (rect->width+1)) / 2;
|
2003-02-23 12:09:46 -05:00
|
|
|
rect->x = work_area->x + fluff;
|
2003-04-05 20:22:56 -05:00
|
|
|
fluff = (work_area->height % (rect->height+1)) / 3;
|
2003-02-23 12:09:46 -05:00
|
|
|
rect->y = work_area->y + fluff;
|
|
|
|
}
|
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
/* Find the leftmost, then topmost, empty area on the workspace
|
|
|
|
* that can contain the new window.
|
2001-07-28 02:35:19 -04:00
|
|
|
*
|
|
|
|
* Cool feature to have: if we can't fit the current window size,
|
|
|
|
* try shrinking the window (within geometry constraints). But
|
|
|
|
* beware windows such as Emacs with no sane minimum size, we
|
|
|
|
* don't want to create a 1x1 Emacs.
|
2001-06-24 04:09:10 -04:00
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
find_first_fit (MetaWindow *window,
|
|
|
|
/* visible windows on relevant workspaces */
|
|
|
|
GList *windows,
|
2009-08-31 09:52:16 -04:00
|
|
|
int monitor,
|
2001-06-24 04:09:10 -04:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int *new_x,
|
|
|
|
int *new_y)
|
|
|
|
{
|
2002-06-17 23:06:07 -04:00
|
|
|
/* This algorithm is limited - it just brute-force tries
|
|
|
|
* to fit the window in a small number of locations that are aligned
|
|
|
|
* with existing windows. It tries to place the window on
|
|
|
|
* the bottom of each existing window, and then to the right
|
|
|
|
* of each existing window, aligned with the left/top of the
|
|
|
|
* existing window in each of those cases.
|
2014-05-02 09:34:02 -04:00
|
|
|
*/
|
2002-06-17 23:06:07 -04:00
|
|
|
int retval;
|
2003-04-06 00:57:36 -05:00
|
|
|
GList *below_sorted;
|
|
|
|
GList *right_sorted;
|
2002-06-17 23:06:07 -04:00
|
|
|
GList *tmp;
|
|
|
|
MetaRectangle rect;
|
2003-02-23 12:09:46 -05:00
|
|
|
MetaRectangle work_area;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-06-17 23:06:07 -04:00
|
|
|
retval = FALSE;
|
2003-04-06 00:57:36 -05:00
|
|
|
|
|
|
|
/* Below each window */
|
|
|
|
below_sorted = g_list_copy (windows);
|
|
|
|
below_sorted = g_list_sort (below_sorted, leftmost_cmp);
|
2014-05-02 09:34:02 -04:00
|
|
|
below_sorted = g_list_sort (below_sorted, topmost_cmp);
|
2003-04-06 00:57:36 -05:00
|
|
|
|
|
|
|
/* To the right of each window */
|
|
|
|
right_sorted = g_list_copy (windows);
|
|
|
|
right_sorted = g_list_sort (right_sorted, topmost_cmp);
|
|
|
|
right_sorted = g_list_sort (right_sorted, leftmost_cmp);
|
2013-11-15 16:11:20 -05:00
|
|
|
|
2013-11-19 12:24:45 -05:00
|
|
|
meta_window_get_frame_rect (window, &rect);
|
2002-09-12 16:46:03 -04:00
|
|
|
|
Merge of all the changes on the constraints_experiments branch. This is
2005-11-18 Elijah Newren <newren@gmail.com>
Merge of all the changes on the constraints_experiments branch.
This is just a summary, to get the full ChangeLog of those
changes (approx. 2000 lines):
cvs -q -z3 update -Pd -r constraints_experiments
cvs -q -z3 diff -pu -r CONSTRAINTS_EXPERIMENTS_BRANCHPOINT ChangeLog
Bugs fixed:
unfiled - constraints.c is overly complicated[1]
unfiled - constraints.c is not robust when all constraints
cannot simultaneously be met (constraints need to be
prioritized)
unfiled - keep-titlebar-onscreen constraint is decoration
unaware (since get_outermost_onscreen_positions()
forgets to include decorations)
unfiled - keyboard snap-moving and snap-resizing snap to hidden
edges
109553 - gravity w/ simultaneous move & resize doesn't work
113601 - maximize vertical and horizontal should toggle and be
constrained
122196 - windows show up under vertical panels
122670 - jerky/random resizing of window via keyboard[2]
124582 - keyboard and mouse snap-resizing and snap-moving
erroneously moves the window multidimensionally
136307 - don't allow apps to resize themselves off the screen
(*cough* filechooser *cough*)
142016, 143784 - windows should not span multiple xineramas
unless placed there by the user
143145 - clamp new windows to screensize and force them
onscreen, if they'll fit
144126 - Handle pathological strut lists sanely[3]
149867 - fixed aspect ratio windows are difficult to resize[4]
152898 - make screen edges consistent; allow easy slamming of
windows into the left, right, and bottom edges of the
screen too.
154706 - bouncing weirdness at screen edge with keyboard moving
or resizing
156699 - avoid struts when placing windows, if possible (nasty
a11y blocker)
302456 - dragging offscreen too restrictive
304857 - wireframe moving off the top of the screen is misleading
308521 - make uni-directional resizing easier with
alt-middle-drag and prevent the occasional super
annoying resize-the-wrong-side(s) behavior
312007 - snap-resize moves windows with a minimum size
constraint
312104 - resizing the top of a window can cause the bottom to
grow
319351 - don't instantly snap on mouse-move-snapping, remove
braindeadedness of having order of releasing shift and
releasing button press matter so much
[1] fixed in my opinion, anyway.
[2] Actually, it's not totally fixed--it's just annoying
instead of almost completely unusable. Matthias had a
suggestion that may fix the remainder of the problems (see
http://tinyurl.com/bwzuu).
[3] This bug was originally about not-quite-so-pathological
cases but was left open for the worse cases. The code from
the branch handles the remainder of the cases mentioned in
this bug.
[4] Actually, although it's far better there's still some minor
issues left: a slight drift that's only noticeable after
lots of resizing, and potential problems with partially
onscreen constraints due to not clearing any
fixed_directions flags (aspect ratio windows get resized in
both directions and thus aren't fixed in one of them)
New feature:
81704 - edge resistance for user move and resize operations;
in particular 3 different kinds of resistance are
implemented:
Pixel-Distance: window movement is resisted when it
aligns with an edge unless the movement is greater than
a threshold number of pixels
Timeout: window movement past an edge is prevented until
a certain amount of time has elapsed during the
operation since the first request to move it past that
edge
Keyboard-Buildup: when moving or resizing with the
keyboard, once a window is aligned with a certain edge
it cannot move past until the correct direction has
been pressed enough times (e.g. 2 or 3 times)
Major changes:
- constraints.c has been rewritten; very few lines of code from
the old version remain. There is a comment near the top of
the function explaining the basics of how the new framework
works. A more detailed explanation can be found in
doc/how-constraints-works.txt
- edge-resistance.[ch] are new files implementing edge-resistance.
- boxes.[ch] are new files containing low-level error-prone
functions used heavily in constraints.c and edge-resistance.c,
among various places throughout the code. testboxes.c
contains a thorough testsuite for the boxes.[ch] functions
compiled into a program, testboxes.
- meta_window_move_resize_internal() *must* be told the gravity
of the associated operation (if it's just a move operation,
the gravity will be ignored, but for resize and move+resize
the correct value is needed)
- the craziness of different values that
meta_window_move_resize_internal() accepts has been documented
in a large comment at the beginning of the function. It may
be possible to clean this up some, but until then things will
remain as they were before--caller beware.
- screen and xinerama usable areas (i.e. places not covered by
e.g. panels) are cached in the workspace now, as are the
screen and xinerama edges. These get updated with the
workarea in src/workspace.c:ensure_work_areas_validated()
2005-11-19 09:58:50 -05:00
|
|
|
#ifdef WITH_VERBOSE_MODE
|
2014-05-29 13:57:11 -04:00
|
|
|
{
|
|
|
|
char monitor_location_string[RECT_LENGTH];
|
|
|
|
meta_rectangle_to_string (&window->screen->monitor_infos[monitor].rect,
|
|
|
|
monitor_location_string);
|
|
|
|
meta_topic (META_DEBUG_XINERAMA,
|
|
|
|
"Natural monitor is %s\n",
|
|
|
|
monitor_location_string);
|
|
|
|
}
|
2007-06-18 07:46:44 -04:00
|
|
|
#endif
|
2002-06-17 23:06:07 -04:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
meta_window_get_work_area_for_monitor (window, monitor, &work_area);
|
2002-06-17 23:06:07 -04:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
center_tile_rect_in_area (&rect, &work_area);
|
2003-04-06 00:57:36 -05:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
if (meta_rectangle_contains_rect (&work_area, &rect) &&
|
|
|
|
!rectangle_overlaps_some_window (&rect, windows))
|
|
|
|
{
|
|
|
|
*new_x = rect.x;
|
|
|
|
*new_y = rect.y;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
retval = TRUE;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
goto out;
|
|
|
|
}
|
2003-02-23 12:09:46 -05:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
/* try below each window */
|
|
|
|
tmp = below_sorted;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
MetaWindow *w = tmp->data;
|
|
|
|
MetaRectangle frame_rect;
|
2003-04-06 00:57:36 -05:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
meta_window_get_frame_rect (w, &frame_rect);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
rect.x = frame_rect.x;
|
|
|
|
rect.y = frame_rect.y + frame_rect.height;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
if (meta_rectangle_contains_rect (&work_area, &rect) &&
|
|
|
|
!rectangle_overlaps_some_window (&rect, below_sorted))
|
|
|
|
{
|
|
|
|
*new_x = rect.x;
|
|
|
|
*new_y = rect.y;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
retval = TRUE;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
goto out;
|
|
|
|
}
|
2002-09-24 21:20:44 -04:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
2003-02-23 12:09:46 -05:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
/* try to the right of each window */
|
|
|
|
tmp = right_sorted;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
MetaWindow *w = tmp->data;
|
|
|
|
MetaRectangle frame_rect;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
meta_window_get_frame_rect (w, &frame_rect);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
rect.x = frame_rect.x + frame_rect.width;
|
|
|
|
rect.y = frame_rect.y;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
if (meta_rectangle_contains_rect (&work_area, &rect) &&
|
|
|
|
!rectangle_overlaps_some_window (&rect, right_sorted))
|
|
|
|
{
|
|
|
|
*new_x = rect.x;
|
|
|
|
*new_y = rect.y;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
retval = TRUE;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
goto out;
|
|
|
|
}
|
2003-04-06 00:57:36 -05:00
|
|
|
|
2014-05-29 13:57:11 -04:00
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-06-17 23:06:07 -04:00
|
|
|
out:
|
2003-04-06 00:57:36 -05:00
|
|
|
g_list_free (below_sorted);
|
|
|
|
g_list_free (right_sorted);
|
2002-06-17 23:06:07 -04:00
|
|
|
return retval;
|
2001-06-24 04:09:10 -04:00
|
|
|
}
|
2001-06-24 02:47:54 -04:00
|
|
|
|
|
|
|
void
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
meta_window_place (MetaWindow *window,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int *new_x,
|
|
|
|
int *new_y)
|
2001-06-24 02:47:54 -04:00
|
|
|
{
|
2014-05-20 15:36:28 -04:00
|
|
|
GList *windows = NULL;
|
2009-08-31 09:52:16 -04:00
|
|
|
const MetaMonitorInfo *xi;
|
2007-06-18 07:46:44 -04:00
|
|
|
|
2002-05-12 20:03:17 -04:00
|
|
|
meta_topic (META_DEBUG_PLACEMENT, "Placing window %s\n", window->desc);
|
|
|
|
|
2002-06-09 14:17:02 -04:00
|
|
|
switch (window->type)
|
|
|
|
{
|
|
|
|
/* Run placement algorithm on these. */
|
|
|
|
case META_WINDOW_NORMAL:
|
|
|
|
case META_WINDOW_DIALOG:
|
|
|
|
case META_WINDOW_MODAL_DIALOG:
|
|
|
|
case META_WINDOW_SPLASHSCREEN:
|
|
|
|
break;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-06-09 14:17:02 -04:00
|
|
|
/* Assume the app knows best how to place these, no placement
|
|
|
|
* algorithm ever (other than "leave them as-is")
|
|
|
|
*/
|
|
|
|
case META_WINDOW_DESKTOP:
|
|
|
|
case META_WINDOW_DOCK:
|
|
|
|
case META_WINDOW_TOOLBAR:
|
|
|
|
case META_WINDOW_MENU:
|
|
|
|
case META_WINDOW_UTILITY:
|
2008-11-23 14:28:40 -05:00
|
|
|
/* override redirect window types: */
|
|
|
|
case META_WINDOW_DROPDOWN_MENU:
|
|
|
|
case META_WINDOW_POPUP_MENU:
|
|
|
|
case META_WINDOW_TOOLTIP:
|
|
|
|
case META_WINDOW_NOTIFICATION:
|
|
|
|
case META_WINDOW_COMBO:
|
|
|
|
case META_WINDOW_DND:
|
|
|
|
case META_WINDOW_OVERRIDE_OTHER:
|
2014-05-20 15:36:28 -04:00
|
|
|
goto done;
|
2002-06-09 14:17:02 -04:00
|
|
|
}
|
2014-03-18 10:12:44 -04:00
|
|
|
|
2002-05-12 20:03:17 -04:00
|
|
|
if (meta_prefs_get_disable_workarounds ())
|
|
|
|
{
|
|
|
|
switch (window->type)
|
|
|
|
{
|
|
|
|
/* Only accept USPosition on normal windows because the app is full
|
|
|
|
* of shit claiming the user set -geometry for a dialog or dock
|
|
|
|
*/
|
|
|
|
case META_WINDOW_NORMAL:
|
|
|
|
if (window->size_hints.flags & USPosition)
|
|
|
|
{
|
|
|
|
/* don't constrain with placement algorithm */
|
|
|
|
meta_topic (META_DEBUG_PLACEMENT,
|
|
|
|
"Honoring USPosition for %s instead of using placement algorithm\n", window->desc);
|
|
|
|
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Ignore even USPosition on dialogs, splashscreen */
|
|
|
|
case META_WINDOW_DIALOG:
|
|
|
|
case META_WINDOW_MODAL_DIALOG:
|
|
|
|
case META_WINDOW_SPLASHSCREEN:
|
|
|
|
break;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-05-12 20:03:17 -04:00
|
|
|
/* Assume the app knows best how to place these. */
|
|
|
|
case META_WINDOW_DESKTOP:
|
|
|
|
case META_WINDOW_DOCK:
|
|
|
|
case META_WINDOW_TOOLBAR:
|
|
|
|
case META_WINDOW_MENU:
|
|
|
|
case META_WINDOW_UTILITY:
|
2008-11-23 14:28:40 -05:00
|
|
|
/* override redirect window types: */
|
|
|
|
case META_WINDOW_DROPDOWN_MENU:
|
|
|
|
case META_WINDOW_POPUP_MENU:
|
|
|
|
case META_WINDOW_TOOLTIP:
|
|
|
|
case META_WINDOW_NOTIFICATION:
|
|
|
|
case META_WINDOW_COMBO:
|
|
|
|
case META_WINDOW_DND:
|
|
|
|
case META_WINDOW_OVERRIDE_OTHER:
|
2002-05-12 20:03:17 -04:00
|
|
|
if (window->size_hints.flags & PPosition)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_PLACEMENT,
|
|
|
|
"Not placing non-normal non-dialog window with PPosition set\n");
|
2014-05-20 15:36:28 -04:00
|
|
|
goto done;
|
2002-05-12 20:03:17 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* workarounds enabled */
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-05-12 20:03:17 -04:00
|
|
|
if ((window->size_hints.flags & PPosition) ||
|
|
|
|
(window->size_hints.flags & USPosition))
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_PLACEMENT,
|
|
|
|
"Not placing window with PPosition or USPosition set\n");
|
2013-11-15 18:03:50 -05:00
|
|
|
avoid_being_obscured_as_second_modal_dialog (window, &x, &y);
|
2014-05-20 15:36:28 -04:00
|
|
|
goto done;
|
2002-05-12 20:03:17 -04:00
|
|
|
}
|
|
|
|
}
|
2001-06-24 02:47:54 -04:00
|
|
|
|
2014-03-18 10:12:44 -04:00
|
|
|
if (window->type == META_WINDOW_DIALOG ||
|
|
|
|
window->type == META_WINDOW_MODAL_DIALOG)
|
|
|
|
{
|
|
|
|
MetaWindow *parent = meta_window_get_transient_for (window);
|
2001-06-24 02:47:54 -04:00
|
|
|
|
|
|
|
if (parent)
|
|
|
|
{
|
2013-11-15 16:11:20 -05:00
|
|
|
MetaRectangle frame_rect, parent_frame_rect;
|
2001-06-24 02:47:54 -04:00
|
|
|
|
2013-11-19 12:24:45 -05:00
|
|
|
meta_window_get_frame_rect (window, &frame_rect);
|
|
|
|
meta_window_get_frame_rect (parent, &parent_frame_rect);
|
2013-11-15 16:11:20 -05:00
|
|
|
|
|
|
|
y = parent_frame_rect.y;
|
2001-06-24 02:47:54 -04:00
|
|
|
|
|
|
|
/* center of parent */
|
2013-11-15 16:11:20 -05:00
|
|
|
x = parent_frame_rect.x + parent_frame_rect.width / 2;
|
2001-06-24 02:47:54 -04:00
|
|
|
/* center of child over center of parent */
|
2013-11-15 16:11:20 -05:00
|
|
|
x -= frame_rect.width / 2;
|
2001-06-24 02:47:54 -04:00
|
|
|
|
2003-11-07 23:43:18 -05:00
|
|
|
/* "visually" center window over parent, leaving twice as
|
|
|
|
* much space below as on top.
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
*/
|
2013-11-15 16:11:20 -05:00
|
|
|
y += (parent_frame_rect.height - frame_rect.height)/3;
|
2001-06-24 02:47:54 -04:00
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_PLACEMENT, "Centered window %s over transient parent\n",
|
|
|
|
window->desc);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2013-11-15 18:03:50 -05:00
|
|
|
avoid_being_obscured_as_second_modal_dialog (window, &x, &y);
|
2005-07-24 22:12:58 -04:00
|
|
|
|
2001-06-24 02:47:54 -04:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-04-30 23:23:46 -04:00
|
|
|
/* FIXME UTILITY with transient set should be stacked up
|
|
|
|
* on the sides of the parent window or something.
|
|
|
|
*/
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2014-04-25 09:26:24 -04:00
|
|
|
if (window_place_centered (window))
|
2001-06-24 02:47:54 -04:00
|
|
|
{
|
2009-08-31 09:52:16 -04:00
|
|
|
/* Center on current monitor */
|
2001-06-24 02:47:54 -04:00
|
|
|
int w, h;
|
2013-11-15 16:11:20 -05:00
|
|
|
MetaRectangle frame_rect;
|
|
|
|
|
2013-11-19 12:24:45 -05:00
|
|
|
meta_window_get_frame_rect (window, &frame_rect);
|
2001-06-24 02:47:54 -04:00
|
|
|
|
2002-06-06 23:18:46 -04:00
|
|
|
/* Warning, this function is a round trip! */
|
2012-06-08 04:21:10 -04:00
|
|
|
xi = meta_screen_get_current_monitor_info (window->screen);
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
|
Merge of all the changes on the constraints_experiments branch. This is
2005-11-18 Elijah Newren <newren@gmail.com>
Merge of all the changes on the constraints_experiments branch.
This is just a summary, to get the full ChangeLog of those
changes (approx. 2000 lines):
cvs -q -z3 update -Pd -r constraints_experiments
cvs -q -z3 diff -pu -r CONSTRAINTS_EXPERIMENTS_BRANCHPOINT ChangeLog
Bugs fixed:
unfiled - constraints.c is overly complicated[1]
unfiled - constraints.c is not robust when all constraints
cannot simultaneously be met (constraints need to be
prioritized)
unfiled - keep-titlebar-onscreen constraint is decoration
unaware (since get_outermost_onscreen_positions()
forgets to include decorations)
unfiled - keyboard snap-moving and snap-resizing snap to hidden
edges
109553 - gravity w/ simultaneous move & resize doesn't work
113601 - maximize vertical and horizontal should toggle and be
constrained
122196 - windows show up under vertical panels
122670 - jerky/random resizing of window via keyboard[2]
124582 - keyboard and mouse snap-resizing and snap-moving
erroneously moves the window multidimensionally
136307 - don't allow apps to resize themselves off the screen
(*cough* filechooser *cough*)
142016, 143784 - windows should not span multiple xineramas
unless placed there by the user
143145 - clamp new windows to screensize and force them
onscreen, if they'll fit
144126 - Handle pathological strut lists sanely[3]
149867 - fixed aspect ratio windows are difficult to resize[4]
152898 - make screen edges consistent; allow easy slamming of
windows into the left, right, and bottom edges of the
screen too.
154706 - bouncing weirdness at screen edge with keyboard moving
or resizing
156699 - avoid struts when placing windows, if possible (nasty
a11y blocker)
302456 - dragging offscreen too restrictive
304857 - wireframe moving off the top of the screen is misleading
308521 - make uni-directional resizing easier with
alt-middle-drag and prevent the occasional super
annoying resize-the-wrong-side(s) behavior
312007 - snap-resize moves windows with a minimum size
constraint
312104 - resizing the top of a window can cause the bottom to
grow
319351 - don't instantly snap on mouse-move-snapping, remove
braindeadedness of having order of releasing shift and
releasing button press matter so much
[1] fixed in my opinion, anyway.
[2] Actually, it's not totally fixed--it's just annoying
instead of almost completely unusable. Matthias had a
suggestion that may fix the remainder of the problems (see
http://tinyurl.com/bwzuu).
[3] This bug was originally about not-quite-so-pathological
cases but was left open for the worse cases. The code from
the branch handles the remainder of the cases mentioned in
this bug.
[4] Actually, although it's far better there's still some minor
issues left: a slight drift that's only noticeable after
lots of resizing, and potential problems with partially
onscreen constraints due to not clearing any
fixed_directions flags (aspect ratio windows get resized in
both directions and thus aren't fixed in one of them)
New feature:
81704 - edge resistance for user move and resize operations;
in particular 3 different kinds of resistance are
implemented:
Pixel-Distance: window movement is resisted when it
aligns with an edge unless the movement is greater than
a threshold number of pixels
Timeout: window movement past an edge is prevented until
a certain amount of time has elapsed during the
operation since the first request to move it past that
edge
Keyboard-Buildup: when moving or resizing with the
keyboard, once a window is aligned with a certain edge
it cannot move past until the correct direction has
been pressed enough times (e.g. 2 or 3 times)
Major changes:
- constraints.c has been rewritten; very few lines of code from
the old version remain. There is a comment near the top of
the function explaining the basics of how the new framework
works. A more detailed explanation can be found in
doc/how-constraints-works.txt
- edge-resistance.[ch] are new files implementing edge-resistance.
- boxes.[ch] are new files containing low-level error-prone
functions used heavily in constraints.c and edge-resistance.c,
among various places throughout the code. testboxes.c
contains a thorough testsuite for the boxes.[ch] functions
compiled into a program, testboxes.
- meta_window_move_resize_internal() *must* be told the gravity
of the associated operation (if it's just a move operation,
the gravity will be ignored, but for resize and move+resize
the correct value is needed)
- the craziness of different values that
meta_window_move_resize_internal() accepts has been documented
in a large comment at the beginning of the function. It may
be possible to clean this up some, but until then things will
remain as they were before--caller beware.
- screen and xinerama usable areas (i.e. places not covered by
e.g. panels) are cached in the workspace now, as are the
screen and xinerama edges. These get updated with the
workarea in src/workspace.c:ensure_work_areas_validated()
2005-11-19 09:58:50 -05:00
|
|
|
w = xi->rect.width;
|
|
|
|
h = xi->rect.height;
|
2001-06-24 02:47:54 -04:00
|
|
|
|
2013-11-15 16:11:20 -05:00
|
|
|
x = (w - frame_rect.width) / 2;
|
|
|
|
y = (h - frame_rect.height) / 2;
|
2001-06-24 02:47:54 -04:00
|
|
|
|
Merge of all the changes on the constraints_experiments branch. This is
2005-11-18 Elijah Newren <newren@gmail.com>
Merge of all the changes on the constraints_experiments branch.
This is just a summary, to get the full ChangeLog of those
changes (approx. 2000 lines):
cvs -q -z3 update -Pd -r constraints_experiments
cvs -q -z3 diff -pu -r CONSTRAINTS_EXPERIMENTS_BRANCHPOINT ChangeLog
Bugs fixed:
unfiled - constraints.c is overly complicated[1]
unfiled - constraints.c is not robust when all constraints
cannot simultaneously be met (constraints need to be
prioritized)
unfiled - keep-titlebar-onscreen constraint is decoration
unaware (since get_outermost_onscreen_positions()
forgets to include decorations)
unfiled - keyboard snap-moving and snap-resizing snap to hidden
edges
109553 - gravity w/ simultaneous move & resize doesn't work
113601 - maximize vertical and horizontal should toggle and be
constrained
122196 - windows show up under vertical panels
122670 - jerky/random resizing of window via keyboard[2]
124582 - keyboard and mouse snap-resizing and snap-moving
erroneously moves the window multidimensionally
136307 - don't allow apps to resize themselves off the screen
(*cough* filechooser *cough*)
142016, 143784 - windows should not span multiple xineramas
unless placed there by the user
143145 - clamp new windows to screensize and force them
onscreen, if they'll fit
144126 - Handle pathological strut lists sanely[3]
149867 - fixed aspect ratio windows are difficult to resize[4]
152898 - make screen edges consistent; allow easy slamming of
windows into the left, right, and bottom edges of the
screen too.
154706 - bouncing weirdness at screen edge with keyboard moving
or resizing
156699 - avoid struts when placing windows, if possible (nasty
a11y blocker)
302456 - dragging offscreen too restrictive
304857 - wireframe moving off the top of the screen is misleading
308521 - make uni-directional resizing easier with
alt-middle-drag and prevent the occasional super
annoying resize-the-wrong-side(s) behavior
312007 - snap-resize moves windows with a minimum size
constraint
312104 - resizing the top of a window can cause the bottom to
grow
319351 - don't instantly snap on mouse-move-snapping, remove
braindeadedness of having order of releasing shift and
releasing button press matter so much
[1] fixed in my opinion, anyway.
[2] Actually, it's not totally fixed--it's just annoying
instead of almost completely unusable. Matthias had a
suggestion that may fix the remainder of the problems (see
http://tinyurl.com/bwzuu).
[3] This bug was originally about not-quite-so-pathological
cases but was left open for the worse cases. The code from
the branch handles the remainder of the cases mentioned in
this bug.
[4] Actually, although it's far better there's still some minor
issues left: a slight drift that's only noticeable after
lots of resizing, and potential problems with partially
onscreen constraints due to not clearing any
fixed_directions flags (aspect ratio windows get resized in
both directions and thus aren't fixed in one of them)
New feature:
81704 - edge resistance for user move and resize operations;
in particular 3 different kinds of resistance are
implemented:
Pixel-Distance: window movement is resisted when it
aligns with an edge unless the movement is greater than
a threshold number of pixels
Timeout: window movement past an edge is prevented until
a certain amount of time has elapsed during the
operation since the first request to move it past that
edge
Keyboard-Buildup: when moving or resizing with the
keyboard, once a window is aligned with a certain edge
it cannot move past until the correct direction has
been pressed enough times (e.g. 2 or 3 times)
Major changes:
- constraints.c has been rewritten; very few lines of code from
the old version remain. There is a comment near the top of
the function explaining the basics of how the new framework
works. A more detailed explanation can be found in
doc/how-constraints-works.txt
- edge-resistance.[ch] are new files implementing edge-resistance.
- boxes.[ch] are new files containing low-level error-prone
functions used heavily in constraints.c and edge-resistance.c,
among various places throughout the code. testboxes.c
contains a thorough testsuite for the boxes.[ch] functions
compiled into a program, testboxes.
- meta_window_move_resize_internal() *must* be told the gravity
of the associated operation (if it's just a move operation,
the gravity will be ignored, but for resize and move+resize
the correct value is needed)
- the craziness of different values that
meta_window_move_resize_internal() accepts has been documented
in a large comment at the beginning of the function. It may
be possible to clean this up some, but until then things will
remain as they were before--caller beware.
- screen and xinerama usable areas (i.e. places not covered by
e.g. panels) are cached in the workspace now, as are the
screen and xinerama edges. These get updated with the
workarea in src/workspace.c:ensure_work_areas_validated()
2005-11-19 09:58:50 -05:00
|
|
|
x += xi->rect.x;
|
|
|
|
y += xi->rect.y;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2016-07-21 09:03:56 -04:00
|
|
|
meta_topic (META_DEBUG_PLACEMENT, "Centered window %s on monitor %d\n",
|
|
|
|
window->desc, xi->number);
|
2001-06-24 02:47:54 -04:00
|
|
|
|
2005-08-12 23:58:24 -04:00
|
|
|
goto done_check_denied_focus;
|
2001-06-24 02:47:54 -04:00
|
|
|
}
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
/* Find windows that matter (not minimized, on same workspace
|
|
|
|
* as placed window, may be shaded - if shaded we pretend it isn't
|
|
|
|
* for placement purposes)
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
GSList *all_windows;
|
|
|
|
GSList *tmp;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2009-06-15 15:32:23 -04:00
|
|
|
all_windows = meta_display_list_windows (window->display, META_LIST_DEFAULT);
|
2001-06-24 04:09:10 -04:00
|
|
|
|
|
|
|
tmp = all_windows;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
MetaWindow *w = tmp->data;
|
|
|
|
|
2013-01-18 14:55:23 -05:00
|
|
|
if (w != window &&
|
|
|
|
meta_window_showing_on_its_workspace (w) &&
|
2015-01-19 16:51:24 -05:00
|
|
|
(window->on_all_workspaces ||
|
|
|
|
meta_window_located_on_workspace (w, window->workspace)))
|
2001-06-24 04:09:10 -04:00
|
|
|
windows = g_list_prepend (windows, w);
|
|
|
|
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
2005-01-27 13:30:27 -05:00
|
|
|
|
|
|
|
g_slist_free (all_windows);
|
2001-06-24 04:09:10 -04:00
|
|
|
}
|
2002-06-06 23:18:46 -04:00
|
|
|
|
|
|
|
/* Warning, this is a round trip! */
|
2012-06-08 04:21:10 -04:00
|
|
|
xi = meta_screen_get_current_monitor_info (window->screen);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2003-06-09 19:49:02 -04:00
|
|
|
/* Maximize windows if they are too big for their work area (bit of
|
|
|
|
* a hack here). Assume undecorated windows probably don't intend to
|
2014-05-02 09:34:02 -04:00
|
|
|
* be maximized.
|
2003-06-09 19:49:02 -04:00
|
|
|
*/
|
|
|
|
if (window->has_maximize_func && window->decorated &&
|
|
|
|
!window->fullscreen)
|
|
|
|
{
|
|
|
|
MetaRectangle workarea;
|
2013-11-19 12:24:45 -05:00
|
|
|
MetaRectangle frame_rect;
|
2003-06-09 19:49:02 -04:00
|
|
|
|
2009-08-31 09:52:16 -04:00
|
|
|
meta_window_get_work_area_for_monitor (window,
|
|
|
|
xi->number,
|
2014-05-02 09:34:02 -04:00
|
|
|
&workarea);
|
2013-11-19 12:24:45 -05:00
|
|
|
meta_window_get_frame_rect (window, &frame_rect);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2007-04-12 18:25:25 -04:00
|
|
|
/* If the window is bigger than the screen, then automaximize. Do NOT
|
|
|
|
* auto-maximize the directions independently. See #419810.
|
|
|
|
*/
|
2013-11-19 12:24:45 -05:00
|
|
|
if (frame_rect.width >= workarea.width && frame_rect.height >= workarea.height)
|
2007-04-12 18:25:25 -04:00
|
|
|
{
|
|
|
|
window->maximize_horizontally_after_placement = TRUE;
|
|
|
|
window->maximize_vertically_after_placement = TRUE;
|
|
|
|
}
|
2003-06-09 19:49:02 -04:00
|
|
|
}
|
2005-02-11 14:20:44 -05:00
|
|
|
|
2014-05-20 15:38:07 -04:00
|
|
|
/* "Origin" placement algorithm */
|
|
|
|
x = xi->rect.x;
|
|
|
|
y = xi->rect.y;
|
|
|
|
|
|
|
|
if (find_first_fit (window, windows,
|
|
|
|
xi->number,
|
|
|
|
x, y, &x, &y))
|
|
|
|
goto done_check_denied_focus;
|
|
|
|
|
2014-05-20 15:38:49 -04:00
|
|
|
/* No good fit? Fall back to cascading... */
|
|
|
|
find_next_cascade (window, windows, x, y, &x, &y);
|
2008-04-27 16:09:47 -04:00
|
|
|
|
2005-02-11 14:20:44 -05:00
|
|
|
done_check_denied_focus:
|
|
|
|
/* If the window is being denied focus and isn't a transient of the
|
|
|
|
* focus window, we do NOT want it to overlap with the focus window
|
|
|
|
* if at all possible. This is guaranteed to only be called if the
|
|
|
|
* focus_window is non-NULL, and we try to avoid that window.
|
|
|
|
*/
|
|
|
|
if (window->denied_focus_and_not_transient)
|
|
|
|
{
|
|
|
|
MetaWindow *focus_window;
|
2013-11-15 16:11:20 -05:00
|
|
|
gboolean found_fit;
|
2005-02-11 14:20:44 -05:00
|
|
|
|
|
|
|
focus_window = window->display->focus_window;
|
|
|
|
g_assert (focus_window != NULL);
|
|
|
|
|
|
|
|
/* No need to do anything if the window doesn't overlap at all */
|
2013-11-15 16:11:20 -05:00
|
|
|
found_fit = !window_overlaps_focus_window (window);
|
2005-02-11 14:20:44 -05:00
|
|
|
|
|
|
|
/* Try to do a first fit again, this time only taking into account the
|
|
|
|
* focus window.
|
|
|
|
*/
|
|
|
|
if (!found_fit)
|
|
|
|
{
|
|
|
|
GList *focus_window_list;
|
|
|
|
focus_window_list = g_list_prepend (NULL, focus_window);
|
|
|
|
|
|
|
|
/* Reset x and y ("origin" placement algorithm) */
|
Merge of all the changes on the constraints_experiments branch. This is
2005-11-18 Elijah Newren <newren@gmail.com>
Merge of all the changes on the constraints_experiments branch.
This is just a summary, to get the full ChangeLog of those
changes (approx. 2000 lines):
cvs -q -z3 update -Pd -r constraints_experiments
cvs -q -z3 diff -pu -r CONSTRAINTS_EXPERIMENTS_BRANCHPOINT ChangeLog
Bugs fixed:
unfiled - constraints.c is overly complicated[1]
unfiled - constraints.c is not robust when all constraints
cannot simultaneously be met (constraints need to be
prioritized)
unfiled - keep-titlebar-onscreen constraint is decoration
unaware (since get_outermost_onscreen_positions()
forgets to include decorations)
unfiled - keyboard snap-moving and snap-resizing snap to hidden
edges
109553 - gravity w/ simultaneous move & resize doesn't work
113601 - maximize vertical and horizontal should toggle and be
constrained
122196 - windows show up under vertical panels
122670 - jerky/random resizing of window via keyboard[2]
124582 - keyboard and mouse snap-resizing and snap-moving
erroneously moves the window multidimensionally
136307 - don't allow apps to resize themselves off the screen
(*cough* filechooser *cough*)
142016, 143784 - windows should not span multiple xineramas
unless placed there by the user
143145 - clamp new windows to screensize and force them
onscreen, if they'll fit
144126 - Handle pathological strut lists sanely[3]
149867 - fixed aspect ratio windows are difficult to resize[4]
152898 - make screen edges consistent; allow easy slamming of
windows into the left, right, and bottom edges of the
screen too.
154706 - bouncing weirdness at screen edge with keyboard moving
or resizing
156699 - avoid struts when placing windows, if possible (nasty
a11y blocker)
302456 - dragging offscreen too restrictive
304857 - wireframe moving off the top of the screen is misleading
308521 - make uni-directional resizing easier with
alt-middle-drag and prevent the occasional super
annoying resize-the-wrong-side(s) behavior
312007 - snap-resize moves windows with a minimum size
constraint
312104 - resizing the top of a window can cause the bottom to
grow
319351 - don't instantly snap on mouse-move-snapping, remove
braindeadedness of having order of releasing shift and
releasing button press matter so much
[1] fixed in my opinion, anyway.
[2] Actually, it's not totally fixed--it's just annoying
instead of almost completely unusable. Matthias had a
suggestion that may fix the remainder of the problems (see
http://tinyurl.com/bwzuu).
[3] This bug was originally about not-quite-so-pathological
cases but was left open for the worse cases. The code from
the branch handles the remainder of the cases mentioned in
this bug.
[4] Actually, although it's far better there's still some minor
issues left: a slight drift that's only noticeable after
lots of resizing, and potential problems with partially
onscreen constraints due to not clearing any
fixed_directions flags (aspect ratio windows get resized in
both directions and thus aren't fixed in one of them)
New feature:
81704 - edge resistance for user move and resize operations;
in particular 3 different kinds of resistance are
implemented:
Pixel-Distance: window movement is resisted when it
aligns with an edge unless the movement is greater than
a threshold number of pixels
Timeout: window movement past an edge is prevented until
a certain amount of time has elapsed during the
operation since the first request to move it past that
edge
Keyboard-Buildup: when moving or resizing with the
keyboard, once a window is aligned with a certain edge
it cannot move past until the correct direction has
been pressed enough times (e.g. 2 or 3 times)
Major changes:
- constraints.c has been rewritten; very few lines of code from
the old version remain. There is a comment near the top of
the function explaining the basics of how the new framework
works. A more detailed explanation can be found in
doc/how-constraints-works.txt
- edge-resistance.[ch] are new files implementing edge-resistance.
- boxes.[ch] are new files containing low-level error-prone
functions used heavily in constraints.c and edge-resistance.c,
among various places throughout the code. testboxes.c
contains a thorough testsuite for the boxes.[ch] functions
compiled into a program, testboxes.
- meta_window_move_resize_internal() *must* be told the gravity
of the associated operation (if it's just a move operation,
the gravity will be ignored, but for resize and move+resize
the correct value is needed)
- the craziness of different values that
meta_window_move_resize_internal() accepts has been documented
in a large comment at the beginning of the function. It may
be possible to clean this up some, but until then things will
remain as they were before--caller beware.
- screen and xinerama usable areas (i.e. places not covered by
e.g. panels) are cached in the workspace now, as are the
screen and xinerama edges. These get updated with the
workarea in src/workspace.c:ensure_work_areas_validated()
2005-11-19 09:58:50 -05:00
|
|
|
x = xi->rect.x;
|
|
|
|
y = xi->rect.y;
|
2005-02-11 14:20:44 -05:00
|
|
|
|
2013-11-15 18:03:50 -05:00
|
|
|
found_fit = find_first_fit (window, focus_window_list,
|
2007-06-18 07:46:44 -04:00
|
|
|
xi->number,
|
2005-02-11 14:20:44 -05:00
|
|
|
x, y, &x, &y);
|
|
|
|
g_list_free (focus_window_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If that still didn't work, just place it where we can see as much
|
|
|
|
* as possible.
|
|
|
|
*/
|
|
|
|
if (!found_fit)
|
2013-11-15 18:03:50 -05:00
|
|
|
find_most_freespace (window, focus_window, x, y, &x, &y);
|
2005-02-11 14:20:44 -05:00
|
|
|
}
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2001-06-24 02:47:54 -04:00
|
|
|
done:
|
2014-05-20 15:36:28 -04:00
|
|
|
if (windows)
|
|
|
|
g_list_free (windows);
|
2003-02-23 12:09:46 -05:00
|
|
|
|
2001-06-24 02:47:54 -04:00
|
|
|
*new_x = x;
|
|
|
|
*new_y = y;
|
|
|
|
}
|