2022-07-21 19:26:10 +02:00
|
|
|
diff --git printing/printing_context_linux.cc printing/printing_context_linux.cc
|
2023-04-26 21:55:59 +02:00
|
|
|
index 4f219a5df0089..31f751068080a 100644
|
2022-07-21 19:26:10 +02:00
|
|
|
--- printing/printing_context_linux.cc
|
|
|
|
+++ printing/printing_context_linux.cc
|
2023-01-12 17:49:21 +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();
|
|
|
|
@@ -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-04-04 20:00:13 +02: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
|
2023-01-12 17:49:21 +01:00
|
|
|
index 29db798e8b171..f8b9546b90321 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
|
2023-08-09 23:17:17 +02:00
|
|
|
index a47134d7fa672..4fef62bbec3ee 100644
|
2022-07-25 19:49:32 +02:00
|
|
|
--- ui/linux/linux_ui.h
|
|
|
|
+++ ui/linux/linux_ui.h
|
2023-08-09 23:17:17 +02:00
|
|
|
@@ -19,6 +19,10 @@
|
2022-08-23 03:37:40 +02:00
|
|
|
#include "printing/buildflags/buildflags.h"
|
2023-08-09 23:17:17 +02:00
|
|
|
#include "ui/gfx/geometry/rect.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.
|
|
|
|
|
2023-08-09 23:17:17 +02:00
|
|
|
@@ -92,9 +96,27 @@ inline DisplayConfig::DisplayConfig(DisplayConfig&& other) = default;
|
|
|
|
inline DisplayConfig& DisplayConfig::operator=(DisplayConfig&& other) = default;
|
|
|
|
inline DisplayConfig::~DisplayConfig() = default;
|
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.
|
2023-08-09 23:17:17 +02:00
|
|
|
@@ -161,14 +183,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
|