2006-10-01 18:30:10 -04:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
2013-02-15 13:42:08 -05:00
|
|
|
/*
|
2011-11-02 11:34:45 -04:00
|
|
|
* SECTION:stack
|
|
|
|
* @short_description: Which windows cover which other windows
|
2008-06-26 23:39:15 -04:00
|
|
|
*/
|
2001-06-10 03:27:11 -04:00
|
|
|
|
2014-05-02 09:34:02 -04:00
|
|
|
/*
|
2001-06-10 03:27:11 -04:00
|
|
|
* Copyright (C) 2001 Havoc Pennington
|
2003-02-23 12:09:46 -05:00
|
|
|
* Copyright (C) 2002, 2003 Red Hat, Inc.
|
2004-02-27 20:49:17 -05:00
|
|
|
* Copyright (C) 2004 Rob Adams
|
2005-10-08 15:38:54 -04:00
|
|
|
* Copyright (C) 2004, 2005 Elijah Newren
|
2014-05-02 09:34:02 -04:00
|
|
|
*
|
2001-06-10 03:27:11 -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-10 03:27:11 -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-10 03:27:11 -04:00
|
|
|
*/
|
|
|
|
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "core/stack.h"
|
2001-06-10 03:52:35 -04:00
|
|
|
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "backends/meta-logical-monitor.h"
|
2020-02-17 12:32:35 -05:00
|
|
|
#include "cogl/cogl.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "core/frame.h"
|
|
|
|
#include "core/meta-workspace-manager-private.h"
|
|
|
|
#include "core/window-private.h"
|
|
|
|
#include "meta/group.h"
|
|
|
|
#include "meta/prefs.h"
|
|
|
|
#include "meta/workspace.h"
|
2019-08-15 18:24:31 -04:00
|
|
|
#include "x11/meta-x11-display-private.h"
|
2014-03-18 21:56:45 -04:00
|
|
|
|
2019-11-26 17:06:09 -05:00
|
|
|
#define WINDOW_TRANSIENT_FOR_WHOLE_GROUP(w) \
|
|
|
|
(meta_window_has_transient_type (w) && w->transient_for == NULL)
|
2004-03-01 21:28:21 -05:00
|
|
|
|
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
|
|
|
static void meta_window_set_stack_position_no_sync (MetaWindow *window,
|
|
|
|
int position);
|
2019-07-04 07:03:40 -04:00
|
|
|
static void stack_do_relayer (MetaStack *stack);
|
|
|
|
static void stack_do_constrain (MetaStack *stack);
|
|
|
|
static void stack_do_resort (MetaStack *stack);
|
2008-06-26 23:39:15 -04:00
|
|
|
static void stack_ensure_sorted (MetaStack *stack);
|
2001-06-10 03:27:11 -04:00
|
|
|
|
2019-05-06 13:25:21 -04:00
|
|
|
enum
|
2001-06-10 03:27:11 -04:00
|
|
|
{
|
2019-05-06 13:25:21 -04:00
|
|
|
PROP_DISPLAY = 1,
|
|
|
|
N_PROPS
|
|
|
|
};
|
2001-06-10 03:27:11 -04:00
|
|
|
|
2019-05-06 13:25:21 -04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
CHANGED,
|
|
|
|
WINDOW_ADDED,
|
|
|
|
WINDOW_REMOVED,
|
|
|
|
N_SIGNALS
|
|
|
|
};
|
2001-10-10 21:29:20 -04:00
|
|
|
|
2019-05-06 13:25:21 -04:00
|
|
|
static GParamSpec *pspecs[N_PROPS] = { 0 };
|
|
|
|
static guint signals[N_SIGNALS] = { 0 };
|
2002-09-28 12:33:39 -04:00
|
|
|
|
2019-05-06 13:25:21 -04:00
|
|
|
G_DEFINE_TYPE (MetaStack, meta_stack, G_TYPE_OBJECT)
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2019-08-15 18:24:31 -04:00
|
|
|
static void
|
|
|
|
on_stack_changed (MetaStack *stack)
|
|
|
|
{
|
|
|
|
MetaDisplay *display = stack->display;
|
|
|
|
GArray *all_root_children_stacked;
|
|
|
|
GList *l;
|
|
|
|
GArray *hidden_stack_ids;
|
|
|
|
GList *sorted;
|
|
|
|
|
2020-11-30 06:06:16 -05:00
|
|
|
COGL_TRACE_BEGIN_SCOPED (StackChanged, "Stack changed");
|
|
|
|
|
2020-10-02 11:47:22 -04:00
|
|
|
meta_topic (META_DEBUG_STACK, "Syncing window stack to server");
|
2019-08-15 18:24:31 -04:00
|
|
|
|
|
|
|
all_root_children_stacked = g_array_new (FALSE, FALSE, sizeof (uint64_t));
|
|
|
|
hidden_stack_ids = g_array_new (FALSE, FALSE, sizeof (uint64_t));
|
|
|
|
|
|
|
|
meta_topic (META_DEBUG_STACK, "Bottom to top: ");
|
|
|
|
meta_push_no_msg_prefix ();
|
|
|
|
|
|
|
|
sorted = meta_stack_list_windows (stack, NULL);
|
|
|
|
|
|
|
|
for (l = sorted; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaWindow *w = l->data;
|
|
|
|
uint64_t top_level_window;
|
|
|
|
uint64_t stack_id;
|
|
|
|
|
|
|
|
if (w->unmanaging)
|
|
|
|
continue;
|
|
|
|
|
2020-10-02 11:54:56 -04:00
|
|
|
meta_topic (META_DEBUG_STACK, " %u:%d - %s ",
|
2019-08-15 18:24:31 -04:00
|
|
|
w->layer, w->stack_position, w->desc);
|
|
|
|
|
|
|
|
if (w->frame)
|
|
|
|
top_level_window = w->frame->xwindow;
|
|
|
|
else
|
|
|
|
top_level_window = w->xwindow;
|
|
|
|
|
|
|
|
if (w->client_type == META_WINDOW_CLIENT_TYPE_X11)
|
|
|
|
stack_id = top_level_window;
|
|
|
|
else
|
|
|
|
stack_id = w->stamp;
|
|
|
|
|
|
|
|
/* We don't restack hidden windows along with the rest, though they are
|
|
|
|
* reflected in the _NET hints. Hidden windows all get pushed below
|
|
|
|
* the screens fullscreen guard_window. */
|
|
|
|
if (w->hidden)
|
|
|
|
{
|
|
|
|
g_array_append_val (hidden_stack_ids, stack_id);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_array_append_val (all_root_children_stacked, stack_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_pop_no_msg_prefix ();
|
|
|
|
|
|
|
|
if (display->x11_display)
|
|
|
|
{
|
|
|
|
uint64_t guard_window_id;
|
|
|
|
|
|
|
|
/* The screen guard window sits above all hidden windows and acts as
|
|
|
|
* a barrier to input reaching these windows. */
|
|
|
|
guard_window_id = display->x11_display->guard_window;
|
|
|
|
g_array_append_val (hidden_stack_ids, guard_window_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sync to server */
|
|
|
|
|
2020-10-02 11:47:22 -04:00
|
|
|
meta_topic (META_DEBUG_STACK, "Restacking %u windows",
|
2019-08-15 18:24:31 -04:00
|
|
|
all_root_children_stacked->len);
|
|
|
|
|
|
|
|
meta_stack_tracker_restack_managed (display->stack_tracker,
|
|
|
|
(uint64_t *)all_root_children_stacked->data,
|
|
|
|
all_root_children_stacked->len);
|
|
|
|
meta_stack_tracker_restack_at_bottom (display->stack_tracker,
|
|
|
|
(uint64_t *)hidden_stack_ids->data,
|
|
|
|
hidden_stack_ids->len);
|
|
|
|
|
|
|
|
g_array_free (hidden_stack_ids, TRUE);
|
|
|
|
g_array_free (all_root_children_stacked, TRUE);
|
|
|
|
g_list_free (sorted);
|
|
|
|
}
|
|
|
|
|
2019-05-06 13:25:21 -04:00
|
|
|
static void
|
|
|
|
meta_stack_init (MetaStack *stack)
|
|
|
|
{
|
2019-08-15 18:24:31 -04:00
|
|
|
g_signal_connect (stack, "changed",
|
|
|
|
G_CALLBACK (on_stack_changed), NULL);
|
2001-06-10 03:27:11 -04:00
|
|
|
}
|
|
|
|
|
2019-05-06 13:25:21 -04:00
|
|
|
static void
|
|
|
|
meta_stack_finalize (GObject *object)
|
2001-06-10 03:27:11 -04:00
|
|
|
{
|
2019-05-06 13:25:21 -04:00
|
|
|
MetaStack *stack = META_STACK (object);
|
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
g_list_free (stack->sorted);
|
2001-10-10 21:29:20 -04:00
|
|
|
|
2019-05-06 13:25:21 -04:00
|
|
|
G_OBJECT_CLASS (meta_stack_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_stack_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
MetaStack *stack = META_STACK (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_DISPLAY:
|
|
|
|
stack->display = g_value_get_object (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_stack_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
MetaStack *stack = META_STACK (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_DISPLAY:
|
|
|
|
g_value_set_object (value, stack->display);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_stack_class_init (MetaStackClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->set_property = meta_stack_set_property;
|
|
|
|
object_class->get_property = meta_stack_get_property;
|
|
|
|
object_class->finalize = meta_stack_finalize;
|
|
|
|
|
|
|
|
signals[CHANGED] =
|
|
|
|
g_signal_new ("changed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0, NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
signals[WINDOW_ADDED] =
|
|
|
|
g_signal_new ("window-added",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0, NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1, META_TYPE_WINDOW);
|
|
|
|
signals[WINDOW_REMOVED] =
|
|
|
|
g_signal_new ("window-removed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0, NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1, META_TYPE_WINDOW);
|
|
|
|
|
|
|
|
pspecs[PROP_DISPLAY] =
|
|
|
|
g_param_spec_object ("display",
|
|
|
|
"Display",
|
|
|
|
"Display",
|
|
|
|
META_TYPE_DISPLAY,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, N_PROPS, pspecs);
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaStack *
|
|
|
|
meta_stack_new (MetaDisplay *display)
|
|
|
|
{
|
|
|
|
return g_object_new (META_TYPE_STACK,
|
|
|
|
"display", display,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_stack_changed (MetaStack *stack)
|
|
|
|
{
|
|
|
|
/* Bail out if frozen */
|
|
|
|
if (stack->freeze_count > 0)
|
|
|
|
return;
|
|
|
|
|
2020-11-30 06:06:16 -05:00
|
|
|
COGL_TRACE_BEGIN_SCOPED (MetaStackChangedSort, "Stack: Changed");
|
|
|
|
|
2019-05-06 13:25:21 -04:00
|
|
|
stack_ensure_sorted (stack);
|
|
|
|
g_signal_emit (stack, signals[CHANGED], 0);
|
2001-06-10 03:27:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_stack_add (MetaStack *stack,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
2017-08-27 15:02:40 -04:00
|
|
|
MetaWorkspaceManager *workspace_manager = window->display->workspace_manager;
|
|
|
|
|
2019-08-29 13:34:18 -04:00
|
|
|
COGL_TRACE_BEGIN_SCOPED (MetaStackAdd,
|
|
|
|
"Stack (add window)");
|
|
|
|
|
2018-01-09 07:19:40 -05:00
|
|
|
g_return_if_fail (meta_window_is_stackable (window));
|
2014-09-09 16:15:51 -04:00
|
|
|
|
2020-10-02 11:47:22 -04:00
|
|
|
meta_topic (META_DEBUG_STACK, "Adding window %s to the stack", window->desc);
|
2001-06-10 03:27:11 -04:00
|
|
|
|
2018-01-09 07:19:40 -05:00
|
|
|
if (meta_window_is_in_stack (window))
|
2020-10-02 11:47:22 -04:00
|
|
|
meta_bug ("Window %s had stack position already", window->desc);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2019-05-07 06:59:50 -04:00
|
|
|
stack->sorted = g_list_prepend (stack->sorted, window);
|
|
|
|
stack->need_resort = TRUE; /* may not be needed as we add to top */
|
|
|
|
stack->need_constrain = TRUE;
|
|
|
|
stack->need_relayer = TRUE;
|
|
|
|
|
2019-05-06 13:25:21 -04:00
|
|
|
g_signal_emit (stack, signals[WINDOW_ADDED], 0, window);
|
2001-06-10 03:27:11 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
window->stack_position = stack->n_positions;
|
|
|
|
stack->n_positions += 1;
|
|
|
|
meta_topic (META_DEBUG_STACK,
|
2020-10-02 11:47:22 -04:00
|
|
|
"Window %s has stack_position initialized to %d",
|
2002-09-28 12:33:39 -04:00
|
|
|
window->desc, window->stack_position);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2019-05-06 13:25:21 -04:00
|
|
|
meta_stack_changed (stack);
|
2017-08-27 15:02:40 -04:00
|
|
|
meta_stack_update_window_tile_matches (stack, workspace_manager->active_workspace);
|
2001-06-10 03:27:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_stack_remove (MetaStack *stack,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
2017-08-27 15:02:40 -04:00
|
|
|
MetaWorkspaceManager *workspace_manager = window->display->workspace_manager;
|
|
|
|
|
2019-08-29 13:34:18 -04:00
|
|
|
COGL_TRACE_BEGIN_SCOPED (MetaStackRemove,
|
|
|
|
"Stack (remove window)");
|
|
|
|
|
2020-10-02 11:47:22 -04:00
|
|
|
meta_topic (META_DEBUG_STACK, "Removing window %s from the stack", window->desc);
|
2001-06-10 03:27:11 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
/* Set window to top position, so removing it will not leave gaps
|
|
|
|
* in the set of positions
|
|
|
|
*/
|
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
|
|
|
meta_window_set_stack_position_no_sync (window,
|
|
|
|
stack->n_positions - 1);
|
2002-09-28 12:33:39 -04:00
|
|
|
window->stack_position = -1;
|
2014-05-02 09:34:02 -04:00
|
|
|
stack->n_positions -= 1;
|
2002-09-28 12:33:39 -04:00
|
|
|
|
|
|
|
stack->sorted = g_list_remove (stack->sorted, window);
|
|
|
|
|
2019-05-06 13:25:21 -04:00
|
|
|
g_signal_emit (stack, signals[WINDOW_REMOVED], 0, window);
|
|
|
|
|
|
|
|
meta_stack_changed (stack);
|
2017-08-27 15:02:40 -04:00
|
|
|
meta_stack_update_window_tile_matches (stack, workspace_manager->active_workspace);
|
2001-06-10 03:27:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_stack_update_layer (MetaStack *stack,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
2017-08-27 15:02:40 -04:00
|
|
|
MetaWorkspaceManager *workspace_manager = window->display->workspace_manager;
|
2002-09-28 12:33:39 -04:00
|
|
|
stack->need_relayer = TRUE;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2019-05-06 13:25:21 -04:00
|
|
|
meta_stack_changed (stack);
|
2017-08-27 15:02:40 -04:00
|
|
|
meta_stack_update_window_tile_matches (stack, workspace_manager->active_workspace);
|
2001-06-10 03:27:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_stack_update_transient (MetaStack *stack,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
2017-08-27 15:02:40 -04:00
|
|
|
MetaWorkspaceManager *workspace_manager = window->display->workspace_manager;
|
2002-09-28 12:33:39 -04:00
|
|
|
stack->need_constrain = TRUE;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2019-05-06 13:25:21 -04:00
|
|
|
meta_stack_changed (stack);
|
2017-08-27 15:02:40 -04:00
|
|
|
meta_stack_update_window_tile_matches (stack, workspace_manager->active_workspace);
|
2001-06-10 03:27:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* raise/lower within a layer */
|
|
|
|
void
|
|
|
|
meta_stack_raise (MetaStack *stack,
|
|
|
|
MetaWindow *window)
|
2011-10-18 00:39:08 -04:00
|
|
|
{
|
2017-08-27 15:02:40 -04:00
|
|
|
MetaWorkspaceManager *workspace_manager = window->display->workspace_manager;
|
2011-10-18 00:39:08 -04:00
|
|
|
GList *l;
|
|
|
|
int max_stack_position = window->stack_position;
|
|
|
|
MetaWorkspace *workspace;
|
|
|
|
|
2012-03-24 14:17:29 -04:00
|
|
|
stack_ensure_sorted (stack);
|
2011-10-18 00:39:08 -04:00
|
|
|
|
|
|
|
workspace = meta_window_get_workspace (window);
|
|
|
|
for (l = stack->sorted; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaWindow *w = (MetaWindow *) l->data;
|
|
|
|
if (meta_window_located_on_workspace (w, workspace) &&
|
|
|
|
w->stack_position > max_stack_position)
|
|
|
|
max_stack_position = w->stack_position;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (max_stack_position == window->stack_position)
|
|
|
|
return;
|
|
|
|
|
|
|
|
meta_window_set_stack_position_no_sync (window, max_stack_position);
|
|
|
|
|
2019-05-06 13:25:21 -04:00
|
|
|
meta_stack_changed (stack);
|
2017-08-27 15:02:40 -04:00
|
|
|
meta_stack_update_window_tile_matches (stack, workspace_manager->active_workspace);
|
2001-06-10 03:27:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_stack_lower (MetaStack *stack,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
2017-08-27 15:02:40 -04:00
|
|
|
MetaWorkspaceManager *workspace_manager = window->display->workspace_manager;
|
2011-10-18 00:39:08 -04:00
|
|
|
GList *l;
|
|
|
|
int min_stack_position = window->stack_position;
|
|
|
|
MetaWorkspace *workspace;
|
|
|
|
|
2012-03-24 14:17:29 -04:00
|
|
|
stack_ensure_sorted (stack);
|
2011-10-18 00:39:08 -04:00
|
|
|
|
|
|
|
workspace = meta_window_get_workspace (window);
|
|
|
|
for (l = stack->sorted; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaWindow *w = (MetaWindow *) l->data;
|
|
|
|
if (meta_window_located_on_workspace (w, workspace) &&
|
|
|
|
w->stack_position < min_stack_position)
|
|
|
|
min_stack_position = w->stack_position;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (min_stack_position == window->stack_position)
|
|
|
|
return;
|
|
|
|
|
|
|
|
meta_window_set_stack_position_no_sync (window, min_stack_position);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2019-05-06 13:25:21 -04:00
|
|
|
meta_stack_changed (stack);
|
2017-08-27 15:02:40 -04:00
|
|
|
meta_stack_update_window_tile_matches (stack, workspace_manager->active_workspace);
|
2001-06-10 03:27:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_stack_freeze (MetaStack *stack)
|
|
|
|
{
|
|
|
|
stack->freeze_count += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_stack_thaw (MetaStack *stack)
|
|
|
|
{
|
|
|
|
g_return_if_fail (stack->freeze_count > 0);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2001-06-10 03:27:11 -04:00
|
|
|
stack->freeze_count -= 1;
|
2019-05-06 13:25:21 -04:00
|
|
|
meta_stack_changed (stack);
|
2016-01-10 09:16:09 -05:00
|
|
|
meta_stack_update_window_tile_matches (stack, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_stack_update_window_tile_matches (MetaStack *stack,
|
|
|
|
MetaWorkspace *workspace)
|
|
|
|
{
|
|
|
|
GList *windows, *tmp;
|
|
|
|
|
|
|
|
if (stack->freeze_count > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
windows = meta_stack_list_windows (stack, workspace);
|
|
|
|
tmp = windows;
|
|
|
|
while (tmp)
|
|
|
|
{
|
|
|
|
meta_window_compute_tile_match ((MetaWindow *) tmp->data);
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (windows);
|
2001-06-10 03:27:11 -04:00
|
|
|
}
|
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
/* Front of the layer list is the topmost window,
|
|
|
|
* so the lower stack position is later in the list
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
compare_window_position (void *a,
|
|
|
|
void *b)
|
|
|
|
{
|
|
|
|
MetaWindow *window_a = a;
|
|
|
|
MetaWindow *window_b = b;
|
2001-06-10 15:23:28 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
/* Go by layer, then stack_position */
|
|
|
|
if (window_a->layer < window_b->layer)
|
|
|
|
return 1; /* move window_a later in list */
|
|
|
|
else if (window_a->layer > window_b->layer)
|
|
|
|
return -1;
|
|
|
|
else if (window_a->stack_position < window_b->stack_position)
|
|
|
|
return 1; /* move window_a later in list */
|
|
|
|
else if (window_a->stack_position > window_b->stack_position)
|
|
|
|
return -1;
|
2001-06-10 15:23:28 -04:00
|
|
|
else
|
2002-09-28 12:33:39 -04:00
|
|
|
return 0; /* not reached */
|
|
|
|
}
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
/*
|
|
|
|
* Stacking constraints
|
2014-05-02 09:34:02 -04:00
|
|
|
*
|
2002-10-18 02:05:09 -04:00
|
|
|
* Assume constraints of the form "AB" meaning "window A must be
|
|
|
|
* below window B"
|
|
|
|
*
|
|
|
|
* If we have windows stacked from bottom to top
|
|
|
|
* "ABC" then raise A we get "BCA". Say C is
|
|
|
|
* transient for B is transient for A. So
|
|
|
|
* we have constraints AB and BC.
|
|
|
|
*
|
|
|
|
* After raising A, we need to reapply the constraints.
|
|
|
|
* If we do this by raising one window at a time -
|
|
|
|
*
|
|
|
|
* start: BCA
|
|
|
|
* apply AB: CAB
|
|
|
|
* apply BC: ABC
|
|
|
|
*
|
|
|
|
* but apply constraints in the wrong order and it breaks:
|
2014-05-02 09:34:02 -04:00
|
|
|
*
|
2002-10-18 02:05:09 -04:00
|
|
|
* start: BCA
|
|
|
|
* apply BC: BCA
|
|
|
|
* apply AB: CAB
|
|
|
|
*
|
|
|
|
* We make a directed graph of the constraints by linking
|
|
|
|
* from "above windows" to "below windows as follows:
|
2014-05-02 09:34:02 -04:00
|
|
|
*
|
2002-10-18 02:05:09 -04:00
|
|
|
* AB -> BC -> CD
|
|
|
|
* \
|
|
|
|
* CE
|
|
|
|
*
|
|
|
|
* If we then walk that graph and apply the constraints in the order
|
|
|
|
* that they appear, we will apply them correctly. Note that the
|
|
|
|
* graph MAY have cycles, so we have to guard against that.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct Constraint Constraint;
|
|
|
|
|
|
|
|
struct Constraint
|
|
|
|
{
|
|
|
|
MetaWindow *above;
|
|
|
|
MetaWindow *below;
|
|
|
|
|
|
|
|
/* used to keep the constraint in the
|
|
|
|
* list of constraints for window "below"
|
|
|
|
*/
|
|
|
|
Constraint *next;
|
2002-09-28 12:33:39 -04:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
/* used to create the graph. */
|
|
|
|
GSList *next_nodes;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
/* constraint has been applied, used
|
|
|
|
* to detect cycles.
|
|
|
|
*/
|
|
|
|
unsigned int applied : 1;
|
|
|
|
|
|
|
|
/* constraint has a previous node in the graph,
|
|
|
|
* used to find places to start in the graph.
|
|
|
|
* (I think this also has the side effect
|
|
|
|
* of preventing cycles, since cycles will
|
|
|
|
* have no starting point - so maybe
|
|
|
|
* the "applied" flag isn't needed.)
|
|
|
|
*/
|
|
|
|
unsigned int has_prev : 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* We index the array of constraints by window
|
|
|
|
* stack positions, just because the stack
|
|
|
|
* positions are a convenient index.
|
|
|
|
*/
|
2002-09-28 12:33:39 -04:00
|
|
|
static void
|
2002-10-18 02:05:09 -04:00
|
|
|
add_constraint (Constraint **constraints,
|
|
|
|
MetaWindow *above,
|
|
|
|
MetaWindow *below)
|
|
|
|
{
|
|
|
|
Constraint *c;
|
2003-02-21 12:51:48 -05:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
/* check if constraint is a duplicate */
|
|
|
|
c = constraints[below->stack_position];
|
|
|
|
while (c != NULL)
|
2001-06-10 15:23:28 -04:00
|
|
|
{
|
2002-10-18 02:05:09 -04:00
|
|
|
if (c->above == above)
|
|
|
|
return;
|
|
|
|
c = c->next;
|
2001-06-10 03:52:35 -04:00
|
|
|
}
|
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
/* if not, add the constraint */
|
|
|
|
c = g_new (Constraint, 1);
|
|
|
|
c->above = above;
|
|
|
|
c->below = below;
|
|
|
|
c->next = constraints[below->stack_position];
|
|
|
|
c->next_nodes = NULL;
|
|
|
|
c->applied = FALSE;
|
|
|
|
c->has_prev = FALSE;
|
|
|
|
|
|
|
|
constraints[below->stack_position] = c;
|
2001-06-10 03:52:35 -04:00
|
|
|
}
|
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
static void
|
2002-10-18 02:05:09 -04:00
|
|
|
create_constraints (Constraint **constraints,
|
|
|
|
GList *windows)
|
2001-06-10 03:52:35 -04:00
|
|
|
{
|
2001-06-10 15:23:28 -04:00
|
|
|
GList *tmp;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
tmp = windows;
|
2001-06-10 15:23:28 -04:00
|
|
|
while (tmp != NULL)
|
2001-06-10 03:52:35 -04:00
|
|
|
{
|
2001-06-10 15:23:28 -04:00
|
|
|
MetaWindow *w = tmp->data;
|
2002-11-03 18:42:21 -05:00
|
|
|
|
2018-01-09 07:19:40 -05:00
|
|
|
if (!meta_window_is_in_stack (w))
|
2002-11-03 18:42:21 -05:00
|
|
|
{
|
2020-10-02 11:47:22 -04:00
|
|
|
meta_topic (META_DEBUG_STACK, "Window %s not in the stack, not constraining it",
|
2002-12-08 09:59:14 -05:00
|
|
|
w->desc);
|
2002-11-03 18:42:21 -05:00
|
|
|
tmp = tmp->next;
|
|
|
|
continue;
|
|
|
|
}
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-17 12:36:50 -04:00
|
|
|
if (WINDOW_TRANSIENT_FOR_WHOLE_GROUP (w))
|
2002-09-27 15:42:59 -04:00
|
|
|
{
|
|
|
|
GSList *group_windows;
|
2002-10-17 12:07:50 -04:00
|
|
|
GSList *tmp2;
|
2002-09-27 15:42:59 -04:00
|
|
|
MetaGroup *group;
|
2001-06-10 15:23:28 -04:00
|
|
|
|
2002-09-27 15:42:59 -04:00
|
|
|
group = meta_window_get_group (w);
|
|
|
|
|
|
|
|
if (group != NULL)
|
|
|
|
group_windows = meta_group_list_windows (group);
|
|
|
|
else
|
|
|
|
group_windows = NULL;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-17 12:07:50 -04:00
|
|
|
tmp2 = group_windows;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-17 12:07:50 -04:00
|
|
|
while (tmp2 != NULL)
|
2002-09-27 15:42:59 -04:00
|
|
|
{
|
2002-10-17 12:07:50 -04:00
|
|
|
MetaWindow *group_window = tmp2->data;
|
2002-10-18 02:05:09 -04:00
|
|
|
|
2018-01-09 07:19:40 -05:00
|
|
|
if (!meta_window_is_in_stack (group_window) ||
|
2009-02-26 09:59:14 -05:00
|
|
|
group_window->override_redirect)
|
2002-11-03 18:42:21 -05:00
|
|
|
{
|
|
|
|
tmp2 = tmp2->next;
|
|
|
|
continue;
|
|
|
|
}
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2012-04-24 18:02:33 -04:00
|
|
|
#if 0
|
|
|
|
/* old way of doing it */
|
|
|
|
if (!(meta_window_is_ancestor_of_transient (w, group_window)) &&
|
|
|
|
!WINDOW_TRANSIENT_FOR_WHOLE_GROUP (group_window)) /* note */;/*note*/
|
|
|
|
#else
|
|
|
|
/* better way I think, so transient-for-group are constrained
|
|
|
|
* only above non-transient-type windows in their group
|
|
|
|
*/
|
2019-11-26 17:06:09 -05:00
|
|
|
if (!meta_window_has_transient_type (group_window))
|
2012-04-24 18:02:33 -04:00
|
|
|
#endif
|
2002-09-28 12:33:39 -04:00
|
|
|
{
|
2020-10-02 11:47:22 -04:00
|
|
|
meta_topic (META_DEBUG_STACK,
|
|
|
|
"Constraining %s above %s as it's transient for its group",
|
2002-09-28 12:33:39 -04:00
|
|
|
w->desc, group_window->desc);
|
2002-10-18 02:05:09 -04:00
|
|
|
add_constraint (constraints, w, group_window);
|
2002-09-28 12:33:39 -04:00
|
|
|
}
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-17 12:07:50 -04:00
|
|
|
tmp2 = tmp2->next;
|
2002-09-27 15:42:59 -04:00
|
|
|
}
|
2002-10-17 12:07:50 -04:00
|
|
|
|
|
|
|
g_slist_free (group_windows);
|
2002-09-27 15:42:59 -04:00
|
|
|
}
|
2014-08-13 18:21:31 -04:00
|
|
|
else if (w->transient_for != NULL)
|
2001-06-10 15:23:28 -04:00
|
|
|
{
|
|
|
|
MetaWindow *parent;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2014-08-13 18:21:31 -04:00
|
|
|
parent = w->transient_for;
|
2001-06-10 15:23:28 -04:00
|
|
|
|
2018-01-09 07:19:40 -05:00
|
|
|
if (parent && meta_window_is_in_stack (parent))
|
2001-06-10 15:23:28 -04:00
|
|
|
{
|
2020-10-02 11:47:22 -04:00
|
|
|
meta_topic (META_DEBUG_STACK,
|
|
|
|
"Constraining %s above %s due to transiency",
|
2002-02-07 22:34:26 -05:00
|
|
|
w->desc, parent->desc);
|
2002-10-18 02:05:09 -04:00
|
|
|
add_constraint (constraints, w, parent);
|
2001-06-10 15:23:28 -04:00
|
|
|
}
|
|
|
|
}
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2001-06-10 15:23:28 -04:00
|
|
|
tmp = tmp->next;
|
2001-06-10 03:52:35 -04:00
|
|
|
}
|
2002-09-28 12:33:39 -04:00
|
|
|
}
|
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
static void
|
|
|
|
graph_constraints (Constraint **constraints,
|
|
|
|
int n_constraints)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < n_constraints)
|
|
|
|
{
|
|
|
|
Constraint *c;
|
|
|
|
|
|
|
|
/* If we have "A below B" and "B below C" then AB -> BC so we
|
|
|
|
* add BC to next_nodes in AB.
|
|
|
|
*/
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
c = constraints[i];
|
|
|
|
while (c != NULL)
|
|
|
|
{
|
|
|
|
Constraint *n;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
g_assert (c->below->stack_position == i);
|
|
|
|
|
|
|
|
/* Constraints where ->above is below are our
|
|
|
|
* next_nodes and we are their previous
|
|
|
|
*/
|
|
|
|
n = constraints[c->above->stack_position];
|
|
|
|
while (n != NULL)
|
|
|
|
{
|
|
|
|
c->next_nodes = g_slist_prepend (c->next_nodes,
|
|
|
|
n);
|
|
|
|
/* c is a previous node of n */
|
|
|
|
n->has_prev = TRUE;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
n = n->next;
|
|
|
|
}
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
c = c->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
free_constraints (Constraint **constraints,
|
|
|
|
int n_constraints)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (i < n_constraints)
|
|
|
|
{
|
|
|
|
Constraint *c;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
c = constraints[i];
|
|
|
|
while (c != NULL)
|
|
|
|
{
|
|
|
|
Constraint *next = c->next;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
g_slist_free (c->next_nodes);
|
|
|
|
|
|
|
|
g_free (c);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
c = next;
|
|
|
|
}
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ensure_above (MetaWindow *above,
|
|
|
|
MetaWindow *below)
|
2014-05-02 09:34:02 -04:00
|
|
|
{
|
2019-11-26 20:00:00 -05:00
|
|
|
gboolean is_transient;
|
|
|
|
|
2019-11-26 17:06:09 -05:00
|
|
|
is_transient = meta_window_has_transient_type (above) ||
|
2019-11-26 20:00:00 -05:00
|
|
|
above->transient_for == below;
|
|
|
|
if (is_transient && above->layer < below->layer)
|
2004-03-01 21:28:21 -05:00
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_STACK,
|
2020-10-02 11:47:22 -04:00
|
|
|
"Promoting window %s from layer %u to %u due to constraint",
|
2004-03-01 21:28:21 -05:00
|
|
|
above->desc, above->layer, below->layer);
|
|
|
|
above->layer = below->layer;
|
|
|
|
}
|
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
if (above->stack_position < below->stack_position)
|
|
|
|
{
|
|
|
|
/* move above to below->stack_position bumping below down the stack */
|
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
|
|
|
meta_window_set_stack_position_no_sync (above, below->stack_position);
|
2002-10-18 02:05:09 -04:00
|
|
|
g_assert (below->stack_position + 1 == above->stack_position);
|
|
|
|
}
|
2020-10-02 11:47:22 -04:00
|
|
|
meta_topic (META_DEBUG_STACK, "%s above at %d > %s below at %d",
|
2002-10-18 02:05:09 -04:00
|
|
|
above->desc, above->stack_position,
|
|
|
|
below->desc, below->stack_position);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
traverse_constraint (Constraint *c)
|
|
|
|
{
|
|
|
|
GSList *tmp;
|
|
|
|
|
|
|
|
if (c->applied)
|
|
|
|
return;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
ensure_above (c->above, c->below);
|
|
|
|
c->applied = TRUE;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
tmp = c->next_nodes;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
traverse_constraint (tmp->data);
|
|
|
|
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
apply_constraints (Constraint **constraints,
|
|
|
|
int n_constraints)
|
|
|
|
{
|
|
|
|
GSList *heads;
|
|
|
|
GSList *tmp;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* List all heads in an ordered constraint chain */
|
|
|
|
heads = NULL;
|
|
|
|
i = 0;
|
|
|
|
while (i < n_constraints)
|
|
|
|
{
|
|
|
|
Constraint *c;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
c = constraints[i];
|
|
|
|
while (c != NULL)
|
|
|
|
{
|
|
|
|
if (!c->has_prev)
|
|
|
|
heads = g_slist_prepend (heads, c);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
c = c->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now traverse the chain and apply constraints */
|
|
|
|
tmp = heads;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
Constraint *c = tmp->data;
|
|
|
|
|
|
|
|
traverse_constraint (c);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_slist_free (heads);
|
|
|
|
}
|
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
/**
|
2011-11-02 11:34:45 -04:00
|
|
|
* stack_do_relayer:
|
|
|
|
*
|
2008-06-26 23:39:15 -04:00
|
|
|
* Update the layers that windows are in
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
stack_do_relayer (MetaStack *stack)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
if (!stack->need_relayer)
|
2014-08-19 14:03:43 -04:00
|
|
|
return;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
meta_topic (META_DEBUG_STACK,
|
2020-10-02 11:47:22 -04:00
|
|
|
"Recomputing layers");
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
tmp = stack->sorted;
|
2002-09-28 12:33:39 -04:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
MetaWindow *w;
|
|
|
|
MetaStackLayer old_layer;
|
2004-02-28 18:58:40 -05:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
w = tmp->data;
|
|
|
|
old_layer = w->layer;
|
2002-09-28 12:33:39 -04:00
|
|
|
|
2019-11-26 14:53:24 -05:00
|
|
|
w->layer = meta_window_calculate_layer (w);
|
2004-02-28 18:58:40 -05:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
if (w->layer != old_layer)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_STACK,
|
2020-10-02 11:47:22 -04:00
|
|
|
"Window %s moved from layer %u to %u",
|
2008-06-26 23:39:15 -04:00
|
|
|
w->desc, old_layer, w->layer);
|
|
|
|
stack->need_resort = TRUE;
|
|
|
|
stack->need_constrain = TRUE;
|
|
|
|
/* don't need to constrain as constraining
|
|
|
|
* purely operates in terms of stack_position
|
|
|
|
* not layer
|
|
|
|
*/
|
2002-09-28 12:33:39 -04:00
|
|
|
}
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
tmp = tmp->next;
|
2002-09-28 12:33:39 -04:00
|
|
|
}
|
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
stack->need_relayer = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-11-02 11:34:45 -04:00
|
|
|
* stack_do_constrain:
|
|
|
|
*
|
2008-06-26 23:39:15 -04:00
|
|
|
* Update stack_position and layer to reflect transiency
|
|
|
|
* constraints
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
stack_do_constrain (MetaStack *stack)
|
|
|
|
{
|
|
|
|
Constraint **constraints;
|
|
|
|
|
|
|
|
/* It'd be nice if this were all faster, probably */
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
if (!stack->need_constrain)
|
|
|
|
return;
|
2002-09-28 12:33:39 -04:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
meta_topic (META_DEBUG_STACK,
|
2020-10-02 11:47:22 -04:00
|
|
|
"Reapplying constraints");
|
2008-06-26 23:39:15 -04:00
|
|
|
|
|
|
|
constraints = g_new0 (Constraint*,
|
|
|
|
stack->n_positions);
|
|
|
|
|
|
|
|
create_constraints (constraints, stack->sorted);
|
|
|
|
|
|
|
|
graph_constraints (constraints, stack->n_positions);
|
|
|
|
|
|
|
|
apply_constraints (constraints, stack->n_positions);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
free_constraints (constraints, stack->n_positions);
|
|
|
|
g_free (constraints);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
stack->need_constrain = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-11-02 11:34:45 -04:00
|
|
|
* stack_do_resort:
|
|
|
|
*
|
2008-06-26 23:39:15 -04:00
|
|
|
* Sort stack->sorted with layers having priority over stack_position.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
stack_do_resort (MetaStack *stack)
|
|
|
|
{
|
|
|
|
if (!stack->need_resort)
|
|
|
|
return;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
meta_topic (META_DEBUG_STACK,
|
2020-10-02 11:47:22 -04:00
|
|
|
"Sorting stack list");
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
stack->sorted = g_list_sort (stack->sorted,
|
|
|
|
(GCompareFunc) compare_window_position);
|
2002-09-28 12:33:39 -04:00
|
|
|
|
2017-08-26 15:10:38 -04:00
|
|
|
meta_display_queue_check_fullscreen (stack->display);
|
2016-07-05 13:57:57 -04:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
stack->need_resort = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-11-02 11:34:45 -04:00
|
|
|
* stack_ensure_sorted:
|
|
|
|
*
|
2008-06-29 14:44:21 -04:00
|
|
|
* Puts the stack into canonical form.
|
|
|
|
*
|
2008-06-26 23:39:15 -04:00
|
|
|
* Honour the removed and added lists of the stack, and then recalculate
|
|
|
|
* all the layers (if the flag is set), re-run all the constraint calculations
|
|
|
|
* (if the flag is set), and finally re-sort the stack (if the flag is set,
|
|
|
|
* and if it wasn't already it might have become so during all the previous
|
|
|
|
* activity).
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
stack_ensure_sorted (MetaStack *stack)
|
|
|
|
{
|
|
|
|
stack_do_relayer (stack);
|
|
|
|
stack_do_constrain (stack);
|
|
|
|
stack_do_resort (stack);
|
2001-06-10 03:27:11 -04:00
|
|
|
}
|
|
|
|
|
2019-07-04 07:03:40 -04:00
|
|
|
MetaWindow *
|
2001-06-23 23:18:10 -04:00
|
|
|
meta_stack_get_top (MetaStack *stack)
|
|
|
|
{
|
2008-06-26 23:39:15 -04:00
|
|
|
stack_ensure_sorted (stack);
|
2002-09-28 12:33:39 -04:00
|
|
|
|
|
|
|
if (stack->sorted)
|
|
|
|
return stack->sorted->data;
|
|
|
|
else
|
|
|
|
return NULL;
|
2001-06-23 23:18:10 -04:00
|
|
|
}
|
|
|
|
|
2019-07-04 07:03:40 -04:00
|
|
|
MetaWindow *
|
2001-06-23 23:18:10 -04:00
|
|
|
meta_stack_get_bottom (MetaStack *stack)
|
|
|
|
{
|
2002-09-28 12:33:39 -04:00
|
|
|
GList *link;
|
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
stack_ensure_sorted (stack);
|
2002-09-28 12:33:39 -04:00
|
|
|
|
|
|
|
link = g_list_last (stack->sorted);
|
|
|
|
if (link != NULL)
|
|
|
|
return link->data;
|
|
|
|
else
|
|
|
|
return NULL;
|
2001-06-23 23:18:10 -04:00
|
|
|
}
|
|
|
|
|
2019-07-04 07:03:40 -04:00
|
|
|
MetaWindow *
|
|
|
|
meta_stack_get_above (MetaStack *stack,
|
|
|
|
MetaWindow *window,
|
|
|
|
gboolean only_within_layer)
|
2001-06-23 23:18:10 -04:00
|
|
|
{
|
|
|
|
GList *link;
|
2002-09-28 12:33:39 -04:00
|
|
|
MetaWindow *above;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
stack_ensure_sorted (stack);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
link = g_list_find (stack->sorted, window);
|
2001-06-23 23:18:10 -04:00
|
|
|
if (link == NULL)
|
|
|
|
return NULL;
|
2002-09-28 12:33:39 -04:00
|
|
|
if (link->prev == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
above = link->prev->data;
|
2001-06-23 23:18:10 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
if (only_within_layer &&
|
|
|
|
above->layer != window->layer)
|
2002-05-28 23:11:24 -04:00
|
|
|
return NULL;
|
2001-06-23 23:18:10 -04:00
|
|
|
else
|
2002-09-28 12:33:39 -04:00
|
|
|
return above;
|
2001-06-23 23:18:10 -04:00
|
|
|
}
|
|
|
|
|
2019-07-04 07:03:40 -04:00
|
|
|
MetaWindow *
|
|
|
|
meta_stack_get_below (MetaStack *stack,
|
|
|
|
MetaWindow *window,
|
|
|
|
gboolean only_within_layer)
|
2001-06-23 23:18:10 -04:00
|
|
|
{
|
|
|
|
GList *link;
|
2002-09-28 12:33:39 -04:00
|
|
|
MetaWindow *below;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
stack_ensure_sorted (stack);
|
2001-06-23 23:18:10 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
link = g_list_find (stack->sorted, window);
|
2001-06-23 23:18:10 -04:00
|
|
|
|
|
|
|
if (link == NULL)
|
|
|
|
return NULL;
|
2002-09-28 12:33:39 -04:00
|
|
|
if (link->next == NULL)
|
|
|
|
return NULL;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
below = link->next->data;
|
2001-06-23 23:18:10 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
if (only_within_layer &&
|
|
|
|
below->layer != window->layer)
|
2002-05-28 23:11:24 -04:00
|
|
|
return NULL;
|
2001-06-23 23:18:10 -04:00
|
|
|
else
|
2002-09-28 12:33:39 -04:00
|
|
|
return below;
|
2003-01-21 23:54:04 -05:00
|
|
|
}
|
2002-01-03 18:28:19 -05:00
|
|
|
|
2003-01-21 23:54:04 -05:00
|
|
|
static gboolean
|
|
|
|
window_contains_point (MetaWindow *window,
|
|
|
|
int root_x,
|
|
|
|
int root_y)
|
|
|
|
{
|
|
|
|
MetaRectangle rect;
|
|
|
|
|
2013-11-19 12:24:45 -05:00
|
|
|
meta_window_get_frame_rect (window, &rect);
|
2003-01-21 23:54:04 -05:00
|
|
|
|
2019-10-02 14:23:41 -04:00
|
|
|
return META_POINT_IN_RECT (root_x, root_y, rect);
|
2003-01-21 23:54:04 -05:00
|
|
|
}
|
|
|
|
|
2019-07-03 12:48:07 -04:00
|
|
|
static gboolean
|
|
|
|
window_can_get_default_focus (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (window->unmaps_pending > 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (window->unmanaging)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!meta_window_is_focusable (window))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!meta_window_should_be_showing (window))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (window->type == META_WINDOW_DOCK)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-07-04 07:03:40 -04:00
|
|
|
static MetaWindow *
|
2003-01-21 23:54:04 -05:00
|
|
|
get_default_focus_window (MetaStack *stack,
|
|
|
|
MetaWorkspace *workspace,
|
|
|
|
MetaWindow *not_this_one,
|
|
|
|
gboolean must_be_at_point,
|
|
|
|
int root_x,
|
|
|
|
int root_y)
|
2002-01-03 18:28:19 -05:00
|
|
|
{
|
2002-09-27 23:50:49 -04:00
|
|
|
/* Find the topmost, focusable, mapped, window.
|
|
|
|
* not_this_one is being unfocused or going away, so exclude it.
|
|
|
|
*/
|
2002-01-03 18:28:19 -05:00
|
|
|
|
2014-03-18 10:17:34 -04:00
|
|
|
GList *l;
|
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
stack_ensure_sorted (stack);
|
2002-01-03 18:28:19 -05:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
/* top of this layer is at the front of the list */
|
2014-03-18 10:17:34 -04:00
|
|
|
for (l = stack->sorted; l != NULL; l = l->next)
|
2002-09-28 12:33:39 -04:00
|
|
|
{
|
2014-03-18 10:17:34 -04:00
|
|
|
MetaWindow *window = l->data;
|
2002-01-03 18:28:19 -05:00
|
|
|
|
2014-03-18 10:17:34 -04:00
|
|
|
if (!window)
|
|
|
|
continue;
|
2002-09-28 12:33:39 -04:00
|
|
|
|
2014-03-18 10:17:34 -04:00
|
|
|
if (window == not_this_one)
|
|
|
|
continue;
|
|
|
|
|
2019-07-03 12:48:07 -04:00
|
|
|
if (!window_can_get_default_focus (window))
|
2014-03-18 10:17:34 -04:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (must_be_at_point && !window_contains_point (window, root_x, root_y))
|
|
|
|
continue;
|
|
|
|
|
2015-07-05 17:31:17 -04:00
|
|
|
return window;
|
2002-01-03 18:28:19 -05:00
|
|
|
}
|
|
|
|
|
2015-07-05 17:31:17 -04:00
|
|
|
return NULL;
|
2001-06-23 23:18:10 -04:00
|
|
|
}
|
2001-06-23 23:41:44 -04:00
|
|
|
|
2019-07-04 07:03:40 -04:00
|
|
|
MetaWindow *
|
2003-01-21 23:54:04 -05:00
|
|
|
meta_stack_get_default_focus_window_at_point (MetaStack *stack,
|
|
|
|
MetaWorkspace *workspace,
|
|
|
|
MetaWindow *not_this_one,
|
|
|
|
int root_x,
|
|
|
|
int root_y)
|
|
|
|
{
|
|
|
|
return get_default_focus_window (stack, workspace, not_this_one,
|
|
|
|
TRUE, root_x, root_y);
|
|
|
|
}
|
|
|
|
|
2019-07-04 07:03:40 -04:00
|
|
|
MetaWindow *
|
2003-01-21 23:54:04 -05:00
|
|
|
meta_stack_get_default_focus_window (MetaStack *stack,
|
|
|
|
MetaWorkspace *workspace,
|
|
|
|
MetaWindow *not_this_one)
|
|
|
|
{
|
|
|
|
return get_default_focus_window (stack, workspace, not_this_one,
|
|
|
|
FALSE, 0, 0);
|
|
|
|
}
|
|
|
|
|
2019-07-04 07:03:40 -04:00
|
|
|
GList *
|
2002-07-06 15:05:37 -04:00
|
|
|
meta_stack_list_windows (MetaStack *stack,
|
|
|
|
MetaWorkspace *workspace)
|
|
|
|
{
|
|
|
|
GList *workspace_windows = NULL;
|
2002-09-28 12:33:39 -04:00
|
|
|
GList *link;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
stack_ensure_sorted (stack); /* do adds/removes */
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
link = stack->sorted;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
while (link)
|
2002-07-06 15:05:37 -04:00
|
|
|
{
|
2002-09-28 12:33:39 -04:00
|
|
|
MetaWindow *window = link->data;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
if (window &&
|
2004-12-22 19:20:33 -05:00
|
|
|
(workspace == NULL || meta_window_located_on_workspace (window, workspace)))
|
2002-07-06 15:05:37 -04:00
|
|
|
{
|
2002-09-28 12:33:39 -04:00
|
|
|
workspace_windows = g_list_prepend (workspace_windows,
|
|
|
|
window);
|
2002-07-06 15:05:37 -04:00
|
|
|
}
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
link = link->next;
|
2002-07-06 15:05:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return workspace_windows;
|
|
|
|
}
|
|
|
|
|
2019-07-03 12:48:07 -04:00
|
|
|
GList *
|
|
|
|
meta_stack_get_default_focus_candidates (MetaStack *stack,
|
|
|
|
MetaWorkspace *workspace)
|
|
|
|
{
|
|
|
|
GList *windows = meta_stack_list_windows (stack, workspace);
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = windows; l;)
|
|
|
|
{
|
|
|
|
GList *next = l->next;
|
|
|
|
|
|
|
|
if (!window_can_get_default_focus (l->data))
|
|
|
|
windows = g_list_delete_link (windows, l);
|
|
|
|
|
|
|
|
l = next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return windows;
|
|
|
|
}
|
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
int
|
2019-07-04 07:03:40 -04:00
|
|
|
meta_stack_windows_cmp (MetaStack *stack,
|
|
|
|
MetaWindow *window_a,
|
|
|
|
MetaWindow *window_b)
|
2001-06-24 04:09:10 -04:00
|
|
|
{
|
|
|
|
/* -1 means a below b */
|
2002-09-28 12:33:39 -04:00
|
|
|
|
2008-06-26 23:39:15 -04:00
|
|
|
stack_ensure_sorted (stack); /* update constraints, layers */
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
if (window_a->layer < window_b->layer)
|
|
|
|
return -1;
|
|
|
|
else if (window_a->layer > window_b->layer)
|
|
|
|
return 1;
|
2002-09-28 12:33:39 -04:00
|
|
|
else if (window_a->stack_position < window_b->stack_position)
|
|
|
|
return -1;
|
|
|
|
else if (window_a->stack_position > window_b->stack_position)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0; /* not reached */
|
|
|
|
}
|
|
|
|
|
2005-01-24 00:58:30 -05:00
|
|
|
static int
|
|
|
|
compare_just_window_stack_position (void *a,
|
|
|
|
void *b)
|
|
|
|
{
|
|
|
|
MetaWindow *window_a = a;
|
|
|
|
MetaWindow *window_b = b;
|
|
|
|
|
|
|
|
if (window_a->stack_position < window_b->stack_position)
|
|
|
|
return -1; /* move window_a earlier in list */
|
|
|
|
else if (window_a->stack_position > window_b->stack_position)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0; /* not reached */
|
|
|
|
}
|
|
|
|
|
2019-07-04 07:03:40 -04:00
|
|
|
GList *
|
2005-01-24 00:58:30 -05:00
|
|
|
meta_stack_get_positions (MetaStack *stack)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
|
|
|
|
/* Make sure to handle any adds or removes */
|
2008-06-26 23:39:15 -04:00
|
|
|
stack_ensure_sorted (stack);
|
2005-01-24 00:58:30 -05:00
|
|
|
|
|
|
|
tmp = g_list_copy (stack->sorted);
|
|
|
|
tmp = g_list_sort (tmp, (GCompareFunc) compare_just_window_stack_position);
|
|
|
|
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2005-01-27 13:28:06 -05:00
|
|
|
static gint
|
2005-01-24 00:58:30 -05:00
|
|
|
compare_pointers (gconstpointer a,
|
|
|
|
gconstpointer b)
|
|
|
|
{
|
|
|
|
if (a > b)
|
|
|
|
return 1;
|
|
|
|
else if (a < b)
|
|
|
|
return -1;
|
2014-05-02 09:34:02 -04:00
|
|
|
else
|
2005-01-24 00:58:30 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
lists_contain_same_windows (GList *a,
|
|
|
|
GList *b)
|
|
|
|
{
|
|
|
|
GList *copy1, *copy2;
|
|
|
|
GList *tmp1, *tmp2;
|
|
|
|
|
|
|
|
if (g_list_length (a) != g_list_length (b))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
tmp1 = copy1 = g_list_sort (g_list_copy (a), compare_pointers);
|
|
|
|
tmp2 = copy2 = g_list_sort (g_list_copy (b), compare_pointers);
|
|
|
|
|
|
|
|
while (tmp1 && tmp1->data == tmp2->data) /* tmp2 is non-NULL if tmp1 is */
|
|
|
|
{
|
|
|
|
tmp1 = tmp1->next;
|
|
|
|
tmp2 = tmp2->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (copy1);
|
|
|
|
g_list_free (copy2);
|
|
|
|
|
|
|
|
return (tmp1 == NULL); /* tmp2 is non-NULL if tmp1 is */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_stack_set_positions (MetaStack *stack,
|
|
|
|
GList *windows)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
GList *tmp;
|
|
|
|
|
|
|
|
/* Make sure any adds or removes aren't in limbo -- is this needed? */
|
2008-06-26 23:39:15 -04:00
|
|
|
stack_ensure_sorted (stack);
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2005-01-24 00:58:30 -05:00
|
|
|
if (!lists_contain_same_windows (windows, stack->sorted))
|
|
|
|
{
|
|
|
|
meta_warning ("This list of windows has somehow changed; not resetting "
|
2020-10-02 11:47:22 -04:00
|
|
|
"positions of the windows.");
|
2005-01-24 00:58:30 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (stack->sorted);
|
|
|
|
stack->sorted = g_list_copy (windows);
|
|
|
|
|
|
|
|
stack->need_resort = TRUE;
|
|
|
|
stack->need_constrain = TRUE;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2005-01-24 00:58:30 -05:00
|
|
|
i = 0;
|
|
|
|
tmp = windows;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
MetaWindow *w = tmp->data;
|
|
|
|
w->stack_position = i++;
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2005-01-24 00:58:30 -05:00
|
|
|
meta_topic (META_DEBUG_STACK,
|
2020-10-02 11:47:22 -04:00
|
|
|
"Reset the stack positions of (nearly) all windows");
|
2005-01-24 00:58:30 -05:00
|
|
|
|
2019-05-06 13:25:21 -04:00
|
|
|
meta_stack_changed (stack);
|
2016-01-10 09:16:09 -05:00
|
|
|
meta_stack_update_window_tile_matches (stack, NULL);
|
2005-01-24 00:58:30 -05:00
|
|
|
}
|
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
void
|
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
|
|
|
meta_window_set_stack_position_no_sync (MetaWindow *window,
|
|
|
|
int position)
|
2002-09-28 12:33:39 -04:00
|
|
|
{
|
|
|
|
int low, high, delta;
|
|
|
|
GList *tmp;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2017-08-26 13:03:51 -04:00
|
|
|
g_return_if_fail (window->display->stack != NULL);
|
2002-09-28 12:33:39 -04:00
|
|
|
g_return_if_fail (window->stack_position >= 0);
|
|
|
|
g_return_if_fail (position >= 0);
|
2017-08-26 13:03:51 -04:00
|
|
|
g_return_if_fail (position < window->display->stack->n_positions);
|
2002-09-28 12:33:39 -04:00
|
|
|
|
|
|
|
if (position == window->stack_position)
|
|
|
|
{
|
2020-10-02 11:47:22 -04:00
|
|
|
meta_topic (META_DEBUG_STACK, "Window %s already has position %d",
|
2002-09-28 12:33:39 -04:00
|
|
|
window->desc, position);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-26 13:03:51 -04:00
|
|
|
window->display->stack->need_resort = TRUE;
|
|
|
|
window->display->stack->need_constrain = TRUE;
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
if (position < window->stack_position)
|
|
|
|
{
|
|
|
|
low = position;
|
|
|
|
high = window->stack_position - 1;
|
|
|
|
delta = 1;
|
|
|
|
}
|
2001-06-24 04:09:10 -04:00
|
|
|
else
|
|
|
|
{
|
2002-09-28 12:33:39 -04:00
|
|
|
low = window->stack_position + 1;
|
|
|
|
high = position;
|
|
|
|
delta = -1;
|
|
|
|
}
|
2001-06-24 04:09:10 -04:00
|
|
|
|
2017-08-26 13:03:51 -04:00
|
|
|
tmp = window->display->stack->sorted;
|
2002-09-28 12:33:39 -04:00
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
MetaWindow *w = tmp->data;
|
2001-06-24 04:09:10 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
if (w->stack_position >= low &&
|
|
|
|
w->stack_position <= high)
|
|
|
|
w->stack_position += delta;
|
2001-06-24 04:09:10 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
tmp = tmp->next;
|
2001-06-24 04:09:10 -04:00
|
|
|
}
|
2014-05-02 09:34:02 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
window->stack_position = position;
|
2001-06-24 04:09:10 -04:00
|
|
|
|
2002-09-28 12:33:39 -04:00
|
|
|
meta_topic (META_DEBUG_STACK,
|
2020-10-02 11:47:22 -04:00
|
|
|
"Window %s had stack_position set to %d",
|
2002-09-28 12:33:39 -04:00
|
|
|
window->desc, window->stack_position);
|
2001-06-24 04:09:10 -04:00
|
|
|
}
|
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_set_stack_position (MetaWindow *window,
|
|
|
|
int position)
|
|
|
|
{
|
2017-08-27 15:02:40 -04:00
|
|
|
MetaWorkspaceManager *workspace_manager = window->display->workspace_manager;
|
|
|
|
|
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
|
|
|
meta_window_set_stack_position_no_sync (window, position);
|
2019-05-06 13:25:21 -04:00
|
|
|
meta_stack_changed (window->display->stack);
|
2017-08-26 13:03:51 -04:00
|
|
|
meta_stack_update_window_tile_matches (window->display->stack,
|
2017-08-27 15:02:40 -04:00
|
|
|
workspace_manager->active_workspace);
|
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
|
|
|
}
|