2006-10-01 22:30:10 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
2014-05-02 13:34:02 +00:00
|
|
|
/*
|
2001-06-10 07:52:35 +00:00
|
|
|
* Copyright (C) 2001 Havoc Pennington
|
2005-10-08 19:38:54 +00:00
|
|
|
* Copyright (C) 2005 Elijah Newren
|
2014-05-02 13:34:02 +00:00
|
|
|
*
|
2001-06-10 07:52:35 +00: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 13:34:02 +00:00
|
|
|
*
|
2001-06-10 07:52:35 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-12 01:42:06 +00:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2001-06-10 07:52:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef META_STACK_H
|
|
|
|
#define META_STACK_H
|
|
|
|
|
2011-11-02 15:34:45 +00:00
|
|
|
/**
|
2023-03-28 14:35:11 +00:00
|
|
|
* stack:
|
2023-05-23 18:25:54 +00:00
|
|
|
*
|
2023-03-28 14:35:11 +00:00
|
|
|
* Which windows cover which other windows
|
2011-11-02 15:34:45 +00:00
|
|
|
*
|
|
|
|
* There are two factors that determine window position.
|
2014-05-02 13:34:02 +00:00
|
|
|
*
|
2011-11-02 15:34:45 +00:00
|
|
|
* One is window->stack_position, which is a unique integer
|
|
|
|
* indicating how windows are ordered with respect to one
|
|
|
|
* another. The ordering here transcends layers; it isn't changed
|
|
|
|
* as the window is moved among layers. This allows us to move several
|
|
|
|
* windows from one layer to another, while preserving the relative
|
|
|
|
* order of the moved windows. Also, it allows us to restore
|
|
|
|
* the stacking order from a saved session.
|
2014-05-02 13:34:02 +00:00
|
|
|
*
|
2011-11-02 15:34:45 +00:00
|
|
|
* However when actually stacking windows on the screen, the
|
|
|
|
* layer overrides the stack_position; windows are first sorted
|
|
|
|
* by layer, then by stack_position within each layer.
|
|
|
|
*/
|
|
|
|
|
2018-07-10 08:36:24 +00:00
|
|
|
#include "core/display-private.h"
|
2001-06-10 07:52:35 +00:00
|
|
|
|
2008-06-28 02:51:18 +00:00
|
|
|
/**
|
|
|
|
* A sorted list of windows bearing some level of resemblance to the stack of
|
|
|
|
* windows on the X server.
|
|
|
|
*
|
|
|
|
* (This is only used as a field within a MetaScreen; we treat it as a separate
|
|
|
|
* class for simplicity.)
|
|
|
|
*/
|
2001-06-10 07:52:35 +00:00
|
|
|
struct _MetaStack
|
|
|
|
{
|
2019-05-06 17:25:21 +00:00
|
|
|
GObject parent;
|
|
|
|
|
2017-08-26 17:03:51 +00:00
|
|
|
/** The MetaDisplay containing this stack. */
|
|
|
|
MetaDisplay *display;
|
2001-06-10 07:52:35 +00:00
|
|
|
|
2008-06-28 02:51:18 +00:00
|
|
|
/** The MetaWindows of the windows we manage, sorted in order. */
|
2002-09-28 16:33:39 +00:00
|
|
|
GList *sorted;
|
2008-06-28 02:51:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If this is zero, the local stack oughtn't to be brought up to date with
|
|
|
|
* the X server's stack, because it is in the middle of being updated.
|
|
|
|
* If it is positive, the local stack is said to be "frozen", and will need
|
|
|
|
* to be thawed that many times before the stack can be brought up to date
|
|
|
|
* again. You may freeze the stack with meta_stack_freeze() and thaw it
|
|
|
|
* with meta_stack_thaw().
|
|
|
|
*/
|
2001-06-10 07:52:35 +00:00
|
|
|
int freeze_count;
|
|
|
|
|
2008-06-28 02:51:18 +00:00
|
|
|
/**
|
|
|
|
* The last-known stack of all windows, bottom to top. We cache it here
|
|
|
|
* so that subsequent times we'll be able to do incremental moves.
|
|
|
|
*/
|
2012-04-05 10:22:13 +00:00
|
|
|
GArray *last_all_root_children_stacked;
|
2002-09-28 16:33:39 +00:00
|
|
|
|
2008-06-28 02:51:18 +00:00
|
|
|
/**
|
|
|
|
* Number of stack positions; same as the length of added, but
|
|
|
|
* kept for quick reference.
|
|
|
|
*/
|
|
|
|
gint n_positions;
|
2002-09-28 16:33:39 +00:00
|
|
|
|
2008-06-28 02:51:18 +00:00
|
|
|
/** Is the stack in need of re-sorting? */
|
2002-09-28 16:33:39 +00:00
|
|
|
unsigned int need_resort : 1;
|
2008-06-28 02:51:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Are the windows in the stack in need of having their
|
|
|
|
* layers recalculated?
|
|
|
|
*/
|
2002-09-28 16:33:39 +00:00
|
|
|
unsigned int need_relayer : 1;
|
2008-06-28 02:51:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Are the windows in the stack in need of having their positions
|
|
|
|
* recalculated with respect to transiency (parent and child windows)?
|
|
|
|
*/
|
2002-09-28 16:33:39 +00:00
|
|
|
unsigned int need_constrain : 1;
|
2001-06-10 07:52:35 +00:00
|
|
|
};
|
|
|
|
|
2019-05-06 17:25:21 +00:00
|
|
|
#define META_TYPE_STACK (meta_stack_get_type ())
|
|
|
|
G_DECLARE_FINAL_TYPE (MetaStack, meta_stack, META, STACK, GObject)
|
|
|
|
|
2008-06-28 02:51:18 +00:00
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_new:
|
2017-08-26 17:03:51 +00:00
|
|
|
* @display: The MetaDisplay which will be the parent of this stack.
|
2011-11-02 15:34:45 +00:00
|
|
|
*
|
2008-06-28 02:51:18 +00:00
|
|
|
* Creates and initialises a MetaStack.
|
|
|
|
*
|
2017-08-26 17:03:51 +00:00
|
|
|
* Returns: The new stack.
|
2008-06-28 02:51:18 +00:00
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
MetaStack * meta_stack_new (MetaDisplay *display);
|
2008-06-28 02:51:18 +00:00
|
|
|
|
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_add:
|
|
|
|
* @stack: The stack to add it to
|
|
|
|
* @window: The window to add
|
|
|
|
*
|
2008-06-28 02:51:18 +00:00
|
|
|
* Adds a window to the local stack. It is a fatal error to call this
|
|
|
|
* function on a window which already exists on the stack of any screen.
|
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
void meta_stack_add (MetaStack *stack,
|
|
|
|
MetaWindow *window);
|
2008-06-28 02:51:18 +00:00
|
|
|
|
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_remove:
|
|
|
|
* @stack: The stack to remove it from
|
|
|
|
* @window: The window to remove
|
|
|
|
*
|
2008-06-28 02:51:18 +00:00
|
|
|
* Removes a window from the local stack. It is a fatal error to call this
|
|
|
|
* function on a window which exists on the stack of any screen.
|
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
void meta_stack_remove (MetaStack *stack,
|
|
|
|
MetaWindow *window);
|
2008-06-28 02:51:18 +00:00
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_update_layer:
|
|
|
|
* @stack: The stack to recalculate
|
|
|
|
* @window: Dummy parameter
|
|
|
|
*
|
2008-06-28 02:51:18 +00:00
|
|
|
* Recalculates the correct layer for all windows in the stack,
|
|
|
|
* and moves them about accordingly.
|
|
|
|
*
|
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
void meta_stack_update_layer (MetaStack *stack,
|
|
|
|
MetaWindow *window);
|
2008-06-28 02:51:18 +00:00
|
|
|
|
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_update_transient:
|
|
|
|
* @stack: The stack to recalculate
|
|
|
|
* @window: Dummy parameter
|
|
|
|
*
|
2008-06-28 02:51:18 +00:00
|
|
|
* Recalculates the correct stacking order for all windows in the stack
|
|
|
|
* according to their transience, and moves them about accordingly.
|
|
|
|
*
|
2011-11-02 15:34:45 +00:00
|
|
|
* FIXME: What's with the dummy parameter?
|
2008-06-28 02:51:18 +00:00
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
void meta_stack_update_transient (MetaStack *stack,
|
|
|
|
MetaWindow *window);
|
2001-06-10 07:52:35 +00:00
|
|
|
|
2008-06-28 02:51:18 +00:00
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_raise:
|
|
|
|
* @stack: The stack to modify.
|
|
|
|
* @window: The window that's making an ascension.
|
|
|
|
* (Amulet of Yendor not required.)
|
2008-06-28 02:51:18 +00:00
|
|
|
*
|
2011-11-02 15:34:45 +00:00
|
|
|
* Move a window to the top of its layer.
|
2008-06-28 02:51:18 +00:00
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
void meta_stack_raise (MetaStack *stack,
|
|
|
|
MetaWindow *window);
|
2008-06-28 02:51:18 +00:00
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_lower:
|
|
|
|
* @stack: The stack to modify.
|
|
|
|
* @window: The window that's on the way downwards.
|
2008-06-28 02:51:18 +00:00
|
|
|
*
|
2011-11-02 15:34:45 +00:00
|
|
|
* Move a window to the bottom of its layer.
|
2008-06-28 02:51:18 +00:00
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
void meta_stack_lower (MetaStack *stack,
|
|
|
|
MetaWindow *window);
|
2001-06-10 07:52:35 +00:00
|
|
|
|
2008-06-28 02:51:18 +00:00
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_freeze:
|
|
|
|
* @stack: The stack to freeze.
|
|
|
|
*
|
2008-06-28 02:51:18 +00:00
|
|
|
* Prevent syncing to server until the next call of meta_stack_thaw(),
|
|
|
|
* so that we can carry out multiple operations in one go without having
|
|
|
|
* everything halfway reflected on the X server.
|
|
|
|
*
|
|
|
|
* (Calls to meta_stack_freeze() nest, so that multiple calls to
|
|
|
|
* meta_stack_freeze will require multiple calls to meta_stack_thaw().)
|
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
void meta_stack_freeze (MetaStack *stack);
|
2008-06-28 02:51:18 +00:00
|
|
|
|
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_thaw:
|
|
|
|
* @stack: The stack to thaw.
|
|
|
|
*
|
2008-06-28 02:51:18 +00:00
|
|
|
* Undoes a meta_stack_freeze(), and processes anything which has become
|
|
|
|
* necessary during the freeze. It is an error to call this function if
|
|
|
|
* the stack has not been frozen.
|
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
void meta_stack_thaw (MetaStack *stack);
|
2001-06-10 07:52:35 +00:00
|
|
|
|
2008-06-28 02:51:18 +00:00
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_get_top:
|
|
|
|
* @stack: The stack to examine.
|
|
|
|
*
|
2008-06-28 02:51:18 +00:00
|
|
|
* Finds the top window on the stack.
|
|
|
|
*
|
2011-11-02 15:34:45 +00:00
|
|
|
* Returns: The top window on the stack, or %NULL in the vanishingly unlikely
|
|
|
|
* event that you have no windows on your screen whatsoever.
|
2008-06-28 02:51:18 +00:00
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
MetaWindow * meta_stack_get_top (MetaStack *stack);
|
2008-06-28 02:51:18 +00:00
|
|
|
|
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_get_bottom:
|
|
|
|
* @stack: The stack to search
|
|
|
|
*
|
2008-06-28 02:51:18 +00:00
|
|
|
* Finds the window at the bottom of the stack. Since that's pretty much
|
|
|
|
* always the desktop, this isn't the most useful of functions, and nobody
|
|
|
|
* actually calls it. We should probably get rid of it.
|
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
MetaWindow * meta_stack_get_bottom (MetaStack *stack);
|
2008-06-28 02:51:18 +00:00
|
|
|
|
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_get_above:
|
|
|
|
* @stack: The stack to search.
|
|
|
|
* @window: The window to look above.
|
|
|
|
* @only_within_layer: If %TRUE, will return %NULL if @window is the
|
|
|
|
* top window in its layer.
|
|
|
|
*
|
2008-06-28 02:51:18 +00:00
|
|
|
* Finds the window above a given window in the stack.
|
|
|
|
* It is not an error to pass in a window which does not exist in
|
2011-11-02 15:34:45 +00:00
|
|
|
* the stack; the function will merely return %NULL.
|
|
|
|
*
|
|
|
|
* Returns: %NULL if there is no such window;
|
|
|
|
* the window above @window otherwise.
|
2008-06-28 02:51:18 +00:00
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
MetaWindow * meta_stack_get_above (MetaStack *stack,
|
2002-05-29 03:11:24 +00:00
|
|
|
MetaWindow *window,
|
|
|
|
gboolean only_within_layer);
|
2008-06-28 02:51:18 +00:00
|
|
|
|
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_get_below:
|
|
|
|
* @stack: The stack to search.
|
|
|
|
* @window: The window to look below.
|
|
|
|
* @only_within_layer: If %TRUE, will return %NULL if window is the
|
|
|
|
* bottom window in its layer.
|
|
|
|
*
|
2008-06-28 02:51:18 +00:00
|
|
|
* Finds the window below a given window in the stack.
|
|
|
|
* It is not an error to pass in a window which does not exist in
|
2011-11-02 15:34:45 +00:00
|
|
|
* the stack; the function will merely return %NULL.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Returns: %NULL if there is no such window;
|
|
|
|
* the window below @window otherwise.
|
2008-06-28 02:51:18 +00:00
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
MetaWindow * meta_stack_get_below (MetaStack *stack,
|
2002-05-29 03:11:24 +00:00
|
|
|
MetaWindow *window,
|
|
|
|
gboolean only_within_layer);
|
2003-01-22 04:54:04 +00:00
|
|
|
|
2008-06-28 02:51:18 +00:00
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_list_windows:
|
|
|
|
* @stack: The stack to examine.
|
|
|
|
* @workspace: If not %NULL, only windows on this workspace will be
|
|
|
|
* returned; otherwise all windows in the stack will be
|
|
|
|
* returned.
|
|
|
|
*
|
2008-06-28 02:51:18 +00:00
|
|
|
* Finds all the windows in the stack, in order.
|
|
|
|
*
|
2019-07-04 11:03:40 +00:00
|
|
|
* Returns: (transfer container) (element-type Meta.Window):
|
|
|
|
* A list of windows, in stacking order, honouring layers.
|
2008-06-28 02:51:18 +00:00
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
GList * meta_stack_list_windows (MetaStack *stack,
|
|
|
|
MetaWorkspace *workspace);
|
2001-06-24 03:18:10 +00:00
|
|
|
|
2008-06-28 02:51:18 +00:00
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_windows_cmp:
|
|
|
|
* @stack: A stack containing both window_a and window_b
|
|
|
|
* @window_a: A window
|
|
|
|
* @window_b Another window
|
|
|
|
*
|
2008-06-28 02:51:18 +00:00
|
|
|
* Comparison function for windows within a stack. This is not directly
|
|
|
|
* suitable for use within a standard comparison routine, because it takes
|
|
|
|
* an extra parameter; you will need to wrap it.
|
|
|
|
*
|
|
|
|
* (FIXME: We could remove the stack parameter and use the stack of
|
|
|
|
* the screen of window A, and complain if the stack of the screen of
|
|
|
|
* window B differed; then this would be a usable general comparison function.)
|
|
|
|
*
|
|
|
|
* (FIXME: Apparently identical to compare_window_position(). Merge them.)
|
|
|
|
*
|
|
|
|
* \return -1 if window_a is below window_b, honouring layers; 1 if it's
|
|
|
|
* above it; 0 if you passed in the same window twice!
|
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
int meta_stack_windows_cmp (MetaStack *stack,
|
|
|
|
MetaWindow *window_a,
|
|
|
|
MetaWindow *window_b);
|
2001-06-24 03:18:10 +00:00
|
|
|
|
2008-06-28 02:51:18 +00:00
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_window_set_stack_position:
|
|
|
|
* @window: The window which is moving.
|
|
|
|
* @position: Where it should move to (0 is the bottom).
|
|
|
|
*
|
2008-06-28 02:51:18 +00:00
|
|
|
* Sets the position of a window within the stack. This will only move it
|
|
|
|
* up or down within its layer. It is an error to attempt to move this
|
|
|
|
* below position zero or above the last position in the stack (however, since
|
|
|
|
* we don't provide a simple way to tell the number of windows in the stack,
|
|
|
|
* this requirement may not be easy to fulfil).
|
|
|
|
*/
|
2002-09-28 16:33:39 +00:00
|
|
|
void meta_window_set_stack_position (MetaWindow *window,
|
|
|
|
int position);
|
|
|
|
|
2008-06-28 02:51:18 +00:00
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_get_positions:
|
|
|
|
* @stack: The stack to examine.
|
|
|
|
*
|
2008-06-28 02:51:18 +00:00
|
|
|
* Returns the current stack state, allowing rudimentary transactions.
|
|
|
|
*
|
2019-07-04 11:03:40 +00:00
|
|
|
* Returns: (transfer container) (element-type Meta.Window):
|
|
|
|
* An opaque #GList representing the current stack sort order;
|
2011-11-02 15:34:45 +00:00
|
|
|
* it is the caller's responsibility to free it.
|
|
|
|
* Pass this to meta_stack_set_positions() later if you want to restore
|
|
|
|
* the state to where it was when you called this function.
|
2008-06-28 02:51:18 +00:00
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
GList * meta_stack_get_positions (MetaStack *stack);
|
2008-06-28 02:51:18 +00:00
|
|
|
|
|
|
|
/**
|
2011-11-02 15:34:45 +00:00
|
|
|
* meta_stack_set_positions:
|
|
|
|
* @stack: The stack to roll back.
|
|
|
|
* @windows: The list returned from meta_stack_get_positions().
|
|
|
|
*
|
2008-06-28 02:51:18 +00:00
|
|
|
* Rolls back a transaction, given the list returned from
|
|
|
|
* meta_stack_get_positions().
|
|
|
|
*
|
|
|
|
*/
|
2019-07-04 11:03:40 +00:00
|
|
|
void meta_stack_set_positions (MetaStack *stack,
|
|
|
|
GList *windows);
|
2005-01-24 05:58:30 +00:00
|
|
|
|
2016-01-10 14:16:09 +00:00
|
|
|
void meta_stack_update_window_tile_matches (MetaStack *stack,
|
|
|
|
MetaWorkspace *workspace);
|
2022-07-11 22:45:43 +00:00
|
|
|
|
2001-06-10 07:52:35 +00:00
|
|
|
#endif
|