Title: [262375] trunk/Source
Revision
262375
Author
[email protected]
Date
2020-06-01 06:33:32 -0700 (Mon, 01 Jun 2020)

Log Message

[GTK4] Add printing support
https://bugs.webkit.org/show_bug.cgi?id=212320

Reviewed by Adrian Perez de Castro.

Source/WebCore:

Add gtk_dialog_run() to GTK4.

* platform/gtk/GtkVersioning.h:
(gtk_dialog_run):

Source/WebKit:

Printing API hasn't changed, the only problem was that we were using gtk_dialog_run() and gdk threads deprecated API.

* UIProcess/API/gtk/WebKitPrintOperation.cpp:
(webkitPrintOperationRunDialog): Remove GTK4 ifdefs.
* WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp:
(WebKit::WebPrintOperationGtk::print): Use g_idle_add_full() instead of gdk threads deprecated API.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (262374 => 262375)


--- trunk/Source/WebCore/ChangeLog	2020-06-01 12:55:50 UTC (rev 262374)
+++ trunk/Source/WebCore/ChangeLog	2020-06-01 13:33:32 UTC (rev 262375)
@@ -1,5 +1,17 @@
 2020-06-01  Carlos Garcia Campos  <[email protected]>
 
+        [GTK4] Add printing support
+        https://bugs.webkit.org/show_bug.cgi?id=212320
+
+        Reviewed by Adrian Perez de Castro.
+
+        Add gtk_dialog_run() to GTK4.
+
+        * platform/gtk/GtkVersioning.h:
+        (gtk_dialog_run):
+
+2020-06-01  Carlos Garcia Campos  <[email protected]>
+
         [GTK4] Make inspector work
         https://bugs.webkit.org/show_bug.cgi?id=212321
 

Modified: trunk/Source/WebCore/platform/gtk/GtkVersioning.h (262374 => 262375)


--- trunk/Source/WebCore/platform/gtk/GtkVersioning.h	2020-06-01 12:55:50 UTC (rev 262374)
+++ trunk/Source/WebCore/platform/gtk/GtkVersioning.h	2020-06-01 13:33:32 UTC (rev 262375)
@@ -202,6 +202,25 @@
     return context.response;
 }
 
+static inline int
+gtk_dialog_run(GtkDialog* dialog)
+{
+    struct RunDialogContext {
+        GMainLoop *loop;
+        int response;
+    } context = { g_main_loop_new(nullptr, FALSE), 0 };
+
+    gtk_widget_show(GTK_WIDGET(dialog));
+    g_signal_connect(dialog, "response", G_CALLBACK(+[](GtkDialog*, int response, RunDialogContext* context) {
+        context->response = response;
+        g_main_loop_quit(context->loop);
+    }), &context);
+    g_main_loop_run(context.loop);
+    g_main_loop_unref(context.loop);
+
+    return context.response;
+}
+
 #else // USE(GTK4)
 
 static inline void

Modified: trunk/Source/WebKit/ChangeLog (262374 => 262375)


--- trunk/Source/WebKit/ChangeLog	2020-06-01 12:55:50 UTC (rev 262374)
+++ trunk/Source/WebKit/ChangeLog	2020-06-01 13:33:32 UTC (rev 262375)
@@ -1,5 +1,19 @@
 2020-06-01  Carlos Garcia Campos  <[email protected]>
 
+        [GTK4] Add printing support
+        https://bugs.webkit.org/show_bug.cgi?id=212320
+
+        Reviewed by Adrian Perez de Castro.
+
+        Printing API hasn't changed, the only problem was that we were using gtk_dialog_run() and gdk threads deprecated API.
+
+        * UIProcess/API/gtk/WebKitPrintOperation.cpp:
+        (webkitPrintOperationRunDialog): Remove GTK4 ifdefs.
+        * WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp:
+        (WebKit::WebPrintOperationGtk::print): Use g_idle_add_full() instead of gdk threads deprecated API.
+
+2020-06-01  Carlos Garcia Campos  <[email protected]>
+
         [GTK4] Wheel events are always handled by the main frame view
         https://bugs.webkit.org/show_bug.cgi?id=212593
 

Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitPrintOperation.cpp (262374 => 262375)


--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitPrintOperation.cpp	2020-06-01 12:55:50 UTC (rev 262374)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitPrintOperation.cpp	2020-06-01 13:33:32 UTC (rev 262375)
@@ -252,9 +252,6 @@
 
 static WebKitPrintOperationResponse webkitPrintOperationRunDialog(WebKitPrintOperation* printOperation, GtkWindow* parent)
 {
-#if USE(GTK4)
-    return WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL;
-#else
     GtkPrintUnixDialog* printDialog = GTK_PRINT_UNIX_DIALOG(gtk_print_unix_dialog_new(0, parent));
     gtk_print_unix_dialog_set_manual_capabilities(printDialog, static_cast<GtkPrintCapabilities>(GTK_PRINT_CAPABILITY_NUMBER_UP
                                                                                                  | GTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT
@@ -299,7 +296,6 @@
     gtk_widget_destroy(GTK_WIDGET(printDialog));
 
     return returnValue;
-#endif
 }
 #else
 // TODO: We need to add an implementation for Windows.

Modified: trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp (262374 => 262375)


--- trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp	2020-06-01 12:55:50 UTC (rev 262374)
+++ trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp	2020-06-01 13:33:32 UTC (rev 262375)
@@ -737,18 +737,17 @@
     m_xDPI = xDPI;
     m_yDPI = yDPI;
     m_cairoContext = adoptRef(cairo_create(surface));
-#if !USE(GTK4)
+
     // Make sure the print pages idle has more priority than IPC messages comming from
     // the IO thread, so that the EndPrinting message is always handled once the print
     // operation has finished. See https://bugs.webkit.org/show_bug.cgi?id=122801.
     unsigned idlePriority = m_printMode == PrintInfo::PrintModeSync ? G_PRIORITY_DEFAULT - 10 : G_PRIORITY_DEFAULT_IDLE + 10;
     GMainLoop* mainLoop = data->mainLoop.get();
-    m_printPagesIdleId = gdk_threads_add_idle_full(idlePriority, printPagesIdle, data.release(), printPagesIdleDone);
+    m_printPagesIdleId = g_idle_add_full(idlePriority, printPagesIdle, data.release(), printPagesIdleDone);
     if (m_printMode == PrintInfo::PrintModeSync) {
         ASSERT(mainLoop);
         g_main_loop_run(mainLoop);
     }
-#endif
 }
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to