Skip to content

macos: Fix 7690

Gets drawing in the canvas speed on retina displays up to the speed of FullHD displays on macOS, making 2.99 usable on macOS.

Generic change:

Changes the cursor_label to delay drawing to the idle queue on all platforms. Especially since any draws on this label force a full canvas redraw on every update (which is every frame given it is updating the cursor position). This is due to a quirk in how GtkLabel functions (discussed further below).

MacOS changes:

Only redraws the cursor position label and each of the horizontal and vertical rules (cursor tracking widgets) 3 times a second max for a total of 9 redraws a second (ideally out of 60, though I don't believe under any circumstances that GIMP achieves a 60fps).

Each of the cursor tracking widgets gets its own timeslice, and so will not redraw when the other cursor tracking widgets are drawing.

This ensures that draw rects are maintained at the smallest possible size. So the typical redraw is a small rect around the brush. 9 times a second, the rect will include one of the cursor tracking widgets.

GtkLabel problem: these widgets resize themselves and everything around them by sending a resize message any time they receive new text. These resizes then trigger a full canvas redraw that cannot be optimized by either Gtk or Big Sur.

This code works around that by checking if the widget is too small, and setting the text in the usual way to cause the widget (and the canvas) to handle a resize, then for subsequent calls, uses the patched API in gimp-macos-build in the file patches/gtk+-3.24.31-gtklabel-set-text-no-resize.patch to ensure there are no futher changes.

Attempts to not require a special API patch that did not work, included:

  • Embedding the GtkLabel in a GtkScrolledWindow
  • Using gtk_label_set_width_chars and/or gtk_widget_set_size_request to set a fixed size. See gtk#4691 (closed)

Merge request reports