2022-07-21 19:26:10 +02:00
|
|
|
diff --git printing/printing_context_linux.cc printing/printing_context_linux.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
index d1ab2a72e0d11..c6be9f1ba1793 100644
|
2022-07-21 19:26:10 +02:00
|
|
|
--- printing/printing_context_linux.cc
|
|
|
|
+++ printing/printing_context_linux.cc
|
2023-12-06 21:16:15 +01:00
|
|
|
@@ -69,11 +69,11 @@ mojom::ResultCode PrintingContextLinux::UseDefaultSettings() {
|
2022-07-25 19:49:32 +02:00
|
|
|
ResetSettings();
|
|
|
|
|
2023-01-12 17:49:21 +01:00
|
|
|
#if BUILDFLAG(IS_LINUX)
|
2022-07-25 19:49:32 +02:00
|
|
|
- if (!ui::LinuxUi::instance())
|
2023-01-12 17:49:21 +01:00
|
|
|
+ if (!ui::PrintingContextLinuxDelegate::instance())
|
2022-07-25 19:49:32 +02:00
|
|
|
return mojom::ResultCode::kSuccess;
|
|
|
|
|
|
|
|
if (!print_dialog_)
|
|
|
|
- print_dialog_ = ui::LinuxUi::instance()->CreatePrintDialog(this);
|
2023-01-12 17:49:21 +01:00
|
|
|
+ print_dialog_ = ui::PrintingContextLinuxDelegate::instance()->CreatePrintDialog(this);
|
2022-07-25 19:49:32 +02:00
|
|
|
|
2023-04-04 20:00:13 +02:00
|
|
|
if (print_dialog_) {
|
|
|
|
print_dialog_->UseDefaultSettings();
|
2023-12-06 21:16:15 +01:00
|
|
|
@@ -85,8 +85,8 @@ mojom::ResultCode PrintingContextLinux::UseDefaultSettings() {
|
2022-07-21 19:26:10 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
gfx::Size PrintingContextLinux::GetPdfPaperSizeDeviceUnits() {
|
2023-01-12 17:49:21 +01:00
|
|
|
#if BUILDFLAG(IS_LINUX)
|
2022-07-25 19:49:32 +02:00
|
|
|
- if (ui::LinuxUi::instance())
|
|
|
|
- return ui::LinuxUi::instance()->GetPdfPaperSize(this);
|
2023-01-12 17:49:21 +01:00
|
|
|
+ if (ui::PrintingContextLinuxDelegate::instance())
|
|
|
|
+ return ui::PrintingContextLinuxDelegate::instance()->GetPdfPaperSize(this);
|
|
|
|
#endif
|
2022-07-25 19:49:32 +02:00
|
|
|
|
|
|
|
return gfx::Size();
|
2023-12-06 21:16:15 +01:00
|
|
|
@@ -98,11 +98,11 @@ mojom::ResultCode PrintingContextLinux::UpdatePrinterSettings(
|
2022-07-25 19:49:32 +02:00
|
|
|
DCHECK(!in_print_job_);
|
|
|
|
|
2023-01-12 17:49:21 +01:00
|
|
|
#if BUILDFLAG(IS_LINUX)
|
2022-07-25 19:49:32 +02:00
|
|
|
- if (!ui::LinuxUi::instance())
|
2023-01-12 17:49:21 +01:00
|
|
|
+ if (!ui::PrintingContextLinuxDelegate::instance())
|
2022-07-25 19:49:32 +02:00
|
|
|
return mojom::ResultCode::kSuccess;
|
|
|
|
|
|
|
|
if (!print_dialog_)
|
|
|
|
- print_dialog_ = ui::LinuxUi::instance()->CreatePrintDialog(this);
|
2023-01-12 17:49:21 +01:00
|
|
|
+ print_dialog_ = ui::PrintingContextLinuxDelegate::instance()->CreatePrintDialog(this);
|
2022-07-25 19:49:32 +02:00
|
|
|
|
2023-04-04 20:00:13 +02:00
|
|
|
if (print_dialog_) {
|
|
|
|
// PrintDialogGtk::UpdateSettings() calls InitWithSettings() so settings_ will
|
2024-08-26 14:44:25 +02:00
|
|
|
diff --git ui/linux/BUILD.gn ui/linux/BUILD.gn
|
|
|
|
index 2a9662e84fbce..a7241dc95a809 100644
|
|
|
|
--- ui/linux/BUILD.gn
|
|
|
|
+++ ui/linux/BUILD.gn
|
|
|
|
@@ -3,6 +3,7 @@
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
import("//build/config/linux/gtk/gtk.gni")
|
|
|
|
+import("//printing/buildflags/buildflags.gni")
|
|
|
|
import("//ui/qt/qt.gni")
|
|
|
|
|
|
|
|
assert(is_linux)
|
|
|
|
@@ -34,6 +35,11 @@ component("linux_ui") {
|
|
|
|
"//ui/display/types",
|
|
|
|
"//ui/gfx/geometry",
|
|
|
|
]
|
|
|
|
+
|
|
|
|
+ if (enable_printing) {
|
|
|
|
+ deps += [ "//printing/mojom" ]
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
public_deps = [ "//printing/buildflags" ]
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
diff --git ui/linux/linux_ui.cc ui/linux/linux_ui.cc
|
2024-08-26 14:44:25 +02:00
|
|
|
index 3ab395e3b0b45..c012641a5dc7e 100644
|
2022-07-25 19:49:32 +02:00
|
|
|
--- ui/linux/linux_ui.cc
|
|
|
|
+++ ui/linux/linux_ui.cc
|
2024-08-26 14:44:25 +02:00
|
|
|
@@ -23,11 +23,29 @@ namespace ui {
|
2023-01-12 17:49:21 +01:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
LinuxUi* g_linux_ui = nullptr;
|
|
|
|
+static PrintingContextLinuxDelegate* g_delegate = nullptr;
|
2022-09-26 21:30:45 +02:00
|
|
|
|
2023-01-12 17:49:21 +01:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
+// static
|
|
|
|
+PrintingContextLinuxDelegate* PrintingContextLinuxDelegate::SetInstance(
|
|
|
|
+ PrintingContextLinuxDelegate* delegate) {
|
|
|
|
+ auto old_delegate = g_delegate;
|
|
|
|
+ g_delegate = delegate;
|
|
|
|
+ return old_delegate;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// static
|
|
|
|
+PrintingContextLinuxDelegate* PrintingContextLinuxDelegate::instance() {
|
|
|
|
+ return g_delegate;
|
|
|
|
+}
|
|
|
|
+
|
2022-08-23 03:37:40 +02:00
|
|
|
// static
|
2022-09-26 21:30:45 +02:00
|
|
|
LinuxUi* LinuxUi::SetInstance(LinuxUi* instance) {
|
2022-07-25 19:49:32 +02:00
|
|
|
+#if BUILDFLAG(IS_LINUX) && BUILDFLAG(ENABLE_PRINTING)
|
2023-01-12 17:49:21 +01:00
|
|
|
+ PrintingContextLinuxDelegate::SetInstance(instance);
|
2022-07-25 19:49:32 +02:00
|
|
|
+#endif
|
2022-08-23 03:37:40 +02:00
|
|
|
+
|
2022-09-26 21:30:45 +02:00
|
|
|
return std::exchange(g_linux_ui, instance);
|
2022-07-25 19:49:32 +02:00
|
|
|
}
|
2022-08-23 03:37:40 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
diff --git ui/linux/linux_ui.h ui/linux/linux_ui.h
|
2024-07-29 19:09:20 +02:00
|
|
|
index 0a4c394b07a68..a726244ad3ea3 100644
|
2022-07-25 19:49:32 +02:00
|
|
|
--- ui/linux/linux_ui.h
|
|
|
|
+++ ui/linux/linux_ui.h
|
2024-02-22 19:36:15 +01:00
|
|
|
@@ -20,6 +20,10 @@
|
2022-08-23 03:37:40 +02:00
|
|
|
#include "printing/buildflags/buildflags.h"
|
2024-02-22 19:36:15 +01:00
|
|
|
#include "ui/display/types/display_config.h"
|
2022-07-25 19:49:32 +02:00
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_PRINTING)
|
|
|
|
+#include "printing/printing_context_linux.h" // nogncheck
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
// The main entrypoint into Linux toolkit specific code. GTK/QT code should only
|
|
|
|
// be executed behind this interface.
|
|
|
|
|
2024-02-22 19:36:15 +01:00
|
|
|
@@ -62,9 +66,27 @@ class TextEditCommandAuraLinux;
|
|
|
|
class WindowButtonOrderObserver;
|
|
|
|
class WindowFrameProvider;
|
2022-08-23 03:37:40 +02:00
|
|
|
|
2023-01-12 17:49:21 +01:00
|
|
|
+class COMPONENT_EXPORT(LINUX_UI) PrintingContextLinuxDelegate {
|
|
|
|
+ public:
|
|
|
|
+ virtual ~PrintingContextLinuxDelegate() = default;
|
|
|
|
+
|
|
|
|
+ virtual printing::PrintDialogLinuxInterface* CreatePrintDialog(
|
|
|
|
+ printing::PrintingContextLinux* context) = 0;
|
|
|
|
+
|
|
|
|
+ virtual gfx::Size GetPdfPaperSize(printing::PrintingContextLinux* context) = 0;
|
|
|
|
+
|
|
|
|
+ static PrintingContextLinuxDelegate* SetInstance(
|
|
|
|
+ PrintingContextLinuxDelegate* delegate);
|
|
|
|
+ static PrintingContextLinuxDelegate* instance();
|
|
|
|
+};
|
|
|
|
+
|
2022-07-25 19:49:32 +02:00
|
|
|
// Adapter class with targets to render like different toolkits. Set by any
|
|
|
|
// project that wants to do linux desktop native rendering.
|
2022-08-23 03:37:40 +02:00
|
|
|
-class COMPONENT_EXPORT(LINUX_UI) LinuxUi {
|
|
|
|
+class COMPONENT_EXPORT(LINUX_UI) LinuxUi
|
2022-07-25 19:49:32 +02:00
|
|
|
+#if BUILDFLAG(ENABLE_PRINTING)
|
2023-01-12 17:49:21 +01:00
|
|
|
+ : public PrintingContextLinuxDelegate
|
2022-07-25 19:49:32 +02:00
|
|
|
+#endif
|
2022-08-23 03:37:40 +02:00
|
|
|
+ {
|
2022-07-25 19:49:32 +02:00
|
|
|
public:
|
2022-11-15 18:50:53 +01:00
|
|
|
// Describes the window management actions that could be taken in response to
|
|
|
|
// a middle click in the non client area.
|
2024-02-22 19:36:15 +01:00
|
|
|
@@ -150,14 +172,6 @@ class COMPONENT_EXPORT(LINUX_UI) LinuxUi {
|
2022-07-25 19:49:32 +02:00
|
|
|
// Returns a map of KeyboardEvent code to KeyboardEvent key values.
|
|
|
|
virtual base::flat_map<std::string, std::string> GetKeyboardLayoutMap() = 0;
|
|
|
|
|
|
|
|
-#if BUILDFLAG(ENABLE_PRINTING)
|
|
|
|
- virtual printing::PrintDialogLinuxInterface* CreatePrintDialog(
|
|
|
|
- printing::PrintingContextLinux* context) = 0;
|
|
|
|
-
|
|
|
|
- virtual gfx::Size GetPdfPaperSize(
|
|
|
|
- printing::PrintingContextLinux* context) = 0;
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
// Returns a native file selection dialog. `listener` is of type
|
|
|
|
// SelectFileDialog::Listener. TODO(thomasanderson): Move
|
|
|
|
// SelectFileDialog::Listener to SelectFileDialogListener so that it can be
|