2022-07-21 19:26:10 +02:00
|
|
|
diff --git printing/printing_context_linux.cc printing/printing_context_linux.cc
|
2024-05-23 03:52:35 +02:00
|
|
|
index 03302777935ba..4e53392605c37 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
|
2022-07-25 19:49:32 +02:00
|
|
|
diff --git ui/linux/linux_ui.cc ui/linux/linux_ui.cc
|
2024-02-22 19:36:15 +01:00
|
|
|
index 3408b6200d17a..5d91e65a2b40f 100644
|
2022-07-25 19:49:32 +02:00
|
|
|
--- ui/linux/linux_ui.cc
|
|
|
|
+++ ui/linux/linux_ui.cc
|
2023-01-12 17:49:21 +01:00
|
|
|
@@ -18,11 +18,29 @@ namespace ui {
|
|
|
|
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-02-22 19:36:15 +01:00
|
|
|
index b940382678ba7..c2fa9b7303e87 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
|