Skip to content

Commit ae76e08

Browse files
masterpigaTurboGit
authored andcommitted
Use keep_on_top on mac, as in GTK3/Quartz
`transient_for` forces the windows to be on the same screen. Also, removes the focus-follow-mouse behavior, as it is adding too much complexity and its really only needed to show the tooltip. Users are responsible to focus the 2nd window if so they want by clicking on it.
1 parent 55a2830 commit ae76e08

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

src/views/darkroom.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4102,10 +4102,6 @@ static gboolean _second_window_buttons_enter_notify_callback(GtkWidget *widget,
41024102
gtk_widget_set_opacity(button_box, 1.0);
41034103
gtk_overlay_set_overlay_pass_through(GTK_OVERLAY(gtk_widget_get_parent(button_box)),
41044104
button_box, FALSE);
4105-
// GTK only shows tooltips for the focused window. Focus the 2nd window when
4106-
// the pointer enters it so that tooltips work. As a transient of the main
4107-
// window, the 2nd window always stays on top regardless of which has focus.
4108-
gtk_window_present_with_time(GTK_WINDOW(widget), event->time);
41094105
return FALSE;
41104106
}
41114107

@@ -4120,11 +4116,6 @@ static gboolean _second_window_buttons_leave_notify_callback(GtkWidget *widget,
41204116
gtk_widget_set_opacity(button_box, 0.0);
41214117
gtk_overlay_set_overlay_pass_through(GTK_OVERLAY(gtk_widget_get_parent(button_box)),
41224118
button_box, TRUE);
4123-
// Return focus to the main window so keyboard shortcuts and other
4124-
// interactions work normally after leaving the 2nd window.
4125-
GtkWindow *main_window = gtk_window_get_transient_for(GTK_WINDOW(widget));
4126-
if(main_window)
4127-
gtk_window_present_with_time(main_window, event->time);
41284119
}
41294120
return FALSE;
41304121
}
@@ -4319,8 +4310,14 @@ static void _darkroom_display_second_window(dt_develop_t *dev)
43194310
gtk_window_set_icon_name(GTK_WINDOW(dev->second_wnd), "darktable");
43204311
gtk_window_set_title(GTK_WINDOW(dev->second_wnd), _("darktable - darkroom preview"));
43214312

4313+
#ifndef GDK_WINDOWING_QUARTZ
4314+
// On macOS, transient_for is implemented via [NSWindow addChildWindow:ordered:],
4315+
// which constrains the child to the parent's screen and prevents it from being
4316+
// moved to a different monitor. Use keep_above instead (see below, after show_all,
4317+
// where the NSWindow is already realized).
43224318
gtk_window_set_transient_for(GTK_WINDOW(dev->second_wnd),
43234319
GTK_WINDOW(dt_ui_main_window(darktable.gui->ui)));
4320+
#endif
43244321

43254322
// Create the overlay for the window
43264323
GtkWidget *overlay = gtk_overlay_new();
@@ -4369,6 +4366,13 @@ static void _darkroom_display_second_window(dt_develop_t *dev)
43694366

43704367
// Show all widgets in the window
43714368
gtk_widget_show_all(dev->second_wnd);
4369+
4370+
#ifdef GDK_WINDOWING_QUARTZ
4371+
// keep_above must be set after the window is realized (i.e. after show_all),
4372+
// because the Quartz backend applies the NSWindow level change only to an
4373+
// already-existing NSWindow object.
4374+
gtk_window_set_keep_above(GTK_WINDOW(dev->second_wnd), TRUE);
4375+
#endif
43724376
}
43734377

43744378
// clang-format off

0 commit comments

Comments
 (0)