mutter/src/core/screen.c

1459 lines
39 KiB
C
Raw Normal View History

/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2014-05-02 13:34:02 +00:00
/*
* Copyright (C) 2001, 2002 Havoc Pennington
* Copyright (C) 2002, 2003 Red Hat Inc.
* Some ICCCM manager selection code derived from fvwm2,
* Copyright (C) 2001 Dominik Vogt, Matthias Clasen, and fvwm2 team
* Copyright (C) 2003 Rob Adams
* Copyright (C) 2004-2006 Elijah Newren
2014-05-02 13:34:02 +00:00
*
2001-05-30 15:36:31 +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-05-30 15:36:31 +00:00
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
2001-05-30 15:36:31 +00:00
*/
2001-05-31 06:42:58 +00:00
/**
* SECTION:screen
* @title: MetaScreen
* @short_description: Mutter X screen handler
*/
#include <config.h>
#include "screen-private.h"
#include <meta/main.h>
#include "util-private.h"
#include <meta/errors.h>
#include "window-private.h"
#include "frame.h"
#include <meta/prefs.h>
#include "workspace-private.h"
#include "keybindings-private.h"
2001-06-10 18:46:46 +00:00
#include "stack.h"
#include <meta/compositor.h>
2015-07-06 04:58:45 +00:00
#include <meta/meta-enum-types.h>
2013-02-07 23:20:03 +00:00
#include "core.h"
#include "meta-cursor-tracker-private.h"
Support scaling of cursor sprites given what output they are on This commits refactors cursor handling code and plugs in logic so that cursor sprites changes appearance as it moves across the screen. Renderers are adapted to handle the necessary functionality. The logic for changing the cursor sprite appearance is done outside of MetaCursorSprite, and actually where depends on what type of cursor it is. In mutter we now have two types of cursors that may have their appearance changed: - Themed cursors (aka root cursors) - wl_surface cursors Themed cursors are created by MetaScreen and when created, when applicable(*), it will extend the cursor via connecting to a signal which is emitted everytime the cursor is moved. The signal handler will calculate the expected scale given the monitor it is on and reload the theme in a correct size when needed. wl_surface cursors are created when a wl_surface is assigned the "cursor" role, i.e. when a client calls wl_pointer.set_cursor. A cursor role object is created which is connected to the cursor object by the position signal, and will set a correct texture scale given what monitor the cursor is on and what scale the wl_surface's active buffer is in. It will also push new buffers to the same to the cursor object when new ones are committed to the surface. This commit also makes texture loading lazy, since the renderer doesn't calculate a rectangle when the cursor position changes. The native backend is refactored to be triple-buffered; see the comment in meta-cursor-renderer-native.c for further explanations. * when we are running as a Wayland compositor https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-07-17 15:16:39 +00:00
#include "boxes-private.h"
#include "backends/meta-backend-private.h"
#include "backends/meta-logical-monitor.h"
2001-06-01 03:00:01 +00:00
#include <X11/extensions/Xinerama.h>
#include <X11/extensions/Xcomposite.h>
2001-06-10 03:17:15 +00:00
#include <X11/Xatom.h>
2001-06-01 03:00:01 +00:00
#include <locale.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
2001-05-30 15:36:31 +00:00
#include "x11/meta-x11-display-private.h"
#include "x11/window-x11.h"
#include "x11/xprops.h"
#include "backends/x11/meta-backend-x11.h"
#include "backends/meta-cursor-sprite-xcursor.h"
static void update_num_workspaces (MetaScreen *screen,
guint32 timestamp);
static void set_workspace_names (MetaScreen *screen);
static void prefs_changed_callback (MetaPreference pref,
gpointer data);
2001-06-03 01:33:27 +00:00
enum
{
PROP_N_WORKSPACES = 1,
};
enum
{
WORKSPACE_ADDED,
WORKSPACE_REMOVED,
WORKSPACE_SWITCHED,
LAST_SIGNAL
};
static guint screen_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (MetaScreen, meta_screen, G_TYPE_OBJECT);
static GQuark quark_screen_x11_logical_monitor_data = 0;
typedef struct _MetaScreenX11LogicalMonitorData
{
int xinerama_index;
} MetaScreenX11LogicalMonitorData;
static void
meta_screen_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
#if 0
MetaScreen *screen = META_SCREEN (object);
#endif
switch (prop_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
meta_screen_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
MetaScreen *screen = META_SCREEN (object);
switch (prop_id)
{
case PROP_N_WORKSPACES:
g_value_set_int (value, meta_screen_get_n_workspaces (screen));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
meta_screen_finalize (GObject *object)
{
/* Actual freeing done in meta_screen_free() for now */
}
static void
meta_screen_class_init (MetaScreenClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GParamSpec *pspec;
object_class->get_property = meta_screen_get_property;
object_class->set_property = meta_screen_set_property;
object_class->finalize = meta_screen_finalize;
pspec = g_param_spec_int ("n-workspaces",
"N Workspaces",
"Number of workspaces",
1, G_MAXINT, 1,
G_PARAM_READABLE);
screen_signals[WORKSPACE_ADDED] =
g_signal_new ("workspace-added",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE,
1,
G_TYPE_INT);
screen_signals[WORKSPACE_REMOVED] =
g_signal_new ("workspace-removed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE,
1,
G_TYPE_INT);
screen_signals[WORKSPACE_SWITCHED] =
g_signal_new ("workspace-switched",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE,
3,
G_TYPE_INT,
G_TYPE_INT,
META_TYPE_MOTION_DIRECTION);
g_object_class_install_property (object_class,
PROP_N_WORKSPACES,
pspec);
quark_screen_x11_logical_monitor_data =
g_quark_from_static_string ("-meta-screen-logical-monitor-x11-data");
}
static void
meta_screen_init (MetaScreen *screen)
{
}
static MetaScreenX11LogicalMonitorData *
get_screen_x11_logical_monitor_data (MetaLogicalMonitor *logical_monitor)
{
return g_object_get_qdata (G_OBJECT (logical_monitor),
quark_screen_x11_logical_monitor_data);
}
static MetaScreenX11LogicalMonitorData *
ensure_screen_x11_logical_monitor_data (MetaLogicalMonitor *logical_monitor)
{
MetaScreenX11LogicalMonitorData *data;
data = get_screen_x11_logical_monitor_data (logical_monitor);
if (data)
return data;
data = g_new0 (MetaScreenX11LogicalMonitorData, 1);
g_object_set_qdata_full (G_OBJECT (logical_monitor),
quark_screen_x11_logical_monitor_data,
data,
g_free);
return data;
}
static void
meta_screen_ensure_xinerama_indices (MetaScreen *screen)
{
MetaBackend *backend = meta_get_backend ();
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
GList *logical_monitors, *l;
XineramaScreenInfo *infos;
int n_infos, j;
if (screen->has_xinerama_indices)
return;
screen->has_xinerama_indices = TRUE;
if (!XineramaIsActive (screen->display->x11_display->xdisplay))
return;
infos = XineramaQueryScreens (screen->display->x11_display->xdisplay,
&n_infos);
if (n_infos <= 0 || infos == NULL)
{
meta_XFree (infos);
return;
}
logical_monitors =
meta_monitor_manager_get_logical_monitors (monitor_manager);
for (l = logical_monitors; l; l = l->next)
{
MetaLogicalMonitor *logical_monitor = l->data;
for (j = 0; j < n_infos; ++j)
{
if (logical_monitor->rect.x == infos[j].x_org &&
logical_monitor->rect.y == infos[j].y_org &&
logical_monitor->rect.width == infos[j].width &&
logical_monitor->rect.height == infos[j].height)
{
MetaScreenX11LogicalMonitorData *logical_monitor_data;
logical_monitor_data =
ensure_screen_x11_logical_monitor_data (logical_monitor);
logical_monitor_data->xinerama_index = j;
}
}
}
meta_XFree (infos);
}
int
meta_screen_logical_monitor_to_xinerama_index (MetaScreen *screen,
MetaLogicalMonitor *logical_monitor)
{
MetaScreenX11LogicalMonitorData *logical_monitor_data;
g_return_val_if_fail (logical_monitor, -1);
meta_screen_ensure_xinerama_indices (screen);
logical_monitor_data = get_screen_x11_logical_monitor_data (logical_monitor);
return logical_monitor_data->xinerama_index;
}
MetaLogicalMonitor *
meta_screen_xinerama_index_to_logical_monitor (MetaScreen *screen,
int xinerama_index)
{
MetaBackend *backend = meta_get_backend ();
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
GList *logical_monitors, *l;
meta_screen_ensure_xinerama_indices (screen);
logical_monitors =
meta_monitor_manager_get_logical_monitors (monitor_manager);
for (l = logical_monitors; l; l = l->next)
{
MetaLogicalMonitor *logical_monitor = l->data;
MetaScreenX11LogicalMonitorData *logical_monitor_data;
logical_monitor_data =
ensure_screen_x11_logical_monitor_data (logical_monitor);
if (logical_monitor_data->xinerama_index == xinerama_index)
return logical_monitor;
}
return NULL;
}
static void
reload_logical_monitors (MetaScreen *screen)
{
GList *l;
for (l = screen->workspaces; l != NULL; l = l->next)
{
MetaWorkspace *space = l->data;
meta_workspace_invalidate_work_area (space);
}
screen->has_xinerama_indices = FALSE;
}
2001-05-30 15:36:31 +00:00
MetaScreen*
meta_screen_new (MetaDisplay *display,
Fix issues on 64-bit machines with timestamps by using guint32 (like gtk+ 2006-09-13 Elijah Newren <newren gmail com> * src/common.h (MetaWindowMenuFunc): * src/core.[ch] (meta_core_user_lower_and_unfocus, meta_core_user_focus, meta_core_show_window_menu, meta_core_begin_grab_op, meta_core_end_grab_op): * src/delete.c (delete_ping_reply_func, delete_ping_timeout_func, meta_window_delete): * src/display.[ch] (struct MetaDisplay, struct MetaPingData, sanity_check_timestamps, meta_display_open, event_callback, meta_spew_event, meta_display_set_grab_op_cursor, meta_display_begin_grab_op, meta_display_end_grab_op, meta_display_ping_timeout, meta_display_ping_window, process_pong_message, timestamp_too_old, meta_display_set_input_focus_window): * src/keybindings.[ch] (grab_keyboard, ungrab_keyboard, meta_screen_grab_all_keys, meta_window_grab_all_keys, meta_window_ungrab_all_keys, error_on_generic_command, error_on_command, error_on_terminal_command): * src/metacity-dialog.c (on_realize, warn_about_no_sm_support, error_about_command, main): * src/screen.[ch] (struct _MetaScreen, meta_screen_new, meta_screen_show_desktop, meta_screen_apply_startup_properties): * src/session.c (warn_about_lame_clients_and_finish_interact): * src/window.[ch] (struct _MetaWindow, intervening_user_event_occurred, window_activate, meta_window_delete, meta_window_focus, meta_window_send_icccm_message, meta_window_client_message, menu_callback, meta_window_show_menu, struct EventScannerData, check_use_this_motion_notify, meta_window_begin_grab_op, meta_window_set_user_time): * src/workspace.[ch] (focus_ancestor_or_mru_window, meta_workspace_activate_with_focus, meta_workspace_activate, meta_workspace_focus_default_window, focus_ancestor_or_mru_window): Fix issues on 64-bit machines with timestamps by using guint32 (like gtk+ does) instead of Time. #348305
2006-09-13 16:32:33 +00:00
guint32 timestamp)
2001-05-30 15:36:31 +00:00
{
MetaScreen *screen;
int number;
Window xroot = meta_x11_display_get_xroot (display->x11_display);
Display *xdisplay = meta_x11_display_get_xdisplay (display->x11_display);
2014-05-02 13:34:02 +00:00
number = meta_ui_get_screen_number ();
2001-05-31 03:30:58 +00:00
meta_verbose ("Trying screen %d on display '%s'\n",
number, display->x11_display->name);
2001-05-31 03:30:58 +00:00
screen = g_object_new (META_TYPE_SCREEN, NULL);
screen->closing = 0;
2014-05-02 13:34:02 +00:00
2001-05-31 06:42:58 +00:00
screen->display = display;
screen->active_workspace = NULL;
screen->workspaces = NULL;
screen->rows_of_workspaces = 1;
screen->columns_of_workspaces = -1;
screen->vertical_workspaces = FALSE;
screen->starting_corner = META_SCREEN_TOPLEFT;
reload_logical_monitors (screen);
meta_screen_update_workspace_layout (screen);
2001-06-06 04:47:37 +00:00
/* Screens must have at least one workspace at all times,
* so create that required workspace.
*/
meta_workspace_new (screen);
screen->keys_grabbed = FALSE;
2001-06-06 04:47:37 +00:00
meta_screen_grab_keys (screen);
2001-06-18 03:24:25 +00:00
screen->ui = meta_ui_new (xdisplay);
2001-06-10 18:46:46 +00:00
meta_prefs_add_listener (prefs_changed_callback, screen);
2001-06-03 01:33:27 +00:00
meta_verbose ("Added screen %d ('%s') root 0x%lx\n",
number, display->x11_display->screen_name,
xroot);
2001-05-30 15:36:31 +00:00
return screen;
}
void
meta_screen_init_workspaces (MetaScreen *screen)
{
MetaDisplay *display = screen->display;
MetaWorkspace *current_workspace;
uint32_t current_workspace_index = 0;
guint32 timestamp;
g_return_if_fail (META_IS_SCREEN (screen));
timestamp = screen->display->x11_display->wm_sn_timestamp;
/* Get current workspace */
if (meta_prop_get_cardinal (display->x11_display,
display->x11_display->xroot,
display->x11_display->atom__NET_CURRENT_DESKTOP,
&current_workspace_index))
meta_verbose ("Read existing _NET_CURRENT_DESKTOP = %d\n",
(int) current_workspace_index);
else
meta_verbose ("No _NET_CURRENT_DESKTOP present\n");
update_num_workspaces (screen, timestamp);
set_workspace_names (screen);
/* Switch to the _NET_CURRENT_DESKTOP workspace */
current_workspace = meta_screen_get_workspace_by_index (screen,
current_workspace_index);
if (current_workspace != NULL)
meta_workspace_activate (current_workspace, timestamp);
else
meta_workspace_activate (screen->workspaces->data, timestamp);
}
2001-05-30 15:36:31 +00:00
void
meta_screen_free (MetaScreen *screen,
guint32 timestamp)
{
screen->closing += 1;
2014-05-02 13:34:02 +00:00
meta_prefs_remove_listener (prefs_changed_callback, screen);
2014-05-02 13:34:02 +00:00
2001-06-06 04:47:37 +00:00
meta_screen_ungrab_keys (screen);
2001-06-18 06:11:53 +00:00
meta_ui_free (screen->ui);
2001-06-03 21:39:57 +00:00
g_object_unref (screen);
2001-05-30 15:36:31 +00:00
}
static void
prefs_changed_callback (MetaPreference pref,
gpointer data)
{
MetaScreen *screen = data;
2014-05-02 13:34:02 +00:00
if ((pref == META_PREF_NUM_WORKSPACES ||
pref == META_PREF_DYNAMIC_WORKSPACES) &&
!meta_prefs_get_dynamic_workspaces ())
{
/* GSettings doesn't provide timestamps, but luckily update_num_workspaces
* often doesn't need it...
*/
2014-05-02 13:34:02 +00:00
guint32 timestamp =
meta_display_get_current_time_roundtrip (screen->display);
update_num_workspaces (screen, timestamp);
}
else if (pref == META_PREF_WORKSPACE_NAMES)
{
set_workspace_names (screen);
}
}
2001-06-09 05:14:43 +00:00
int
meta_screen_get_n_workspaces (MetaScreen *screen)
{
return g_list_length (screen->workspaces);
}
/**
* meta_screen_get_workspace_by_index:
* @screen: a #MetaScreen
* @index: index of one of the screen's workspaces
*
* Gets the workspace object for one of a screen's workspaces given the workspace
* index. It's valid to call this function with an out-of-range index and it
* will robustly return %NULL.
*
* Return value: (transfer none): the workspace object with specified index, or %NULL
* if the index is out of range.
*/
MetaWorkspace*
meta_screen_get_workspace_by_index (MetaScreen *screen,
int idx)
2001-06-09 05:14:43 +00:00
{
return g_list_nth_data (screen->workspaces, idx);
}
2001-06-09 05:14:43 +00:00
static void
set_number_of_spaces_hint (MetaScreen *screen,
int n_spaces)
{
MetaX11Display *x11_display = screen->display->x11_display;
unsigned long data[1];
if (screen->closing > 0)
return;
data[0] = n_spaces;
meta_verbose ("Setting _NET_NUMBER_OF_DESKTOPS to %lu\n", data[0]);
meta_error_trap_push (x11_display);
XChangeProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom__NET_NUMBER_OF_DESKTOPS,
XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 1);
meta_error_trap_pop (x11_display);
}
2008-10-24 10:03:43 +00:00
void
meta_screen_remove_workspace (MetaScreen *screen, MetaWorkspace *workspace,
guint32 timestamp)
{
GList *l;
GList *next;
2008-10-24 10:03:43 +00:00
MetaWorkspace *neighbour = NULL;
int index;
gboolean active_index_changed;
int new_num;
2008-10-24 10:03:43 +00:00
l = g_list_find (screen->workspaces, workspace);
if (!l)
return;
2008-10-24 10:03:43 +00:00
next = l->next;
2008-10-24 10:03:43 +00:00
if (l->prev)
neighbour = l->prev->data;
else if (l->next)
neighbour = l->next->data;
else
{
/* Cannot remove the only workspace! */
return;
}
2008-10-24 10:03:43 +00:00
meta_workspace_relocate_windows (workspace, neighbour);
if (workspace == screen->active_workspace)
meta_workspace_activate (neighbour, timestamp);
/* To emit the signal after removing the workspace */
index = meta_workspace_index (workspace);
active_index_changed = index < meta_screen_get_active_workspace_index (screen);
2008-10-24 10:03:43 +00:00
/* This also removes the workspace from the screens list */
meta_workspace_remove (workspace);
2008-10-24 10:03:43 +00:00
new_num = g_list_length (screen->workspaces);
set_number_of_spaces_hint (screen, new_num);
if (!meta_prefs_get_dynamic_workspaces ())
meta_prefs_set_num_workspaces (new_num);
2008-10-24 10:03:43 +00:00
/* If deleting a workspace before the current workspace, the active
* workspace index changes, so we need to update that hint */
if (active_index_changed)
2012-03-07 21:32:34 +00:00
meta_screen_set_active_workspace_hint (screen);
for (l = next; l != NULL; l = l->next)
{
MetaWorkspace *w = l->data;
meta_workspace_index_changed (w);
}
meta_display_queue_workarea_recalc (screen->display);
g_signal_emit (screen, screen_signals[WORKSPACE_REMOVED], 0, index);
g_object_notify (G_OBJECT (screen), "n-workspaces");
2008-10-24 10:03:43 +00:00
}
/**
* meta_screen_append_new_workspace:
* @screen: a #MetaScreen
* @activate: %TRUE if the workspace should be switched to after creation
* @timestamp: if switching to a new workspace, timestamp to be used when
* focusing a window on the new workspace. (Doesn't hurt to pass a valid
* timestamp when available even if not switching workspaces.)
*
* Append a new workspace to the screen and (optionally) switch to that
* screen.
*
* Return value: (transfer none): the newly appended workspace.
*/
2008-10-24 10:11:28 +00:00
MetaWorkspace *
meta_screen_append_new_workspace (MetaScreen *screen, gboolean activate,
guint32 timestamp)
{
MetaWorkspace *w;
int new_num;
2008-10-24 10:11:28 +00:00
/* This also adds the workspace to the screen list */
w = meta_workspace_new (screen);
if (!w)
return NULL;
if (activate)
meta_workspace_activate (w, timestamp);
new_num = g_list_length (screen->workspaces);
set_number_of_spaces_hint (screen, new_num);
if (!meta_prefs_get_dynamic_workspaces ())
meta_prefs_set_num_workspaces (new_num);
2008-10-24 10:11:28 +00:00
meta_display_queue_workarea_recalc (screen->display);
2008-10-24 10:11:28 +00:00
g_signal_emit (screen, screen_signals[WORKSPACE_ADDED],
0, meta_workspace_index (w));
g_object_notify (G_OBJECT (screen), "n-workspaces");
2008-10-24 10:11:28 +00:00
return w;
}
2008-10-24 10:03:43 +00:00
static void
update_num_workspaces (MetaScreen *screen,
guint32 timestamp)
{
MetaDisplay *display = screen->display;
int new_num, old_num;
GList *l;
int i;
GList *extras;
MetaWorkspace *last_remaining;
gboolean need_change_space;
2014-05-02 13:34:02 +00:00
if (meta_prefs_get_dynamic_workspaces ())
{
int n_items;
uint32_t *list;
n_items = 0;
list = NULL;
if (meta_prop_get_cardinal_list (display->x11_display,
display->x11_display->xroot,
display->x11_display->atom__NET_NUMBER_OF_DESKTOPS,
&list, &n_items))
{
new_num = list[0];
meta_XFree (list);
}
else
{
new_num = 1;
}
}
else
{
new_num = meta_prefs_get_num_workspaces ();
}
g_assert (new_num > 0);
if (g_list_length (screen->workspaces) == (guint) new_num)
{
if (screen->display->display_opening)
set_number_of_spaces_hint (screen, new_num);
return;
}
last_remaining = NULL;
extras = NULL;
i = 0;
for (l = screen->workspaces; l != NULL; l = l->next)
{
MetaWorkspace *w = l->data;
if (i >= new_num)
extras = g_list_prepend (extras, w);
else
last_remaining = w;
2014-05-02 13:34:02 +00:00
++i;
}
old_num = i;
g_assert (last_remaining);
2014-05-02 13:34:02 +00:00
/* Get rid of the extra workspaces by moving all their windows
* to last_remaining, then activating last_remaining if
* one of the removed workspaces was active. This will be a bit
* wacky if the config tool for changing number of workspaces
* is on a removed workspace ;-)
*/
need_change_space = FALSE;
for (l = extras; l != NULL; l = l->next)
{
MetaWorkspace *w = l->data;
2014-05-02 13:34:02 +00:00
meta_workspace_relocate_windows (w, last_remaining);
if (w == screen->active_workspace)
need_change_space = TRUE;
}
if (need_change_space)
meta_workspace_activate (last_remaining, timestamp);
/* Should now be safe to free the workspaces */
for (l = extras; l != NULL; l = l->next)
{
MetaWorkspace *w = l->data;
meta_workspace_remove (w);
}
g_list_free (extras);
for (i = old_num; i < new_num; i++)
meta_workspace_new (screen);
set_number_of_spaces_hint (screen, new_num);
meta_display_queue_workarea_recalc (display);
for (i = old_num; i < new_num; i++)
g_signal_emit (screen, screen_signals[WORKSPACE_ADDED], 0, i);
g_object_notify (G_OBJECT (screen), "n-workspaces");
2001-06-09 05:14:43 +00:00
}
2001-07-26 03:14:45 +00:00
MetaWindow*
meta_screen_get_mouse_window (MetaScreen *screen,
MetaWindow *not_this_one)
{
MetaBackend *backend = meta_get_backend ();
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
MetaWindow *window;
int x, y;
if (not_this_one)
meta_topic (META_DEBUG_FOCUS,
"Focusing mouse window excluding %s\n", not_this_one->desc);
meta_cursor_tracker_get_pointer (cursor_tracker, &x, &y, NULL);
window = meta_stack_get_default_focus_window_at_point (screen->display->stack,
screen->active_workspace,
not_this_one,
x, y);
return window;
}
#define _NET_WM_ORIENTATION_HORZ 0
#define _NET_WM_ORIENTATION_VERT 1
#define _NET_WM_TOPLEFT 0
#define _NET_WM_TOPRIGHT 1
#define _NET_WM_BOTTOMRIGHT 2
#define _NET_WM_BOTTOMLEFT 3
void
meta_screen_update_workspace_layout (MetaScreen *screen)
{
uint32_t *list;
int n_items;
MetaDisplay *display = screen->display;
if (screen->workspace_layout_overridden)
return;
2014-05-02 13:34:02 +00:00
list = NULL;
n_items = 0;
if (meta_prop_get_cardinal_list (display->x11_display,
display->x11_display->xroot,
display->x11_display->atom__NET_DESKTOP_LAYOUT,
&list, &n_items))
{
if (n_items == 3 || n_items == 4)
{
int cols, rows;
2014-05-02 13:34:02 +00:00
switch (list[0])
{
case _NET_WM_ORIENTATION_HORZ:
screen->vertical_workspaces = FALSE;
break;
case _NET_WM_ORIENTATION_VERT:
screen->vertical_workspaces = TRUE;
break;
default:
meta_warning ("Someone set a weird orientation in _NET_DESKTOP_LAYOUT\n");
break;
}
cols = list[1];
rows = list[2];
if (rows <= 0 && cols <= 0)
{
meta_warning ("Columns = %d rows = %d in _NET_DESKTOP_LAYOUT makes no sense\n", rows, cols);
}
else
{
if (rows > 0)
screen->rows_of_workspaces = rows;
else
screen->rows_of_workspaces = -1;
2014-05-02 13:34:02 +00:00
if (cols > 0)
screen->columns_of_workspaces = cols;
else
screen->columns_of_workspaces = -1;
}
if (n_items == 4)
{
switch (list[3])
{
case _NET_WM_TOPLEFT:
screen->starting_corner = META_SCREEN_TOPLEFT;
break;
case _NET_WM_TOPRIGHT:
screen->starting_corner = META_SCREEN_TOPRIGHT;
break;
case _NET_WM_BOTTOMRIGHT:
screen->starting_corner = META_SCREEN_BOTTOMRIGHT;
break;
case _NET_WM_BOTTOMLEFT:
screen->starting_corner = META_SCREEN_BOTTOMLEFT;
break;
default:
meta_warning ("Someone set a weird starting corner in _NET_DESKTOP_LAYOUT\n");
break;
}
}
else
screen->starting_corner = META_SCREEN_TOPLEFT;
}
else
{
meta_warning ("Someone set _NET_DESKTOP_LAYOUT to %d integers instead of 4 "
"(3 is accepted for backwards compat)\n", n_items);
}
meta_XFree (list);
}
meta_verbose ("Workspace layout rows = %d cols = %d orientation = %d starting corner = %u\n",
screen->rows_of_workspaces,
screen->columns_of_workspaces,
screen->vertical_workspaces,
screen->starting_corner);
}
/**
* meta_screen_override_workspace_layout:
* @screen: a #MetaScreen
* @starting_corner: the corner at which the first workspace is found
* @vertical_layout: if %TRUE the workspaces are laid out in columns rather than rows
* @n_rows: number of rows of workspaces, or -1 to determine the number of rows from
* @n_columns and the total number of workspaces
* @n_columns: number of columns of workspaces, or -1 to determine the number of columns from
* @n_rows and the total number of workspaces
*
* Explicitly set the layout of workspaces. Once this has been called, the contents of the
* _NET_DESKTOP_LAYOUT property on the root window are completely ignored.
*/
void
meta_screen_override_workspace_layout (MetaScreen *screen,
MetaScreenCorner starting_corner,
gboolean vertical_layout,
int n_rows,
int n_columns)
{
g_return_if_fail (META_IS_SCREEN (screen));
g_return_if_fail (n_rows > 0 || n_columns > 0);
g_return_if_fail (n_rows != 0 && n_columns != 0);
screen->workspace_layout_overridden = TRUE;
screen->vertical_workspaces = vertical_layout != FALSE;
screen->starting_corner = starting_corner;
screen->rows_of_workspaces = n_rows;
screen->columns_of_workspaces = n_columns;
/* In theory we should remove _NET_DESKTOP_LAYOUT from _NET_SUPPORTED at this
* point, but it's unlikely that anybody checks that, and it's unlikely that
* anybody who checks that handles changes, so we'd probably just create
* a race condition. And it's hard to implement with the code in set_supported_hint()
*/
}
static void
set_workspace_names (MetaScreen *screen)
{
/* This updates names on root window when the pref changes,
* note we only get prefs change notify if things have
* really changed.
*/
MetaX11Display *x11_display = screen->display->x11_display;
GString *flattened;
int i;
int n_spaces;
/* flatten to nul-separated list */
n_spaces = meta_screen_get_n_workspaces (screen);
flattened = g_string_new ("");
i = 0;
while (i < n_spaces)
{
const char *name;
name = meta_prefs_get_workspace_name (i);
if (name)
g_string_append_len (flattened, name,
strlen (name) + 1);
else
g_string_append_len (flattened, "", 1);
2014-05-02 13:34:02 +00:00
++i;
}
2014-05-02 13:34:02 +00:00
meta_error_trap_push (x11_display);
XChangeProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom__NET_DESKTOP_NAMES,
x11_display->atom_UTF8_STRING,
8, PropModeReplace,
2006-04-13 13:16:42 +00:00
(unsigned char *)flattened->str, flattened->len);
meta_error_trap_pop (x11_display);
2014-05-02 13:34:02 +00:00
g_string_free (flattened, TRUE);
}
void
meta_screen_update_workspace_names (MetaScreen *screen)
{
MetaX11Display *x11_display = screen->display->x11_display;
char **names;
int n_names;
int i;
/* this updates names in prefs when the root window property changes,
* iff the new property contents don't match what's already in prefs
*/
2014-05-02 13:34:02 +00:00
names = NULL;
n_names = 0;
if (!meta_prop_get_utf8_list (x11_display,
x11_display->xroot,
x11_display->atom__NET_DESKTOP_NAMES,
&names, &n_names))
{
meta_verbose ("Failed to get workspace names from root window\n");
return;
}
i = 0;
while (i < n_names)
{
meta_topic (META_DEBUG_PREFS,
"Setting workspace %d name to \"%s\" due to _NET_DESKTOP_NAMES change\n",
i, names[i] ? names[i] : "null");
meta_prefs_change_workspace_name (i, names[i]);
2014-05-02 13:34:02 +00:00
++i;
}
2014-05-02 13:34:02 +00:00
g_strfreev (names);
}
#ifdef WITH_VERBOSE_MODE
2015-09-23 23:13:59 +00:00
static const char *
meta_screen_corner_to_string (MetaScreenCorner corner)
{
switch (corner)
{
case META_SCREEN_TOPLEFT:
return "TopLeft";
case META_SCREEN_TOPRIGHT:
return "TopRight";
case META_SCREEN_BOTTOMLEFT:
return "BottomLeft";
case META_SCREEN_BOTTOMRIGHT:
return "BottomRight";
}
return "Unknown";
}
#endif /* WITH_VERBOSE_MODE */
void
meta_screen_calc_workspace_layout (MetaScreen *screen,
int num_workspaces,
int current_space,
MetaWorkspaceLayout *layout)
{
int rows, cols;
int grid_area;
int *grid;
int i, r, c;
int current_row, current_col;
2014-05-02 13:34:02 +00:00
rows = screen->rows_of_workspaces;
cols = screen->columns_of_workspaces;
if (rows <= 0 && cols <= 0)
cols = num_workspaces;
if (rows <= 0)
rows = num_workspaces / cols + ((num_workspaces % cols) > 0 ? 1 : 0);
if (cols <= 0)
cols = num_workspaces / rows + ((num_workspaces % rows) > 0 ? 1 : 0);
/* paranoia */
if (rows < 1)
rows = 1;
if (cols < 1)
cols = 1;
g_assert (rows != 0 && cols != 0);
2014-05-02 13:34:02 +00:00
grid_area = rows * cols;
2014-05-02 13:34:02 +00:00
meta_verbose ("Getting layout rows = %d cols = %d current = %d "
"num_spaces = %d vertical = %s corner = %s\n",
rows, cols, current_space, num_workspaces,
screen->vertical_workspaces ? "(true)" : "(false)",
meta_screen_corner_to_string (screen->starting_corner));
2014-05-02 13:34:02 +00:00
/* ok, we want to setup the distances in the workspace array to go
* in each direction. Remember, there are many ways that a workspace
* array can be setup.
* see http://www.freedesktop.org/standards/wm-spec/1.2/html/x109.html
* and look at the _NET_DESKTOP_LAYOUT section for details.
* For instance:
*/
2014-05-02 13:34:02 +00:00
/* starting_corner = META_SCREEN_TOPLEFT
* vertical_workspaces = 0 vertical_workspaces=1
2014-05-02 13:34:02 +00:00
* 1234 1357
* 5678 2468
*
* starting_corner = META_SCREEN_TOPRIGHT
* vertical_workspaces = 0 vertical_workspaces=1
2014-05-02 13:34:02 +00:00
* 4321 7531
* 8765 8642
*
* starting_corner = META_SCREEN_BOTTOMLEFT
* vertical_workspaces = 0 vertical_workspaces=1
2014-05-02 13:34:02 +00:00
* 5678 2468
* 1234 1357
*
* starting_corner = META_SCREEN_BOTTOMRIGHT
* vertical_workspaces = 0 vertical_workspaces=1
2014-05-02 13:34:02 +00:00
* 8765 8642
* 4321 7531
*
*/
/* keep in mind that we could have a ragged layout, e.g. the "8"
* in the above grids could be missing
*/
2014-05-02 13:34:02 +00:00
grid = g_new (int, grid_area);
current_row = -1;
current_col = -1;
i = 0;
2014-05-02 13:34:02 +00:00
switch (screen->starting_corner)
{
case META_SCREEN_TOPLEFT:
2014-05-02 13:34:02 +00:00
if (screen->vertical_workspaces)
{
c = 0;
while (c < cols)
{
r = 0;
while (r < rows)
{
grid[r*cols+c] = i;
++i;
++r;
}
++c;
}
}
else
{
r = 0;
while (r < rows)
{
c = 0;
while (c < cols)
{
grid[r*cols+c] = i;
++i;
++c;
}
++r;
}
}
break;
case META_SCREEN_TOPRIGHT:
2014-05-02 13:34:02 +00:00
if (screen->vertical_workspaces)
{
c = cols - 1;
while (c >= 0)
{
r = 0;
while (r < rows)
{
grid[r*cols+c] = i;
++i;
++r;
}
--c;
}
}
else
{
r = 0;
while (r < rows)
{
c = cols - 1;
while (c >= 0)
{
grid[r*cols+c] = i;
++i;
--c;
}
++r;
}
}
break;
case META_SCREEN_BOTTOMLEFT:
2014-05-02 13:34:02 +00:00
if (screen->vertical_workspaces)
{
c = 0;
while (c < cols)
{
r = rows - 1;
while (r >= 0)
{
grid[r*cols+c] = i;
++i;
--r;
}
++c;
}
}
else
{
r = rows - 1;
while (r >= 0)
{
c = 0;
while (c < cols)
{
grid[r*cols+c] = i;
++i;
++c;
}
--r;
}
}
break;
case META_SCREEN_BOTTOMRIGHT:
2014-05-02 13:34:02 +00:00
if (screen->vertical_workspaces)
{
c = cols - 1;
while (c >= 0)
{
r = rows - 1;
while (r >= 0)
{
grid[r*cols+c] = i;
++i;
--r;
}
--c;
}
}
else
{
r = rows - 1;
while (r >= 0)
{
c = cols - 1;
while (c >= 0)
{
grid[r*cols+c] = i;
++i;
--c;
}
--r;
}
}
break;
2014-05-02 13:34:02 +00:00
}
if (i != grid_area)
meta_bug ("did not fill in the whole workspace grid in %s (%d filled)\n",
G_STRFUNC, i);
2014-05-02 13:34:02 +00:00
current_row = 0;
current_col = 0;
r = 0;
while (r < rows)
{
c = 0;
while (c < cols)
{
if (grid[r*cols+c] == current_space)
{
current_row = r;
current_col = c;
}
else if (grid[r*cols+c] >= num_workspaces)
{
/* flag nonexistent spaces with -1 */
grid[r*cols+c] = -1;
}
++c;
}
++r;
}
layout->rows = rows;
layout->cols = cols;
layout->grid = grid;
layout->grid_area = grid_area;
layout->current_row = current_row;
layout->current_col = current_col;
#ifdef WITH_VERBOSE_MODE
if (meta_is_verbose ())
{
r = 0;
while (r < layout->rows)
{
meta_verbose (" ");
meta_push_no_msg_prefix ();
c = 0;
while (c < layout->cols)
{
if (r == layout->current_row &&
c == layout->current_col)
meta_verbose ("*%2d ", layout->grid[r*layout->cols+c]);
else
meta_verbose ("%3d ", layout->grid[r*layout->cols+c]);
++c;
}
meta_verbose ("\n");
meta_pop_no_msg_prefix ();
++r;
}
}
#endif /* WITH_VERBOSE_MODE */
}
void
meta_screen_free_workspace_layout (MetaWorkspaceLayout *layout)
{
g_free (layout->grid);
}
void
meta_screen_on_monitors_changed (MetaScreen *screen)
{
reload_logical_monitors (screen);
}
Make the "showing desktop" mode be per-workspace instead of per-screen. 2004-10-16 Elijah Newren <newren@math.utah.edu> Make the "showing desktop" mode be per-workspace instead of per-screen. (fixes #142198) * src/keybindings.c (handle_toggle_desktop): access showing_desktop through the active workspace * src/screen.c (meta_screen_new): remove initialization of screen->showing_desktop, (meta_screen_update_showing_desktop_hint): rename and make not static and access showing_desktop through the active workspace, (queue_windows_showing): replace meta_display_list_windows() with screen->active_workspace->windows, (meta_screen_minimize_all_on_active_workspace_except): renamed from meta_screen_minimize_all_except since it now only works on the active workspace, (meta_screen_show_desktop, meta_screen_unshow_desktop): access showing_desktop through the active workspace * src/screen.h (struct _MetaScreen): remove showing_desktop field, (meta_screen_minimize_all_on_active_workspace_except): rename from meta_screen_minimize_all_except, (meta_screen_update)_showing_desktop_hint): export this function too * src/window.c (maybe_leave_show_desktop_mode): access showing_desktop through the active workspace and use new name for meta_screen_minimize_all_on_active_workspace_except, (window_should_be_showing): access showing_desktop through the active workspace * src/workspace.c (meta_workspace_new): initialize workspace->showing_desktop, (meta_workspace_activate_with_focus): add note that old can be NULL, update showing_desktop_hint if different on this workspace than the previous one * src/workspace.h (struct _MetaWorkspace): add showing_desktop field
2004-10-17 04:28:29 +00:00
void
meta_screen_update_showing_desktop_hint (MetaScreen *screen)
{
MetaX11Display *x11_display = screen->display->x11_display;
unsigned long data[1];
Make the "showing desktop" mode be per-workspace instead of per-screen. 2004-10-16 Elijah Newren <newren@math.utah.edu> Make the "showing desktop" mode be per-workspace instead of per-screen. (fixes #142198) * src/keybindings.c (handle_toggle_desktop): access showing_desktop through the active workspace * src/screen.c (meta_screen_new): remove initialization of screen->showing_desktop, (meta_screen_update_showing_desktop_hint): rename and make not static and access showing_desktop through the active workspace, (queue_windows_showing): replace meta_display_list_windows() with screen->active_workspace->windows, (meta_screen_minimize_all_on_active_workspace_except): renamed from meta_screen_minimize_all_except since it now only works on the active workspace, (meta_screen_show_desktop, meta_screen_unshow_desktop): access showing_desktop through the active workspace * src/screen.h (struct _MetaScreen): remove showing_desktop field, (meta_screen_minimize_all_on_active_workspace_except): rename from meta_screen_minimize_all_except, (meta_screen_update)_showing_desktop_hint): export this function too * src/window.c (maybe_leave_show_desktop_mode): access showing_desktop through the active workspace and use new name for meta_screen_minimize_all_on_active_workspace_except, (window_should_be_showing): access showing_desktop through the active workspace * src/workspace.c (meta_workspace_new): initialize workspace->showing_desktop, (meta_workspace_activate_with_focus): add note that old can be NULL, update showing_desktop_hint if different on this workspace than the previous one * src/workspace.h (struct _MetaWorkspace): add showing_desktop field
2004-10-17 04:28:29 +00:00
data[0] = screen->active_workspace->showing_desktop ? 1 : 0;
2014-05-02 13:34:02 +00:00
meta_error_trap_push (x11_display);
XChangeProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom__NET_SHOWING_DESKTOP,
XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 1);
meta_error_trap_pop (x11_display);
}
static void
queue_windows_showing (MetaScreen *screen)
{
GSList *windows, *l;
/* Must operate on all windows on display instead of just on the
* active_workspace's window list, because the active_workspace's
* window list may not contain the on_all_workspace windows.
*/
windows = meta_display_list_windows (screen->display, META_LIST_DEFAULT);
for (l = windows; l != NULL; l = l->next)
{
MetaWindow *w = l->data;
meta_window_queue (w, META_QUEUE_CALC_SHOWING);
}
g_slist_free (windows);
}
void
Make the "showing desktop" mode be per-workspace instead of per-screen. 2004-10-16 Elijah Newren <newren@math.utah.edu> Make the "showing desktop" mode be per-workspace instead of per-screen. (fixes #142198) * src/keybindings.c (handle_toggle_desktop): access showing_desktop through the active workspace * src/screen.c (meta_screen_new): remove initialization of screen->showing_desktop, (meta_screen_update_showing_desktop_hint): rename and make not static and access showing_desktop through the active workspace, (queue_windows_showing): replace meta_display_list_windows() with screen->active_workspace->windows, (meta_screen_minimize_all_on_active_workspace_except): renamed from meta_screen_minimize_all_except since it now only works on the active workspace, (meta_screen_show_desktop, meta_screen_unshow_desktop): access showing_desktop through the active workspace * src/screen.h (struct _MetaScreen): remove showing_desktop field, (meta_screen_minimize_all_on_active_workspace_except): rename from meta_screen_minimize_all_except, (meta_screen_update)_showing_desktop_hint): export this function too * src/window.c (maybe_leave_show_desktop_mode): access showing_desktop through the active workspace and use new name for meta_screen_minimize_all_on_active_workspace_except, (window_should_be_showing): access showing_desktop through the active workspace * src/workspace.c (meta_workspace_new): initialize workspace->showing_desktop, (meta_workspace_activate_with_focus): add note that old can be NULL, update showing_desktop_hint if different on this workspace than the previous one * src/workspace.h (struct _MetaWorkspace): add showing_desktop field
2004-10-17 04:28:29 +00:00
meta_screen_minimize_all_on_active_workspace_except (MetaScreen *screen,
MetaWindow *keep)
{
GList *l;
Make the "showing desktop" mode be per-workspace instead of per-screen. 2004-10-16 Elijah Newren <newren@math.utah.edu> Make the "showing desktop" mode be per-workspace instead of per-screen. (fixes #142198) * src/keybindings.c (handle_toggle_desktop): access showing_desktop through the active workspace * src/screen.c (meta_screen_new): remove initialization of screen->showing_desktop, (meta_screen_update_showing_desktop_hint): rename and make not static and access showing_desktop through the active workspace, (queue_windows_showing): replace meta_display_list_windows() with screen->active_workspace->windows, (meta_screen_minimize_all_on_active_workspace_except): renamed from meta_screen_minimize_all_except since it now only works on the active workspace, (meta_screen_show_desktop, meta_screen_unshow_desktop): access showing_desktop through the active workspace * src/screen.h (struct _MetaScreen): remove showing_desktop field, (meta_screen_minimize_all_on_active_workspace_except): rename from meta_screen_minimize_all_except, (meta_screen_update)_showing_desktop_hint): export this function too * src/window.c (maybe_leave_show_desktop_mode): access showing_desktop through the active workspace and use new name for meta_screen_minimize_all_on_active_workspace_except, (window_should_be_showing): access showing_desktop through the active workspace * src/workspace.c (meta_workspace_new): initialize workspace->showing_desktop, (meta_workspace_activate_with_focus): add note that old can be NULL, update showing_desktop_hint if different on this workspace than the previous one * src/workspace.h (struct _MetaWorkspace): add showing_desktop field
2004-10-17 04:28:29 +00:00
for (l = screen->active_workspace->windows; l != NULL; l = l->next)
{
MetaWindow *w = l->data;
2014-05-02 13:34:02 +00:00
if (w->has_minimize_func && w != keep)
meta_window_minimize (w);
}
}
void
2014-05-02 13:34:02 +00:00
meta_screen_show_desktop (MetaScreen *screen,
Fix issues on 64-bit machines with timestamps by using guint32 (like gtk+ 2006-09-13 Elijah Newren <newren gmail com> * src/common.h (MetaWindowMenuFunc): * src/core.[ch] (meta_core_user_lower_and_unfocus, meta_core_user_focus, meta_core_show_window_menu, meta_core_begin_grab_op, meta_core_end_grab_op): * src/delete.c (delete_ping_reply_func, delete_ping_timeout_func, meta_window_delete): * src/display.[ch] (struct MetaDisplay, struct MetaPingData, sanity_check_timestamps, meta_display_open, event_callback, meta_spew_event, meta_display_set_grab_op_cursor, meta_display_begin_grab_op, meta_display_end_grab_op, meta_display_ping_timeout, meta_display_ping_window, process_pong_message, timestamp_too_old, meta_display_set_input_focus_window): * src/keybindings.[ch] (grab_keyboard, ungrab_keyboard, meta_screen_grab_all_keys, meta_window_grab_all_keys, meta_window_ungrab_all_keys, error_on_generic_command, error_on_command, error_on_terminal_command): * src/metacity-dialog.c (on_realize, warn_about_no_sm_support, error_about_command, main): * src/screen.[ch] (struct _MetaScreen, meta_screen_new, meta_screen_show_desktop, meta_screen_apply_startup_properties): * src/session.c (warn_about_lame_clients_and_finish_interact): * src/window.[ch] (struct _MetaWindow, intervening_user_event_occurred, window_activate, meta_window_delete, meta_window_focus, meta_window_send_icccm_message, meta_window_client_message, menu_callback, meta_window_show_menu, struct EventScannerData, check_use_this_motion_notify, meta_window_begin_grab_op, meta_window_set_user_time): * src/workspace.[ch] (focus_ancestor_or_mru_window, meta_workspace_activate_with_focus, meta_workspace_activate, meta_workspace_focus_default_window, focus_ancestor_or_mru_window): Fix issues on 64-bit machines with timestamps by using guint32 (like gtk+ does) instead of Time. #348305
2006-09-13 16:32:33 +00:00
guint32 timestamp)
{
GList *l;
Make the "showing desktop" mode be per-workspace instead of per-screen. 2004-10-16 Elijah Newren <newren@math.utah.edu> Make the "showing desktop" mode be per-workspace instead of per-screen. (fixes #142198) * src/keybindings.c (handle_toggle_desktop): access showing_desktop through the active workspace * src/screen.c (meta_screen_new): remove initialization of screen->showing_desktop, (meta_screen_update_showing_desktop_hint): rename and make not static and access showing_desktop through the active workspace, (queue_windows_showing): replace meta_display_list_windows() with screen->active_workspace->windows, (meta_screen_minimize_all_on_active_workspace_except): renamed from meta_screen_minimize_all_except since it now only works on the active workspace, (meta_screen_show_desktop, meta_screen_unshow_desktop): access showing_desktop through the active workspace * src/screen.h (struct _MetaScreen): remove showing_desktop field, (meta_screen_minimize_all_on_active_workspace_except): rename from meta_screen_minimize_all_except, (meta_screen_update)_showing_desktop_hint): export this function too * src/window.c (maybe_leave_show_desktop_mode): access showing_desktop through the active workspace and use new name for meta_screen_minimize_all_on_active_workspace_except, (window_should_be_showing): access showing_desktop through the active workspace * src/workspace.c (meta_workspace_new): initialize workspace->showing_desktop, (meta_workspace_activate_with_focus): add note that old can be NULL, update showing_desktop_hint if different on this workspace than the previous one * src/workspace.h (struct _MetaWorkspace): add showing_desktop field
2004-10-17 04:28:29 +00:00
if (screen->active_workspace->showing_desktop)
return;
2014-05-02 13:34:02 +00:00
Make the "showing desktop" mode be per-workspace instead of per-screen. 2004-10-16 Elijah Newren <newren@math.utah.edu> Make the "showing desktop" mode be per-workspace instead of per-screen. (fixes #142198) * src/keybindings.c (handle_toggle_desktop): access showing_desktop through the active workspace * src/screen.c (meta_screen_new): remove initialization of screen->showing_desktop, (meta_screen_update_showing_desktop_hint): rename and make not static and access showing_desktop through the active workspace, (queue_windows_showing): replace meta_display_list_windows() with screen->active_workspace->windows, (meta_screen_minimize_all_on_active_workspace_except): renamed from meta_screen_minimize_all_except since it now only works on the active workspace, (meta_screen_show_desktop, meta_screen_unshow_desktop): access showing_desktop through the active workspace * src/screen.h (struct _MetaScreen): remove showing_desktop field, (meta_screen_minimize_all_on_active_workspace_except): rename from meta_screen_minimize_all_except, (meta_screen_update)_showing_desktop_hint): export this function too * src/window.c (maybe_leave_show_desktop_mode): access showing_desktop through the active workspace and use new name for meta_screen_minimize_all_on_active_workspace_except, (window_should_be_showing): access showing_desktop through the active workspace * src/workspace.c (meta_workspace_new): initialize workspace->showing_desktop, (meta_workspace_activate_with_focus): add note that old can be NULL, update showing_desktop_hint if different on this workspace than the previous one * src/workspace.h (struct _MetaWorkspace): add showing_desktop field
2004-10-17 04:28:29 +00:00
screen->active_workspace->showing_desktop = TRUE;
2014-05-02 13:34:02 +00:00
queue_windows_showing (screen);
/* Focus the most recently used META_WINDOW_DESKTOP window, if there is one;
* see bug 159257.
*/
for (l = screen->active_workspace->mru_list; l != NULL; l = l->next)
{
MetaWindow *w = l->data;
2014-05-02 13:34:02 +00:00
if (w->type == META_WINDOW_DESKTOP)
{
meta_window_focus (w, timestamp);
break;
}
}
Make the "showing desktop" mode be per-workspace instead of per-screen. 2004-10-16 Elijah Newren <newren@math.utah.edu> Make the "showing desktop" mode be per-workspace instead of per-screen. (fixes #142198) * src/keybindings.c (handle_toggle_desktop): access showing_desktop through the active workspace * src/screen.c (meta_screen_new): remove initialization of screen->showing_desktop, (meta_screen_update_showing_desktop_hint): rename and make not static and access showing_desktop through the active workspace, (queue_windows_showing): replace meta_display_list_windows() with screen->active_workspace->windows, (meta_screen_minimize_all_on_active_workspace_except): renamed from meta_screen_minimize_all_except since it now only works on the active workspace, (meta_screen_show_desktop, meta_screen_unshow_desktop): access showing_desktop through the active workspace * src/screen.h (struct _MetaScreen): remove showing_desktop field, (meta_screen_minimize_all_on_active_workspace_except): rename from meta_screen_minimize_all_except, (meta_screen_update)_showing_desktop_hint): export this function too * src/window.c (maybe_leave_show_desktop_mode): access showing_desktop through the active workspace and use new name for meta_screen_minimize_all_on_active_workspace_except, (window_should_be_showing): access showing_desktop through the active workspace * src/workspace.c (meta_workspace_new): initialize workspace->showing_desktop, (meta_workspace_activate_with_focus): add note that old can be NULL, update showing_desktop_hint if different on this workspace than the previous one * src/workspace.h (struct _MetaWorkspace): add showing_desktop field
2004-10-17 04:28:29 +00:00
meta_screen_update_showing_desktop_hint (screen);
}
void
meta_screen_unshow_desktop (MetaScreen *screen)
{
Make the "showing desktop" mode be per-workspace instead of per-screen. 2004-10-16 Elijah Newren <newren@math.utah.edu> Make the "showing desktop" mode be per-workspace instead of per-screen. (fixes #142198) * src/keybindings.c (handle_toggle_desktop): access showing_desktop through the active workspace * src/screen.c (meta_screen_new): remove initialization of screen->showing_desktop, (meta_screen_update_showing_desktop_hint): rename and make not static and access showing_desktop through the active workspace, (queue_windows_showing): replace meta_display_list_windows() with screen->active_workspace->windows, (meta_screen_minimize_all_on_active_workspace_except): renamed from meta_screen_minimize_all_except since it now only works on the active workspace, (meta_screen_show_desktop, meta_screen_unshow_desktop): access showing_desktop through the active workspace * src/screen.h (struct _MetaScreen): remove showing_desktop field, (meta_screen_minimize_all_on_active_workspace_except): rename from meta_screen_minimize_all_except, (meta_screen_update)_showing_desktop_hint): export this function too * src/window.c (maybe_leave_show_desktop_mode): access showing_desktop through the active workspace and use new name for meta_screen_minimize_all_on_active_workspace_except, (window_should_be_showing): access showing_desktop through the active workspace * src/workspace.c (meta_workspace_new): initialize workspace->showing_desktop, (meta_workspace_activate_with_focus): add note that old can be NULL, update showing_desktop_hint if different on this workspace than the previous one * src/workspace.h (struct _MetaWorkspace): add showing_desktop field
2004-10-17 04:28:29 +00:00
if (!screen->active_workspace->showing_desktop)
return;
Make the "showing desktop" mode be per-workspace instead of per-screen. 2004-10-16 Elijah Newren <newren@math.utah.edu> Make the "showing desktop" mode be per-workspace instead of per-screen. (fixes #142198) * src/keybindings.c (handle_toggle_desktop): access showing_desktop through the active workspace * src/screen.c (meta_screen_new): remove initialization of screen->showing_desktop, (meta_screen_update_showing_desktop_hint): rename and make not static and access showing_desktop through the active workspace, (queue_windows_showing): replace meta_display_list_windows() with screen->active_workspace->windows, (meta_screen_minimize_all_on_active_workspace_except): renamed from meta_screen_minimize_all_except since it now only works on the active workspace, (meta_screen_show_desktop, meta_screen_unshow_desktop): access showing_desktop through the active workspace * src/screen.h (struct _MetaScreen): remove showing_desktop field, (meta_screen_minimize_all_on_active_workspace_except): rename from meta_screen_minimize_all_except, (meta_screen_update)_showing_desktop_hint): export this function too * src/window.c (maybe_leave_show_desktop_mode): access showing_desktop through the active workspace and use new name for meta_screen_minimize_all_on_active_workspace_except, (window_should_be_showing): access showing_desktop through the active workspace * src/workspace.c (meta_workspace_new): initialize workspace->showing_desktop, (meta_workspace_activate_with_focus): add note that old can be NULL, update showing_desktop_hint if different on this workspace than the previous one * src/workspace.h (struct _MetaWorkspace): add showing_desktop field
2004-10-17 04:28:29 +00:00
screen->active_workspace->showing_desktop = FALSE;
queue_windows_showing (screen);
Make the "showing desktop" mode be per-workspace instead of per-screen. 2004-10-16 Elijah Newren <newren@math.utah.edu> Make the "showing desktop" mode be per-workspace instead of per-screen. (fixes #142198) * src/keybindings.c (handle_toggle_desktop): access showing_desktop through the active workspace * src/screen.c (meta_screen_new): remove initialization of screen->showing_desktop, (meta_screen_update_showing_desktop_hint): rename and make not static and access showing_desktop through the active workspace, (queue_windows_showing): replace meta_display_list_windows() with screen->active_workspace->windows, (meta_screen_minimize_all_on_active_workspace_except): renamed from meta_screen_minimize_all_except since it now only works on the active workspace, (meta_screen_show_desktop, meta_screen_unshow_desktop): access showing_desktop through the active workspace * src/screen.h (struct _MetaScreen): remove showing_desktop field, (meta_screen_minimize_all_on_active_workspace_except): rename from meta_screen_minimize_all_except, (meta_screen_update)_showing_desktop_hint): export this function too * src/window.c (maybe_leave_show_desktop_mode): access showing_desktop through the active workspace and use new name for meta_screen_minimize_all_on_active_workspace_except, (window_should_be_showing): access showing_desktop through the active workspace * src/workspace.c (meta_workspace_new): initialize workspace->showing_desktop, (meta_workspace_activate_with_focus): add note that old can be NULL, update showing_desktop_hint if different on this workspace than the previous one * src/workspace.h (struct _MetaWorkspace): add showing_desktop field
2004-10-17 04:28:29 +00:00
meta_screen_update_showing_desktop_hint (screen);
}
/**
* meta_screen_get_display:
* @screen: A #MetaScreen
2014-05-02 13:34:02 +00:00
*
* Retrieve the display associated with screen.
*
2014-05-02 13:34:02 +00:00
* Returns: (transfer none): Display
*/
MetaDisplay *
meta_screen_get_display (MetaScreen *screen)
{
return screen->display;
}
/**
* meta_screen_get_workspaces: (skip)
* @screen: a #MetaScreen
*
* Returns: (transfer none) (element-type Meta.Workspace): The workspaces for @screen
*/
GList *
meta_screen_get_workspaces (MetaScreen *screen)
{
return screen->workspaces;
}
int
meta_screen_get_active_workspace_index (MetaScreen *screen)
{
MetaWorkspace *active = screen->active_workspace;
if (!active)
return -1;
return meta_workspace_index (active);
}
2008-11-20 12:41:28 +00:00
/**
* meta_screen_get_active_workspace:
* @screen: A #MetaScreen
*
* Returns: (transfer none): The current workspace
*/
2008-11-20 12:41:28 +00:00
MetaWorkspace *
meta_screen_get_active_workspace (MetaScreen *screen)
{
return screen->active_workspace;
}
void
meta_screen_focus_default_window (MetaScreen *screen,
guint32 timestamp)
{
meta_workspace_focus_default_window (screen->active_workspace,
NULL,
timestamp);
}
void
meta_screen_workspace_switched (MetaScreen *screen,
int from,
int to,
MetaMotionDirection direction)
{
g_signal_emit (screen, screen_signals[WORKSPACE_SWITCHED], 0,
from, to, direction);
}
void
meta_screen_set_active_workspace_hint (MetaScreen *screen)
{
MetaX11Display *x11_display = screen->display->x11_display;
unsigned long data[1];
/* this is because we destroy the spaces in order,
* so we always end up setting a current desktop of
* 0 when closing a screen, so lose the current desktop
* on restart. By doing this we keep the current
* desktop on restart.
*/
if (screen->closing > 0)
return;
2014-05-02 13:34:02 +00:00
data[0] = meta_workspace_index (screen->active_workspace);
meta_verbose ("Setting _NET_CURRENT_DESKTOP to %lu\n", data[0]);
2014-05-02 13:34:02 +00:00
meta_error_trap_push (x11_display);
XChangeProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom__NET_CURRENT_DESKTOP,
XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 1);
meta_error_trap_pop (x11_display);
}