Skip to content

Commit

Permalink
Merge pull request #1237 from mypaint/development
Browse files Browse the repository at this point in the history
Merge development into master
  • Loading branch information
AesaraB committed Feb 4, 2024
2 parents f95972f + c5ff707 commit 1a0e072
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 33 deletions.
2 changes: 1 addition & 1 deletion gui/brushmanip.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def inactive_cursor(self):

@property
def active_cursor(self):
return Gdk.Cursor.new(Gdk.CursorType.BLANK_CURSOR)
return Gdk.Cursor.new_from_name(Gdk.Display.get_default(), "none")

def enter(self, doc, **kwds):
super(BrushResizeMode, self).enter(doc, **kwds)
Expand Down
2 changes: 1 addition & 1 deletion gui/buttonmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def _bp_edit_box_enter_cb(self, evbox, event):
window = evbox.get_window()
disp = window.get_display()
try: # Wayland themes are a bit incomplete
cursor = Gdk.Cursor.new_for_display(disp, Gdk.CursorType.CROSSHAIR)
cursor = Gdk.Cursor.new_from_name(disp, "crosshair")
window.set_cursor(cursor)
except Exception:
logger.exception("Cursor setting failed") # and otherwise ignore
Expand Down
4 changes: 2 additions & 2 deletions gui/colors/adjbases.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ def __init__(self, prefs, datapath):
self._palette = None #: Current working palette
self._adjusters = weakref.WeakSet() #: The set of registered adjusters
#: Cursor for pickers
# FIXME: Use Gdk.Cursor.new_for_display()
self._picker_cursor = Gdk.Cursor.new(Gdk.CursorType.CROSSHAIR)
self._picker_cursor = Gdk.Cursor.new_from_name(
Gdk.Display.get_default(), "crosshair")
self._datapath = datapath #: Base path for saving palettes and masks
self._hue_distorts = None #: Hue-remapping table for color wheels
self._prefs = prefs #: Shared preferences dictionary
Expand Down
22 changes: 14 additions & 8 deletions gui/colors/hcywheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,14 +431,20 @@ def __init__(self):
def _realize_cb(self, widget):
display = self.get_window().get_display()

self.__add_cursor = Gdk.Cursor.new_for_display(
display, Gdk.CursorType.PLUS)
self.__move_cursor = Gdk.Cursor.new_for_display(
display, Gdk.CursorType.FLEUR)
self.__move_point_cursor = Gdk.Cursor.new_for_display(
display, Gdk.CursorType.CROSSHAIR)
self.__rotate_cursor = Gdk.Cursor.new_for_display(
display, Gdk.CursorType.EXCHANGE)
try:
# non-standard cursor
self.__add_cursor = Gdk.Cursor.new_from_name(display, "plus")
except Exception:
self.__add_cursor = Gdk.Cursor.new_from_name(display, "default")
self.__move_cursor = Gdk.Cursor.new_from_name(display, "move")
self.__move_point_cursor = Gdk.Cursor.new_from_name(
display, "crosshair")
try:
# non-standard cursor
self.__rotate_cursor = Gdk.Cursor.new_from_name(
display, "exchange")
except Exception:
self.__rotate_cursor = Gdk.Cursor.new_from_name(display, "grab")

def __leave_cb(self, widget, event):
# Reset the active objects when the pointer leaves.
Expand Down
6 changes: 4 additions & 2 deletions gui/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,12 @@ def get_action_cursor(self, action_name, cursor_name=Name.ARROW):
# Find a small action icon for the overlay
action = self.app.find_action(action_name)
if action is None:
return Gdk.Cursor.new(Gdk.CursorType.ARROW)
return Gdk.Cursor.new_from_name(
Gdk.Display.get_default(), "default")
icon_name = action.get_icon_name()
if icon_name is None:
return Gdk.Cursor.new(Gdk.CursorType.ARROW)
return Gdk.Cursor.new_from_name(
Gdk.Display.get_default(), "default")
return self.get_icon_cursor(icon_name, cursor_name)

def get_icon_cursor(self, icon_name, cursor_name=Name.ARROW):
Expand Down
3 changes: 1 addition & 2 deletions gui/freehand.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ def _hide_drawing_cursor(self, tdw):

if self._cursor_hidden is None:
window = tdw.get_window()
cursor = Gdk.Cursor.new_for_display(
window.get_display(), Gdk.CursorType.BLANK_CURSOR)
cursor = Gdk.Cursor.new_from_name(window.get_display(), "none")
self._cursor_hidden = cursor

tdw.set_override_cursor(self._cursor_hidden)
Expand Down
3 changes: 1 addition & 2 deletions gui/historypopup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ def enter(self):
self.show_all()

window = self.get_window()
cursor = Gdk.Cursor.new_for_display(
window.get_display(), Gdk.CursorType.CROSSHAIR)
cursor = Gdk.Cursor.new_from_name(window.get_display(), "crosshair")
window.set_cursor(cursor)

def leave(self, reason):
Expand Down
3 changes: 1 addition & 2 deletions gui/layermanip.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ def drag_stop_cb(self, tdw):
tdw.set_sensitive(False)

window = tdw.get_window()
cursor = Gdk.Cursor.new_for_display(
window.get_display(), Gdk.CursorType.WATCH)
cursor = Gdk.Cursor.new_from_name(window.get_display(), "wait")
tdw.set_override_cursor(cursor)

self.final_modifiers = self.current_modifiers()
Expand Down
3 changes: 1 addition & 2 deletions gui/tileddrawwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,7 @@ def update_cursor(self):
elif not layer.get_paintable():
# Cursor to represent that one cannot draw.
# Often a red circle with a diagonal bar through it.
c = Gdk.Cursor.new_for_display(
window.get_display(), Gdk.CursorType.CIRCLE)
c = Gdk.Cursor.new_from_name(window.get_display(), "not-allowed")
elif app is None:
logger.error("update_cursor: no app")
return
Expand Down
3 changes: 2 additions & 1 deletion gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ def with_wait_cursor(func):
"""python decorator that adds a wait cursor around a function"""
@functools.wraps(func)
def wrapper(self, *args, **kwargs):
wait_cursor = Gdk.Cursor.new(Gdk.CursorType.WATCH)
wait_cursor = Gdk.Cursor.new_from_name(
Gdk.Display.get_default(), "wait")
toplevels = Gtk.Window.list_toplevels()
toplevels = [t for t in toplevels if t.get_window() is not None]
for toplevel in toplevels:
Expand Down
21 changes: 11 additions & 10 deletions gui/windowing.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ class ChooserPopup (Gtk.Window):
EDGE_SIZE = 12
EDGE_CURSORS = {
None: None,
Gdk.WindowEdge.NORTH_EAST: Gdk.CursorType.TOP_RIGHT_CORNER,
Gdk.WindowEdge.NORTH_WEST: Gdk.CursorType.TOP_LEFT_CORNER,
Gdk.WindowEdge.SOUTH_EAST: Gdk.CursorType.BOTTOM_RIGHT_CORNER,
Gdk.WindowEdge.SOUTH_WEST: Gdk.CursorType.BOTTOM_LEFT_CORNER,
Gdk.WindowEdge.WEST: Gdk.CursorType.LEFT_SIDE,
Gdk.WindowEdge.EAST: Gdk.CursorType.RIGHT_SIDE,
Gdk.WindowEdge.SOUTH: Gdk.CursorType.BOTTOM_SIDE,
Gdk.WindowEdge.NORTH: Gdk.CursorType.TOP_SIDE,
Gdk.WindowEdge.NORTH_EAST: "ne-resize",
Gdk.WindowEdge.NORTH_WEST: "nw-resize",
Gdk.WindowEdge.SOUTH_EAST: "se-resize",
Gdk.WindowEdge.SOUTH_WEST: "sw-resize",
Gdk.WindowEdge.WEST: "w-resize",
Gdk.WindowEdge.EAST: "e-resize",
Gdk.WindowEdge.SOUTH: "s-resize",
Gdk.WindowEdge.NORTH: "n-resize",
}

## Method defs
Expand Down Expand Up @@ -175,7 +175,8 @@ def __init__(self, app, actions, config_name):
self._prefs_size_key = "%s.window_size" % (config_name,)
self._resize_info = None # state during an edge resize
self._outside_grab_active = False
self._outside_cursor = Gdk.Cursor(Gdk.CursorType.LEFT_PTR)
self._outside_cursor = Gdk.Cursor.new_from_name(
self.get_display(), "default")
self._popup_info = None

# Initial positioning
Expand All @@ -186,7 +187,7 @@ def __init__(self, app, actions, config_name):
self._edge_cursors = {}
for edge, cursor in self.EDGE_CURSORS.items():
if cursor is not None:
cursor = Gdk.Cursor(cursor)
cursor = Gdk.Cursor.new_from_name(self.get_display(), cursor)
self._edge_cursors[edge] = cursor

# Default size
Expand Down

0 comments on commit 1a0e072

Please sign in to comment.