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
|
|
|
/*
|
2002-06-08 23:55:27 +00:00
|
|
|
* Copyright (C) 2001, 2002 Havoc Pennington
|
2003-01-23 01:53:18 +00:00
|
|
|
* Copyright (C) 2002, 2003 Red Hat Inc.
|
2002-06-08 23:55:27 +00:00
|
|
|
* Some ICCCM manager selection code derived from fvwm2,
|
2002-07-10 14:41:19 +00:00
|
|
|
* Copyright (C) 2001 Dominik Vogt, Matthias Clasen, and fvwm2 team
|
2003-02-23 17:09:46 +00:00
|
|
|
* Copyright (C) 2003 Rob Adams
|
2006-01-10 19:43:21 +00:00
|
|
|
* 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
|
2014-01-12 01:42:06 +00:00
|
|
|
* 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
|
|
|
|
2013-03-11 15:52:36 +00:00
|
|
|
/**
|
|
|
|
* SECTION:screen
|
|
|
|
* @title: MetaScreen
|
|
|
|
* @short_description: Mutter X screen handler
|
|
|
|
*/
|
|
|
|
|
2001-12-09 22:41:12 +00:00
|
|
|
#include <config.h>
|
2008-05-19 00:00:09 +00:00
|
|
|
#include "screen-private.h"
|
2011-03-23 17:11:05 +00:00
|
|
|
#include <meta/main.h>
|
2013-09-11 08:18:53 +00:00
|
|
|
#include "util-private.h"
|
2011-03-06 00:29:12 +00:00
|
|
|
#include <meta/errors.h>
|
2008-05-19 00:00:09 +00:00
|
|
|
#include "window-private.h"
|
2011-03-06 00:29:12 +00:00
|
|
|
#include "frame.h"
|
|
|
|
#include <meta/prefs.h>
|
2008-09-18 15:09:11 +00:00
|
|
|
#include "workspace-private.h"
|
2009-01-29 14:16:01 +00:00
|
|
|
#include "keybindings-private.h"
|
2001-06-10 18:46:46 +00:00
|
|
|
#include "stack.h"
|
2011-03-06 00:29:12 +00:00
|
|
|
#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"
|
2013-08-13 10:57:41 +00:00
|
|
|
#include "meta-cursor-tracker-private.h"
|
2015-07-17 15:16:39 +00:00
|
|
|
#include "boxes-private.h"
|
2016-12-01 04:52:07 +00:00
|
|
|
#include "backends/meta-backend-private.h"
|
2016-12-13 02:37:11 +00:00
|
|
|
#include "backends/meta-logical-monitor.h"
|
2001-06-01 03:00:01 +00:00
|
|
|
|
2002-04-21 19:35:02 +00:00
|
|
|
#include <X11/extensions/Xinerama.h>
|
2014-07-10 18:03:03 +00:00
|
|
|
#include <X11/extensions/Xcomposite.h>
|
2012-04-24 19:18:46 +00:00
|
|
|
|
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>
|
2002-06-08 23:55:27 +00:00
|
|
|
#include <stdio.h>
|
2013-03-04 14:57:01 +00:00
|
|
|
#include <stdlib.h>
|
2001-05-30 15:36:31 +00:00
|
|
|
|
2017-08-26 16:26:30 +00:00
|
|
|
#include "x11/meta-x11-display-private.h"
|
2014-05-20 13:18:45 +00:00
|
|
|
#include "x11/window-x11.h"
|
2014-03-19 01:56:45 +00:00
|
|
|
#include "x11/xprops.h"
|
|
|
|
|
2014-07-15 21:13:31 +00:00
|
|
|
#include "backends/x11/meta-backend-x11.h"
|
2018-04-27 13:43:37 +00:00
|
|
|
#include "backends/meta-cursor-sprite-xcursor.h"
|
2014-07-15 21:13:31 +00:00
|
|
|
|
Partial audit to fix timestamp usage. One step towards fixing #355180; see
2006-09-18 Elijah Newren <newren gmail com>
Partial audit to fix timestamp usage. One step towards fixing
#355180; see important comments in that bug.
* src/core.[ch] (meta_core_unshade, meta_core_shade):
* src/delete.c (meta_window_present_delete_dialog,
delete_ping_timeout_func):
* src/display.[ch] (meta_display_open, meta_display_close,
event_callback, meta_display_begin_grab_op,
process_selection_clear, meta_display_unmanage_screen,
meta_display_unmanage_windows_for_screen):
* src/frames.c (meta_frames_button_press_event):
* src/keybindings.c (handle_toggle_shade):
* src/main.c (main):
* src/screen.[ch] (update_num_workspaces, meta_screen_new,
meta_screen_free, prefs_changed_callback):
* src/window.[ch] (meta_window_free, finish_minimize,
implement_showing, meta_window_show, meta_window_maximize,
meta_window_make_fullscreen_internal,
meta_window_unmake_fullscreen, meta_window_shade,
meta_window_unshade, window_activate, send_sync_request,
meta_window_client_message, menu_callback,
meta_window_update_keyboard_resize):
Remove usage of CurrentTime, meta_display_get_current_time() and
meta_display_get_current_time_roundtrip() where possible, or
document why it isn't possible, or at very least add a FIXME with
some explanation of my laziness and what needs to be done.
2006-09-18 17:27:24 +00:00
|
|
|
static void update_num_workspaces (MetaScreen *screen,
|
|
|
|
guint32 timestamp);
|
2003-02-14 07:03:46 +00:00
|
|
|
static void set_workspace_names (MetaScreen *screen);
|
2001-12-10 03:55:26 +00:00
|
|
|
static void prefs_changed_callback (MetaPreference pref,
|
|
|
|
gpointer data);
|
2001-06-03 01:33:27 +00:00
|
|
|
|
2008-11-17 22:22:28 +00:00
|
|
|
enum
|
|
|
|
{
|
2009-05-05 08:39:29 +00:00
|
|
|
PROP_N_WORKSPACES = 1,
|
2008-11-17 22:22:28 +00:00
|
|
|
};
|
|
|
|
|
2009-03-12 21:07:27 +00:00
|
|
|
enum
|
|
|
|
{
|
2009-07-02 15:19:02 +00:00
|
|
|
WORKSPACE_ADDED,
|
|
|
|
WORKSPACE_REMOVED,
|
|
|
|
WORKSPACE_SWITCHED,
|
2009-03-12 21:07:27 +00:00
|
|
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint screen_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2008-11-17 20:56:34 +00:00
|
|
|
G_DEFINE_TYPE (MetaScreen, meta_screen, G_TYPE_OBJECT);
|
|
|
|
|
2016-12-02 14:09:43 +00:00
|
|
|
static GQuark quark_screen_x11_logical_monitor_data = 0;
|
|
|
|
|
|
|
|
typedef struct _MetaScreenX11LogicalMonitorData
|
|
|
|
{
|
|
|
|
int xinerama_index;
|
|
|
|
} MetaScreenX11LogicalMonitorData;
|
|
|
|
|
2008-11-17 22:22:28 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-17 20:56:34 +00:00
|
|
|
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);
|
2008-11-17 22:22:28 +00:00
|
|
|
GParamSpec *pspec;
|
2008-11-17 20:56:34 +00:00
|
|
|
|
2008-11-17 22:22:28 +00:00
|
|
|
object_class->get_property = meta_screen_get_property;
|
|
|
|
object_class->set_property = meta_screen_set_property;
|
2008-11-17 20:56:34 +00:00
|
|
|
object_class->finalize = meta_screen_finalize;
|
2008-11-17 22:22:28 +00:00
|
|
|
|
|
|
|
pspec = g_param_spec_int ("n-workspaces",
|
|
|
|
"N Workspaces",
|
|
|
|
"Number of workspaces",
|
|
|
|
1, G_MAXINT, 1,
|
|
|
|
G_PARAM_READABLE);
|
|
|
|
|
2009-07-02 15:19:02 +00:00
|
|
|
screen_signals[WORKSPACE_ADDED] =
|
|
|
|
g_signal_new ("workspace-added",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
2011-10-18 22:06:14 +00:00
|
|
|
NULL, NULL, NULL,
|
2009-07-02 15:19:02 +00:00
|
|
|
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,
|
2011-10-18 22:06:14 +00:00
|
|
|
NULL, NULL, NULL,
|
2009-07-02 15:19:02 +00:00
|
|
|
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,
|
2011-10-18 22:06:14 +00:00
|
|
|
NULL, NULL, NULL,
|
2009-07-02 15:19:02 +00:00
|
|
|
G_TYPE_NONE,
|
|
|
|
3,
|
|
|
|
G_TYPE_INT,
|
|
|
|
G_TYPE_INT,
|
2012-02-23 19:39:58 +00:00
|
|
|
META_TYPE_MOTION_DIRECTION);
|
2009-07-02 15:19:02 +00:00
|
|
|
|
2008-11-17 22:22:28 +00:00
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_N_WORKSPACES,
|
|
|
|
pspec);
|
2016-12-02 14:09:43 +00:00
|
|
|
|
|
|
|
quark_screen_x11_logical_monitor_data =
|
|
|
|
g_quark_from_static_string ("-meta-screen-logical-monitor-x11-data");
|
2008-11-17 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_screen_init (MetaScreen *screen)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-12-02 14:09:43 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-05-03 17:04:01 +00:00
|
|
|
static void
|
2013-07-18 11:09:16 +00:00
|
|
|
meta_screen_ensure_xinerama_indices (MetaScreen *screen)
|
2011-05-03 17:04:01 +00:00
|
|
|
{
|
2016-11-28 12:11:24 +00:00
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
2016-12-02 08:00:03 +00:00
|
|
|
GList *logical_monitors, *l;
|
2013-07-18 11:09:16 +00:00
|
|
|
XineramaScreenInfo *infos;
|
2016-11-28 12:11:24 +00:00
|
|
|
int n_infos, j;
|
2011-05-03 17:04:01 +00:00
|
|
|
|
2013-07-18 11:09:16 +00:00
|
|
|
if (screen->has_xinerama_indices)
|
|
|
|
return;
|
2011-05-03 17:04:01 +00:00
|
|
|
|
2013-07-18 11:09:16 +00:00
|
|
|
screen->has_xinerama_indices = TRUE;
|
2011-05-03 17:04:01 +00:00
|
|
|
|
2017-08-26 16:26:30 +00:00
|
|
|
if (!XineramaIsActive (screen->display->x11_display->xdisplay))
|
2013-07-18 11:09:16 +00:00
|
|
|
return;
|
|
|
|
|
2017-08-26 16:26:30 +00:00
|
|
|
infos = XineramaQueryScreens (screen->display->x11_display->xdisplay,
|
|
|
|
&n_infos);
|
2013-07-18 11:09:16 +00:00
|
|
|
if (n_infos <= 0 || infos == NULL)
|
2011-05-03 17:04:01 +00:00
|
|
|
{
|
2013-07-18 11:09:16 +00:00
|
|
|
meta_XFree (infos);
|
|
|
|
return;
|
|
|
|
}
|
2011-05-03 17:04:01 +00:00
|
|
|
|
2016-11-28 12:11:24 +00:00
|
|
|
logical_monitors =
|
2016-12-02 08:00:03 +00:00
|
|
|
meta_monitor_manager_get_logical_monitors (monitor_manager);
|
2016-11-28 12:11:24 +00:00
|
|
|
|
2016-12-02 08:00:03 +00:00
|
|
|
for (l = logical_monitors; l; l = l->next)
|
2013-07-18 11:09:16 +00:00
|
|
|
{
|
2016-12-02 08:00:03 +00:00
|
|
|
MetaLogicalMonitor *logical_monitor = l->data;
|
|
|
|
|
2013-07-18 11:09:16 +00:00
|
|
|
for (j = 0; j < n_infos; ++j)
|
2011-05-03 17:04:01 +00:00
|
|
|
{
|
2016-12-02 08:00:03 +00:00
|
|
|
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)
|
2016-12-02 14:09:43 +00:00
|
|
|
{
|
|
|
|
MetaScreenX11LogicalMonitorData *logical_monitor_data;
|
|
|
|
|
|
|
|
logical_monitor_data =
|
|
|
|
ensure_screen_x11_logical_monitor_data (logical_monitor);
|
|
|
|
logical_monitor_data->xinerama_index = j;
|
|
|
|
}
|
2011-05-03 17:04:01 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-18 11:09:16 +00:00
|
|
|
|
|
|
|
meta_XFree (infos);
|
2011-05-03 17:04:01 +00:00
|
|
|
}
|
|
|
|
|
2013-07-18 11:09:16 +00:00
|
|
|
int
|
2016-11-29 09:50:17 +00:00
|
|
|
meta_screen_logical_monitor_to_xinerama_index (MetaScreen *screen,
|
|
|
|
MetaLogicalMonitor *logical_monitor)
|
2011-05-20 08:56:12 +00:00
|
|
|
{
|
2016-12-02 14:09:43 +00:00
|
|
|
MetaScreenX11LogicalMonitorData *logical_monitor_data;
|
|
|
|
|
2016-11-29 09:50:17 +00:00
|
|
|
g_return_val_if_fail (logical_monitor, -1);
|
2013-12-14 13:24:27 +00:00
|
|
|
|
2013-07-18 11:09:16 +00:00
|
|
|
meta_screen_ensure_xinerama_indices (screen);
|
2011-05-20 08:56:12 +00:00
|
|
|
|
2016-12-02 14:09:43 +00:00
|
|
|
logical_monitor_data = get_screen_x11_logical_monitor_data (logical_monitor);
|
|
|
|
|
|
|
|
return logical_monitor_data->xinerama_index;
|
2011-05-20 08:56:12 +00:00
|
|
|
}
|
|
|
|
|
2016-11-29 09:50:17 +00:00
|
|
|
MetaLogicalMonitor *
|
|
|
|
meta_screen_xinerama_index_to_logical_monitor (MetaScreen *screen,
|
|
|
|
int xinerama_index)
|
2011-05-20 08:56:12 +00:00
|
|
|
{
|
2016-11-28 12:11:24 +00:00
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
2016-12-02 08:00:03 +00:00
|
|
|
GList *logical_monitors, *l;
|
2011-05-20 08:56:12 +00:00
|
|
|
|
2013-07-18 11:09:16 +00:00
|
|
|
meta_screen_ensure_xinerama_indices (screen);
|
2011-05-20 08:56:12 +00:00
|
|
|
|
2016-11-28 12:11:24 +00:00
|
|
|
logical_monitors =
|
2016-12-02 08:00:03 +00:00
|
|
|
meta_monitor_manager_get_logical_monitors (monitor_manager);
|
|
|
|
|
|
|
|
for (l = logical_monitors; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaLogicalMonitor *logical_monitor = l->data;
|
2016-12-02 14:09:43 +00:00
|
|
|
MetaScreenX11LogicalMonitorData *logical_monitor_data;
|
|
|
|
|
|
|
|
logical_monitor_data =
|
|
|
|
ensure_screen_x11_logical_monitor_data (logical_monitor);
|
2016-11-28 12:11:24 +00:00
|
|
|
|
2016-12-02 14:09:43 +00:00
|
|
|
if (logical_monitor_data->xinerama_index == xinerama_index)
|
2016-12-02 08:00:03 +00:00
|
|
|
return logical_monitor;
|
|
|
|
}
|
2011-05-20 08:56:12 +00:00
|
|
|
|
2016-11-29 09:50:17 +00:00
|
|
|
return NULL;
|
2011-05-20 08:56:12 +00:00
|
|
|
}
|
|
|
|
|
2002-09-29 02:50:24 +00:00
|
|
|
static void
|
2016-11-25 06:31:38 +00:00
|
|
|
reload_logical_monitors (MetaScreen *screen)
|
2002-09-29 02:50:24 +00:00
|
|
|
{
|
2014-08-15 23:49:49 +00:00
|
|
|
GList *l;
|
2011-05-20 08:56:12 +00:00
|
|
|
|
2014-08-15 23:49:49 +00:00
|
|
|
for (l = screen->workspaces; l != NULL; l = l->next)
|
2002-09-29 02:50:24 +00:00
|
|
|
{
|
2014-08-15 23:49:49 +00:00
|
|
|
MetaWorkspace *space = l->data;
|
2013-07-18 11:09:16 +00:00
|
|
|
meta_workspace_invalidate_work_area (space);
|
2002-09-29 02:50:24 +00:00
|
|
|
}
|
|
|
|
|
2013-07-18 11:09:16 +00:00
|
|
|
screen->has_xinerama_indices = FALSE;
|
2002-09-29 02:50:24 +00:00
|
|
|
}
|
|
|
|
|
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;
|
2016-07-21 13:03:56 +00:00
|
|
|
int number;
|
2017-08-26 16:26:30 +00:00
|
|
|
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
|
|
|
|
2016-07-21 13:03:56 +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",
|
2017-08-26 16:26:30 +00:00
|
|
|
number, display->x11_display->name);
|
2001-05-31 03:30:58 +00:00
|
|
|
|
2008-11-17 20:56:34 +00:00
|
|
|
screen = g_object_new (META_TYPE_SCREEN, NULL);
|
2002-06-22 05:11:04 +00:00
|
|
|
screen->closing = 0;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-05-31 06:42:58 +00:00
|
|
|
screen->display = display;
|
2002-04-21 19:35:02 +00:00
|
|
|
|
2002-08-04 20:17:37 +00:00
|
|
|
screen->active_workspace = NULL;
|
2002-10-16 20:12:24 +00:00
|
|
|
screen->workspaces = NULL;
|
2002-05-16 04:03:36 +00:00
|
|
|
screen->rows_of_workspaces = 1;
|
|
|
|
screen->columns_of_workspaces = -1;
|
|
|
|
screen->vertical_workspaces = FALSE;
|
2002-10-01 19:57:26 +00:00
|
|
|
screen->starting_corner = META_SCREEN_TOPLEFT;
|
2002-09-29 02:50:24 +00:00
|
|
|
|
2016-11-25 06:31:38 +00:00
|
|
|
reload_logical_monitors (screen);
|
2013-08-13 10:57:41 +00:00
|
|
|
|
2002-05-16 04:03:36 +00:00
|
|
|
meta_screen_update_workspace_layout (screen);
|
2002-11-21 04:48:53 +00:00
|
|
|
|
2001-06-06 04:47:37 +00:00
|
|
|
/* Screens must have at least one workspace at all times,
|
|
|
|
* so create that required workspace.
|
|
|
|
*/
|
2014-06-05 20:28:56 +00:00
|
|
|
meta_workspace_new (screen);
|
2003-02-14 07:03:46 +00:00
|
|
|
|
2002-04-28 04:52:26 +00:00
|
|
|
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
|
|
|
|
2017-08-26 16:26:30 +00:00
|
|
|
screen->ui = meta_ui_new (xdisplay);
|
2001-06-10 18:46:46 +00:00
|
|
|
|
2001-12-10 03:55:26 +00:00
|
|
|
meta_prefs_add_listener (prefs_changed_callback, screen);
|
2002-10-25 23:35:50 +00:00
|
|
|
|
2001-06-03 01:33:27 +00:00
|
|
|
meta_verbose ("Added screen %d ('%s') root 0x%lx\n",
|
2017-08-26 16:26:30 +00:00
|
|
|
number, display->x11_display->screen_name,
|
|
|
|
xroot);
|
2013-07-18 11:09:16 +00:00
|
|
|
|
2001-05-30 15:36:31 +00:00
|
|
|
return screen;
|
|
|
|
}
|
|
|
|
|
2014-06-05 20:28:56 +00:00
|
|
|
void
|
|
|
|
meta_screen_init_workspaces (MetaScreen *screen)
|
|
|
|
{
|
2017-08-26 16:26:30 +00:00
|
|
|
MetaDisplay *display = screen->display;
|
2014-06-05 20:28:56 +00:00
|
|
|
MetaWorkspace *current_workspace;
|
2015-06-23 22:32:07 +00:00
|
|
|
uint32_t current_workspace_index = 0;
|
2014-06-05 20:28:56 +00:00
|
|
|
guint32 timestamp;
|
|
|
|
|
|
|
|
g_return_if_fail (META_IS_SCREEN (screen));
|
|
|
|
|
2017-08-26 18:51:28 +00:00
|
|
|
timestamp = screen->display->x11_display->wm_sn_timestamp;
|
2014-06-05 20:28:56 +00:00
|
|
|
|
|
|
|
/* Get current workspace */
|
2017-08-26 18:51:28 +00:00
|
|
|
if (meta_prop_get_cardinal (display->x11_display,
|
2017-08-26 16:26:30 +00:00
|
|
|
display->x11_display->xroot,
|
|
|
|
display->x11_display->atom__NET_CURRENT_DESKTOP,
|
2014-06-05 20:28:56 +00:00
|
|
|
¤t_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);
|
2014-07-10 15:24:32 +00:00
|
|
|
else
|
|
|
|
meta_workspace_activate (screen->workspaces->data, timestamp);
|
2014-06-05 20:28:56 +00:00
|
|
|
}
|
|
|
|
|
2001-05-30 15:36:31 +00:00
|
|
|
void
|
Partial audit to fix timestamp usage. One step towards fixing #355180; see
2006-09-18 Elijah Newren <newren gmail com>
Partial audit to fix timestamp usage. One step towards fixing
#355180; see important comments in that bug.
* src/core.[ch] (meta_core_unshade, meta_core_shade):
* src/delete.c (meta_window_present_delete_dialog,
delete_ping_timeout_func):
* src/display.[ch] (meta_display_open, meta_display_close,
event_callback, meta_display_begin_grab_op,
process_selection_clear, meta_display_unmanage_screen,
meta_display_unmanage_windows_for_screen):
* src/frames.c (meta_frames_button_press_event):
* src/keybindings.c (handle_toggle_shade):
* src/main.c (main):
* src/screen.[ch] (update_num_workspaces, meta_screen_new,
meta_screen_free, prefs_changed_callback):
* src/window.[ch] (meta_window_free, finish_minimize,
implement_showing, meta_window_show, meta_window_maximize,
meta_window_make_fullscreen_internal,
meta_window_unmake_fullscreen, meta_window_shade,
meta_window_unshade, window_activate, send_sync_request,
meta_window_client_message, menu_callback,
meta_window_update_keyboard_resize):
Remove usage of CurrentTime, meta_display_get_current_time() and
meta_display_get_current_time_roundtrip() where possible, or
document why it isn't possible, or at very least add a FIXME with
some explanation of my laziness and what needs to be done.
2006-09-18 17:27:24 +00:00
|
|
|
meta_screen_free (MetaScreen *screen,
|
|
|
|
guint32 timestamp)
|
2002-06-08 23:55:27 +00:00
|
|
|
{
|
2002-06-22 05:11:04 +00:00
|
|
|
screen->closing += 1;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-12-10 03:55:26 +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-08-19 18:09:10 +00:00
|
|
|
|
2001-06-18 06:11:53 +00:00
|
|
|
meta_ui_free (screen->ui);
|
2001-06-03 21:39:57 +00:00
|
|
|
|
2008-11-17 20:56:34 +00:00
|
|
|
g_object_unref (screen);
|
2001-05-30 15:36:31 +00:00
|
|
|
}
|
|
|
|
|
2001-12-10 03:55:26 +00:00
|
|
|
static void
|
|
|
|
prefs_changed_callback (MetaPreference pref,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
MetaScreen *screen = data;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2012-03-08 00:29:58 +00:00
|
|
|
if ((pref == META_PREF_NUM_WORKSPACES ||
|
|
|
|
pref == META_PREF_DYNAMIC_WORKSPACES) &&
|
|
|
|
!meta_prefs_get_dynamic_workspaces ())
|
2001-12-10 03:55:26 +00:00
|
|
|
{
|
2011-06-24 16:14:15 +00:00
|
|
|
/* GSettings doesn't provide timestamps, but luckily update_num_workspaces
|
Partial audit to fix timestamp usage. One step towards fixing #355180; see
2006-09-18 Elijah Newren <newren gmail com>
Partial audit to fix timestamp usage. One step towards fixing
#355180; see important comments in that bug.
* src/core.[ch] (meta_core_unshade, meta_core_shade):
* src/delete.c (meta_window_present_delete_dialog,
delete_ping_timeout_func):
* src/display.[ch] (meta_display_open, meta_display_close,
event_callback, meta_display_begin_grab_op,
process_selection_clear, meta_display_unmanage_screen,
meta_display_unmanage_windows_for_screen):
* src/frames.c (meta_frames_button_press_event):
* src/keybindings.c (handle_toggle_shade):
* src/main.c (main):
* src/screen.[ch] (update_num_workspaces, meta_screen_new,
meta_screen_free, prefs_changed_callback):
* src/window.[ch] (meta_window_free, finish_minimize,
implement_showing, meta_window_show, meta_window_maximize,
meta_window_make_fullscreen_internal,
meta_window_unmake_fullscreen, meta_window_shade,
meta_window_unshade, window_activate, send_sync_request,
meta_window_client_message, menu_callback,
meta_window_update_keyboard_resize):
Remove usage of CurrentTime, meta_display_get_current_time() and
meta_display_get_current_time_roundtrip() where possible, or
document why it isn't possible, or at very least add a FIXME with
some explanation of my laziness and what needs to be done.
2006-09-18 17:27:24 +00:00
|
|
|
* often doesn't need it...
|
|
|
|
*/
|
2014-05-02 13:34:02 +00:00
|
|
|
guint32 timestamp =
|
Partial audit to fix timestamp usage. One step towards fixing #355180; see
2006-09-18 Elijah Newren <newren gmail com>
Partial audit to fix timestamp usage. One step towards fixing
#355180; see important comments in that bug.
* src/core.[ch] (meta_core_unshade, meta_core_shade):
* src/delete.c (meta_window_present_delete_dialog,
delete_ping_timeout_func):
* src/display.[ch] (meta_display_open, meta_display_close,
event_callback, meta_display_begin_grab_op,
process_selection_clear, meta_display_unmanage_screen,
meta_display_unmanage_windows_for_screen):
* src/frames.c (meta_frames_button_press_event):
* src/keybindings.c (handle_toggle_shade):
* src/main.c (main):
* src/screen.[ch] (update_num_workspaces, meta_screen_new,
meta_screen_free, prefs_changed_callback):
* src/window.[ch] (meta_window_free, finish_minimize,
implement_showing, meta_window_show, meta_window_maximize,
meta_window_make_fullscreen_internal,
meta_window_unmake_fullscreen, meta_window_shade,
meta_window_unshade, window_activate, send_sync_request,
meta_window_client_message, menu_callback,
meta_window_update_keyboard_resize):
Remove usage of CurrentTime, meta_display_get_current_time() and
meta_display_get_current_time_roundtrip() where possible, or
document why it isn't possible, or at very least add a FIXME with
some explanation of my laziness and what needs to be done.
2006-09-18 17:27:24 +00:00
|
|
|
meta_display_get_current_time_roundtrip (screen->display);
|
|
|
|
update_num_workspaces (screen, timestamp);
|
2001-12-10 03:55:26 +00:00
|
|
|
}
|
2002-11-03 19:06:39 +00:00
|
|
|
else if (pref == META_PREF_WORKSPACE_NAMES)
|
|
|
|
{
|
2003-02-14 07:03:46 +00:00
|
|
|
set_workspace_names (screen);
|
2002-11-03 19:06:39 +00:00
|
|
|
}
|
2001-12-10 03:55:26 +00:00
|
|
|
}
|
|
|
|
|
2001-06-09 05:14:43 +00:00
|
|
|
int
|
|
|
|
meta_screen_get_n_workspaces (MetaScreen *screen)
|
2002-10-16 20:12:24 +00:00
|
|
|
{
|
|
|
|
return g_list_length (screen->workspaces);
|
|
|
|
}
|
|
|
|
|
2008-11-17 21:34:28 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2002-10-16 20:12:24 +00:00
|
|
|
MetaWorkspace*
|
|
|
|
meta_screen_get_workspace_by_index (MetaScreen *screen,
|
|
|
|
int idx)
|
2001-06-09 05:14:43 +00:00
|
|
|
{
|
2014-08-15 23:41:37 +00:00
|
|
|
return g_list_nth_data (screen->workspaces, idx);
|
2001-12-10 03:55:26 +00:00
|
|
|
}
|
2001-06-09 05:14:43 +00:00
|
|
|
|
2002-10-21 21:44:35 +00:00
|
|
|
static void
|
2002-08-14 00:08:30 +00:00
|
|
|
set_number_of_spaces_hint (MetaScreen *screen,
|
2017-08-26 19:10:38 +00:00
|
|
|
int n_spaces)
|
2002-08-14 00:08:30 +00:00
|
|
|
{
|
2017-08-26 16:26:30 +00:00
|
|
|
MetaX11Display *x11_display = screen->display->x11_display;
|
2002-08-14 00:08:30 +00:00
|
|
|
unsigned long data[1];
|
|
|
|
|
|
|
|
if (screen->closing > 0)
|
2002-10-21 21:44:35 +00:00
|
|
|
return;
|
2002-08-14 00:08:30 +00:00
|
|
|
|
|
|
|
data[0] = n_spaces;
|
|
|
|
|
2006-01-20 22:03:56 +00:00
|
|
|
meta_verbose ("Setting _NET_NUMBER_OF_DESKTOPS to %lu\n", data[0]);
|
2002-08-14 00:08:30 +00:00
|
|
|
|
2017-08-26 16:27:50 +00:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 16:26:30 +00:00
|
|
|
XChangeProperty (x11_display->xdisplay,
|
|
|
|
x11_display->xroot,
|
|
|
|
x11_display->atom__NET_NUMBER_OF_DESKTOPS,
|
2002-08-14 00:08:30 +00:00
|
|
|
XA_CARDINAL,
|
|
|
|
32, PropModeReplace, (guchar*) data, 1);
|
2017-08-26 16:27:50 +00:00
|
|
|
meta_error_trap_pop (x11_display);
|
2002-08-14 00:08:30 +00:00
|
|
|
}
|
|
|
|
|
2008-10-24 10:03:43 +00:00
|
|
|
void
|
|
|
|
meta_screen_remove_workspace (MetaScreen *screen, MetaWorkspace *workspace,
|
|
|
|
guint32 timestamp)
|
|
|
|
{
|
|
|
|
GList *l;
|
2014-08-16 18:49:18 +00:00
|
|
|
GList *next;
|
2008-10-24 10:03:43 +00:00
|
|
|
MetaWorkspace *neighbour = NULL;
|
2010-02-11 10:06:38 +00:00
|
|
|
int index;
|
2011-01-25 21:27:31 +00:00
|
|
|
gboolean active_index_changed;
|
2010-02-11 10:06:38 +00:00
|
|
|
int new_num;
|
2008-10-24 10:03:43 +00:00
|
|
|
|
2014-08-16 18:49:18 +00:00
|
|
|
l = g_list_find (screen->workspaces, workspace);
|
|
|
|
if (!l)
|
|
|
|
return;
|
2008-10-24 10:03:43 +00:00
|
|
|
|
2014-08-16 18:49:18 +00:00
|
|
|
next = l->next;
|
2008-10-24 10:03:43 +00:00
|
|
|
|
2014-08-16 18:49:18 +00:00
|
|
|
if (l->prev)
|
|
|
|
neighbour = l->prev->data;
|
|
|
|
else if (l->next)
|
|
|
|
neighbour = l->next->data;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Cannot remove the only workspace! */
|
|
|
|
return;
|
|
|
|
}
|
2009-01-20 12:48:59 +00:00
|
|
|
|
2008-10-24 10:03:43 +00:00
|
|
|
meta_workspace_relocate_windows (workspace, neighbour);
|
|
|
|
|
|
|
|
if (workspace == screen->active_workspace)
|
|
|
|
meta_workspace_activate (neighbour, timestamp);
|
|
|
|
|
2009-07-02 15:19:02 +00:00
|
|
|
/* To emit the signal after removing the workspace */
|
|
|
|
index = meta_workspace_index (workspace);
|
2011-01-25 21:27:31 +00:00
|
|
|
active_index_changed = index < meta_screen_get_active_workspace_index (screen);
|
2009-07-02 15:19:02 +00:00
|
|
|
|
2008-10-24 10:03:43 +00:00
|
|
|
/* This also removes the workspace from the screens list */
|
2008-11-17 20:56:34 +00:00
|
|
|
meta_workspace_remove (workspace);
|
2008-10-24 10:03:43 +00:00
|
|
|
|
2010-02-11 10:06:38 +00:00
|
|
|
new_num = g_list_length (screen->workspaces);
|
|
|
|
|
|
|
|
set_number_of_spaces_hint (screen, new_num);
|
2012-03-08 00:29:58 +00:00
|
|
|
|
|
|
|
if (!meta_prefs_get_dynamic_workspaces ())
|
|
|
|
meta_prefs_set_num_workspaces (new_num);
|
2008-10-24 10:03:43 +00:00
|
|
|
|
2011-01-25 21:27:31 +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);
|
2011-01-25 21:27:31 +00:00
|
|
|
|
2014-08-15 23:49:49 +00:00
|
|
|
for (l = next; l != NULL; l = l->next)
|
2009-01-09 15:04:53 +00:00
|
|
|
{
|
|
|
|
MetaWorkspace *w = l->data;
|
2014-08-16 12:03:10 +00:00
|
|
|
meta_workspace_index_changed (w);
|
2009-01-09 15:04:53 +00:00
|
|
|
}
|
|
|
|
|
2017-08-26 19:10:38 +00:00
|
|
|
meta_display_queue_workarea_recalc (screen->display);
|
2008-11-17 22:22:28 +00:00
|
|
|
|
2009-07-02 15:19:02 +00:00
|
|
|
g_signal_emit (screen, screen_signals[WORKSPACE_REMOVED], 0, index);
|
2008-11-17 22:22:28 +00:00
|
|
|
g_object_notify (G_OBJECT (screen), "n-workspaces");
|
2008-10-24 10:03:43 +00:00
|
|
|
}
|
|
|
|
|
2008-11-17 21:34:28 +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;
|
2010-02-11 10:06:38 +00:00
|
|
|
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);
|
|
|
|
|
2010-02-11 10:06:38 +00:00
|
|
|
new_num = g_list_length (screen->workspaces);
|
|
|
|
|
|
|
|
set_number_of_spaces_hint (screen, new_num);
|
2012-03-08 00:29:58 +00:00
|
|
|
|
|
|
|
if (!meta_prefs_get_dynamic_workspaces ())
|
|
|
|
meta_prefs_set_num_workspaces (new_num);
|
2008-10-24 10:11:28 +00:00
|
|
|
|
2017-08-26 19:10:38 +00:00
|
|
|
meta_display_queue_workarea_recalc (screen->display);
|
2008-10-24 10:11:28 +00:00
|
|
|
|
2009-07-02 15:19:02 +00:00
|
|
|
g_signal_emit (screen, screen_signals[WORKSPACE_ADDED],
|
|
|
|
0, meta_workspace_index (w));
|
2008-11-17 22:22:28 +00:00
|
|
|
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
|
|
|
|
2001-12-10 03:55:26 +00:00
|
|
|
static void
|
Partial audit to fix timestamp usage. One step towards fixing #355180; see
2006-09-18 Elijah Newren <newren gmail com>
Partial audit to fix timestamp usage. One step towards fixing
#355180; see important comments in that bug.
* src/core.[ch] (meta_core_unshade, meta_core_shade):
* src/delete.c (meta_window_present_delete_dialog,
delete_ping_timeout_func):
* src/display.[ch] (meta_display_open, meta_display_close,
event_callback, meta_display_begin_grab_op,
process_selection_clear, meta_display_unmanage_screen,
meta_display_unmanage_windows_for_screen):
* src/frames.c (meta_frames_button_press_event):
* src/keybindings.c (handle_toggle_shade):
* src/main.c (main):
* src/screen.[ch] (update_num_workspaces, meta_screen_new,
meta_screen_free, prefs_changed_callback):
* src/window.[ch] (meta_window_free, finish_minimize,
implement_showing, meta_window_show, meta_window_maximize,
meta_window_make_fullscreen_internal,
meta_window_unmake_fullscreen, meta_window_shade,
meta_window_unshade, window_activate, send_sync_request,
meta_window_client_message, menu_callback,
meta_window_update_keyboard_resize):
Remove usage of CurrentTime, meta_display_get_current_time() and
meta_display_get_current_time_roundtrip() where possible, or
document why it isn't possible, or at very least add a FIXME with
some explanation of my laziness and what needs to be done.
2006-09-18 17:27:24 +00:00
|
|
|
update_num_workspaces (MetaScreen *screen,
|
|
|
|
guint32 timestamp)
|
2001-12-10 03:55:26 +00:00
|
|
|
{
|
2017-08-26 16:26:30 +00:00
|
|
|
MetaDisplay *display = screen->display;
|
2011-12-06 15:41:27 +00:00
|
|
|
int new_num, old_num;
|
2014-08-15 23:49:49 +00:00
|
|
|
GList *l;
|
2001-12-10 03:55:26 +00:00
|
|
|
int i;
|
|
|
|
GList *extras;
|
|
|
|
MetaWorkspace *last_remaining;
|
|
|
|
gboolean need_change_space;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2012-10-17 18:15:10 +00:00
|
|
|
if (meta_prefs_get_dynamic_workspaces ())
|
|
|
|
{
|
|
|
|
int n_items;
|
2015-06-23 22:09:07 +00:00
|
|
|
uint32_t *list;
|
2012-10-17 18:15:10 +00:00
|
|
|
|
|
|
|
n_items = 0;
|
|
|
|
list = NULL;
|
|
|
|
|
2017-08-26 18:51:28 +00:00
|
|
|
if (meta_prop_get_cardinal_list (display->x11_display,
|
2017-08-26 16:26:30 +00:00
|
|
|
display->x11_display->xroot,
|
|
|
|
display->x11_display->atom__NET_NUMBER_OF_DESKTOPS,
|
2012-10-17 18:15:10 +00:00
|
|
|
&list, &n_items))
|
|
|
|
{
|
|
|
|
new_num = list[0];
|
|
|
|
meta_XFree (list);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
new_num = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
new_num = meta_prefs_get_num_workspaces ();
|
|
|
|
}
|
2001-12-10 03:55:26 +00:00
|
|
|
|
|
|
|
g_assert (new_num > 0);
|
|
|
|
|
2010-02-11 10:06:38 +00:00
|
|
|
if (g_list_length (screen->workspaces) == (guint) new_num)
|
2017-09-29 22:38:37 +00:00
|
|
|
{
|
|
|
|
if (screen->display->display_opening)
|
|
|
|
set_number_of_spaces_hint (screen, new_num);
|
|
|
|
return;
|
|
|
|
}
|
2010-02-11 10:06:38 +00:00
|
|
|
|
2001-12-10 03:55:26 +00:00
|
|
|
last_remaining = NULL;
|
|
|
|
extras = NULL;
|
|
|
|
i = 0;
|
2014-08-15 23:49:49 +00:00
|
|
|
for (l = screen->workspaces; l != NULL; l = l->next)
|
2001-12-10 03:55:26 +00:00
|
|
|
{
|
2014-08-15 23:49:49 +00:00
|
|
|
MetaWorkspace *w = l->data;
|
2001-12-10 03:55:26 +00:00
|
|
|
|
2003-01-08 04:23:18 +00:00
|
|
|
if (i >= new_num)
|
2002-10-16 20:12:24 +00:00
|
|
|
extras = g_list_prepend (extras, w);
|
|
|
|
else
|
|
|
|
last_remaining = w;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2002-10-16 20:12:24 +00:00
|
|
|
++i;
|
2001-12-10 03:55:26 +00:00
|
|
|
}
|
2011-12-06 15:41:27 +00:00
|
|
|
old_num = i;
|
2001-12-10 03:55:26 +00:00
|
|
|
|
|
|
|
g_assert (last_remaining);
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2001-12-10 03:55:26 +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;
|
2014-08-15 23:49:49 +00:00
|
|
|
for (l = extras; l != NULL; l = l->next)
|
2001-12-10 03:55:26 +00:00
|
|
|
{
|
2014-08-15 23:49:49 +00:00
|
|
|
MetaWorkspace *w = l->data;
|
2001-12-10 03:55:26 +00:00
|
|
|
|
2014-05-02 13:34:02 +00:00
|
|
|
meta_workspace_relocate_windows (w, last_remaining);
|
2001-12-10 03:55:26 +00:00
|
|
|
|
|
|
|
if (w == screen->active_workspace)
|
|
|
|
need_change_space = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (need_change_space)
|
Partial audit to fix timestamp usage. One step towards fixing #355180; see
2006-09-18 Elijah Newren <newren gmail com>
Partial audit to fix timestamp usage. One step towards fixing
#355180; see important comments in that bug.
* src/core.[ch] (meta_core_unshade, meta_core_shade):
* src/delete.c (meta_window_present_delete_dialog,
delete_ping_timeout_func):
* src/display.[ch] (meta_display_open, meta_display_close,
event_callback, meta_display_begin_grab_op,
process_selection_clear, meta_display_unmanage_screen,
meta_display_unmanage_windows_for_screen):
* src/frames.c (meta_frames_button_press_event):
* src/keybindings.c (handle_toggle_shade):
* src/main.c (main):
* src/screen.[ch] (update_num_workspaces, meta_screen_new,
meta_screen_free, prefs_changed_callback):
* src/window.[ch] (meta_window_free, finish_minimize,
implement_showing, meta_window_show, meta_window_maximize,
meta_window_make_fullscreen_internal,
meta_window_unmake_fullscreen, meta_window_shade,
meta_window_unshade, window_activate, send_sync_request,
meta_window_client_message, menu_callback,
meta_window_update_keyboard_resize):
Remove usage of CurrentTime, meta_display_get_current_time() and
meta_display_get_current_time_roundtrip() where possible, or
document why it isn't possible, or at very least add a FIXME with
some explanation of my laziness and what needs to be done.
2006-09-18 17:27:24 +00:00
|
|
|
meta_workspace_activate (last_remaining, timestamp);
|
2001-12-10 03:55:26 +00:00
|
|
|
|
|
|
|
/* Should now be safe to free the workspaces */
|
2014-08-15 23:49:49 +00:00
|
|
|
for (l = extras; l != NULL; l = l->next)
|
2001-12-10 03:55:26 +00:00
|
|
|
{
|
2014-08-15 23:49:49 +00:00
|
|
|
MetaWorkspace *w = l->data;
|
2001-12-10 03:55:26 +00:00
|
|
|
|
2008-11-17 20:56:34 +00:00
|
|
|
meta_workspace_remove (w);
|
2001-12-10 03:55:26 +00:00
|
|
|
}
|
2011-12-06 15:41:27 +00:00
|
|
|
|
2001-12-10 03:55:26 +00:00
|
|
|
g_list_free (extras);
|
2011-12-06 15:41:27 +00:00
|
|
|
|
|
|
|
for (i = old_num; i < new_num; i++)
|
|
|
|
meta_workspace_new (screen);
|
2002-06-25 01:12:37 +00:00
|
|
|
|
2002-08-14 00:08:30 +00:00
|
|
|
set_number_of_spaces_hint (screen, new_num);
|
|
|
|
|
2017-08-26 19:10:38 +00:00
|
|
|
meta_display_queue_workarea_recalc (display);
|
2008-11-17 22:22:28 +00:00
|
|
|
|
2011-12-06 15:41:27 +00:00
|
|
|
for (i = old_num; i < new_num; i++)
|
|
|
|
g_signal_emit (screen, screen_signals[WORKSPACE_ADDED], 0, i);
|
|
|
|
|
2008-11-17 22:22:28 +00:00
|
|
|
g_object_notify (G_OBJECT (screen), "n-workspaces");
|
2001-06-09 05:14:43 +00:00
|
|
|
}
|
2001-07-26 03:14:45 +00:00
|
|
|
|
2004-06-24 20:02:46 +00:00
|
|
|
MetaWindow*
|
|
|
|
meta_screen_get_mouse_window (MetaScreen *screen,
|
|
|
|
MetaWindow *not_this_one)
|
2003-01-22 04:54:04 +00:00
|
|
|
{
|
2016-11-29 12:30:22 +00:00
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
2003-01-22 04:54:04 +00:00
|
|
|
MetaWindow *window;
|
2014-03-02 22:27:50 +00:00
|
|
|
int x, y;
|
2012-12-17 02:47:11 +00:00
|
|
|
|
2003-01-22 04:54:04 +00:00
|
|
|
if (not_this_one)
|
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Focusing mouse window excluding %s\n", not_this_one->desc);
|
|
|
|
|
2016-11-29 12:30:22 +00:00
|
|
|
meta_cursor_tracker_get_pointer (cursor_tracker, &x, &y, NULL);
|
2003-01-22 04:54:04 +00:00
|
|
|
|
2017-08-26 17:03:51 +00:00
|
|
|
window = meta_stack_get_default_focus_window_at_point (screen->display->stack,
|
2003-01-22 04:54:04 +00:00
|
|
|
screen->active_workspace,
|
|
|
|
not_this_one,
|
2014-03-02 22:27:50 +00:00
|
|
|
x, y);
|
2003-01-22 04:54:04 +00:00
|
|
|
|
2004-06-24 20:02:46 +00:00
|
|
|
return window;
|
2003-01-22 04:54:04 +00:00
|
|
|
}
|
|
|
|
|
2002-05-16 04:03:36 +00:00
|
|
|
#define _NET_WM_ORIENTATION_HORZ 0
|
|
|
|
#define _NET_WM_ORIENTATION_VERT 1
|
|
|
|
|
2002-10-01 19:57:26 +00:00
|
|
|
#define _NET_WM_TOPLEFT 0
|
|
|
|
#define _NET_WM_TOPRIGHT 1
|
|
|
|
#define _NET_WM_BOTTOMRIGHT 2
|
|
|
|
#define _NET_WM_BOTTOMLEFT 3
|
|
|
|
|
2002-05-16 04:03:36 +00:00
|
|
|
void
|
|
|
|
meta_screen_update_workspace_layout (MetaScreen *screen)
|
|
|
|
{
|
2015-06-23 22:09:07 +00:00
|
|
|
uint32_t *list;
|
2002-05-16 04:03:36 +00:00
|
|
|
int n_items;
|
2017-08-26 16:26:30 +00:00
|
|
|
MetaDisplay *display = screen->display;
|
2011-01-24 20:40:30 +00:00
|
|
|
|
|
|
|
if (screen->workspace_layout_overridden)
|
|
|
|
return;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2002-05-16 04:03:36 +00:00
|
|
|
list = NULL;
|
|
|
|
n_items = 0;
|
|
|
|
|
2017-08-26 18:51:28 +00:00
|
|
|
if (meta_prop_get_cardinal_list (display->x11_display,
|
2017-08-26 16:26:30 +00:00
|
|
|
display->x11_display->xroot,
|
|
|
|
display->x11_display->atom__NET_DESKTOP_LAYOUT,
|
2002-05-16 04:03:36 +00:00
|
|
|
&list, &n_items))
|
|
|
|
{
|
2002-10-01 19:57:26 +00:00
|
|
|
if (n_items == 3 || n_items == 4)
|
2002-05-16 04:03:36 +00:00
|
|
|
{
|
|
|
|
int cols, rows;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2002-05-16 04:03:36 +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;
|
|
|
|
}
|
|
|
|
|
2002-10-01 19:57:26 +00:00
|
|
|
cols = list[1];
|
|
|
|
rows = list[2];
|
2002-05-16 04:03:36 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2002-05-16 04:03:36 +00:00
|
|
|
if (cols > 0)
|
|
|
|
screen->columns_of_workspaces = cols;
|
|
|
|
else
|
|
|
|
screen->columns_of_workspaces = -1;
|
|
|
|
}
|
2002-10-01 19:57:26 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2003-11-17 00:06:58 +00:00
|
|
|
else
|
|
|
|
screen->starting_corner = META_SCREEN_TOPLEFT;
|
2002-05-16 04:03:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-10-01 19:57:26 +00:00
|
|
|
meta_warning ("Someone set _NET_DESKTOP_LAYOUT to %d integers instead of 4 "
|
|
|
|
"(3 is accepted for backwards compat)\n", n_items);
|
2002-05-16 04:03:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
meta_XFree (list);
|
|
|
|
}
|
|
|
|
|
2006-01-20 22:03:56 +00:00
|
|
|
meta_verbose ("Workspace layout rows = %d cols = %d orientation = %d starting corner = %u\n",
|
2002-05-16 04:03:36 +00:00
|
|
|
screen->rows_of_workspaces,
|
|
|
|
screen->columns_of_workspaces,
|
2002-10-01 19:57:26 +00:00
|
|
|
screen->vertical_workspaces,
|
|
|
|
screen->starting_corner);
|
2002-05-16 04:03:36 +00:00
|
|
|
}
|
2002-06-09 03:44:16 +00:00
|
|
|
|
2011-01-24 20:40:30 +00:00
|
|
|
/**
|
|
|
|
* 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()
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2002-11-03 19:06:39 +00:00
|
|
|
static void
|
2003-02-14 07:03:46 +00:00
|
|
|
set_workspace_names (MetaScreen *screen)
|
2002-11-03 19:06:39 +00:00
|
|
|
{
|
|
|
|
/* This updates names on root window when the pref changes,
|
|
|
|
* note we only get prefs change notify if things have
|
|
|
|
* really changed.
|
|
|
|
*/
|
2017-08-26 16:26:30 +00:00
|
|
|
MetaX11Display *x11_display = screen->display->x11_display;
|
2002-11-03 19:06:39 +00:00
|
|
|
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)
|
2002-11-20 03:57:20 +00:00
|
|
|
g_string_append_len (flattened, name,
|
2002-11-03 19:06:39 +00:00
|
|
|
strlen (name) + 1);
|
|
|
|
else
|
|
|
|
g_string_append_len (flattened, "", 1);
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2002-11-03 19:06:39 +00:00
|
|
|
++i;
|
|
|
|
}
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2017-08-26 16:27:50 +00:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 16:26:30 +00:00
|
|
|
XChangeProperty (x11_display->xdisplay,
|
|
|
|
x11_display->xroot,
|
|
|
|
x11_display->atom__NET_DESKTOP_NAMES,
|
|
|
|
x11_display->atom_UTF8_STRING,
|
2002-11-03 19:06:39 +00:00
|
|
|
8, PropModeReplace,
|
2006-04-13 13:16:42 +00:00
|
|
|
(unsigned char *)flattened->str, flattened->len);
|
2017-08-26 16:27:50 +00:00
|
|
|
meta_error_trap_pop (x11_display);
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2002-11-03 19:06:39 +00:00
|
|
|
g_string_free (flattened, TRUE);
|
|
|
|
}
|
|
|
|
|
2002-06-22 04:52:35 +00:00
|
|
|
void
|
|
|
|
meta_screen_update_workspace_names (MetaScreen *screen)
|
|
|
|
{
|
2017-08-26 16:26:30 +00:00
|
|
|
MetaX11Display *x11_display = screen->display->x11_display;
|
2002-06-22 04:52:35 +00:00
|
|
|
char **names;
|
|
|
|
int n_names;
|
|
|
|
int i;
|
2002-11-03 19:06:39 +00:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
2002-06-22 04:52:35 +00:00
|
|
|
names = NULL;
|
|
|
|
n_names = 0;
|
2017-08-26 18:51:28 +00:00
|
|
|
if (!meta_prop_get_utf8_list (x11_display,
|
2017-08-26 16:26:30 +00:00
|
|
|
x11_display->xroot,
|
|
|
|
x11_display->atom__NET_DESKTOP_NAMES,
|
2002-06-22 04:52:35 +00:00
|
|
|
&names, &n_names))
|
|
|
|
{
|
2016-07-21 13:03:56 +00:00
|
|
|
meta_verbose ("Failed to get workspace names from root window\n");
|
2002-06-22 04:52:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
2002-11-03 19:06:39 +00:00
|
|
|
while (i < n_names)
|
2002-06-22 04:52:35 +00:00
|
|
|
{
|
2002-11-20 03:57:20 +00:00
|
|
|
meta_topic (META_DEBUG_PREFS,
|
|
|
|
"Setting workspace %d name to \"%s\" due to _NET_DESKTOP_NAMES change\n",
|
|
|
|
i, names[i] ? names[i] : "null");
|
2002-11-03 19:06:39 +00:00
|
|
|
meta_prefs_change_workspace_name (i, names[i]);
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2002-11-03 19:06:39 +00:00
|
|
|
++i;
|
2002-06-22 04:52:35 +00:00
|
|
|
}
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2002-06-22 04:52:35 +00:00
|
|
|
g_strfreev (names);
|
|
|
|
}
|
|
|
|
|
2003-01-05 18:36:01 +00:00
|
|
|
#ifdef WITH_VERBOSE_MODE
|
2015-09-23 23:13:59 +00:00
|
|
|
static const char *
|
2003-01-05 18:36:01 +00:00
|
|
|
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 */
|
|
|
|
|
2002-06-22 05:11:04 +00:00
|
|
|
void
|
2003-01-05 18:36:01 +00:00
|
|
|
meta_screen_calc_workspace_layout (MetaScreen *screen,
|
|
|
|
int num_workspaces,
|
|
|
|
int current_space,
|
|
|
|
MetaWorkspaceLayout *layout)
|
2002-06-22 05:11:04 +00:00
|
|
|
{
|
2003-01-05 18:36:01 +00:00
|
|
|
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
|
|
|
|
2002-06-22 05:11:04 +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;
|
|
|
|
|
2003-01-05 18:36:01 +00:00
|
|
|
g_assert (rows != 0 && cols != 0);
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2003-01-05 18:36:01 +00:00
|
|
|
grid_area = rows * cols;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2003-01-05 18:36:01 +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.
|
2003-01-05 18:36:01 +00:00
|
|
|
* For instance:
|
|
|
|
*/
|
2014-05-02 13:34:02 +00:00
|
|
|
/* starting_corner = META_SCREEN_TOPLEFT
|
2003-01-05 18:36:01 +00:00
|
|
|
* vertical_workspaces = 0 vertical_workspaces=1
|
2014-05-02 13:34:02 +00:00
|
|
|
* 1234 1357
|
|
|
|
* 5678 2468
|
|
|
|
*
|
|
|
|
* starting_corner = META_SCREEN_TOPRIGHT
|
2003-01-05 18:36:01 +00:00
|
|
|
* vertical_workspaces = 0 vertical_workspaces=1
|
2014-05-02 13:34:02 +00:00
|
|
|
* 4321 7531
|
|
|
|
* 8765 8642
|
|
|
|
*
|
|
|
|
* starting_corner = META_SCREEN_BOTTOMLEFT
|
2003-01-05 18:36:01 +00:00
|
|
|
* vertical_workspaces = 0 vertical_workspaces=1
|
2014-05-02 13:34:02 +00:00
|
|
|
* 5678 2468
|
|
|
|
* 1234 1357
|
|
|
|
*
|
|
|
|
* starting_corner = META_SCREEN_BOTTOMRIGHT
|
2003-01-05 18:36:01 +00:00
|
|
|
* vertical_workspaces = 0 vertical_workspaces=1
|
2014-05-02 13:34:02 +00:00
|
|
|
* 8765 8642
|
|
|
|
* 4321 7531
|
2003-01-05 18:36:01 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
/* 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
|
|
|
|
2003-01-05 18:36:01 +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)
|
2003-01-05 18:36:01 +00:00
|
|
|
{
|
|
|
|
case META_SCREEN_TOPLEFT:
|
2014-05-02 13:34:02 +00:00
|
|
|
if (screen->vertical_workspaces)
|
2003-01-05 18:36:01 +00:00
|
|
|
{
|
|
|
|
c = 0;
|
|
|
|
while (c < cols)
|
|
|
|
{
|
|
|
|
r = 0;
|
|
|
|
while (r < rows)
|
|
|
|
{
|
|
|
|
grid[r*cols+c] = i;
|
|
|
|
++i;
|
|
|
|
++r;
|
|
|
|
}
|
|
|
|
++c;
|
|
|
|
}
|
|
|
|
}
|
2003-01-06 02:59:19 +00:00
|
|
|
else
|
2003-01-05 18:36:01 +00:00
|
|
|
{
|
|
|
|
r = 0;
|
|
|
|
while (r < rows)
|
|
|
|
{
|
2003-01-06 02:59:19 +00:00
|
|
|
c = 0;
|
|
|
|
while (c < cols)
|
2003-01-05 18:36:01 +00:00
|
|
|
{
|
|
|
|
grid[r*cols+c] = i;
|
|
|
|
++i;
|
2003-01-06 02:59:19 +00:00
|
|
|
++c;
|
2003-01-05 18:36:01 +00:00
|
|
|
}
|
|
|
|
++r;
|
|
|
|
}
|
|
|
|
}
|
2003-01-06 02:59:19 +00:00
|
|
|
break;
|
|
|
|
case META_SCREEN_TOPRIGHT:
|
2014-05-02 13:34:02 +00:00
|
|
|
if (screen->vertical_workspaces)
|
2003-01-05 18:36:01 +00:00
|
|
|
{
|
|
|
|
c = cols - 1;
|
|
|
|
while (c >= 0)
|
|
|
|
{
|
|
|
|
r = 0;
|
|
|
|
while (r < rows)
|
|
|
|
{
|
|
|
|
grid[r*cols+c] = i;
|
|
|
|
++i;
|
|
|
|
++r;
|
|
|
|
}
|
|
|
|
--c;
|
|
|
|
}
|
|
|
|
}
|
2003-01-06 02:59:19 +00:00
|
|
|
else
|
2003-01-05 18:36:01 +00:00
|
|
|
{
|
2003-01-06 02:59:19 +00:00
|
|
|
r = 0;
|
|
|
|
while (r < rows)
|
2003-01-05 18:36:01 +00:00
|
|
|
{
|
2003-01-06 02:59:19 +00:00
|
|
|
c = cols - 1;
|
|
|
|
while (c >= 0)
|
2003-01-05 18:36:01 +00:00
|
|
|
{
|
|
|
|
grid[r*cols+c] = i;
|
|
|
|
++i;
|
2003-01-06 02:59:19 +00:00
|
|
|
--c;
|
2003-01-05 18:36:01 +00:00
|
|
|
}
|
2003-01-06 02:59:19 +00:00
|
|
|
++r;
|
2003-01-05 18:36:01 +00:00
|
|
|
}
|
|
|
|
}
|
2003-01-06 02:59:19 +00:00
|
|
|
break;
|
|
|
|
case META_SCREEN_BOTTOMLEFT:
|
2014-05-02 13:34:02 +00:00
|
|
|
if (screen->vertical_workspaces)
|
2003-01-05 18:36:01 +00:00
|
|
|
{
|
|
|
|
c = 0;
|
|
|
|
while (c < cols)
|
|
|
|
{
|
|
|
|
r = rows - 1;
|
|
|
|
while (r >= 0)
|
|
|
|
{
|
|
|
|
grid[r*cols+c] = i;
|
|
|
|
++i;
|
|
|
|
--r;
|
|
|
|
}
|
|
|
|
++c;
|
|
|
|
}
|
|
|
|
}
|
2003-01-06 02:59:19 +00:00
|
|
|
else
|
2003-01-05 18:36:01 +00:00
|
|
|
{
|
|
|
|
r = rows - 1;
|
|
|
|
while (r >= 0)
|
|
|
|
{
|
2003-01-06 02:59:19 +00:00
|
|
|
c = 0;
|
|
|
|
while (c < cols)
|
2003-01-05 18:36:01 +00:00
|
|
|
{
|
|
|
|
grid[r*cols+c] = i;
|
|
|
|
++i;
|
2003-01-06 02:59:19 +00:00
|
|
|
++c;
|
2003-01-05 18:36:01 +00:00
|
|
|
}
|
|
|
|
--r;
|
|
|
|
}
|
|
|
|
}
|
2003-01-06 02:59:19 +00:00
|
|
|
break;
|
|
|
|
case META_SCREEN_BOTTOMRIGHT:
|
2014-05-02 13:34:02 +00:00
|
|
|
if (screen->vertical_workspaces)
|
2003-01-05 18:36:01 +00:00
|
|
|
{
|
|
|
|
c = cols - 1;
|
|
|
|
while (c >= 0)
|
|
|
|
{
|
|
|
|
r = rows - 1;
|
|
|
|
while (r >= 0)
|
|
|
|
{
|
|
|
|
grid[r*cols+c] = i;
|
|
|
|
++i;
|
|
|
|
--r;
|
|
|
|
}
|
|
|
|
--c;
|
|
|
|
}
|
|
|
|
}
|
2003-01-06 02:59:19 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
r = rows - 1;
|
|
|
|
while (r >= 0)
|
|
|
|
{
|
|
|
|
c = cols - 1;
|
|
|
|
while (c >= 0)
|
|
|
|
{
|
|
|
|
grid[r*cols+c] = i;
|
|
|
|
++i;
|
|
|
|
--c;
|
|
|
|
}
|
|
|
|
--r;
|
|
|
|
}
|
|
|
|
}
|
2003-01-05 18:36:01 +00:00
|
|
|
break;
|
2014-05-02 13:34:02 +00:00
|
|
|
}
|
2003-01-05 18:36:01 +00:00
|
|
|
|
|
|
|
if (i != grid_area)
|
|
|
|
meta_bug ("did not fill in the whole workspace grid in %s (%d filled)\n",
|
2008-01-28 14:52:34 +00:00
|
|
|
G_STRFUNC, i);
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2003-01-05 18:36:01 +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)
|
|
|
|
{
|
2003-01-06 02:59:19 +00:00
|
|
|
meta_verbose (" ");
|
2003-01-05 18:36:01 +00:00
|
|
|
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);
|
2002-06-22 05:11:04 +00:00
|
|
|
}
|
2002-09-29 02:50:24 +00:00
|
|
|
|
2017-08-26 16:37:29 +00:00
|
|
|
void
|
|
|
|
meta_screen_on_monitors_changed (MetaScreen *screen)
|
2011-02-25 15:37:05 +00:00
|
|
|
{
|
2016-11-25 06:31:38 +00:00
|
|
|
reload_logical_monitors (screen);
|
2017-10-13 00:14:40 +00:00
|
|
|
}
|
2017-02-24 10:10:52 +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
|
|
|
void
|
|
|
|
meta_screen_update_showing_desktop_hint (MetaScreen *screen)
|
2002-10-16 20:12:24 +00:00
|
|
|
{
|
2017-08-26 16:26:30 +00:00
|
|
|
MetaX11Display *x11_display = screen->display->x11_display;
|
2002-10-16 20:12:24 +00:00
|
|
|
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
|
|
|
|
2017-08-26 16:27:50 +00:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 16:26:30 +00:00
|
|
|
XChangeProperty (x11_display->xdisplay,
|
|
|
|
x11_display->xroot,
|
|
|
|
x11_display->atom__NET_SHOWING_DESKTOP,
|
2002-10-16 20:12:24 +00:00
|
|
|
XA_CARDINAL,
|
|
|
|
32, PropModeReplace, (guchar*) data, 1);
|
2017-08-26 16:27:50 +00:00
|
|
|
meta_error_trap_pop (x11_display);
|
2002-10-16 20:12:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
queue_windows_showing (MetaScreen *screen)
|
|
|
|
{
|
2014-08-15 23:49:49 +00:00
|
|
|
GSList *windows, *l;
|
2002-10-16 20:12:24 +00:00
|
|
|
|
2004-10-22 20:28:36 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
2009-06-15 19:32:23 +00:00
|
|
|
windows = meta_display_list_windows (screen->display, META_LIST_DEFAULT);
|
2002-10-16 20:12:24 +00:00
|
|
|
|
2014-08-15 23:49:49 +00:00
|
|
|
for (l = windows; l != NULL; l = l->next)
|
2002-10-16 20:12:24 +00:00
|
|
|
{
|
2014-08-15 23:49:49 +00:00
|
|
|
MetaWindow *w = l->data;
|
2014-08-15 23:43:08 +00:00
|
|
|
meta_window_queue (w, META_QUEUE_CALC_SHOWING);
|
2002-10-16 20:12:24 +00:00
|
|
|
}
|
2004-10-22 20:28:36 +00:00
|
|
|
|
|
|
|
g_slist_free (windows);
|
2002-10-16 20:12:24 +00:00
|
|
|
}
|
|
|
|
|
2003-05-16 21:59:08 +00:00
|
|
|
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)
|
2003-05-16 21:59:08 +00:00
|
|
|
{
|
2014-08-15 23:49:49 +00:00
|
|
|
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
|
|
|
|
2014-08-15 23:49:49 +00:00
|
|
|
for (l = screen->active_workspace->windows; l != NULL; l = l->next)
|
2003-05-16 21:59:08 +00:00
|
|
|
{
|
2014-08-15 23:49:49 +00:00
|
|
|
MetaWindow *w = l->data;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2014-08-15 23:43:08 +00:00
|
|
|
if (w->has_minimize_func && w != keep)
|
2003-05-16 21:59:08 +00:00
|
|
|
meta_window_minimize (w);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-16 20:12:24 +00:00
|
|
|
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)
|
2002-10-16 20:12:24 +00:00
|
|
|
{
|
2014-08-15 23:49:49 +00:00
|
|
|
GList *l;
|
2004-12-20 02:46:42 +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
|
|
|
if (screen->active_workspace->showing_desktop)
|
2002-10-16 20:12:24 +00:00
|
|
|
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
|
|
|
|
2002-10-16 20:12:24 +00:00
|
|
|
queue_windows_showing (screen);
|
2004-12-20 02:46:42 +00:00
|
|
|
|
|
|
|
/* Focus the most recently used META_WINDOW_DESKTOP window, if there is one;
|
|
|
|
* see bug 159257.
|
|
|
|
*/
|
2014-08-15 23:49:49 +00:00
|
|
|
for (l = screen->active_workspace->mru_list; l != NULL; l = l->next)
|
2004-12-20 02:46:42 +00:00
|
|
|
{
|
2014-08-15 23:49:49 +00:00
|
|
|
MetaWindow *w = l->data;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2014-08-15 23:43:08 +00:00
|
|
|
if (w->type == META_WINDOW_DESKTOP)
|
2004-12-20 02:46:42 +00:00
|
|
|
{
|
|
|
|
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);
|
2002-10-16 20:12:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
2002-10-16 20:12:24 +00:00
|
|
|
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;
|
|
|
|
|
2002-10-16 20:12:24 +00:00
|
|
|
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);
|
2002-10-16 20:12:24 +00:00
|
|
|
}
|
2002-10-25 23:35:50 +00:00
|
|
|
|
2008-12-02 23:13:11 +00:00
|
|
|
/**
|
|
|
|
* meta_screen_get_display:
|
|
|
|
* @screen: A #MetaScreen
|
2014-05-02 13:34:02 +00:00
|
|
|
*
|
2011-11-02 15:34:45 +00:00
|
|
|
* Retrieve the display associated with screen.
|
|
|
|
*
|
2014-05-02 13:34:02 +00:00
|
|
|
* Returns: (transfer none): Display
|
2008-12-02 23:13:11 +00:00
|
|
|
*/
|
2008-05-19 00:00:09 +00:00
|
|
|
MetaDisplay *
|
|
|
|
meta_screen_get_display (MetaScreen *screen)
|
|
|
|
{
|
|
|
|
return screen->display;
|
|
|
|
}
|
|
|
|
|
2010-09-01 19:39:53 +00:00
|
|
|
/**
|
|
|
|
* meta_screen_get_workspaces: (skip)
|
|
|
|
* @screen: a #MetaScreen
|
|
|
|
*
|
|
|
|
* Returns: (transfer none) (element-type Meta.Workspace): The workspaces for @screen
|
|
|
|
*/
|
2008-09-18 15:09:11 +00:00
|
|
|
GList *
|
|
|
|
meta_screen_get_workspaces (MetaScreen *screen)
|
|
|
|
{
|
|
|
|
return screen->workspaces;
|
|
|
|
}
|
|
|
|
|
2008-11-03 12:32:25 +00:00
|
|
|
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
|
|
|
|
2009-09-04 00:57:01 +00:00
|
|
|
/**
|
|
|
|
* meta_screen_get_active_workspace:
|
2013-02-15 18:42:08 +00:00
|
|
|
* @screen: A #MetaScreen
|
2009-09-04 00:57:01 +00:00
|
|
|
*
|
|
|
|
* 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;
|
|
|
|
}
|
2009-03-12 21:07:27 +00:00
|
|
|
|
2012-12-04 19:30:55 +00:00
|
|
|
void
|
|
|
|
meta_screen_focus_default_window (MetaScreen *screen,
|
|
|
|
guint32 timestamp)
|
|
|
|
{
|
|
|
|
meta_workspace_focus_default_window (screen->active_workspace,
|
|
|
|
NULL,
|
|
|
|
timestamp);
|
|
|
|
}
|
|
|
|
|
2009-07-02 15:19:02 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2011-01-25 21:27:31 +00:00
|
|
|
void
|
|
|
|
meta_screen_set_active_workspace_hint (MetaScreen *screen)
|
|
|
|
{
|
2017-08-26 16:26:30 +00:00
|
|
|
MetaX11Display *x11_display = screen->display->x11_display;
|
|
|
|
|
2011-01-25 21:27:31 +00:00
|
|
|
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
|
|
|
|
2011-01-25 21:27:31 +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
|
|
|
|
2017-08-26 16:27:50 +00:00
|
|
|
meta_error_trap_push (x11_display);
|
2017-08-26 16:26:30 +00:00
|
|
|
XChangeProperty (x11_display->xdisplay,
|
|
|
|
x11_display->xroot,
|
|
|
|
x11_display->atom__NET_CURRENT_DESKTOP,
|
2011-01-25 21:27:31 +00:00
|
|
|
XA_CARDINAL,
|
|
|
|
32, PropModeReplace, (guchar*) data, 1);
|
2017-08-26 16:27:50 +00:00
|
|
|
meta_error_trap_pop (x11_display);
|
2011-01-25 21:27:31 +00:00
|
|
|
}
|