ShellGlobal: remove cursor manipulation functions

Use the new API in MetaScreen instead, which is automatically
routed to MetaCursorTracker as appropriate.

https://bugzilla.gnome.org/show_bug.cgi?id=707467
This commit is contained in:
Giovanni Campagna 2013-09-11 17:35:58 +02:00
parent fbd4951ea7
commit 11c2933e23
5 changed files with 18 additions and 114 deletions

View File

@ -5,6 +5,7 @@ const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk; const Gtk = imports.gi.Gtk;
const St = imports.gi.St; const St = imports.gi.St;
const Lang = imports.lang; const Lang = imports.lang;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const Signals = imports.signals; const Signals = imports.signals;
const Tweener = imports.ui.tweener; const Tweener = imports.ui.tweener;
@ -27,9 +28,9 @@ const DragMotionResult = {
}; };
const DRAG_CURSOR_MAP = { const DRAG_CURSOR_MAP = {
0: Shell.Cursor.DND_UNSUPPORTED_TARGET, 0: Meta.Cursor.DND_UNSUPPORTED_TARGET,
1: Shell.Cursor.DND_COPY, 1: Meta.Cursor.DND_COPY,
2: Shell.Cursor.DND_MOVE 2: Meta.Cursor.DND_MOVE
}; };
const DragDropResult = { const DragDropResult = {
@ -244,7 +245,7 @@ const _Draggable = new Lang.Class({
if (this._onEventId) if (this._onEventId)
this._ungrabActor(); this._ungrabActor();
this._grabEvents(); this._grabEvents();
global.set_cursor(Shell.Cursor.DND_IN_DRAG); global.screen.set_cursor(Meta.Cursor.DND_IN_DRAG);
this._dragX = this._dragStartX = stageX; this._dragX = this._dragStartX = stageX;
this._dragY = this._dragStartY = stageY; this._dragY = this._dragStartY = stageY;
@ -374,7 +375,7 @@ const _Draggable = new Lang.Class({
if (motionFunc) { if (motionFunc) {
let result = motionFunc(dragEvent); let result = motionFunc(dragEvent);
if (result != DragMotionResult.CONTINUE) { if (result != DragMotionResult.CONTINUE) {
global.set_cursor(DRAG_CURSOR_MAP[result]); global.screen.set_cursor(DRAG_CURSOR_MAP[result]);
return false; return false;
} }
} }
@ -392,13 +393,13 @@ const _Draggable = new Lang.Class({
targY, targY,
0); 0);
if (result != DragMotionResult.CONTINUE) { if (result != DragMotionResult.CONTINUE) {
global.set_cursor(DRAG_CURSOR_MAP[result]); global.screen.set_cursor(DRAG_CURSOR_MAP[result]);
return false; return false;
} }
} }
target = target.get_parent(); target = target.get_parent();
} }
global.set_cursor(Shell.Cursor.DND_IN_DRAG); global.screen.set_cursor(Meta.Cursor.DND_IN_DRAG);
return false; return false;
}, },
@ -470,7 +471,7 @@ const _Draggable = new Lang.Class({
} }
this._dragInProgress = false; this._dragInProgress = false;
global.unset_cursor(); global.screen.set_cursor(Meta.Cursor.DEFAULT);
this.emit('drag-end', event.get_time(), true); this.emit('drag-end', event.get_time(), true);
this._dragComplete(); this._dragComplete();
return true; return true;
@ -522,7 +523,7 @@ const _Draggable = new Lang.Class({
let [snapBackX, snapBackY, snapBackScale] = this._getRestoreLocation(); let [snapBackX, snapBackY, snapBackScale] = this._getRestoreLocation();
if (this._actorDestroyed) { if (this._actorDestroyed) {
global.unset_cursor(); global.screen.set_cursor(Meta.Cursor.DEFAULT);
if (!this._buttonDown) if (!this._buttonDown)
this._dragComplete(); this._dragComplete();
this.emit('drag-end', eventTime, false); this.emit('drag-end', eventTime, false);
@ -576,7 +577,7 @@ const _Draggable = new Lang.Class({
} else { } else {
dragActor.destroy(); dragActor.destroy();
} }
global.unset_cursor(); global.screen.set_cursor(Meta.Cursor.DEFAULT);
this.emit('drag-end', eventTime, false); this.emit('drag-end', eventTime, false);
this._animationInProgress = false; this._animationInProgress = false;

View File

@ -215,10 +215,10 @@ const URLHighlighter = new Lang.Class({
let urlId = this._findUrlAtPos(event); let urlId = this._findUrlAtPos(event);
if (urlId != -1 && !this._cursorChanged) { if (urlId != -1 && !this._cursorChanged) {
global.set_cursor(Shell.Cursor.POINTING_HAND); global.screen.set_cursor(Meta.Cursor.POINTING_HAND);
this._cursorChanged = true; this._cursorChanged = true;
} else if (urlId == -1) { } else if (urlId == -1) {
global.unset_cursor(); global.screen.set_cursor(Meta.Cursor.DEFAULT);
this._cursorChanged = false; this._cursorChanged = false;
} }
return false; return false;
@ -229,7 +229,7 @@ const URLHighlighter = new Lang.Class({
if (this._cursorChanged) { if (this._cursorChanged) {
this._cursorChanged = false; this._cursorChanged = false;
global.unset_cursor(); global.screen.set_cursor(Meta.Cursor.DEFAULT);
} }
})); }));
}, },

View File

@ -6,6 +6,7 @@ const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib; const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk; const Gtk = imports.gi.Gtk;
const Lang = imports.lang; const Lang = imports.lang;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const Signals = imports.signals; const Signals = imports.signals;
const St = imports.gi.St; const St = imports.gi.St;
@ -167,7 +168,7 @@ const SelectArea = new Lang.Class({
if (!Main.pushModal(this._group) || this._group.visible) if (!Main.pushModal(this._group) || this._group.visible)
return; return;
global.set_cursor(Shell.Cursor.CROSSHAIR); global.screen.set_cursor(Meta.Cursor.CROSSHAIR);
this._group.visible = true; this._group.visible = true;
}, },
@ -238,7 +239,7 @@ const SelectArea = new Lang.Class({
function() { function() {
Main.popModal(this._group); Main.popModal(this._group);
this._group.destroy(); this._group.destroy();
global.unset_cursor(); global.screen.set_cursor(Meta.Cursor.DEFAULT);
this.emit('finished', geometry); this.emit('finished', geometry);
}) })

View File

@ -27,6 +27,7 @@
#include <meta/display.h> #include <meta/display.h>
#include <meta/util.h> #include <meta/util.h>
#include <meta/meta-shaped-texture.h> #include <meta/meta-shaped-texture.h>
#include <meta/meta-cursor-tracker.h>
/* Memory report bits */ /* Memory report bits */
#ifdef HAVE_MALLINFO #ifdef HAVE_MALLINFO
@ -599,91 +600,6 @@ sync_input_region (ShellGlobal *global)
meta_set_stage_input_region (screen, global->input_region); meta_set_stage_input_region (screen, global->input_region);
} }
/**
* 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;
case SHELL_CURSOR_POINTING_HAND:
name = "hand";
break;
case SHELL_CURSOR_CROSSHAIR:
name = "crosshair";
break;
default:
g_return_if_reached ();
}
cursor = gdk_cursor_new_from_name (global->gdk_display, name);
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;
case SHELL_CURSOR_POINTING_HAND:
cursor_type = GDK_HAND2;
break;
case SHELL_CURSOR_CROSSHAIR:
cursor_type = GDK_CROSSHAIR;
break;
case SHELL_CURSOR_DND_UNSUPPORTED_TARGET:
cursor_type = GDK_X_CURSOR;
break;
default:
g_return_if_reached ();
}
cursor = gdk_cursor_new (cursor_type);
}
gdk_window_set_cursor (global->stage_gdk_window, cursor);
g_object_unref (cursor);
}
/**
* shell_global_unset_cursor:
* @global: A #ShellGlobal
*
* Unset the cursor on the stage window.
*/
void
shell_global_unset_cursor (ShellGlobal *global)
{
gdk_window_set_cursor (global->stage_gdk_window, NULL);
}
/** /**
* shell_global_set_stage_input_region: * shell_global_set_stage_input_region:
* @global: the #ShellGlobal * @global: the #ShellGlobal

View File

@ -50,20 +50,6 @@ void shell_global_freeze_keyboard (ShellGlobal *global,
void shell_global_set_stage_input_region (ShellGlobal *global, void shell_global_set_stage_input_region (ShellGlobal *global,
GSList *rectangles); GSList *rectangles);
/* X utilities */
typedef enum {
SHELL_CURSOR_DND_IN_DRAG,
SHELL_CURSOR_DND_UNSUPPORTED_TARGET,
SHELL_CURSOR_DND_MOVE,
SHELL_CURSOR_DND_COPY,
SHELL_CURSOR_POINTING_HAND,
SHELL_CURSOR_CROSSHAIR
} ShellCursor;
void shell_global_set_cursor (ShellGlobal *global,
ShellCursor type);
void shell_global_unset_cursor (ShellGlobal *global);
void shell_global_get_pointer (ShellGlobal *global, void shell_global_get_pointer (ShellGlobal *global,
int *x, int *x,
int *y, int *y,