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:
parent
fbd4951ea7
commit
11c2933e23
21
js/ui/dnd.js
21
js/ui/dnd.js
@ -5,6 +5,7 @@ const GLib = imports.gi.GLib;
|
||||
const Gtk = imports.gi.Gtk;
|
||||
const St = imports.gi.St;
|
||||
const Lang = imports.lang;
|
||||
const Meta = imports.gi.Meta;
|
||||
const Shell = imports.gi.Shell;
|
||||
const Signals = imports.signals;
|
||||
const Tweener = imports.ui.tweener;
|
||||
@ -27,9 +28,9 @@ const DragMotionResult = {
|
||||
};
|
||||
|
||||
const DRAG_CURSOR_MAP = {
|
||||
0: Shell.Cursor.DND_UNSUPPORTED_TARGET,
|
||||
1: Shell.Cursor.DND_COPY,
|
||||
2: Shell.Cursor.DND_MOVE
|
||||
0: Meta.Cursor.DND_UNSUPPORTED_TARGET,
|
||||
1: Meta.Cursor.DND_COPY,
|
||||
2: Meta.Cursor.DND_MOVE
|
||||
};
|
||||
|
||||
const DragDropResult = {
|
||||
@ -244,7 +245,7 @@ const _Draggable = new Lang.Class({
|
||||
if (this._onEventId)
|
||||
this._ungrabActor();
|
||||
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._dragY = this._dragStartY = stageY;
|
||||
@ -374,7 +375,7 @@ const _Draggable = new Lang.Class({
|
||||
if (motionFunc) {
|
||||
let result = motionFunc(dragEvent);
|
||||
if (result != DragMotionResult.CONTINUE) {
|
||||
global.set_cursor(DRAG_CURSOR_MAP[result]);
|
||||
global.screen.set_cursor(DRAG_CURSOR_MAP[result]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -392,13 +393,13 @@ const _Draggable = new Lang.Class({
|
||||
targY,
|
||||
0);
|
||||
if (result != DragMotionResult.CONTINUE) {
|
||||
global.set_cursor(DRAG_CURSOR_MAP[result]);
|
||||
global.screen.set_cursor(DRAG_CURSOR_MAP[result]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
target = target.get_parent();
|
||||
}
|
||||
global.set_cursor(Shell.Cursor.DND_IN_DRAG);
|
||||
global.screen.set_cursor(Meta.Cursor.DND_IN_DRAG);
|
||||
return false;
|
||||
},
|
||||
|
||||
@ -470,7 +471,7 @@ const _Draggable = new Lang.Class({
|
||||
}
|
||||
|
||||
this._dragInProgress = false;
|
||||
global.unset_cursor();
|
||||
global.screen.set_cursor(Meta.Cursor.DEFAULT);
|
||||
this.emit('drag-end', event.get_time(), true);
|
||||
this._dragComplete();
|
||||
return true;
|
||||
@ -522,7 +523,7 @@ const _Draggable = new Lang.Class({
|
||||
let [snapBackX, snapBackY, snapBackScale] = this._getRestoreLocation();
|
||||
|
||||
if (this._actorDestroyed) {
|
||||
global.unset_cursor();
|
||||
global.screen.set_cursor(Meta.Cursor.DEFAULT);
|
||||
if (!this._buttonDown)
|
||||
this._dragComplete();
|
||||
this.emit('drag-end', eventTime, false);
|
||||
@ -576,7 +577,7 @@ const _Draggable = new Lang.Class({
|
||||
} else {
|
||||
dragActor.destroy();
|
||||
}
|
||||
global.unset_cursor();
|
||||
global.screen.set_cursor(Meta.Cursor.DEFAULT);
|
||||
this.emit('drag-end', eventTime, false);
|
||||
|
||||
this._animationInProgress = false;
|
||||
|
@ -215,10 +215,10 @@ const URLHighlighter = new Lang.Class({
|
||||
|
||||
let urlId = this._findUrlAtPos(event);
|
||||
if (urlId != -1 && !this._cursorChanged) {
|
||||
global.set_cursor(Shell.Cursor.POINTING_HAND);
|
||||
global.screen.set_cursor(Meta.Cursor.POINTING_HAND);
|
||||
this._cursorChanged = true;
|
||||
} else if (urlId == -1) {
|
||||
global.unset_cursor();
|
||||
global.screen.set_cursor(Meta.Cursor.DEFAULT);
|
||||
this._cursorChanged = false;
|
||||
}
|
||||
return false;
|
||||
@ -229,7 +229,7 @@ const URLHighlighter = new Lang.Class({
|
||||
|
||||
if (this._cursorChanged) {
|
||||
this._cursorChanged = false;
|
||||
global.unset_cursor();
|
||||
global.screen.set_cursor(Meta.Cursor.DEFAULT);
|
||||
}
|
||||
}));
|
||||
},
|
||||
|
@ -6,6 +6,7 @@ const Gio = imports.gi.Gio;
|
||||
const GLib = imports.gi.GLib;
|
||||
const Gtk = imports.gi.Gtk;
|
||||
const Lang = imports.lang;
|
||||
const Meta = imports.gi.Meta;
|
||||
const Shell = imports.gi.Shell;
|
||||
const Signals = imports.signals;
|
||||
const St = imports.gi.St;
|
||||
@ -167,7 +168,7 @@ const SelectArea = new Lang.Class({
|
||||
if (!Main.pushModal(this._group) || this._group.visible)
|
||||
return;
|
||||
|
||||
global.set_cursor(Shell.Cursor.CROSSHAIR);
|
||||
global.screen.set_cursor(Meta.Cursor.CROSSHAIR);
|
||||
this._group.visible = true;
|
||||
},
|
||||
|
||||
@ -238,7 +239,7 @@ const SelectArea = new Lang.Class({
|
||||
function() {
|
||||
Main.popModal(this._group);
|
||||
this._group.destroy();
|
||||
global.unset_cursor();
|
||||
global.screen.set_cursor(Meta.Cursor.DEFAULT);
|
||||
|
||||
this.emit('finished', geometry);
|
||||
})
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <meta/display.h>
|
||||
#include <meta/util.h>
|
||||
#include <meta/meta-shaped-texture.h>
|
||||
#include <meta/meta-cursor-tracker.h>
|
||||
|
||||
/* Memory report bits */
|
||||
#ifdef HAVE_MALLINFO
|
||||
@ -599,91 +600,6 @@ sync_input_region (ShellGlobal *global)
|
||||
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:
|
||||
* @global: the #ShellGlobal
|
||||
|
@ -50,20 +50,6 @@ void shell_global_freeze_keyboard (ShellGlobal *global,
|
||||
void shell_global_set_stage_input_region (ShellGlobal *global,
|
||||
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,
|
||||
int *x,
|
||||
int *y,
|
||||
|
Loading…
Reference in New Issue
Block a user