Bug 1496836 - Set colorpicker widget as modal if parent widget is also modal on GTK. r=karlt
authorTim Nguyen <ntim.bugs@gmail.com>
Wed, 10 Oct 2018 20:21:39 +0000
changeset 488978 9a802bdfec41c901a97985088fdfe2867cd41cb0
parent 488977 55588bdd2ee8f5bcd66c6af0b340d5b02bf0411e
child 488979 0bd0dc3c8183e67a37fd08617a5b456049bf444b
push id246
push userfmarier@mozilla.com
push dateSat, 13 Oct 2018 00:15:40 +0000
reviewerskarlt
bugs1496836
milestone64.0a1
Bug 1496836 - Set colorpicker widget as modal if parent widget is also modal on GTK. r=karlt Differential Revision: https://phabricator.services.mozilla.com/D8199
widget/gtk/mozgtk/mozgtk.c
widget/gtk/nsColorPicker.cpp
--- a/widget/gtk/mozgtk/mozgtk.c
+++ b/widget/gtk/mozgtk/mozgtk.c
@@ -490,16 +490,17 @@ STUB(gtk_widget_show)
 STUB(gtk_widget_show_all)
 STUB(gtk_widget_size_allocate)
 STUB(gtk_widget_style_get)
 STUB(gtk_widget_unparent)
 STUB(gtk_widget_unrealize)
 STUB(gtk_window_deiconify)
 STUB(gtk_window_fullscreen)
 STUB(gtk_window_get_group)
+STUB(gtk_window_get_modal)
 STUB(gtk_window_get_transient_for)
 STUB(gtk_window_get_type)
 STUB(gtk_window_get_type_hint)
 STUB(gtk_window_get_window_type)
 STUB(gtk_window_group_add_window)
 STUB(gtk_window_group_get_current_grab)
 STUB(gtk_window_group_new)
 STUB(gtk_window_iconify)
--- a/widget/gtk/nsColorPicker.cpp
+++ b/widget/gtk/nsColorPicker.cpp
@@ -95,33 +95,40 @@ NS_IMETHODIMP nsColorPicker::Open(nsICol
   nsCString title;
   title.Adopt(ToNewUTF8String(mTitle));
   GtkWindow *parent_window = GTK_WINDOW(mParentWidget->GetNativeData(NS_NATIVE_SHELLWIDGET));
 
 #if defined(ACTIVATE_GTK3_COLOR_PICKER) && GTK_CHECK_VERSION(3,4,0)
   GtkWidget* color_chooser = gtk_color_chooser_dialog_new(title, parent_window);
 
   if (parent_window) {
-      gtk_window_set_destroy_with_parent(GTK_WINDOW(color_chooser), TRUE);
+    GtkWindow *window = GTK_WINDOW(color_chooser);
+    gtk_window_set_destroy_with_parent(window, TRUE);
+    if (gtk_window_get_modal(parent_window)) {
+      gtk_window_set_modal(window, TRUE);
+    }
   }
 
   gtk_color_chooser_set_use_alpha(GTK_COLOR_CHOOSER(color_chooser), FALSE);
   GdkRGBA color_rgba = convertToRgbaColor(color);
   gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(color_chooser),
                              &color_rgba);
 
   g_signal_connect(GTK_COLOR_CHOOSER(color_chooser), "color-activated",
                    G_CALLBACK(OnColorChanged), this);
 #else
   GtkWidget *color_chooser = gtk_color_selection_dialog_new(title.get());
 
   if (parent_window) {
     GtkWindow *window = GTK_WINDOW(color_chooser);
     gtk_window_set_transient_for(window, parent_window);
     gtk_window_set_destroy_with_parent(window, TRUE);
+    if (gtk_window_get_modal(parent_window)) {
+      gtk_window_set_modal(window, TRUE);
+    }
   }
 
   GdkColor color_gdk = convertToGdkColor(color);
   gtk_color_selection_set_current_color(WidgetGetColorSelection(color_chooser),
                                         &color_gdk);
 
   g_signal_connect(WidgetGetColorSelection(color_chooser), "color-changed",
                    G_CALLBACK(OnColorChanged), this);