зеркало из https://github.com/mozilla/gecko-dev.git
Bug 310924 - GTK: Try named cursors before defaulting to hardcoded glyphs. r=karlt
This commit is contained in:
Родитель
2a9fd71c02
Коммит
25ab080eb6
|
@ -4904,7 +4904,12 @@ get_gtk_cursor(nsCursor aCursor)
|
||||||
if ((gdkcursor = gCursorCache[aCursor])) {
|
if ((gdkcursor = gCursorCache[aCursor])) {
|
||||||
return gdkcursor;
|
return gdkcursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GdkDisplay *defaultDisplay = gdk_display_get_default();
|
||||||
|
|
||||||
|
// The strategy here is to use standard GDK cursors, and, if not available,
|
||||||
|
// load by standard name with gdk_cursor_new_from_name.
|
||||||
|
// Spec is here: http://www.freedesktop.org/wiki/Specifications/cursor-spec/
|
||||||
switch (aCursor) {
|
switch (aCursor) {
|
||||||
case eCursor_standard:
|
case eCursor_standard:
|
||||||
gdkcursor = gdk_cursor_new(GDK_LEFT_PTR);
|
gdkcursor = gdk_cursor_new(GDK_LEFT_PTR);
|
||||||
|
@ -4952,25 +4957,42 @@ get_gtk_cursor(nsCursor aCursor)
|
||||||
gdkcursor = gdk_cursor_new(GDK_QUESTION_ARROW);
|
gdkcursor = gdk_cursor_new(GDK_QUESTION_ARROW);
|
||||||
break;
|
break;
|
||||||
case eCursor_copy: // CSS3
|
case eCursor_copy: // CSS3
|
||||||
newType = MOZ_CURSOR_COPY;
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "copy");
|
||||||
|
if (!gdkcursor)
|
||||||
|
newType = MOZ_CURSOR_COPY;
|
||||||
break;
|
break;
|
||||||
case eCursor_alias:
|
case eCursor_alias:
|
||||||
newType = MOZ_CURSOR_ALIAS;
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "alias");
|
||||||
|
if (!gdkcursor)
|
||||||
|
newType = MOZ_CURSOR_ALIAS;
|
||||||
break;
|
break;
|
||||||
case eCursor_context_menu:
|
case eCursor_context_menu:
|
||||||
newType = MOZ_CURSOR_CONTEXT_MENU;
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "context-menu");
|
||||||
|
if (!gdkcursor)
|
||||||
|
newType = MOZ_CURSOR_CONTEXT_MENU;
|
||||||
break;
|
break;
|
||||||
case eCursor_cell:
|
case eCursor_cell:
|
||||||
gdkcursor = gdk_cursor_new(GDK_PLUS);
|
gdkcursor = gdk_cursor_new(GDK_PLUS);
|
||||||
break;
|
break;
|
||||||
|
// Those two aren’t standardized. Trying both KDE’s and GNOME’s names
|
||||||
case eCursor_grab:
|
case eCursor_grab:
|
||||||
newType = MOZ_CURSOR_HAND_GRAB;
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "openhand");
|
||||||
|
if (!gdkcursor)
|
||||||
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "hand1");
|
||||||
|
if (!gdkcursor)
|
||||||
|
newType = MOZ_CURSOR_HAND_GRAB;
|
||||||
break;
|
break;
|
||||||
case eCursor_grabbing:
|
case eCursor_grabbing:
|
||||||
newType = MOZ_CURSOR_HAND_GRABBING;
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "closedhand");
|
||||||
|
if (!gdkcursor)
|
||||||
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "grabbing");
|
||||||
|
if (!gdkcursor)
|
||||||
|
newType = MOZ_CURSOR_HAND_GRABBING;
|
||||||
break;
|
break;
|
||||||
case eCursor_spinning:
|
case eCursor_spinning:
|
||||||
newType = MOZ_CURSOR_SPINNING;
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "progress");
|
||||||
|
if (!gdkcursor)
|
||||||
|
newType = MOZ_CURSOR_SPINNING;
|
||||||
break;
|
break;
|
||||||
case eCursor_zoom_in:
|
case eCursor_zoom_in:
|
||||||
newType = MOZ_CURSOR_ZOOM_IN;
|
newType = MOZ_CURSOR_ZOOM_IN;
|
||||||
|
@ -4979,8 +5001,20 @@ get_gtk_cursor(nsCursor aCursor)
|
||||||
newType = MOZ_CURSOR_ZOOM_OUT;
|
newType = MOZ_CURSOR_ZOOM_OUT;
|
||||||
break;
|
break;
|
||||||
case eCursor_not_allowed:
|
case eCursor_not_allowed:
|
||||||
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "not-allowed");
|
||||||
|
if (!gdkcursor) // nonstandard, yet common
|
||||||
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "crossed_circle");
|
||||||
|
if (!gdkcursor)
|
||||||
|
newType = MOZ_CURSOR_NOT_ALLOWED;
|
||||||
|
break;
|
||||||
case eCursor_no_drop:
|
case eCursor_no_drop:
|
||||||
newType = MOZ_CURSOR_NOT_ALLOWED;
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "no-drop");
|
||||||
|
if (!gdkcursor) // this nonstandard sequence makes it work on KDE and GNOME
|
||||||
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "forbidden");
|
||||||
|
if (!gdkcursor)
|
||||||
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "circle");
|
||||||
|
if (!gdkcursor)
|
||||||
|
newType = MOZ_CURSOR_NOT_ALLOWED;
|
||||||
break;
|
break;
|
||||||
case eCursor_vertical_text:
|
case eCursor_vertical_text:
|
||||||
newType = MOZ_CURSOR_VERTICAL_TEXT;
|
newType = MOZ_CURSOR_VERTICAL_TEXT;
|
||||||
|
@ -4989,19 +5023,32 @@ get_gtk_cursor(nsCursor aCursor)
|
||||||
gdkcursor = gdk_cursor_new(GDK_FLEUR);
|
gdkcursor = gdk_cursor_new(GDK_FLEUR);
|
||||||
break;
|
break;
|
||||||
case eCursor_nesw_resize:
|
case eCursor_nesw_resize:
|
||||||
newType = MOZ_CURSOR_NESW_RESIZE;
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "size_bdiag");
|
||||||
|
if (!gdkcursor)
|
||||||
|
newType = MOZ_CURSOR_NESW_RESIZE;
|
||||||
break;
|
break;
|
||||||
case eCursor_nwse_resize:
|
case eCursor_nwse_resize:
|
||||||
newType = MOZ_CURSOR_NWSE_RESIZE;
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "size_fdiag");
|
||||||
|
if (!gdkcursor)
|
||||||
|
newType = MOZ_CURSOR_NWSE_RESIZE;
|
||||||
break;
|
break;
|
||||||
case eCursor_ns_resize:
|
case eCursor_ns_resize:
|
||||||
case eCursor_row_resize:
|
|
||||||
gdkcursor = gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW);
|
gdkcursor = gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW);
|
||||||
break;
|
break;
|
||||||
case eCursor_ew_resize:
|
case eCursor_ew_resize:
|
||||||
case eCursor_col_resize:
|
|
||||||
gdkcursor = gdk_cursor_new(GDK_SB_H_DOUBLE_ARROW);
|
gdkcursor = gdk_cursor_new(GDK_SB_H_DOUBLE_ARROW);
|
||||||
break;
|
break;
|
||||||
|
// Here, two better fitting cursors exist in some cursor themes. Try those first
|
||||||
|
case eCursor_row_resize:
|
||||||
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "split_v");
|
||||||
|
if (!gdkcursor)
|
||||||
|
gdkcursor = gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW);
|
||||||
|
break;
|
||||||
|
case eCursor_col_resize:
|
||||||
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, "split_h");
|
||||||
|
if (!gdkcursor)
|
||||||
|
gdkcursor = gdk_cursor_new(GDK_SB_H_DOUBLE_ARROW);
|
||||||
|
break;
|
||||||
case eCursor_none:
|
case eCursor_none:
|
||||||
newType = MOZ_CURSOR_NONE;
|
newType = MOZ_CURSOR_NONE;
|
||||||
break;
|
break;
|
||||||
|
@ -5016,8 +5063,7 @@ get_gtk_cursor(nsCursor aCursor)
|
||||||
// custom bitmap, as libXcursor has some magic to convert bitmapped cursors
|
// custom bitmap, as libXcursor has some magic to convert bitmapped cursors
|
||||||
// to themed cursors
|
// to themed cursors
|
||||||
if (newType != 0xFF && GtkCursors[newType].hash) {
|
if (newType != 0xFF && GtkCursors[newType].hash) {
|
||||||
gdkcursor = gdk_cursor_new_from_name(gdk_display_get_default(),
|
gdkcursor = gdk_cursor_new_from_name(defaultDisplay, GtkCursors[newType].hash);
|
||||||
GtkCursors[newType].hash);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we still don't have a xcursor, we now really create a bitmap cursor
|
// If we still don't have a xcursor, we now really create a bitmap cursor
|
||||||
|
|
Загрузка…
Ссылка в новой задаче