2008-10-31 11:20:54 -04:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
2009-11-24 09:07:40 -05:00
|
|
|
#include "config.h"
|
|
|
|
|
2009-04-21 17:21:06 -04:00
|
|
|
#include <dirent.h>
|
2008-12-18 15:57:37 -05:00
|
|
|
#include <errno.h>
|
2009-04-21 17:21:06 -04:00
|
|
|
#include <fcntl.h>
|
2011-03-05 10:49:24 -05:00
|
|
|
#include <math.h>
|
2011-08-28 01:32:12 -04:00
|
|
|
#include <stdarg.h>
|
2009-01-19 18:06:59 -05:00
|
|
|
#include <stdlib.h>
|
2008-12-18 15:57:37 -05:00
|
|
|
#include <string.h>
|
2009-04-21 17:21:06 -04:00
|
|
|
#include <unistd.h>
|
2011-03-05 10:49:24 -05:00
|
|
|
#ifdef HAVE_SYS_RESOURCE_H
|
|
|
|
#include <sys/resource.h>
|
|
|
|
#endif
|
2012-11-04 13:53:49 -05:00
|
|
|
#include <locale.h>
|
2011-03-05 10:49:24 -05:00
|
|
|
|
|
|
|
#include <X11/extensions/Xfixes.h>
|
|
|
|
#include <canberra.h>
|
2012-11-04 13:53:49 -05:00
|
|
|
#include <canberra-gtk.h>
|
2011-03-05 10:49:24 -05:00
|
|
|
#include <clutter/glx/clutter-glx.h>
|
|
|
|
#include <clutter/x11/clutter-x11.h>
|
|
|
|
#include <gdk/gdkx.h>
|
2009-07-06 23:13:58 -04:00
|
|
|
#include <gio/gio.h>
|
2010-10-21 10:50:30 -04:00
|
|
|
#include <gjs/gjs-module.h>
|
2011-03-15 18:31:16 -04:00
|
|
|
#include <girepository.h>
|
2011-03-05 10:49:24 -05:00
|
|
|
#include <meta/display.h>
|
|
|
|
#include <meta/util.h>
|
2011-12-19 11:37:24 -05:00
|
|
|
#include <meta/meta-shaped-texture.h>
|
2011-03-05 10:49:24 -05:00
|
|
|
|
2011-05-20 15:50:54 -04:00
|
|
|
/* Memory report bits */
|
|
|
|
#ifdef HAVE_MALLINFO
|
|
|
|
#include <malloc.h>
|
|
|
|
#endif
|
|
|
|
|
2011-03-05 10:49:24 -05:00
|
|
|
#include "shell-enum-types.h"
|
|
|
|
#include "shell-global-private.h"
|
|
|
|
#include "shell-perf-log.h"
|
|
|
|
#include "shell-window-tracker.h"
|
|
|
|
#include "shell-wm.h"
|
|
|
|
#include "st.h"
|
2008-11-19 14:54:17 -05:00
|
|
|
|
2011-05-05 18:09:59 -04:00
|
|
|
static ShellGlobal *the_object = NULL;
|
|
|
|
|
2009-02-06 17:33:08 -05:00
|
|
|
static void grab_notify (GtkWidget *widget, gboolean is_grab, gpointer user_data);
|
2011-09-15 19:36:07 -04:00
|
|
|
static void shell_global_on_gc (GjsContext *context,
|
|
|
|
ShellGlobal *global);
|
2009-02-06 17:33:08 -05:00
|
|
|
|
2008-10-31 00:22:44 -04:00
|
|
|
struct _ShellGlobal {
|
|
|
|
GObject parent;
|
2011-07-13 12:22:32 -04:00
|
|
|
|
|
|
|
ClutterStage *stage;
|
|
|
|
Window stage_xwindow;
|
|
|
|
GdkWindow *stage_gdk_window;
|
|
|
|
|
|
|
|
MetaDisplay *meta_display;
|
|
|
|
GdkDisplay *gdk_display;
|
|
|
|
Display *xdisplay;
|
|
|
|
MetaScreen *meta_screen;
|
|
|
|
GdkScreen *gdk_screen;
|
|
|
|
|
2012-05-16 17:11:57 -04:00
|
|
|
char *session_mode;
|
2011-06-21 10:09:09 -04:00
|
|
|
|
2009-02-06 17:33:08 -05:00
|
|
|
/* We use this window to get a notification from GTK+ when
|
|
|
|
* a widget in our process does a GTK+ grab. See
|
|
|
|
* http://bugzilla.gnome.org/show_bug.cgi?id=570641
|
|
|
|
*
|
|
|
|
* This window is never mapped or shown.
|
|
|
|
*/
|
|
|
|
GtkWindow *grab_notifier;
|
2009-04-29 14:01:09 -04:00
|
|
|
gboolean gtk_grab_active;
|
|
|
|
|
|
|
|
ShellStageInputMode input_mode;
|
|
|
|
XserverRegion input_region;
|
2009-10-24 13:40:13 -04:00
|
|
|
|
|
|
|
GjsContext *js_context;
|
2010-10-19 14:55:43 -04:00
|
|
|
MetaPlugin *plugin;
|
2008-11-21 09:02:09 -05:00
|
|
|
ShellWM *wm;
|
2010-05-05 17:05:42 -04:00
|
|
|
GSettings *settings;
|
2009-09-10 01:36:05 -04:00
|
|
|
const char *datadir;
|
2008-12-22 17:05:56 -05:00
|
|
|
const char *imagedir;
|
2010-05-04 07:24:06 -04:00
|
|
|
const char *userdatadir;
|
2010-10-05 10:09:40 -04:00
|
|
|
StFocusManager *focus_manager;
|
2009-04-21 20:23:06 -04:00
|
|
|
|
2010-05-09 00:34:15 -04:00
|
|
|
guint work_count;
|
|
|
|
GSList *leisure_closures;
|
|
|
|
guint leisure_function_id;
|
2010-07-22 20:39:44 -04:00
|
|
|
|
|
|
|
/* For sound notifications */
|
|
|
|
ca_context *sound_context;
|
2011-01-05 09:47:27 -05:00
|
|
|
|
|
|
|
guint32 xdnd_timestamp;
|
2011-09-15 19:36:07 -04:00
|
|
|
|
|
|
|
gint64 last_gc_end_time;
|
2008-10-31 00:22:44 -04:00
|
|
|
};
|
|
|
|
|
2008-10-31 11:20:54 -04:00
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
|
2012-05-16 17:11:57 -04:00
|
|
|
PROP_SESSION_MODE,
|
2008-10-31 11:20:54 -04:00
|
|
|
PROP_OVERLAY_GROUP,
|
2008-11-19 17:54:42 -05:00
|
|
|
PROP_SCREEN,
|
2010-06-03 11:14:58 -04:00
|
|
|
PROP_GDK_SCREEN,
|
2011-07-13 12:34:31 -04:00
|
|
|
PROP_DISPLAY,
|
2008-10-31 11:20:54 -04:00
|
|
|
PROP_SCREEN_WIDTH,
|
2008-10-31 14:04:38 -04:00
|
|
|
PROP_SCREEN_HEIGHT,
|
2008-11-08 14:33:33 -05:00
|
|
|
PROP_STAGE,
|
2010-07-02 13:36:13 -04:00
|
|
|
PROP_STAGE_INPUT_MODE,
|
2008-11-21 09:02:09 -05:00
|
|
|
PROP_WINDOW_GROUP,
|
2013-02-12 16:00:41 -05:00
|
|
|
PROP_TOP_WINDOW_GROUP,
|
2008-12-22 17:05:56 -05:00
|
|
|
PROP_WINDOW_MANAGER,
|
2010-05-05 17:05:42 -04:00
|
|
|
PROP_SETTINGS,
|
2009-09-10 01:36:05 -04:00
|
|
|
PROP_DATADIR,
|
2009-04-23 17:10:37 -04:00
|
|
|
PROP_IMAGEDIR,
|
2010-05-04 07:24:06 -04:00
|
|
|
PROP_USERDATADIR,
|
2010-10-05 10:09:40 -04:00
|
|
|
PROP_FOCUS_MANAGER,
|
2008-10-31 11:20:54 -04:00
|
|
|
};
|
|
|
|
|
2011-01-05 09:47:27 -05:00
|
|
|
/* Signals */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
XDND_POSITION_CHANGED,
|
|
|
|
XDND_LEAVE,
|
|
|
|
XDND_ENTER,
|
2011-03-15 18:31:16 -04:00
|
|
|
NOTIFY_ERROR,
|
2011-01-05 09:47:27 -05:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2008-10-31 00:22:44 -04:00
|
|
|
G_DEFINE_TYPE(ShellGlobal, shell_global, G_TYPE_OBJECT);
|
|
|
|
|
2011-01-05 09:47:27 -05:00
|
|
|
static guint shell_global_signals [LAST_SIGNAL] = { 0 };
|
|
|
|
|
2008-10-31 11:20:54 -04:00
|
|
|
static void
|
|
|
|
shell_global_set_property(GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2010-07-02 13:36:13 -04:00
|
|
|
ShellGlobal *global = SHELL_GLOBAL (object);
|
|
|
|
|
2008-10-31 11:20:54 -04:00
|
|
|
switch (prop_id)
|
|
|
|
{
|
2010-07-02 13:36:13 -04:00
|
|
|
case PROP_STAGE_INPUT_MODE:
|
|
|
|
shell_global_set_stage_input_mode (global, g_value_get_enum (value));
|
|
|
|
break;
|
2012-05-16 17:11:57 -04:00
|
|
|
case PROP_SESSION_MODE:
|
|
|
|
g_clear_pointer (&global->session_mode, g_free);
|
|
|
|
global->session_mode = g_ascii_strdown (g_value_get_string (value), -1);
|
2011-06-21 10:09:09 -04:00
|
|
|
break;
|
2008-10-31 11:20:54 -04:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shell_global_get_property(GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ShellGlobal *global = SHELL_GLOBAL (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2012-05-16 17:11:57 -04:00
|
|
|
case PROP_SESSION_MODE:
|
|
|
|
g_value_set_string (value, shell_global_get_session_mode (global));
|
|
|
|
break;
|
2008-10-31 11:20:54 -04:00
|
|
|
case PROP_OVERLAY_GROUP:
|
2011-03-24 16:12:33 -04:00
|
|
|
g_value_set_object (value, meta_get_overlay_group_for_screen (global->meta_screen));
|
2008-10-31 11:20:54 -04:00
|
|
|
break;
|
2008-11-19 17:54:42 -05:00
|
|
|
case PROP_SCREEN:
|
2011-07-13 12:22:32 -04:00
|
|
|
g_value_set_object (value, global->meta_screen);
|
2008-11-19 17:54:42 -05:00
|
|
|
break;
|
2010-06-03 11:14:58 -04:00
|
|
|
case PROP_GDK_SCREEN:
|
2011-07-13 12:22:32 -04:00
|
|
|
g_value_set_object (value, global->gdk_screen);
|
2010-06-03 11:14:58 -04:00
|
|
|
break;
|
2011-07-13 12:34:31 -04:00
|
|
|
case PROP_DISPLAY:
|
|
|
|
g_value_set_object (value, global->meta_display);
|
|
|
|
break;
|
2008-10-31 11:20:54 -04:00
|
|
|
case PROP_SCREEN_WIDTH:
|
|
|
|
{
|
|
|
|
int width, height;
|
|
|
|
|
2011-03-24 16:12:33 -04:00
|
|
|
meta_screen_get_size (global->meta_screen, &width, &height);
|
2008-10-31 11:20:54 -04:00
|
|
|
g_value_set_int (value, width);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PROP_SCREEN_HEIGHT:
|
|
|
|
{
|
|
|
|
int width, height;
|
|
|
|
|
2011-03-24 16:12:33 -04:00
|
|
|
meta_screen_get_size (global->meta_screen, &width, &height);
|
2008-10-31 11:20:54 -04:00
|
|
|
g_value_set_int (value, height);
|
|
|
|
}
|
|
|
|
break;
|
2008-10-31 14:04:38 -04:00
|
|
|
case PROP_STAGE:
|
2011-07-13 12:22:32 -04:00
|
|
|
g_value_set_object (value, global->stage);
|
2008-10-31 14:04:38 -04:00
|
|
|
break;
|
2010-07-02 13:36:13 -04:00
|
|
|
case PROP_STAGE_INPUT_MODE:
|
|
|
|
g_value_set_enum (value, global->input_mode);
|
|
|
|
break;
|
2008-11-08 14:33:33 -05:00
|
|
|
case PROP_WINDOW_GROUP:
|
2011-03-24 16:12:33 -04:00
|
|
|
g_value_set_object (value, meta_get_window_group_for_screen (global->meta_screen));
|
2008-11-08 14:33:33 -05:00
|
|
|
break;
|
2013-02-12 16:00:41 -05:00
|
|
|
case PROP_TOP_WINDOW_GROUP:
|
|
|
|
g_value_set_object (value, meta_get_top_window_group_for_screen (global->meta_screen));
|
|
|
|
break;
|
2008-11-21 09:02:09 -05:00
|
|
|
case PROP_WINDOW_MANAGER:
|
|
|
|
g_value_set_object (value, global->wm);
|
|
|
|
break;
|
2010-05-05 17:05:42 -04:00
|
|
|
case PROP_SETTINGS:
|
|
|
|
g_value_set_object (value, global->settings);
|
|
|
|
break;
|
2009-09-10 01:36:05 -04:00
|
|
|
case PROP_DATADIR:
|
|
|
|
g_value_set_string (value, global->datadir);
|
|
|
|
break;
|
2008-12-22 17:05:56 -05:00
|
|
|
case PROP_IMAGEDIR:
|
|
|
|
g_value_set_string (value, global->imagedir);
|
|
|
|
break;
|
2010-05-04 07:24:06 -04:00
|
|
|
case PROP_USERDATADIR:
|
|
|
|
g_value_set_string (value, global->userdatadir);
|
2009-04-23 17:10:37 -04:00
|
|
|
break;
|
2010-10-05 10:09:40 -04:00
|
|
|
case PROP_FOCUS_MANAGER:
|
|
|
|
g_value_set_object (value, global->focus_manager);
|
|
|
|
break;
|
2008-10-31 11:20:54 -04:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-31 00:22:44 -04:00
|
|
|
static void
|
2008-12-22 17:05:56 -05:00
|
|
|
shell_global_init (ShellGlobal *global)
|
2008-10-31 00:22:44 -04:00
|
|
|
{
|
2008-12-22 17:05:56 -05:00
|
|
|
const char *datadir = g_getenv ("GNOME_SHELL_DATADIR");
|
2011-02-25 11:20:27 -05:00
|
|
|
const char *shell_js = g_getenv("GNOME_SHELL_JS");
|
|
|
|
char *imagedir, **search_path;
|
2008-12-22 17:05:56 -05:00
|
|
|
|
|
|
|
if (!datadir)
|
|
|
|
datadir = GNOME_SHELL_DATADIR;
|
2009-09-10 01:36:05 -04:00
|
|
|
global->datadir = datadir;
|
2008-12-22 17:05:56 -05:00
|
|
|
|
|
|
|
/* We make sure imagedir ends with a '/', since the JS won't have
|
|
|
|
* access to g_build_filename() and so will end up just
|
|
|
|
* concatenating global.imagedir to a filename.
|
|
|
|
*/
|
|
|
|
imagedir = g_build_filename (datadir, "images/", NULL);
|
|
|
|
if (g_file_test (imagedir, G_FILE_TEST_IS_DIR))
|
|
|
|
global->imagedir = imagedir;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_free (imagedir);
|
|
|
|
global->imagedir = g_strdup_printf ("%s/", datadir);
|
|
|
|
}
|
2009-04-23 17:10:37 -04:00
|
|
|
|
|
|
|
/* Ensure config dir exists for later use */
|
2010-05-04 07:24:06 -04:00
|
|
|
global->userdatadir = g_build_filename (g_get_user_data_dir (), "gnome-shell", NULL);
|
2010-05-06 03:42:53 -04:00
|
|
|
g_mkdir_with_parents (global->userdatadir, 0700);
|
2010-05-05 17:05:42 -04:00
|
|
|
|
|
|
|
global->settings = g_settings_new ("org.gnome.shell");
|
2009-02-06 17:33:08 -05:00
|
|
|
|
|
|
|
global->grab_notifier = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL));
|
|
|
|
g_signal_connect (global->grab_notifier, "grab-notify", G_CALLBACK (grab_notify), global);
|
2009-04-29 14:01:09 -04:00
|
|
|
global->gtk_grab_active = FALSE;
|
2009-04-21 20:23:06 -04:00
|
|
|
|
2009-04-29 14:01:09 -04:00
|
|
|
global->input_mode = SHELL_STAGE_INPUT_MODE_NORMAL;
|
2010-01-19 12:59:29 -05:00
|
|
|
|
2012-11-04 13:53:49 -05:00
|
|
|
global->sound_context = ca_gtk_context_get ();
|
|
|
|
ca_context_change_props (global->sound_context,
|
|
|
|
CA_PROP_APPLICATION_NAME, "GNOME Shell",
|
|
|
|
CA_PROP_APPLICATION_ID, "org.gnome.Shell",
|
|
|
|
CA_PROP_APPLICATION_ICON_NAME, "start-here",
|
|
|
|
CA_PROP_APPLICATION_LANGUAGE, setlocale (LC_MESSAGES, NULL),
|
|
|
|
NULL);
|
2010-07-22 20:39:44 -04:00
|
|
|
ca_context_open (global->sound_context);
|
2011-02-25 11:20:27 -05:00
|
|
|
|
|
|
|
if (!shell_js)
|
|
|
|
shell_js = JSDIR;
|
|
|
|
search_path = g_strsplit (shell_js, ":", -1);
|
|
|
|
global->js_context = g_object_new (GJS_TYPE_CONTEXT,
|
|
|
|
"search-path", search_path,
|
|
|
|
"js-version", "1.8",
|
2011-09-15 19:36:07 -04:00
|
|
|
"gc-notifications", TRUE,
|
2011-02-25 11:20:27 -05:00
|
|
|
NULL);
|
2011-09-15 19:36:07 -04:00
|
|
|
g_signal_connect (global->js_context, "gc", G_CALLBACK (shell_global_on_gc), global);
|
|
|
|
|
2011-02-25 11:20:27 -05:00
|
|
|
g_strfreev (search_path);
|
2008-10-31 00:22:44 -04:00
|
|
|
}
|
|
|
|
|
2011-05-05 18:09:59 -04:00
|
|
|
static void
|
|
|
|
shell_global_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
ShellGlobal *global = SHELL_GLOBAL (object);
|
|
|
|
|
|
|
|
g_object_unref (global->js_context);
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (global->grab_notifier));
|
|
|
|
g_object_unref (global->settings);
|
|
|
|
|
|
|
|
the_object = NULL;
|
|
|
|
|
|
|
|
G_OBJECT_CLASS(shell_global_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2008-10-31 00:22:44 -04:00
|
|
|
static void
|
2008-10-31 11:20:54 -04:00
|
|
|
shell_global_class_init (ShellGlobalClass *klass)
|
2008-10-31 00:22:44 -04:00
|
|
|
{
|
2008-10-31 11:20:54 -04:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
gobject_class->get_property = shell_global_get_property;
|
|
|
|
gobject_class->set_property = shell_global_set_property;
|
2011-05-05 18:09:59 -04:00
|
|
|
gobject_class->finalize = shell_global_finalize;
|
2008-10-31 11:20:54 -04:00
|
|
|
|
2011-01-05 09:47:27 -05:00
|
|
|
/* Emitted from gnome-shell-plugin.c during event handling */
|
|
|
|
shell_global_signals[XDND_POSITION_CHANGED] =
|
|
|
|
g_signal_new ("xdnd-position-changed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
2011-10-18 18:19:32 -04:00
|
|
|
NULL, NULL, NULL,
|
2011-01-05 09:47:27 -05:00
|
|
|
G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
|
|
|
|
|
|
|
|
/* Emitted from gnome-shell-plugin.c during event handling */
|
|
|
|
shell_global_signals[XDND_LEAVE] =
|
|
|
|
g_signal_new ("xdnd-leave",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
2011-10-18 18:19:32 -04:00
|
|
|
NULL, NULL, NULL,
|
2011-01-05 09:47:27 -05:00
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
/* Emitted from gnome-shell-plugin.c during event handling */
|
|
|
|
shell_global_signals[XDND_ENTER] =
|
|
|
|
g_signal_new ("xdnd-enter",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
2011-10-18 18:19:32 -04:00
|
|
|
NULL, NULL, NULL,
|
2011-01-05 09:47:27 -05:00
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2011-03-15 18:31:16 -04:00
|
|
|
shell_global_signals[NOTIFY_ERROR] =
|
|
|
|
g_signal_new ("notify-error",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
2011-10-18 18:19:32 -04:00
|
|
|
NULL, NULL, NULL,
|
2011-03-15 18:31:16 -04:00
|
|
|
G_TYPE_NONE, 2,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING);
|
|
|
|
|
2012-05-16 17:11:57 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_SESSION_MODE,
|
|
|
|
g_param_spec_string ("session-mode",
|
|
|
|
"Session Mode",
|
|
|
|
"The session mode to use",
|
|
|
|
"user",
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
2008-10-31 11:20:54 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_OVERLAY_GROUP,
|
|
|
|
g_param_spec_object ("overlay-group",
|
|
|
|
"Overlay Group",
|
|
|
|
"Actor holding objects that appear above the desktop contents",
|
|
|
|
CLUTTER_TYPE_ACTOR,
|
|
|
|
G_PARAM_READABLE));
|
2008-11-19 17:54:42 -05:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_SCREEN,
|
|
|
|
g_param_spec_object ("screen",
|
|
|
|
"Screen",
|
|
|
|
"Metacity screen object for the shell",
|
|
|
|
META_TYPE_SCREEN,
|
|
|
|
G_PARAM_READABLE));
|
2010-06-03 11:14:58 -04:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_GDK_SCREEN,
|
|
|
|
g_param_spec_object ("gdk-screen",
|
|
|
|
"GdkScreen",
|
|
|
|
"Gdk screen object for the shell",
|
|
|
|
GDK_TYPE_SCREEN,
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
2008-10-31 11:20:54 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_SCREEN_WIDTH,
|
|
|
|
g_param_spec_int ("screen-width",
|
|
|
|
"Screen Width",
|
|
|
|
"Screen width, in pixels",
|
|
|
|
0, G_MAXINT, 1,
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_SCREEN_HEIGHT,
|
|
|
|
g_param_spec_int ("screen-height",
|
|
|
|
"Screen Height",
|
|
|
|
"Screen height, in pixels",
|
|
|
|
0, G_MAXINT, 1,
|
|
|
|
G_PARAM_READABLE));
|
2011-07-13 12:34:31 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_DISPLAY,
|
|
|
|
g_param_spec_object ("display",
|
|
|
|
"Display",
|
|
|
|
"Metacity display object for the shell",
|
|
|
|
META_TYPE_DISPLAY,
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
2008-10-31 14:04:38 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_STAGE,
|
|
|
|
g_param_spec_object ("stage",
|
|
|
|
"Stage",
|
|
|
|
"Stage holding the desktop scene graph",
|
|
|
|
CLUTTER_TYPE_ACTOR,
|
|
|
|
G_PARAM_READABLE));
|
2010-07-02 13:36:13 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_STAGE_INPUT_MODE,
|
|
|
|
g_param_spec_enum ("stage-input-mode",
|
|
|
|
"Stage input mode",
|
|
|
|
"The stage input mode",
|
|
|
|
SHELL_TYPE_STAGE_INPUT_MODE,
|
|
|
|
SHELL_STAGE_INPUT_MODE_NORMAL,
|
|
|
|
G_PARAM_READWRITE));
|
2008-11-08 14:33:33 -05:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_WINDOW_GROUP,
|
|
|
|
g_param_spec_object ("window-group",
|
|
|
|
"Window Group",
|
|
|
|
"Actor holding window actors",
|
|
|
|
CLUTTER_TYPE_ACTOR,
|
|
|
|
G_PARAM_READABLE));
|
2013-02-12 16:00:41 -05:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_TOP_WINDOW_GROUP,
|
|
|
|
g_param_spec_object ("top-window-group",
|
|
|
|
"Top Window Group",
|
|
|
|
"Actor holding override-redirect windows",
|
|
|
|
CLUTTER_TYPE_ACTOR,
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
2008-11-21 09:02:09 -05:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_WINDOW_MANAGER,
|
|
|
|
g_param_spec_object ("window-manager",
|
|
|
|
"Window Manager",
|
|
|
|
"Window management interface",
|
|
|
|
SHELL_TYPE_WM,
|
|
|
|
G_PARAM_READABLE));
|
2010-05-05 17:05:42 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_SETTINGS,
|
|
|
|
g_param_spec_object ("settings",
|
|
|
|
"Settings",
|
|
|
|
"GSettings instance for gnome-shell configuration",
|
|
|
|
G_TYPE_SETTINGS,
|
|
|
|
G_PARAM_READABLE));
|
2009-09-10 01:36:05 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_DATADIR,
|
|
|
|
g_param_spec_string ("datadir",
|
|
|
|
"Data directory",
|
|
|
|
"Directory containing gnome-shell data files",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READABLE));
|
2008-12-22 17:05:56 -05:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_IMAGEDIR,
|
|
|
|
g_param_spec_string ("imagedir",
|
|
|
|
"Image directory",
|
|
|
|
"Directory containing gnome-shell image files",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READABLE));
|
2009-04-23 17:10:37 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
2010-05-04 07:24:06 -04:00
|
|
|
PROP_USERDATADIR,
|
|
|
|
g_param_spec_string ("userdatadir",
|
|
|
|
"User data directory",
|
|
|
|
"Directory containing gnome-shell user data",
|
2009-04-23 17:10:37 -04:00
|
|
|
NULL,
|
|
|
|
G_PARAM_READABLE));
|
2010-10-05 10:09:40 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_FOCUS_MANAGER,
|
|
|
|
g_param_spec_object ("focus-manager",
|
|
|
|
"Focus manager",
|
|
|
|
"The shell's StFocusManager",
|
|
|
|
ST_TYPE_FOCUS_MANAGER,
|
|
|
|
G_PARAM_READABLE));
|
2008-10-31 00:22:44 -04:00
|
|
|
}
|
|
|
|
|
2011-08-28 01:32:12 -04:00
|
|
|
/**•
|
|
|
|
* _shell_global_init: (skip)•
|
|
|
|
* @first_property_name: the name of the first property
|
|
|
|
* @...: the value of the first property, followed optionally by more
|
|
|
|
* name/value pairs, followed by %NULL
|
|
|
|
*•
|
|
|
|
* Initializes the shell global singleton with the construction-time
|
|
|
|
* properties.
|
|
|
|
*
|
|
|
|
* There are currently no such properties, so @first_property_name should
|
|
|
|
* always be %NULL.
|
|
|
|
*
|
|
|
|
* This call must be called before shell_global_get() and shouldn't be called
|
|
|
|
* more than once.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
_shell_global_init (const char *first_property_name,
|
|
|
|
...)
|
|
|
|
{
|
|
|
|
va_list argument_list;
|
|
|
|
|
|
|
|
g_return_if_fail (the_object == NULL);
|
|
|
|
|
|
|
|
va_start (argument_list, first_property_name);
|
|
|
|
the_object = SHELL_GLOBAL (g_object_new_valist (SHELL_TYPE_GLOBAL,
|
|
|
|
first_property_name,
|
|
|
|
argument_list));
|
|
|
|
va_end (argument_list);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-10-31 14:24:29 -04:00
|
|
|
/**
|
|
|
|
* shell_global_get:
|
|
|
|
*
|
|
|
|
* Gets the singleton global object that represents the desktop.
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): the singleton global object
|
|
|
|
*/
|
2008-10-31 00:22:44 -04:00
|
|
|
ShellGlobal *
|
|
|
|
shell_global_get (void)
|
|
|
|
{
|
|
|
|
return the_object;
|
|
|
|
}
|
|
|
|
|
2010-07-02 13:36:13 -04:00
|
|
|
static void
|
|
|
|
focus_window_changed (MetaDisplay *display,
|
|
|
|
GParamSpec *param,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
ShellGlobal *global = user_data;
|
|
|
|
|
|
|
|
if (global->input_mode == SHELL_STAGE_INPUT_MODE_FOCUSED &&
|
|
|
|
meta_display_get_focus_window (display) != NULL)
|
|
|
|
shell_global_set_stage_input_mode (global, SHELL_STAGE_INPUT_MODE_NORMAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shell_global_focus_stage (ShellGlobal *global)
|
|
|
|
{
|
2011-07-13 12:22:32 -04:00
|
|
|
XSetInputFocus (global->xdisplay, global->stage_xwindow,
|
|
|
|
RevertToPointerRoot,
|
2010-07-02 13:36:13 -04:00
|
|
|
shell_global_get_current_time (global));
|
|
|
|
}
|
|
|
|
|
2008-10-31 14:24:29 -04:00
|
|
|
/**
|
2009-04-29 14:01:09 -04:00
|
|
|
* shell_global_set_stage_input_mode:
|
|
|
|
* @global: the #ShellGlobal
|
|
|
|
* @mode: the stage input mode
|
2008-10-31 14:24:29 -04:00
|
|
|
*
|
2009-04-29 14:01:09 -04:00
|
|
|
* Sets the input mode of the stage; when @mode is
|
|
|
|
* %SHELL_STAGE_INPUT_MODE_NONREACTIVE, then the stage does not absorb
|
|
|
|
* any clicks, but just passes them through to underlying windows.
|
|
|
|
* When it is %SHELL_STAGE_INPUT_MODE_NORMAL, then the stage accepts
|
|
|
|
* clicks in the region defined by
|
|
|
|
* shell_global_set_stage_input_region() but passes through clicks
|
|
|
|
* outside that region. When it is %SHELL_STAGE_INPUT_MODE_FULLSCREEN,
|
|
|
|
* the stage absorbs all input.
|
|
|
|
*
|
2010-07-02 13:36:13 -04:00
|
|
|
* When the input mode is %SHELL_STAGE_INPUT_MODE_FOCUSED, the pointer
|
|
|
|
* is handled as with %SHELL_STAGE_INPUT_MODE_NORMAL, but additionally
|
|
|
|
* the stage window has the keyboard focus. If the stage loses the
|
|
|
|
* focus (eg, because the user clicked into a window) the input mode
|
|
|
|
* will revert to %SHELL_STAGE_INPUT_MODE_NORMAL.
|
|
|
|
*
|
2009-04-29 14:01:09 -04:00
|
|
|
* Note that whenever a mutter-internal Gtk widget has a pointer grab,
|
|
|
|
* the shell behaves as though it was in
|
|
|
|
* %SHELL_STAGE_INPUT_MODE_NONREACTIVE, to ensure that the widget gets
|
|
|
|
* any clicks it is expecting.
|
2008-10-31 14:24:29 -04:00
|
|
|
*/
|
2008-10-31 00:22:44 -04:00
|
|
|
void
|
2009-04-29 14:01:09 -04:00
|
|
|
shell_global_set_stage_input_mode (ShellGlobal *global,
|
|
|
|
ShellStageInputMode mode)
|
2008-10-31 00:22:44 -04:00
|
|
|
{
|
2012-02-29 22:38:35 -05:00
|
|
|
MetaScreen *screen;
|
|
|
|
|
2008-10-31 11:20:54 -04:00
|
|
|
g_return_if_fail (SHELL_IS_GLOBAL (global));
|
2008-10-31 00:22:44 -04:00
|
|
|
|
2012-02-29 22:38:35 -05:00
|
|
|
screen = meta_plugin_get_screen (global->plugin);
|
|
|
|
|
2009-04-29 14:01:09 -04:00
|
|
|
if (mode == SHELL_STAGE_INPUT_MODE_NONREACTIVE || global->gtk_grab_active)
|
2012-02-29 22:38:35 -05:00
|
|
|
meta_empty_stage_input_region (screen);
|
2009-04-29 14:01:09 -04:00
|
|
|
else if (mode == SHELL_STAGE_INPUT_MODE_FULLSCREEN || !global->input_region)
|
2012-02-29 22:38:35 -05:00
|
|
|
meta_set_stage_input_region (screen, None);
|
2009-04-29 14:01:09 -04:00
|
|
|
else
|
2012-02-29 22:38:35 -05:00
|
|
|
meta_set_stage_input_region (screen, global->input_region);
|
2009-04-29 14:01:09 -04:00
|
|
|
|
2010-07-02 13:36:13 -04:00
|
|
|
if (mode == SHELL_STAGE_INPUT_MODE_FOCUSED)
|
|
|
|
shell_global_focus_stage (global);
|
|
|
|
|
|
|
|
if (mode != global->input_mode)
|
|
|
|
{
|
|
|
|
global->input_mode = mode;
|
|
|
|
g_object_notify (G_OBJECT (global), "stage-input-mode");
|
|
|
|
}
|
2009-04-29 14:01:09 -04:00
|
|
|
}
|
|
|
|
|
2010-09-09 21:46:13 -04:00
|
|
|
/**
|
|
|
|
* shell_global_set_cursor:
|
|
|
|
* @global: A #ShellGlobal
|
|
|
|
* @type: the type of the cursor
|
|
|
|
*
|
|
|
|
* Set the cursor on the stage window.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
shell_global_set_cursor (ShellGlobal *global,
|
|
|
|
ShellCursor type)
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
GdkCursor *cursor;
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case SHELL_CURSOR_DND_IN_DRAG:
|
|
|
|
name = "dnd-none";
|
|
|
|
break;
|
|
|
|
case SHELL_CURSOR_DND_MOVE:
|
|
|
|
name = "dnd-move";
|
|
|
|
break;
|
|
|
|
case SHELL_CURSOR_DND_COPY:
|
|
|
|
name = "dnd-copy";
|
|
|
|
break;
|
|
|
|
case SHELL_CURSOR_DND_UNSUPPORTED_TARGET:
|
|
|
|
name = "dnd-none";
|
|
|
|
break;
|
2010-11-23 18:27:47 -05:00
|
|
|
case SHELL_CURSOR_POINTING_HAND:
|
|
|
|
name = "hand";
|
|
|
|
break;
|
2012-11-08 20:19:19 -05:00
|
|
|
case SHELL_CURSOR_CROSSHAIR:
|
|
|
|
name = "crosshair";
|
|
|
|
break;
|
2010-09-09 21:46:13 -04:00
|
|
|
default:
|
|
|
|
g_return_if_reached ();
|
|
|
|
}
|
|
|
|
|
2011-07-13 12:22:32 -04:00
|
|
|
cursor = gdk_cursor_new_from_name (global->gdk_display, name);
|
2010-09-09 21:46:13 -04:00
|
|
|
if (!cursor)
|
|
|
|
{
|
|
|
|
GdkCursorType cursor_type;
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case SHELL_CURSOR_DND_IN_DRAG:
|
|
|
|
cursor_type = GDK_FLEUR;
|
|
|
|
break;
|
|
|
|
case SHELL_CURSOR_DND_MOVE:
|
|
|
|
cursor_type = GDK_TARGET;
|
|
|
|
break;
|
|
|
|
case SHELL_CURSOR_DND_COPY:
|
|
|
|
cursor_type = GDK_PLUS;
|
|
|
|
break;
|
2010-11-23 18:27:47 -05:00
|
|
|
case SHELL_CURSOR_POINTING_HAND:
|
|
|
|
cursor_type = GDK_HAND2;
|
2011-10-19 16:13:06 -04:00
|
|
|
break;
|
2012-11-08 20:19:19 -05:00
|
|
|
case SHELL_CURSOR_CROSSHAIR:
|
|
|
|
cursor_type = GDK_CROSSHAIR;
|
|
|
|
break;
|
2010-09-09 21:46:13 -04:00
|
|
|
case SHELL_CURSOR_DND_UNSUPPORTED_TARGET:
|
|
|
|
cursor_type = GDK_X_CURSOR;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_return_if_reached ();
|
|
|
|
}
|
|
|
|
cursor = gdk_cursor_new (cursor_type);
|
|
|
|
}
|
|
|
|
|
2011-07-13 12:22:32 -04:00
|
|
|
gdk_window_set_cursor (global->stage_gdk_window, cursor);
|
2010-09-09 21:46:13 -04:00
|
|
|
|
2011-10-19 17:52:11 -04:00
|
|
|
g_object_unref (cursor);
|
2010-09-09 21:46:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* shell_global_unset_cursor:
|
|
|
|
* @global: A #ShellGlobal
|
|
|
|
*
|
|
|
|
* Unset the cursor on the stage window.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
shell_global_unset_cursor (ShellGlobal *global)
|
|
|
|
{
|
2011-07-13 12:22:32 -04:00
|
|
|
gdk_window_set_cursor (global->stage_gdk_window, NULL);
|
2010-09-09 21:46:13 -04:00
|
|
|
}
|
|
|
|
|
2009-04-29 14:01:09 -04:00
|
|
|
/**
|
|
|
|
* shell_global_set_stage_input_region:
|
|
|
|
* @global: the #ShellGlobal
|
|
|
|
* @rectangles: (element-type Meta.Rectangle): a list of #MetaRectangle
|
|
|
|
* describing the input region.
|
|
|
|
*
|
|
|
|
* Sets the area of the stage that is responsive to mouse clicks when
|
|
|
|
* the stage mode is %SHELL_STAGE_INPUT_MODE_NORMAL (but does not change the
|
|
|
|
* current stage mode).
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
shell_global_set_stage_input_region (ShellGlobal *global,
|
|
|
|
GSList *rectangles)
|
|
|
|
{
|
|
|
|
MetaRectangle *rect;
|
|
|
|
XRectangle *rects;
|
|
|
|
int nrects, i;
|
|
|
|
GSList *r;
|
|
|
|
|
|
|
|
g_return_if_fail (SHELL_IS_GLOBAL (global));
|
|
|
|
|
|
|
|
nrects = g_slist_length (rectangles);
|
|
|
|
rects = g_new (XRectangle, nrects);
|
|
|
|
for (r = rectangles, i = 0; r; r = r->next, i++)
|
|
|
|
{
|
|
|
|
rect = (MetaRectangle *)r->data;
|
|
|
|
rects[i].x = rect->x;
|
|
|
|
rects[i].y = rect->y;
|
|
|
|
rects[i].width = rect->width;
|
|
|
|
rects[i].height = rect->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (global->input_region)
|
2011-07-13 12:22:32 -04:00
|
|
|
XFixesDestroyRegion (global->xdisplay, global->input_region);
|
2009-04-29 14:01:09 -04:00
|
|
|
|
2011-07-13 12:22:32 -04:00
|
|
|
global->input_region = XFixesCreateRegion (global->xdisplay, rects, nrects);
|
2009-04-29 14:01:09 -04:00
|
|
|
g_free (rects);
|
|
|
|
|
|
|
|
/* set_stage_input_mode() will figure out whether or not we
|
|
|
|
* should actually change the input region right now.
|
|
|
|
*/
|
|
|
|
shell_global_set_stage_input_mode (global, global->input_mode);
|
2008-10-31 00:22:44 -04:00
|
|
|
}
|
|
|
|
|
2012-02-14 14:33:56 -05:00
|
|
|
/**
|
|
|
|
* shell_global_get_stage:
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): The default #ClutterStage
|
|
|
|
*/
|
|
|
|
ClutterStage *
|
|
|
|
shell_global_get_stage (ShellGlobal *global)
|
|
|
|
{
|
|
|
|
return global->stage;
|
|
|
|
}
|
|
|
|
|
2009-06-25 17:42:46 -04:00
|
|
|
/**
|
|
|
|
* shell_global_get_screen:
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): The default #MetaScreen
|
|
|
|
*/
|
|
|
|
MetaScreen *
|
|
|
|
shell_global_get_screen (ShellGlobal *global)
|
|
|
|
{
|
2011-07-13 12:22:32 -04:00
|
|
|
return global->meta_screen;
|
2009-06-25 17:42:46 -04:00
|
|
|
}
|
|
|
|
|
2010-06-03 11:14:58 -04:00
|
|
|
/**
|
|
|
|
* shell_global_get_gdk_screen:
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): Gdk screen object for the shell
|
|
|
|
*/
|
|
|
|
GdkScreen *
|
|
|
|
shell_global_get_gdk_screen (ShellGlobal *global)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (SHELL_IS_GLOBAL (global), NULL);
|
|
|
|
|
2011-07-13 12:22:32 -04:00
|
|
|
return global->gdk_screen;
|
2010-06-03 11:14:58 -04:00
|
|
|
}
|
|
|
|
|
2011-07-13 12:34:31 -04:00
|
|
|
/**
|
|
|
|
* shell_global_get_display:
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): The default #MetaDisplay
|
|
|
|
*/
|
|
|
|
MetaDisplay *
|
|
|
|
shell_global_get_display (ShellGlobal *global)
|
|
|
|
{
|
|
|
|
return global->meta_display;
|
|
|
|
}
|
|
|
|
|
2008-11-02 00:18:41 -04:00
|
|
|
/**
|
2010-10-19 14:55:43 -04:00
|
|
|
* shell_global_get_window_actors:
|
2008-11-02 00:18:41 -04:00
|
|
|
*
|
2010-10-19 14:55:43 -04:00
|
|
|
* Gets the list of #MetaWindowActor for the plugin's screen
|
2008-11-02 00:18:41 -04:00
|
|
|
*
|
2010-10-19 14:55:43 -04:00
|
|
|
* Return value: (element-type Meta.WindowActor) (transfer none): the list of windows
|
2008-11-02 00:18:41 -04:00
|
|
|
*/
|
|
|
|
GList *
|
2010-10-19 14:55:43 -04:00
|
|
|
shell_global_get_window_actors (ShellGlobal *global)
|
2008-11-02 00:18:41 -04:00
|
|
|
{
|
2008-11-07 13:42:23 -05:00
|
|
|
g_return_val_if_fail (SHELL_IS_GLOBAL (global), NULL);
|
2008-11-02 00:18:41 -04:00
|
|
|
|
2011-03-24 16:12:33 -04:00
|
|
|
return meta_get_window_actors (global->meta_screen);
|
2008-11-02 00:18:41 -04:00
|
|
|
}
|
|
|
|
|
2010-01-19 12:59:29 -05:00
|
|
|
static void
|
|
|
|
global_stage_notify_width (GObject *gobject,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
ShellGlobal *global = SHELL_GLOBAL (data);
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (global), "screen-width");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
global_stage_notify_height (GObject *gobject,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
ShellGlobal *global = SHELL_GLOBAL (data);
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (global), "screen-height");
|
|
|
|
}
|
|
|
|
|
2010-05-09 13:24:13 -04:00
|
|
|
static void
|
|
|
|
global_stage_before_paint (ClutterStage *stage,
|
|
|
|
ShellGlobal *global)
|
|
|
|
{
|
|
|
|
shell_perf_log_event (shell_perf_log_get_default (),
|
|
|
|
"clutter.stagePaintStart");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
global_stage_after_paint (ClutterStage *stage,
|
|
|
|
ShellGlobal *global)
|
|
|
|
{
|
|
|
|
shell_perf_log_event (shell_perf_log_get_default (),
|
|
|
|
"clutter.stagePaintDone");
|
|
|
|
}
|
|
|
|
|
2011-11-21 11:56:24 -05:00
|
|
|
/* This is an IBus workaround. The flow of events with IBus is that every time
|
|
|
|
* it gets gets a key event, it:
|
|
|
|
*
|
|
|
|
* Sends it to the daemon via D-Bus asynchronously
|
|
|
|
* When it gets an reply, synthesizes a new GdkEvent and puts it into the
|
|
|
|
* GDK event queue with gdk_event_put(), including
|
|
|
|
* IBUS_FORWARD_MASK = 1 << 25 in the state to prevent a loop.
|
|
|
|
*
|
|
|
|
* (Normally, IBus uses the GTK+ key snooper mechanism to get the key
|
|
|
|
* events early, but since our key events aren't visible to GTK+ key snoopers,
|
|
|
|
* IBus will instead get the events via the standard
|
|
|
|
* GtkIMContext.filter_keypress() mechanism.)
|
|
|
|
*
|
|
|
|
* There are a number of potential problems here; probably the worst
|
|
|
|
* problem is that IBus doesn't forward the timestamp with the event
|
|
|
|
* so that every key event that gets delivered ends up with
|
|
|
|
* GDK_CURRENT_TIME. This creates some very subtle bugs; for example
|
|
|
|
* if you have IBus running and a keystroke is used to trigger
|
|
|
|
* launching an application, focus stealing prevention won't work
|
|
|
|
* right. http://code.google.com/p/ibus/issues/detail?id=1184
|
|
|
|
*
|
|
|
|
* In any case, our normal flow of key events is:
|
|
|
|
*
|
|
|
|
* GDK filter function => clutter_x11_handle_event => clutter actor
|
|
|
|
*
|
|
|
|
* So, if we see a key event that gets delivered via the GDK event handler
|
|
|
|
* function - then we know it must be one of these synthesized events, and
|
|
|
|
* we should push it back to clutter.
|
|
|
|
*
|
|
|
|
* To summarize, the full key event flow with IBus is:
|
|
|
|
*
|
|
|
|
* GDK filter function
|
|
|
|
* => Mutter
|
|
|
|
* => gnome_shell_plugin_xevent_filter()
|
|
|
|
* => clutter_x11_handle_event()
|
|
|
|
* => clutter event delivery to actor
|
|
|
|
* => gtk_im_context_filter_event()
|
|
|
|
* => sent to IBus daemon
|
|
|
|
* => response received from IBus daemon
|
|
|
|
* => gdk_event_put()
|
|
|
|
* => GDK event handler
|
|
|
|
* => <this function>
|
|
|
|
* => clutter_event_put()
|
|
|
|
* => clutter event delivery to actor
|
|
|
|
*
|
|
|
|
* Anything else we see here we just pass on to the normal GDK event handler
|
|
|
|
* gtk_main_do_event().
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
gnome_shell_gdk_event_handler (GdkEvent *event_gdk,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
if (event_gdk->type == GDK_KEY_PRESS || event_gdk->type == GDK_KEY_RELEASE)
|
|
|
|
{
|
|
|
|
ClutterActor *stage;
|
|
|
|
Window stage_xwindow;
|
|
|
|
|
|
|
|
stage = CLUTTER_ACTOR (data);
|
|
|
|
stage_xwindow = clutter_x11_get_stage_window (CLUTTER_STAGE (stage));
|
|
|
|
|
|
|
|
if (GDK_WINDOW_XID (event_gdk->key.window) == stage_xwindow)
|
|
|
|
{
|
|
|
|
ClutterDeviceManager *device_manager = clutter_device_manager_get_default ();
|
|
|
|
ClutterInputDevice *keyboard = clutter_device_manager_get_core_device (device_manager,
|
|
|
|
CLUTTER_KEYBOARD_DEVICE);
|
|
|
|
|
|
|
|
ClutterEvent *event_clutter = clutter_event_new ((event_gdk->type == GDK_KEY_PRESS) ?
|
|
|
|
CLUTTER_KEY_PRESS : CLUTTER_KEY_RELEASE);
|
|
|
|
event_clutter->key.time = event_gdk->key.time;
|
|
|
|
event_clutter->key.flags = CLUTTER_EVENT_NONE;
|
|
|
|
event_clutter->key.stage = CLUTTER_STAGE (stage);
|
|
|
|
event_clutter->key.source = NULL;
|
|
|
|
|
|
|
|
/* This depends on ClutterModifierType and GdkModifierType being
|
|
|
|
* identical, which they are currently. (They both match the X
|
|
|
|
* modifier state in the low 16-bits and have the same extensions.) */
|
|
|
|
event_clutter->key.modifier_state = event_gdk->key.state;
|
|
|
|
|
|
|
|
event_clutter->key.keyval = event_gdk->key.keyval;
|
|
|
|
event_clutter->key.hardware_keycode = event_gdk->key.hardware_keycode;
|
|
|
|
event_clutter->key.unicode_value = gdk_keyval_to_unicode (event_clutter->key.keyval);
|
|
|
|
event_clutter->key.device = keyboard;
|
|
|
|
|
|
|
|
clutter_event_put (event_clutter);
|
|
|
|
clutter_event_free (event_clutter);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_main_do_event (event_gdk);
|
|
|
|
}
|
|
|
|
|
2008-10-31 00:22:44 -04:00
|
|
|
void
|
2010-10-19 14:55:43 -04:00
|
|
|
_shell_global_set_plugin (ShellGlobal *global,
|
|
|
|
MetaPlugin *plugin)
|
2008-10-31 00:22:44 -04:00
|
|
|
{
|
2008-10-31 11:20:54 -04:00
|
|
|
g_return_if_fail (SHELL_IS_GLOBAL (global));
|
2008-11-21 09:02:09 -05:00
|
|
|
g_return_if_fail (global->plugin == NULL);
|
2008-10-31 11:20:54 -04:00
|
|
|
|
|
|
|
global->plugin = plugin;
|
2008-11-21 09:02:09 -05:00
|
|
|
global->wm = shell_wm_new (plugin);
|
2010-01-19 12:59:29 -05:00
|
|
|
|
2011-07-13 12:22:32 -04:00
|
|
|
global->meta_screen = meta_plugin_get_screen (plugin);
|
|
|
|
global->meta_display = meta_screen_get_display (global->meta_screen);
|
|
|
|
global->xdisplay = meta_display_get_xdisplay (global->meta_display);
|
2010-05-11 10:35:27 -04:00
|
|
|
|
2011-07-13 12:22:32 -04:00
|
|
|
global->gdk_display = gdk_x11_lookup_xdisplay (global->xdisplay);
|
|
|
|
global->gdk_screen = gdk_display_get_screen (global->gdk_display,
|
|
|
|
meta_screen_get_screen_number (global->meta_screen));
|
|
|
|
|
2012-02-29 22:38:35 -05:00
|
|
|
global->stage = CLUTTER_STAGE (meta_get_stage_for_screen (global->meta_screen));
|
2011-07-13 12:22:32 -04:00
|
|
|
global->stage_xwindow = clutter_x11_get_stage_window (global->stage);
|
|
|
|
global->stage_gdk_window = gdk_x11_window_foreign_new_for_display (global->gdk_display,
|
|
|
|
global->stage_xwindow);
|
|
|
|
|
|
|
|
g_signal_connect (global->stage, "notify::width",
|
2010-05-11 10:35:27 -04:00
|
|
|
G_CALLBACK (global_stage_notify_width), global);
|
2011-07-13 12:22:32 -04:00
|
|
|
g_signal_connect (global->stage, "notify::height",
|
2010-05-11 10:35:27 -04:00
|
|
|
G_CALLBACK (global_stage_notify_height), global);
|
2010-05-09 13:24:13 -04:00
|
|
|
|
2011-07-13 12:22:32 -04:00
|
|
|
g_signal_connect (global->stage, "paint",
|
2010-05-09 13:24:13 -04:00
|
|
|
G_CALLBACK (global_stage_before_paint), global);
|
2011-07-13 12:22:32 -04:00
|
|
|
g_signal_connect_after (global->stage, "paint",
|
2010-05-09 13:24:13 -04:00
|
|
|
G_CALLBACK (global_stage_after_paint), global);
|
|
|
|
|
|
|
|
shell_perf_log_define_event (shell_perf_log_get_default(),
|
|
|
|
"clutter.stagePaintStart",
|
|
|
|
"Start of stage page repaint",
|
|
|
|
"");
|
|
|
|
shell_perf_log_define_event (shell_perf_log_get_default(),
|
|
|
|
"clutter.stagePaintDone",
|
|
|
|
"End of stage page repaint",
|
|
|
|
"");
|
2010-07-02 13:36:13 -04:00
|
|
|
|
2011-07-13 12:22:32 -04:00
|
|
|
g_signal_connect (global->meta_display, "notify::focus-window",
|
2010-07-02 13:36:13 -04:00
|
|
|
G_CALLBACK (focus_window_changed), global);
|
2010-10-05 10:09:40 -04:00
|
|
|
|
2011-11-21 11:56:24 -05:00
|
|
|
gdk_event_handler_set (gnome_shell_gdk_event_handler, global->stage, NULL);
|
|
|
|
|
2011-07-13 12:22:32 -04:00
|
|
|
global->focus_manager = st_focus_manager_get_for_stage (global->stage);
|
2008-10-31 00:22:44 -04:00
|
|
|
}
|
2008-11-19 14:54:17 -05:00
|
|
|
|
2011-02-25 11:20:27 -05:00
|
|
|
GjsContext *
|
|
|
|
_shell_global_get_gjs_context (ShellGlobal *global)
|
2009-10-24 13:40:13 -04:00
|
|
|
{
|
2011-02-25 11:20:27 -05:00
|
|
|
return global->js_context;
|
2009-10-24 13:40:13 -04:00
|
|
|
}
|
|
|
|
|
2008-11-19 14:54:17 -05:00
|
|
|
/**
|
2009-08-12 00:22:46 -04:00
|
|
|
* shell_global_begin_modal:
|
2008-11-24 14:07:18 -05:00
|
|
|
* @global: a #ShellGlobal
|
2008-11-19 14:54:17 -05:00
|
|
|
*
|
2009-08-12 00:22:46 -04:00
|
|
|
* Grabs the keyboard and mouse to the stage window. The stage will
|
|
|
|
* receive all keyboard and mouse events until shell_global_end_modal()
|
|
|
|
* is called. This is used to implement "modes" for the shell, such as the
|
|
|
|
* overview mode or the "looking glass" debug overlay, that block
|
|
|
|
* application and normal key shortcuts.
|
|
|
|
*
|
2011-11-02 12:24:49 -04:00
|
|
|
* Returns: %TRUE if we succesfully entered the mode. %FALSE if we couldn't
|
2009-08-12 00:22:46 -04:00
|
|
|
* enter the mode. Failure may occur because an application has the pointer
|
|
|
|
* or keyboard grabbed, because Mutter is in a mode itself like moving a
|
|
|
|
* window or alt-Tab window selection, or because shell_global_begin_modal()
|
|
|
|
* was previouly called.
|
2008-11-19 14:54:17 -05:00
|
|
|
*/
|
2008-11-24 14:07:18 -05:00
|
|
|
gboolean
|
2011-10-21 03:12:17 -04:00
|
|
|
shell_global_begin_modal (ShellGlobal *global,
|
|
|
|
guint32 timestamp,
|
|
|
|
MetaModalOptions options)
|
2008-11-19 14:54:17 -05:00
|
|
|
{
|
2011-10-21 03:12:17 -04:00
|
|
|
return meta_plugin_begin_modal (global->plugin, global->stage_xwindow, None, options, timestamp);
|
2008-11-24 14:07:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-08-12 00:22:46 -04:00
|
|
|
* shell_global_end_modal:
|
2008-11-24 14:07:18 -05:00
|
|
|
* @global: a #ShellGlobal
|
|
|
|
*
|
2009-08-12 00:22:46 -04:00
|
|
|
* Undoes the effect of shell_global_begin_modal().
|
2008-11-24 14:07:18 -05:00
|
|
|
*/
|
|
|
|
void
|
2009-08-12 00:22:46 -04:00
|
|
|
shell_global_end_modal (ShellGlobal *global,
|
|
|
|
guint32 timestamp)
|
2008-11-24 14:07:18 -05:00
|
|
|
{
|
2010-10-19 14:55:43 -04:00
|
|
|
meta_plugin_end_modal (global->plugin, timestamp);
|
2008-11-19 14:54:17 -05:00
|
|
|
}
|
2008-12-18 15:57:37 -05:00
|
|
|
|
2009-04-21 17:21:06 -04:00
|
|
|
/* Code to close all file descriptors before we exec; copied from gspawn.c in GLib.
|
|
|
|
*
|
|
|
|
* Authors: Padraig O'Briain, Matthias Clasen, Lennart Poettering
|
|
|
|
*
|
|
|
|
* http://bugzilla.gnome.org/show_bug.cgi?id=469231
|
|
|
|
* http://bugzilla.gnome.org/show_bug.cgi?id=357585
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
|
|
|
set_cloexec (void *data, gint fd)
|
|
|
|
{
|
|
|
|
if (fd >= GPOINTER_TO_INT (data))
|
|
|
|
fcntl (fd, F_SETFD, FD_CLOEXEC);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef HAVE_FDWALK
|
|
|
|
static int
|
|
|
|
fdwalk (int (*cb)(void *data, int fd), void *data)
|
|
|
|
{
|
|
|
|
gint open_max;
|
|
|
|
gint fd;
|
|
|
|
gint res = 0;
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_RESOURCE_H
|
|
|
|
struct rlimit rl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __linux__
|
|
|
|
DIR *d;
|
|
|
|
|
|
|
|
if ((d = opendir("/proc/self/fd"))) {
|
|
|
|
struct dirent *de;
|
|
|
|
|
|
|
|
while ((de = readdir(d))) {
|
|
|
|
glong l;
|
|
|
|
gchar *e = NULL;
|
|
|
|
|
|
|
|
if (de->d_name[0] == '.')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
l = strtol(de->d_name, &e, 10);
|
|
|
|
if (errno != 0 || !e || *e)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
fd = (gint) l;
|
|
|
|
|
|
|
|
if ((glong) fd != l)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (fd == dirfd(d))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((res = cb (data, fd)) != 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
closedir(d);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If /proc is not mounted or not accessible we fall back to the old
|
|
|
|
* rlimit trick */
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_RESOURCE_H
|
|
|
|
if (getrlimit(RLIMIT_NOFILE, &rl) == 0 && rl.rlim_max != RLIM_INFINITY)
|
|
|
|
open_max = rl.rlim_max;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
open_max = sysconf (_SC_OPEN_MAX);
|
|
|
|
|
|
|
|
for (fd = 0; fd < open_max; fd++)
|
|
|
|
if ((res = cb (data, fd)) != 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
|
|
|
pre_exec_close_fds(void)
|
|
|
|
{
|
|
|
|
fdwalk (set_cloexec, GINT_TO_POINTER(3));
|
|
|
|
}
|
|
|
|
|
2008-12-18 15:57:37 -05:00
|
|
|
/**
|
|
|
|
* shell_global_reexec_self:
|
|
|
|
* @global: A #ShellGlobal
|
|
|
|
*
|
|
|
|
* Restart the current process. Only intended for development purposes.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
shell_global_reexec_self (ShellGlobal *global)
|
|
|
|
{
|
|
|
|
GPtrArray *arr;
|
|
|
|
gsize len;
|
|
|
|
char *buf;
|
|
|
|
char *buf_p;
|
|
|
|
char *buf_end;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
/* Linux specific (I think, anyways). */
|
|
|
|
if (!g_file_get_contents ("/proc/self/cmdline", &buf, &len, &error))
|
|
|
|
{
|
|
|
|
g_warning ("failed to get /proc/self/cmdline: %s", error->message);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf_end = buf+len;
|
|
|
|
arr = g_ptr_array_new ();
|
|
|
|
/* The cmdline file is NUL-separated */
|
|
|
|
for (buf_p = buf; buf_p < buf_end; buf_p = buf_p + strlen (buf_p) + 1)
|
|
|
|
g_ptr_array_add (arr, buf_p);
|
|
|
|
|
2009-04-21 17:21:06 -04:00
|
|
|
g_ptr_array_add (arr, NULL);
|
|
|
|
|
|
|
|
/* Close all file descriptors other than stdin/stdout/stderr, otherwise
|
|
|
|
* they will leak and stay open after the exec. In particular, this is
|
|
|
|
* important for file descriptors that represent mapped graphics buffer
|
|
|
|
* objects.
|
|
|
|
*/
|
|
|
|
pre_exec_close_fds ();
|
|
|
|
|
2011-10-17 15:19:46 -04:00
|
|
|
meta_display_unmanage_screen (shell_global_get_display (global),
|
|
|
|
shell_global_get_screen (global),
|
|
|
|
shell_global_get_current_time (global));
|
|
|
|
|
2008-12-18 15:57:37 -05:00
|
|
|
execvp (arr->pdata[0], (char**)arr->pdata);
|
|
|
|
g_warning ("failed to reexec: %s", g_strerror (errno));
|
|
|
|
g_ptr_array_free (arr, TRUE);
|
2009-01-08 20:09:35 -05:00
|
|
|
}
|
2009-01-19 18:06:59 -05:00
|
|
|
|
2011-09-15 19:36:07 -04:00
|
|
|
static void
|
|
|
|
shell_global_on_gc (GjsContext *context,
|
|
|
|
ShellGlobal *global)
|
|
|
|
{
|
|
|
|
global->last_gc_end_time = g_get_monotonic_time ();
|
|
|
|
}
|
|
|
|
|
2011-05-20 15:50:54 -04:00
|
|
|
/**
|
|
|
|
* shell_global_get_memory_info:
|
|
|
|
* @global:
|
|
|
|
* @meminfo: (out caller-allocates): Output location for memory information
|
|
|
|
*
|
|
|
|
* Load process-global data about memory usage.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
shell_global_get_memory_info (ShellGlobal *global,
|
|
|
|
ShellMemoryInfo *meminfo)
|
|
|
|
{
|
|
|
|
JSContext *context;
|
2011-09-15 19:36:07 -04:00
|
|
|
gint64 now;
|
2011-05-20 15:50:54 -04:00
|
|
|
|
|
|
|
#ifdef HAVE_MALLINFO
|
|
|
|
{
|
|
|
|
struct mallinfo info = mallinfo ();
|
|
|
|
meminfo->glibc_uordblks = info.uordblks;
|
|
|
|
}
|
2011-10-19 16:21:59 -04:00
|
|
|
#else
|
|
|
|
meminfo->glibc_uordblks = 0;
|
2011-05-20 15:50:54 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
context = gjs_context_get_native_context (global->js_context);
|
|
|
|
|
|
|
|
meminfo->js_bytes = JS_GetGCParameter (JS_GetRuntime (context), JSGC_BYTES);
|
|
|
|
|
|
|
|
meminfo->gjs_boxed = (unsigned int) gjs_counter_boxed.value;
|
|
|
|
meminfo->gjs_gobject = (unsigned int) gjs_counter_object.value;
|
|
|
|
meminfo->gjs_function = (unsigned int) gjs_counter_function.value;
|
|
|
|
meminfo->gjs_closure = (unsigned int) gjs_counter_closure.value;
|
2011-09-15 19:36:07 -04:00
|
|
|
|
|
|
|
now = g_get_monotonic_time ();
|
|
|
|
|
|
|
|
meminfo->last_gc_seconds_ago = (now - global->last_gc_end_time) / G_TIME_SPAN_SECOND;
|
2011-05-20 15:50:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-15 18:31:16 -04:00
|
|
|
/**
|
|
|
|
* shell_global_notify_error:
|
|
|
|
* @global: a #ShellGlobal
|
|
|
|
* @msg: Error message
|
|
|
|
* @details: Error details
|
|
|
|
*
|
|
|
|
* Show a system error notification. Use this function
|
|
|
|
* when a user-initiated action results in a non-fatal problem
|
|
|
|
* from causes that may not be under system control. For
|
|
|
|
* example, an application crash.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
shell_global_notify_error (ShellGlobal *global,
|
|
|
|
const char *msg,
|
|
|
|
const char *details)
|
|
|
|
{
|
|
|
|
g_signal_emit_by_name (global, "notify-error", msg, details);
|
|
|
|
}
|
|
|
|
|
2010-05-10 12:40:03 -04:00
|
|
|
static void
|
2009-02-06 17:33:08 -05:00
|
|
|
grab_notify (GtkWidget *widget, gboolean was_grabbed, gpointer user_data)
|
|
|
|
{
|
|
|
|
ShellGlobal *global = SHELL_GLOBAL (user_data);
|
|
|
|
|
2009-04-29 14:01:09 -04:00
|
|
|
global->gtk_grab_active = !was_grabbed;
|
|
|
|
|
|
|
|
/* Update for the new setting of gtk_grab_active */
|
|
|
|
shell_global_set_stage_input_mode (global, global->input_mode);
|
2009-02-06 17:33:08 -05:00
|
|
|
}
|
2009-03-24 14:25:07 -04:00
|
|
|
|
2011-01-05 09:47:27 -05:00
|
|
|
/**
|
|
|
|
* shell_global_init_xdnd:
|
|
|
|
* @global: the #ShellGlobal
|
|
|
|
*
|
|
|
|
* Enables tracking of Xdnd events
|
|
|
|
*/
|
|
|
|
void shell_global_init_xdnd (ShellGlobal *global)
|
|
|
|
{
|
2011-07-13 12:22:32 -04:00
|
|
|
Window output_window = meta_get_overlay_window (global->meta_screen);
|
2011-01-05 09:47:27 -05:00
|
|
|
long xdnd_version = 5;
|
|
|
|
|
2011-07-13 12:22:32 -04:00
|
|
|
XChangeProperty (global->xdisplay, global->stage_xwindow,
|
|
|
|
gdk_x11_get_xatom_by_name ("XdndAware"), XA_ATOM,
|
|
|
|
32, PropModeReplace, (const unsigned char *)&xdnd_version, 1);
|
2011-01-05 09:47:27 -05:00
|
|
|
|
2011-07-13 12:22:32 -04:00
|
|
|
XChangeProperty (global->xdisplay, output_window,
|
|
|
|
gdk_x11_get_xatom_by_name ("XdndProxy"), XA_WINDOW,
|
|
|
|
32, PropModeReplace, (const unsigned char *)&global->stage_xwindow, 1);
|
2011-01-05 09:47:27 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XdndProxy is additionally set on the proxy window as verification that the
|
|
|
|
* XdndProxy property on the target window isn't a left-over
|
|
|
|
*/
|
2011-07-13 12:22:32 -04:00
|
|
|
XChangeProperty (global->xdisplay, global->stage_xwindow,
|
|
|
|
gdk_x11_get_xatom_by_name ("XdndProxy"), XA_WINDOW,
|
|
|
|
32, PropModeReplace, (const unsigned char *)&global->stage_xwindow, 1);
|
2011-01-05 09:47:27 -05:00
|
|
|
}
|
|
|
|
|
2009-10-06 10:53:25 -04:00
|
|
|
/**
|
2010-04-08 14:41:54 -04:00
|
|
|
* shell_global_get_pointer:
|
2009-10-06 10:53:25 -04:00
|
|
|
* @global: the #ShellGlobal
|
2010-04-08 14:41:54 -04:00
|
|
|
* @x: (out): the X coordinate of the pointer, in global coordinates
|
|
|
|
* @y: (out): the Y coordinate of the pointer, in global coordinates
|
|
|
|
* @mods: (out): the current set of modifier keys that are pressed down
|
2009-10-06 10:53:25 -04:00
|
|
|
*
|
2010-04-08 14:41:54 -04:00
|
|
|
* Gets the pointer coordinates and current modifier key state.
|
|
|
|
* This is a wrapper around gdk_display_get_pointer() that strips
|
2009-10-06 10:53:25 -04:00
|
|
|
* out any un-declared modifier flags, to make gjs happy; see
|
|
|
|
* https://bugzilla.gnome.org/show_bug.cgi?id=597292.
|
|
|
|
*/
|
2010-04-08 14:41:54 -04:00
|
|
|
void
|
|
|
|
shell_global_get_pointer (ShellGlobal *global,
|
|
|
|
int *x,
|
|
|
|
int *y,
|
|
|
|
ClutterModifierType *mods)
|
2009-10-06 10:53:25 -04:00
|
|
|
{
|
2011-10-19 17:52:11 -04:00
|
|
|
GdkDeviceManager *gmanager;
|
|
|
|
GdkDevice *gdevice;
|
|
|
|
GdkScreen *gscreen;
|
2010-04-08 14:41:54 -04:00
|
|
|
GdkModifierType raw_mods;
|
2009-10-06 10:53:25 -04:00
|
|
|
|
2011-10-19 17:52:11 -04:00
|
|
|
gmanager = gdk_display_get_device_manager (global->gdk_display);
|
|
|
|
gdevice = gdk_device_manager_get_client_pointer (gmanager);
|
|
|
|
gdk_device_get_position (gdevice, &gscreen, x, y);
|
|
|
|
gdk_device_get_state (gdevice,
|
|
|
|
gdk_screen_get_root_window (gscreen),
|
|
|
|
NULL, &raw_mods);
|
2010-04-08 14:41:54 -04:00
|
|
|
*mods = raw_mods & GDK_MODIFIER_MASK;
|
2009-10-06 10:53:25 -04:00
|
|
|
}
|
2009-10-07 17:20:33 -04:00
|
|
|
|
2011-01-19 10:29:50 -05:00
|
|
|
/**
|
|
|
|
* shell_global_sync_pointer:
|
|
|
|
* @global: the #ShellGlobal
|
|
|
|
*
|
|
|
|
* Ensures that clutter is aware of the current pointer position,
|
|
|
|
* causing enter and leave events to be emitted if the pointer moved
|
|
|
|
* behind our back (ie, during a pointer grab).
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
shell_global_sync_pointer (ShellGlobal *global)
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
GdkModifierType mods;
|
2011-10-19 17:52:11 -04:00
|
|
|
GdkDeviceManager *gmanager;
|
|
|
|
GdkDevice *gdevice;
|
|
|
|
GdkScreen *gscreen;
|
2011-01-19 10:29:50 -05:00
|
|
|
ClutterMotionEvent event;
|
|
|
|
|
2011-10-19 17:52:11 -04:00
|
|
|
gmanager = gdk_display_get_device_manager (global->gdk_display);
|
|
|
|
gdevice = gdk_device_manager_get_client_pointer (gmanager);
|
|
|
|
|
|
|
|
gdk_device_get_position (gdevice, &gscreen, &x, &y);
|
|
|
|
gdk_device_get_state (gdevice,
|
|
|
|
gdk_screen_get_root_window (gscreen),
|
|
|
|
NULL, &mods);
|
2011-01-19 10:29:50 -05:00
|
|
|
|
|
|
|
event.type = CLUTTER_MOTION;
|
|
|
|
event.time = shell_global_get_current_time (global);
|
|
|
|
event.flags = 0;
|
|
|
|
/* This is wrong: we should be setting event.stage to NULL if the
|
|
|
|
* pointer is not inside the bounds of the stage given the current
|
|
|
|
* stage_input_mode. For our current purposes however, this works.
|
|
|
|
*/
|
2011-07-13 12:22:32 -04:00
|
|
|
event.stage = global->stage;
|
2011-01-19 10:29:50 -05:00
|
|
|
event.x = x;
|
|
|
|
event.y = y;
|
|
|
|
event.modifier_state = mods;
|
|
|
|
event.axes = NULL;
|
|
|
|
event.device = clutter_device_manager_get_core_device (clutter_device_manager_get_default (),
|
|
|
|
CLUTTER_POINTER_DEVICE);
|
|
|
|
|
|
|
|
/* Leaving event.source NULL will force clutter to look it up, which
|
|
|
|
* will generate enter/leave events as a side effect, if they are
|
|
|
|
* needed. We need a better way to do this though... see
|
|
|
|
* http://bugzilla.clutter-project.org/show_bug.cgi?id=2615.
|
|
|
|
*/
|
|
|
|
event.source = NULL;
|
|
|
|
|
|
|
|
clutter_event_put ((ClutterEvent *)&event);
|
|
|
|
}
|
|
|
|
|
2010-05-05 17:05:42 -04:00
|
|
|
/**
|
|
|
|
* shell_global_get_settings:
|
|
|
|
* @global: A #ShellGlobal
|
|
|
|
*
|
|
|
|
* Get the global GSettings instance.
|
|
|
|
*
|
2010-09-01 20:48:11 -04:00
|
|
|
* Return value: (transfer none): The GSettings object
|
2010-05-05 17:05:42 -04:00
|
|
|
*/
|
|
|
|
GSettings *
|
|
|
|
shell_global_get_settings (ShellGlobal *global)
|
|
|
|
{
|
|
|
|
return global->settings;
|
|
|
|
}
|
|
|
|
|
2009-12-03 15:59:52 -05:00
|
|
|
/**
|
|
|
|
* shell_global_get_current_time:
|
|
|
|
* @global: A #ShellGlobal
|
|
|
|
*
|
|
|
|
* Returns: the current X server time from the current Clutter, Gdk, or X
|
|
|
|
* event. If called from outside an event handler, this may return
|
|
|
|
* %Clutter.CURRENT_TIME (aka 0), or it may return a slightly
|
|
|
|
* out-of-date timestamp.
|
|
|
|
*/
|
|
|
|
guint32
|
|
|
|
shell_global_get_current_time (ShellGlobal *global)
|
|
|
|
{
|
|
|
|
guint32 time;
|
|
|
|
|
2011-01-05 09:47:27 -05:00
|
|
|
/* In case we have a xdnd timestamp use it */
|
|
|
|
if (global->xdnd_timestamp != 0)
|
|
|
|
return global->xdnd_timestamp;
|
|
|
|
|
2009-12-03 15:59:52 -05:00
|
|
|
/* meta_display_get_current_time() will return the correct time
|
|
|
|
when handling an X or Gdk event, but will return CurrentTime
|
|
|
|
from some Clutter event callbacks.
|
|
|
|
|
|
|
|
clutter_get_current_event_time() will return the correct time
|
2012-12-23 04:15:51 -05:00
|
|
|
from a Clutter event callback, but may return CLUTTER_CURRENT_TIME
|
2009-12-03 15:59:52 -05:00
|
|
|
timestamp if called at other times.
|
|
|
|
|
|
|
|
So we try meta_display_get_current_time() first, since we
|
|
|
|
can recognize a "wrong" answer from that, and then fall back
|
|
|
|
to clutter_get_current_event_time().
|
|
|
|
*/
|
|
|
|
|
2011-07-13 12:22:32 -04:00
|
|
|
time = meta_display_get_current_time (global->meta_display);
|
2009-12-03 15:59:52 -05:00
|
|
|
if (time != CLUTTER_CURRENT_TIME)
|
2012-12-23 04:15:51 -05:00
|
|
|
return time;
|
2009-12-03 15:59:52 -05:00
|
|
|
|
2012-12-23 04:15:51 -05:00
|
|
|
return clutter_get_current_event_time ();
|
2009-12-03 15:59:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-09-01 20:48:11 -04:00
|
|
|
* shell_global_create_app_launch_context:
|
2009-12-03 15:59:52 -05:00
|
|
|
* @global: A #ShellGlobal
|
|
|
|
*
|
|
|
|
* Create a #GAppLaunchContext set up with the correct timestamp, and
|
|
|
|
* targeted to activate on the current workspace.
|
|
|
|
*
|
2010-09-01 20:48:11 -04:00
|
|
|
* Return value: (transfer full): A new #GAppLaunchContext
|
2009-12-03 15:59:52 -05:00
|
|
|
*/
|
|
|
|
GAppLaunchContext *
|
|
|
|
shell_global_create_app_launch_context (ShellGlobal *global)
|
|
|
|
{
|
|
|
|
GdkAppLaunchContext *context;
|
|
|
|
|
2011-10-19 17:52:11 -04:00
|
|
|
context = gdk_display_get_app_launch_context (global->gdk_display);
|
2009-12-03 15:59:52 -05:00
|
|
|
gdk_app_launch_context_set_timestamp (context, shell_global_get_current_time (global));
|
|
|
|
|
|
|
|
// Make sure that the app is opened on the current workspace even if
|
|
|
|
// the user switches before it starts
|
2011-07-13 12:22:32 -04:00
|
|
|
gdk_app_launch_context_set_desktop (context, meta_screen_get_active_workspace_index (global->meta_screen));
|
2009-12-03 15:59:52 -05:00
|
|
|
|
|
|
|
return (GAppLaunchContext *)context;
|
|
|
|
}
|
2010-03-26 16:38:03 -04:00
|
|
|
|
2010-05-09 00:34:15 -04:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
ShellLeisureFunction func;
|
|
|
|
gpointer user_data;
|
|
|
|
GDestroyNotify notify;
|
|
|
|
} LeisureClosure;
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
run_leisure_functions (gpointer data)
|
|
|
|
{
|
|
|
|
ShellGlobal *global = data;
|
|
|
|
GSList *closures;
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
global->leisure_function_id = 0;
|
|
|
|
|
|
|
|
/* We started more work since we scheduled the idle */
|
|
|
|
if (global->work_count > 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2010-05-21 17:25:41 -04:00
|
|
|
/* No leisure closures, so we are done */
|
|
|
|
if (global->leisure_closures == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2010-05-09 00:34:15 -04:00
|
|
|
closures = global->leisure_closures;
|
|
|
|
global->leisure_closures = NULL;
|
|
|
|
|
|
|
|
for (iter = closures; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
LeisureClosure *closure = closures->data;
|
|
|
|
closure->func (closure->user_data);
|
|
|
|
|
|
|
|
if (closure->notify)
|
|
|
|
closure->notify (closure->user_data);
|
|
|
|
|
|
|
|
g_slice_free (LeisureClosure, closure);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_slist_free (closures);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
schedule_leisure_functions (ShellGlobal *global)
|
|
|
|
{
|
|
|
|
/* This is called when we think we are ready to run leisure functions
|
|
|
|
* by our own accounting. We try to handle other types of business
|
|
|
|
* (like ClutterAnimation) by adding a low priority idle function.
|
|
|
|
*
|
|
|
|
* This won't work properly if the mainloop goes idle waiting for
|
|
|
|
* the vertical blanking interval or waiting for work being done
|
|
|
|
* in another thread.
|
|
|
|
*/
|
|
|
|
if (!global->leisure_function_id)
|
|
|
|
global->leisure_function_id = g_idle_add_full (G_PRIORITY_LOW,
|
|
|
|
run_leisure_functions,
|
|
|
|
global, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* shell_global_begin_work:
|
|
|
|
* @global: the #ShellGlobal
|
|
|
|
*
|
|
|
|
* Marks that we are currently doing work. This is used to to track
|
|
|
|
* whether we are busy for the purposes of shell_global_run_at_leisure().
|
|
|
|
* A count is kept and shell_global_end_work() must be called exactly
|
|
|
|
* as many times as shell_global_begin_work().
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
shell_global_begin_work (ShellGlobal *global)
|
|
|
|
{
|
|
|
|
global->work_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* shell_global_end_work:
|
|
|
|
* @global: the #ShellGlobal
|
|
|
|
*
|
|
|
|
* Marks the end of work that we started with shell_global_begin_work().
|
|
|
|
* If no other work is ongoing and functions have been added with
|
|
|
|
* shell_global_run_at_leisure(), they will be run at the next
|
|
|
|
* opportunity.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
shell_global_end_work (ShellGlobal *global)
|
|
|
|
{
|
|
|
|
g_return_if_fail (global->work_count > 0);
|
|
|
|
|
|
|
|
global->work_count--;
|
2010-05-21 17:25:41 -04:00
|
|
|
if (global->work_count == 0)
|
2010-05-09 00:34:15 -04:00
|
|
|
schedule_leisure_functions (global);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* shell_global_run_at_leisure:
|
|
|
|
* @global: the #ShellGlobal
|
|
|
|
* @func: function to call at leisure
|
|
|
|
* @user_data: data to pass to @func
|
|
|
|
* @notify: function to call to free @user_data
|
|
|
|
*
|
|
|
|
* Schedules a function to be called the next time the shell is idle.
|
|
|
|
* Idle means here no animations, no redrawing, and no ongoing background
|
|
|
|
* work. Since there is currently no way to hook into the Clutter master
|
|
|
|
* clock and know when is running, the implementation here is somewhat
|
|
|
|
* approximation. Animations done through the shell's Tweener module will
|
|
|
|
* be handled properly, but other animations may be detected as terminating
|
|
|
|
* early if they can be drawn fast enough so that the event loop goes idle
|
|
|
|
* between frames.
|
|
|
|
*
|
|
|
|
* The intent of this function is for performance measurement runs
|
|
|
|
* where a number of actions should be run serially and each action is
|
|
|
|
* timed individually. Using this function for other purposes will
|
|
|
|
* interfere with the ability to use it for performance measurement so
|
|
|
|
* should be avoided.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
shell_global_run_at_leisure (ShellGlobal *global,
|
|
|
|
ShellLeisureFunction func,
|
|
|
|
gpointer user_data,
|
|
|
|
GDestroyNotify notify)
|
|
|
|
{
|
|
|
|
LeisureClosure *closure = g_slice_new (LeisureClosure);
|
|
|
|
closure->func = func;
|
|
|
|
closure->user_data = user_data;
|
|
|
|
closure->notify = notify;
|
|
|
|
|
|
|
|
global->leisure_closures = g_slist_append (global->leisure_closures,
|
|
|
|
closure);
|
|
|
|
|
|
|
|
if (global->work_count == 0)
|
|
|
|
schedule_leisure_functions (global);
|
|
|
|
}
|
2010-07-22 20:39:44 -04:00
|
|
|
|
2012-11-04 13:53:49 -05:00
|
|
|
static void
|
|
|
|
build_ca_proplist_for_event (ca_proplist *props,
|
2012-11-05 12:10:24 -05:00
|
|
|
const char *event_property,
|
2012-11-04 13:53:49 -05:00
|
|
|
const char *event_id,
|
|
|
|
const char *event_description,
|
|
|
|
ClutterEvent *for_event)
|
|
|
|
{
|
2012-11-05 12:10:24 -05:00
|
|
|
ca_proplist_sets (props, event_property, event_id);
|
2012-11-04 13:53:49 -05:00
|
|
|
ca_proplist_sets (props, CA_PROP_EVENT_DESCRIPTION, event_description);
|
|
|
|
ca_proplist_sets (props, CA_PROP_CANBERRA_CACHE_CONTROL, "volatile");
|
|
|
|
|
|
|
|
if (for_event)
|
|
|
|
{
|
|
|
|
if (clutter_event_type (for_event) != CLUTTER_KEY_PRESS &&
|
|
|
|
clutter_event_type (for_event) != CLUTTER_KEY_RELEASE)
|
|
|
|
{
|
|
|
|
ClutterPoint point;
|
|
|
|
|
|
|
|
clutter_event_get_position (for_event, &point);
|
|
|
|
|
|
|
|
ca_proplist_setf (props, CA_PROP_EVENT_MOUSE_X, "%d", (int)point.x);
|
|
|
|
ca_proplist_setf (props, CA_PROP_EVENT_MOUSE_Y, "%d", (int)point.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (clutter_event_type (for_event) == CLUTTER_BUTTON_PRESS ||
|
|
|
|
clutter_event_type (for_event) == CLUTTER_BUTTON_RELEASE)
|
|
|
|
{
|
|
|
|
gint button;
|
|
|
|
|
|
|
|
button = clutter_event_get_button (for_event);
|
|
|
|
ca_proplist_setf (props, CA_PROP_EVENT_MOUSE_BUTTON, "%d", button);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-22 20:39:44 -04:00
|
|
|
/**
|
|
|
|
* shell_global_play_theme_sound:
|
|
|
|
* @global: the #ShellGlobal
|
2011-02-15 13:23:36 -05:00
|
|
|
* @id: an id, used to cancel later (0 if not needed)
|
2010-07-22 20:39:44 -04:00
|
|
|
* @name: the sound name
|
2012-11-04 13:53:49 -05:00
|
|
|
* @for_event: (allow-none): a #ClutterEvent in response to which the sound is played
|
2010-07-22 20:39:44 -04:00
|
|
|
*
|
|
|
|
* Plays a simple sound picked according to Freedesktop sound theme.
|
|
|
|
* Really just a workaround for libcanberra not being introspected.
|
|
|
|
*/
|
|
|
|
void
|
2012-11-04 13:53:49 -05:00
|
|
|
shell_global_play_theme_sound (ShellGlobal *global,
|
|
|
|
guint id,
|
|
|
|
const char *name,
|
|
|
|
const char *description,
|
|
|
|
ClutterEvent *for_event)
|
2010-07-22 20:39:44 -04:00
|
|
|
{
|
2012-11-04 13:53:49 -05:00
|
|
|
ca_proplist *props;
|
|
|
|
|
|
|
|
ca_proplist_create (&props);
|
2012-11-05 12:10:24 -05:00
|
|
|
build_ca_proplist_for_event (props, CA_PROP_EVENT_ID, name, description, for_event);
|
2012-11-04 13:53:49 -05:00
|
|
|
|
|
|
|
ca_context_play_full (global->sound_context, id, props, NULL, NULL);
|
|
|
|
|
|
|
|
ca_proplist_destroy (props);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* shell_global_play_theme_sound_full:
|
|
|
|
* @global: the #ShellGlobal
|
|
|
|
* @id: an id, used to cancel later (0 if not needed)
|
|
|
|
* @name: the sound name
|
|
|
|
* @description: the localized description of the event that triggered this alert
|
|
|
|
* @for_event: (allow-none): a #ClutterEvent in response to which the sound is played
|
|
|
|
* @application_id: application on behalf of which the sound is played
|
|
|
|
* @application_name:
|
|
|
|
*
|
|
|
|
* Plays a simple sound picked according to Freedesktop sound theme.
|
|
|
|
* Really just a workaround for libcanberra not being introspected.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
shell_global_play_theme_sound_full (ShellGlobal *global,
|
|
|
|
guint id,
|
|
|
|
const char *name,
|
|
|
|
const char *description,
|
|
|
|
ClutterEvent *for_event,
|
|
|
|
const char *application_id,
|
|
|
|
const char *application_name)
|
|
|
|
{
|
|
|
|
ca_proplist *props;
|
|
|
|
|
|
|
|
ca_proplist_create (&props);
|
2012-11-05 12:10:24 -05:00
|
|
|
build_ca_proplist_for_event (props, CA_PROP_EVENT_ID, name, description, for_event);
|
2012-11-04 13:53:49 -05:00
|
|
|
ca_proplist_sets (props, CA_PROP_APPLICATION_ID, application_id);
|
|
|
|
ca_proplist_sets (props, CA_PROP_APPLICATION_NAME, application_name);
|
|
|
|
|
|
|
|
ca_context_play_full (global->sound_context, id, props, NULL, NULL);
|
|
|
|
|
|
|
|
ca_proplist_destroy (props);
|
2011-02-15 13:23:36 -05:00
|
|
|
}
|
|
|
|
|
2012-11-05 12:10:24 -05:00
|
|
|
/**
|
|
|
|
* shell_global_play_sound_file_full:
|
|
|
|
* @global: the #ShellGlobal
|
|
|
|
* @id: an id, used to cancel later (0 if not needed)
|
|
|
|
* @file_name: the file name to play
|
|
|
|
* @description: the localized description of the event that triggered this alert
|
|
|
|
* @for_event: (allow-none): a #ClutterEvent in response to which the sound is played
|
|
|
|
* @application_id: application on behalf of which the sound is played
|
|
|
|
* @application_name:
|
|
|
|
*
|
|
|
|
* Like shell_global_play_theme_sound_full(), but with an explicit path
|
|
|
|
* instead of a themed sound.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
shell_global_play_sound_file_full (ShellGlobal *global,
|
|
|
|
guint id,
|
|
|
|
const char *file_name,
|
|
|
|
const char *description,
|
|
|
|
ClutterEvent *for_event,
|
|
|
|
const char *application_id,
|
|
|
|
const char *application_name)
|
|
|
|
{
|
|
|
|
ca_proplist *props;
|
|
|
|
|
|
|
|
ca_proplist_create (&props);
|
|
|
|
build_ca_proplist_for_event (props, CA_PROP_MEDIA_FILENAME, file_name, description, for_event);
|
|
|
|
ca_proplist_sets (props, CA_PROP_APPLICATION_ID, application_id);
|
|
|
|
ca_proplist_sets (props, CA_PROP_APPLICATION_NAME, application_name);
|
|
|
|
|
|
|
|
ca_context_play_full (global->sound_context, id, props, NULL, NULL);
|
|
|
|
|
|
|
|
ca_proplist_destroy (props);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* shell_global_play_sound_file:
|
|
|
|
* @global: the #ShellGlobal
|
|
|
|
* @id: an id, used to cancel later (0 if not needed)
|
|
|
|
* @file_name: the file name to play
|
|
|
|
* @description: the localized description of the event that triggered this alert
|
|
|
|
* @for_event: (allow-none): a #ClutterEvent in response to which the sound is played
|
|
|
|
*
|
|
|
|
* Like shell_global_play_theme_sound(), but with an explicit path
|
|
|
|
* instead of a themed sound.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
shell_global_play_sound_file (ShellGlobal *global,
|
|
|
|
guint id,
|
|
|
|
const char *file_name,
|
|
|
|
const char *description,
|
|
|
|
ClutterEvent *for_event)
|
|
|
|
{
|
|
|
|
ca_proplist *props;
|
|
|
|
|
|
|
|
ca_proplist_create (&props);
|
|
|
|
build_ca_proplist_for_event (props, CA_PROP_MEDIA_FILENAME, file_name, description, for_event);
|
|
|
|
|
|
|
|
ca_context_play_full (global->sound_context, id, props, NULL, NULL);
|
|
|
|
|
|
|
|
ca_proplist_destroy (props);
|
|
|
|
}
|
|
|
|
|
2011-02-15 13:23:36 -05:00
|
|
|
/**
|
|
|
|
* shell_global_cancel_theme_sound:
|
|
|
|
* @global: the #ShellGlobal
|
|
|
|
* @id: the id previously passed to shell_global_play_theme_sound()
|
|
|
|
*
|
|
|
|
* Cancels a sound notification.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
shell_global_cancel_theme_sound (ShellGlobal *global,
|
|
|
|
guint id)
|
|
|
|
{
|
|
|
|
ca_context_cancel (global->sound_context, id);
|
2010-07-22 20:39:44 -04:00
|
|
|
}
|
2011-01-05 09:47:27 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Process Xdnd events
|
|
|
|
*
|
|
|
|
* We pass the position and leave events to JS via a signal
|
|
|
|
* where the actual drag & drop handling happens.
|
|
|
|
*
|
|
|
|
* http://www.freedesktop.org/wiki/Specifications/XDND
|
|
|
|
*/
|
|
|
|
gboolean _shell_global_check_xdnd_event (ShellGlobal *global,
|
|
|
|
XEvent *xev)
|
|
|
|
{
|
2011-07-13 12:22:32 -04:00
|
|
|
Window output_window = meta_get_overlay_window (global->meta_screen);
|
2011-01-05 09:47:27 -05:00
|
|
|
|
2011-07-13 12:22:32 -04:00
|
|
|
if (xev->xany.window != output_window && xev->xany.window != global->stage_xwindow)
|
2011-01-05 09:47:27 -05:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (xev->xany.type == ClientMessage && xev->xclient.message_type == gdk_x11_get_xatom_by_name ("XdndPosition"))
|
|
|
|
{
|
|
|
|
XEvent xevent;
|
|
|
|
Window src = xev->xclient.data.l[0];
|
|
|
|
|
|
|
|
memset (&xevent, 0, sizeof(xevent));
|
|
|
|
xevent.xany.type = ClientMessage;
|
2011-07-13 12:22:32 -04:00
|
|
|
xevent.xany.display = global->xdisplay;
|
2011-01-05 09:47:27 -05:00
|
|
|
xevent.xclient.window = src;
|
|
|
|
xevent.xclient.message_type = gdk_x11_get_xatom_by_name ("XdndStatus");
|
|
|
|
xevent.xclient.format = 32;
|
|
|
|
xevent.xclient.data.l[0] = output_window;
|
|
|
|
/* flags: bit 0: will we accept the drop? bit 1: do we want more position messages */
|
|
|
|
xevent.xclient.data.l[1] = 2;
|
|
|
|
xevent.xclient.data.l[4] = None;
|
|
|
|
|
2011-07-13 12:22:32 -04:00
|
|
|
XSendEvent (global->xdisplay, src, False, 0, &xevent);
|
2011-01-05 09:47:27 -05:00
|
|
|
|
|
|
|
/* Store the timestamp of the xdnd position event */
|
|
|
|
global->xdnd_timestamp = xev->xclient.data.l[3];
|
|
|
|
g_signal_emit_by_name (G_OBJECT (global), "xdnd-position-changed",
|
|
|
|
(int)(xev->xclient.data.l[2] >> 16), (int)(xev->xclient.data.l[2] & 0xFFFF));
|
|
|
|
global->xdnd_timestamp = 0;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (xev->xany.type == ClientMessage && xev->xclient.message_type == gdk_x11_get_xatom_by_name ("XdndLeave"))
|
|
|
|
{
|
|
|
|
g_signal_emit_by_name (G_OBJECT (global), "xdnd-leave");
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (xev->xany.type == ClientMessage && xev->xclient.message_type == gdk_x11_get_xatom_by_name ("XdndEnter"))
|
|
|
|
{
|
|
|
|
g_signal_emit_by_name (G_OBJECT (global), "xdnd-enter");
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-02-07 10:21:30 -05:00
|
|
|
|
2012-05-16 17:11:57 -04:00
|
|
|
const char *
|
|
|
|
shell_global_get_session_mode (ShellGlobal *global)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (SHELL_IS_GLOBAL (global), "user");
|
|
|
|
|
|
|
|
return global->session_mode;
|
2011-06-21 10:09:09 -04:00
|
|
|
}
|