summaryrefslogtreecommitdiff
path: root/chromium/ui/gtk
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-29 10:46:47 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-11-02 12:02:10 +0000
commit99677208ff3b216fdfec551fbe548da5520cd6fb (patch)
tree476a4865c10320249360e859d8fdd3e01833b03a /chromium/ui/gtk
parentc30a6232df03e1efbd9f3b226777b07e087a1122 (diff)
downloadqtwebengine-chromium-99677208ff3b216fdfec551fbe548da5520cd6fb.tar.gz
BASELINE: Update Chromium to 86.0.4240.124
Change-Id: Ide0ff151e94cd665ae6521a446995d34a9d1d644 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/ui/gtk')
-rw-r--r--chromium/ui/gtk/BUILD.gn5
-rw-r--r--chromium/ui/gtk/gtk_ui.cc8
-rw-r--r--chromium/ui/gtk/gtk_ui_delegate.h1
-rw-r--r--chromium/ui/gtk/gtk_util.cc4
-rw-r--r--chromium/ui/gtk/gtk_util.h2
-rw-r--r--chromium/ui/gtk/printing/print_dialog_gtk.cc10
-rw-r--r--chromium/ui/gtk/select_file_dialog_impl.cc10
-rw-r--r--chromium/ui/gtk/select_file_dialog_impl.h5
-rw-r--r--chromium/ui/gtk/select_file_dialog_impl_gtk.cc3
-rw-r--r--chromium/ui/gtk/select_file_dialog_impl_kde.cc114
-rw-r--r--chromium/ui/gtk/x/BUILD.gn1
-rw-r--r--chromium/ui/gtk/x/DEPS3
-rw-r--r--chromium/ui/gtk/x/gtk_event_loop_x11.cc1
-rw-r--r--chromium/ui/gtk/x/gtk_ui_delegate_x11.cc39
-rw-r--r--chromium/ui/gtk/x/gtk_ui_delegate_x11.h7
15 files changed, 156 insertions, 57 deletions
diff --git a/chromium/ui/gtk/BUILD.gn b/chromium/ui/gtk/BUILD.gn
index 02e12b9db88..3759400373b 100644
--- a/chromium/ui/gtk/BUILD.gn
+++ b/chromium/ui/gtk/BUILD.gn
@@ -2,10 +2,9 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-assert(is_linux, "This file should only be referenced on Linux")
+assert(is_linux || is_chromeos, "This file should only be referenced on Linux")
import("//build/config/features.gni")
-import("//build/config/jumbo.gni")
import("//build/config/linux/gtk/gtk.gni")
import("//build/config/ui.gni")
import("//printing/buildflags/buildflags.gni")
@@ -21,7 +20,7 @@ component("gtk_ui_delegate") {
defines = [ "IS_GTK_IMPL" ]
}
-jumbo_component("gtk") {
+component("gtk") {
public = [ "gtk_ui.h" ]
sources = [
"gtk_key_bindings_handler.cc",
diff --git a/chromium/ui/gtk/gtk_ui.cc b/chromium/ui/gtk/gtk_ui.cc
index 69d7afecc3a..9905c4f0b35 100644
--- a/chromium/ui/gtk/gtk_ui.cc
+++ b/chromium/ui/gtk/gtk_ui.cc
@@ -70,6 +70,7 @@
#if defined(USE_OZONE)
#include "ui/base/ime/input_method.h"
+#include "ui/base/ui_base_features.h"
#include "ui/ozone/public/ozone_platform.h"
#endif
@@ -404,10 +405,11 @@ void GtkUi::Initialize() {
// instance instead of using GtkUi context factory. This step is made upon
// CreateInputMethod call. If the factory is not set, use the GtkUi context
// factory.
- if (!ui::OzonePlatform::GetInstance()->CreateInputMethod(
+ if (!features::IsUsingOzonePlatform() ||
+ !ui::OzonePlatform::GetInstance()->CreateInputMethod(
nullptr, gfx::kNullAcceleratedWidget)) {
- DCHECK(!ui::LinuxInputMethodContextFactory::instance());
- ui::LinuxInputMethodContextFactory::SetInstance(this);
+ if (!ui::LinuxInputMethodContextFactory::instance())
+ ui::LinuxInputMethodContextFactory::SetInstance(this);
}
#endif
diff --git a/chromium/ui/gtk/gtk_ui_delegate.h b/chromium/ui/gtk/gtk_ui_delegate.h
index 22ae1ce976e..9daed0a8f46 100644
--- a/chromium/ui/gtk/gtk_ui_delegate.h
+++ b/chromium/ui/gtk/gtk_ui_delegate.h
@@ -50,6 +50,7 @@ class COMPONENT_EXPORT(GTK) GtkUiDelegate {
// function abstracts away such functionality.
virtual bool SetGdkWindowTransientFor(GdkWindow* window,
gfx::AcceleratedWidget parent) = 0;
+ virtual void ClearTransientFor(gfx::AcceleratedWidget parent) = 0;
// Presents |window|, doing all the necessary platform-specific operations
// needed, if any.
diff --git a/chromium/ui/gtk/gtk_util.cc b/chromium/ui/gtk/gtk_util.cc
index 5a8d3a8e33a..6cd7e64be6c 100644
--- a/chromium/ui/gtk/gtk_util.cc
+++ b/chromium/ui/gtk/gtk_util.cc
@@ -156,8 +156,10 @@ aura::Window* GetAuraTransientParent(GtkWidget* dialog) {
g_object_get_data(G_OBJECT(dialog), kAuraTransientParent));
}
-void ClearAuraTransientParent(GtkWidget* dialog) {
+void ClearAuraTransientParent(GtkWidget* dialog, aura::Window* parent) {
g_object_set_data(G_OBJECT(dialog), kAuraTransientParent, nullptr);
+ GtkUi::GetDelegate()->ClearTransientFor(
+ parent->GetHost()->GetAcceleratedWidget());
}
void ParseButtonLayout(const std::string& button_string,
diff --git a/chromium/ui/gtk/gtk_util.h b/chromium/ui/gtk/gtk_util.h
index 1104755bdf7..1512a55ed7b 100644
--- a/chromium/ui/gtk/gtk_util.h
+++ b/chromium/ui/gtk/gtk_util.h
@@ -48,7 +48,7 @@ void SetGtkTransientForAura(GtkWidget* dialog, aura::Window* parent);
aura::Window* GetAuraTransientParent(GtkWidget* dialog);
// Clears the transient parent for |dialog|.
-void ClearAuraTransientParent(GtkWidget* dialog);
+void ClearAuraTransientParent(GtkWidget* dialog, aura::Window* parent);
// Parses |button_string| into |leading_buttons| and
// |trailing_buttons|. The string is of the format
diff --git a/chromium/ui/gtk/printing/print_dialog_gtk.cc b/chromium/ui/gtk/printing/print_dialog_gtk.cc
index 57900d2854d..de7cfff0801 100644
--- a/chromium/ui/gtk/printing/print_dialog_gtk.cc
+++ b/chromium/ui/gtk/printing/print_dialog_gtk.cc
@@ -190,7 +190,7 @@ PrintDialogGtk::~PrintDialogGtk() {
aura::Window* parent = gtk::GetAuraTransientParent(dialog_);
if (parent) {
parent->RemoveObserver(this);
- gtk::ClearAuraTransientParent(dialog_);
+ gtk::ClearAuraTransientParent(dialog_, parent);
}
gtk_widget_destroy(dialog_);
dialog_ = nullptr;
@@ -254,8 +254,8 @@ void PrintDialogGtk::UpdateSettings(
std::string color_value;
std::string color_setting_name;
- printing::GetColorModelForMode(settings->color(), &color_setting_name,
- &color_value);
+ printing::GetColorModelForMode(static_cast<int>(settings->color()),
+ &color_setting_name, &color_value);
gtk_print_settings_set(gtk_settings_, color_setting_name.c_str(),
color_value.c_str());
@@ -389,7 +389,7 @@ void PrintDialogGtk::PrintDocument(const printing::MetafilePlayer& metafile,
success = metafile.SaveTo(&file);
file.Close();
if (!success)
- base::DeleteFile(path_to_pdf_, false);
+ base::DeleteFile(path_to_pdf_);
}
if (!success) {
@@ -544,7 +544,7 @@ void PrintDialogGtk::InitPrintSettings(
void PrintDialogGtk::OnWindowDestroying(aura::Window* window) {
DCHECK_EQ(gtk::GetAuraTransientParent(dialog_), window);
- gtk::ClearAuraTransientParent(dialog_);
+ gtk::ClearAuraTransientParent(dialog_, window);
window->RemoveObserver(this);
if (callback_)
std::move(callback_).Run(PrintingContextLinux::CANCEL);
diff --git a/chromium/ui/gtk/select_file_dialog_impl.cc b/chromium/ui/gtk/select_file_dialog_impl.cc
index b20a1a58948..8dfc91f918e 100644
--- a/chromium/ui/gtk/select_file_dialog_impl.cc
+++ b/chromium/ui/gtk/select_file_dialog_impl.cc
@@ -9,6 +9,7 @@
#include "base/environment.h"
#include "base/files/file_util.h"
#include "base/nix/xdg_util.h"
+#include "base/no_destructor.h"
#include "base/threading/thread_restrictions.h"
namespace {
@@ -16,6 +17,10 @@ namespace {
enum UseKdeFileDialogStatus { UNKNOWN, NO_KDE, YES_KDE };
UseKdeFileDialogStatus use_kde_ = UNKNOWN;
+std::string& KDialogVersion() {
+ static base::NoDestructor<std::string> version;
+ return *version;
+}
} // namespace
@@ -42,7 +47,8 @@ ui::SelectFileDialog* SelectFileDialogImpl::Create(
// Check to see if the user dislikes the KDE file dialog.
if (!env->HasVar("NO_CHROME_KDE_FILE_DIALOG")) {
// Check to see if the KDE dialog works.
- if (SelectFileDialogImpl::CheckKDEDialogWorksOnUIThread()) {
+ if (SelectFileDialogImpl::CheckKDEDialogWorksOnUIThread(
+ KDialogVersion())) {
use_kde_ = YES_KDE;
}
}
@@ -58,7 +64,7 @@ ui::SelectFileDialog* SelectFileDialogImpl::Create(
base::nix::DesktopEnvironment desktop =
base::nix::GetDesktopEnvironment(env.get());
return SelectFileDialogImpl::NewSelectFileDialogImplKDE(
- listener, std::move(policy), desktop);
+ listener, std::move(policy), desktop, KDialogVersion());
}
SelectFileDialogImpl::SelectFileDialogImpl(
diff --git a/chromium/ui/gtk/select_file_dialog_impl.h b/chromium/ui/gtk/select_file_dialog_impl.h
index 64a82ff5023..3cb8ee5d6a9 100644
--- a/chromium/ui/gtk/select_file_dialog_impl.h
+++ b/chromium/ui/gtk/select_file_dialog_impl.h
@@ -37,11 +37,12 @@ class SelectFileDialogImpl : public ui::SelectFileDialog {
static SelectFileDialogImpl* NewSelectFileDialogImplKDE(
Listener* listener,
std::unique_ptr<ui::SelectFilePolicy> policy,
- base::nix::DesktopEnvironment desktop);
+ base::nix::DesktopEnvironment desktop,
+ const std::string& kdialog_version);
// Returns true if the SelectFileDialog class returned by
// NewSelectFileDialogImplKDE will actually work.
- static bool CheckKDEDialogWorksOnUIThread();
+ static bool CheckKDEDialogWorksOnUIThread(std::string& kdialog_version);
// BaseShellDialog implementation.
void ListenerDestroyed() override;
diff --git a/chromium/ui/gtk/select_file_dialog_impl_gtk.cc b/chromium/ui/gtk/select_file_dialog_impl_gtk.cc
index 9d58610dfee..f810e48d364 100644
--- a/chromium/ui/gtk/select_file_dialog_impl_gtk.cc
+++ b/chromium/ui/gtk/select_file_dialog_impl_gtk.cc
@@ -117,7 +117,7 @@ void SelectFileDialogImplGTK::OnWindowDestroying(aura::Window* window) {
it != dialogs_.end(); ++it) {
aura::Window* parent = GetAuraTransientParent(*it);
if (parent == window)
- ClearAuraTransientParent(*it);
+ ClearAuraTransientParent(*it, parent);
}
std::set<aura::Window*>::iterator iter = parents_.find(window);
@@ -548,6 +548,7 @@ void SelectFileDialogImplGTK::OnFileChooserDestroy(GtkWidget* dialog) {
aura::Window* parent = GetAuraTransientParent(dialog);
if (!parent)
return;
+ ClearAuraTransientParent(dialog, parent);
std::set<aura::Window*>::iterator iter = parents_.find(parent);
if (iter != parents_.end()) {
(*iter)->RemoveObserver(this);
diff --git a/chromium/ui/gtk/select_file_dialog_impl_kde.cc b/chromium/ui/gtk/select_file_dialog_impl_kde.cc
index 4eba97d573d..464aa72e1d4 100644
--- a/chromium/ui/gtk/select_file_dialog_impl_kde.cc
+++ b/chromium/ui/gtk/select_file_dialog_impl_kde.cc
@@ -25,6 +25,7 @@
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/threading/thread_restrictions.h"
+#include "base/version.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/x/x11.h"
@@ -49,7 +50,8 @@ class SelectFileDialogImplKDE : public SelectFileDialogImpl {
public:
SelectFileDialogImplKDE(Listener* listener,
std::unique_ptr<ui::SelectFilePolicy> policy,
- base::nix::DesktopEnvironment desktop);
+ base::nix::DesktopEnvironment desktop,
+ const std::string& kdialog_version);
protected:
~SelectFileDialogImplKDE() override;
@@ -174,6 +176,11 @@ class SelectFileDialogImplKDE : public SelectFileDialogImpl {
// dialogs. This should only be accessed on the UI thread.
std::set<gfx::AcceleratedWidget> parents_;
+ // Set to true if the kdialog version is new enough to support passing
+ // multiple extensions with descriptions, eliminating the need for the lossy
+ // conversion of extensions to mime-types.
+ bool kdialog_supports_multiple_extensions_ = false;
+
// A task runner for blocking pipe reads.
scoped_refptr<base::SequencedTaskRunner> pipe_task_runner_;
@@ -183,7 +190,8 @@ class SelectFileDialogImplKDE : public SelectFileDialogImpl {
};
// static
-bool SelectFileDialogImpl::CheckKDEDialogWorksOnUIThread() {
+bool SelectFileDialogImpl::CheckKDEDialogWorksOnUIThread(
+ std::string& kdialog_version) {
// No choice. UI thread can't continue without an answer here. Fortunately we
// only do this once, the first time a file dialog is displayed.
base::ThreadRestrictions::ScopedAllowIO allow_io;
@@ -192,22 +200,24 @@ bool SelectFileDialogImpl::CheckKDEDialogWorksOnUIThread() {
cmd_vector.push_back(kKdialogBinary);
cmd_vector.push_back("--version");
base::CommandLine command_line(cmd_vector);
- std::string dummy;
- return base::GetAppOutput(command_line, &dummy);
+ return base::GetAppOutput(command_line, &kdialog_version);
}
// static
SelectFileDialogImpl* SelectFileDialogImpl::NewSelectFileDialogImplKDE(
Listener* listener,
std::unique_ptr<ui::SelectFilePolicy> policy,
- base::nix::DesktopEnvironment desktop) {
- return new SelectFileDialogImplKDE(listener, std::move(policy), desktop);
+ base::nix::DesktopEnvironment desktop,
+ const std::string& kdialog_version) {
+ return new SelectFileDialogImplKDE(listener, std::move(policy), desktop,
+ kdialog_version);
}
SelectFileDialogImplKDE::SelectFileDialogImplKDE(
Listener* listener,
std::unique_ptr<ui::SelectFilePolicy> policy,
- base::nix::DesktopEnvironment desktop)
+ base::nix::DesktopEnvironment desktop,
+ const std::string& kdialog_version)
: SelectFileDialogImpl(listener, std::move(policy)),
desktop_(desktop),
pipe_task_runner_(base::ThreadPool::CreateSequencedTaskRunner(
@@ -216,6 +226,19 @@ SelectFileDialogImplKDE::SelectFileDialogImplKDE(
DCHECK(desktop_ == base::nix::DESKTOP_ENVIRONMENT_KDE3 ||
desktop_ == base::nix::DESKTOP_ENVIRONMENT_KDE4 ||
desktop_ == base::nix::DESKTOP_ENVIRONMENT_KDE5);
+ // |kdialog_version| should be of the form "kdialog 1.2.3", so split on
+ // whitespace and then try to parse a version from the second piece. If
+ // parsing fails for whatever reason, we fall back to the behavior that works
+ // with all currently known versions of kdialog.
+ std::vector<base::StringPiece> version_pieces = base::SplitStringPiece(
+ kdialog_version, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
+ if (version_pieces.size() >= 2) {
+ base::Version parsed_version(version_pieces[1]);
+ if (parsed_version.IsValid()) {
+ kdialog_supports_multiple_extensions_ =
+ parsed_version >= base::Version("19.12");
+ }
+ }
}
SelectFileDialogImplKDE::~SelectFileDialogImplKDE() = default;
@@ -288,27 +311,70 @@ bool SelectFileDialogImplKDE::HasMultipleFileTypeChoicesImpl() {
std::string SelectFileDialogImplKDE::GetMimeTypeFilterString() {
DCHECK(pipe_task_runner_->RunsTasksInCurrentSequence());
- // We need a filter set because the same mime type can appear multiple times.
- std::set<std::string> filter_set;
- for (auto& extensions : file_types_.extensions) {
- for (auto& extension : extensions) {
- if (!extension.empty()) {
- std::string mime_type = base::nix::GetFileMimeType(
- base::FilePath("name").ReplaceExtension(extension));
- filter_set.insert(mime_type);
+
+ if (!kdialog_supports_multiple_extensions_) {
+ // We need a filter set because the same mime type can appear multiple
+ // times.
+ std::set<std::string> filter_set;
+ for (auto& extensions : file_types_.extensions) {
+ for (auto& extension : extensions) {
+ if (!extension.empty()) {
+ std::string mime_type = base::nix::GetFileMimeType(
+ base::FilePath("name").ReplaceExtension(extension));
+ filter_set.insert(mime_type);
+ }
}
}
+ std::vector<std::string> filter_vector(filter_set.cbegin(),
+ filter_set.cend());
+ // Add the *.* filter, but only if we have added other filters (otherwise it
+ // is implied). It needs to be added last to avoid being picked as the
+ // default filter.
+ if (file_types_.include_all_files && !file_types_.extensions.empty()) {
+ DCHECK(filter_set.find("application/octet-stream") == filter_set.end());
+ filter_vector.push_back("application/octet-stream");
+ }
+ return base::JoinString(filter_vector, " ");
}
- std::vector<std::string> filter_vector(filter_set.cbegin(),
- filter_set.cend());
- // Add the *.* filter, but only if we have added other filters (otherwise it
- // is implied). It needs to be added last to avoid being picked as the default
- // filter.
- if (file_types_.include_all_files && !file_types_.extensions.empty()) {
- DCHECK(filter_set.find("application/octet-stream") == filter_set.end());
- filter_vector.push_back("application/octet-stream");
+
+ std::vector<std::string> filters;
+ for (size_t i = 0; i < file_types_.extensions.size(); ++i) {
+ std::set<std::string> extension_filters;
+ for (const auto& extension : file_types_.extensions[i]) {
+ if (extension.empty())
+ continue;
+ extension_filters.insert(std::string("*.") + extension);
+ }
+
+ // We didn't find any non-empty extensions to filter on.
+ if (extension_filters.empty())
+ continue;
+
+ std::vector<std::string> extension_filters_vector(extension_filters.begin(),
+ extension_filters.end());
+
+ std::string description;
+ // The description vector may be blank, in which case we are supposed to
+ // use some sort of default description based on the filter.
+ if (i < file_types_.extension_description_overrides.size()) {
+ description =
+ base::UTF16ToUTF8(file_types_.extension_description_overrides[i]);
+ // Filter out any characters that would mess up kdialog's parsing.
+ base::ReplaceChars(description, "|()", "", &description);
+ } else {
+ // There is no system default filter description so we use
+ // the extensions themselves if the description is blank.
+ description = base::JoinString(extension_filters_vector, ",");
+ }
+
+ filters.push_back(description + " (" +
+ base::JoinString(extension_filters_vector, " ") + ")");
}
- return base::JoinString(filter_vector, " ");
+
+ if (file_types_.include_all_files && !file_types_.extensions.empty())
+ filters.push_back(l10n_util::GetStringUTF8(IDS_SAVEAS_ALL_FILES) + " (*)");
+
+ return base::JoinString(filters, "|");
}
std::unique_ptr<SelectFileDialogImplKDE::KDialogOutputParams>
diff --git a/chromium/ui/gtk/x/BUILD.gn b/chromium/ui/gtk/x/BUILD.gn
index 9cdf6607336..f773ee3ced9 100644
--- a/chromium/ui/gtk/x/BUILD.gn
+++ b/chromium/ui/gtk/x/BUILD.gn
@@ -21,6 +21,7 @@ component("x") {
"//ui/base",
"//ui/events/platform/x11",
"//ui/gfx/x",
+ "//ui/platform_window/x11",
]
public_deps = [ "//ui/gtk:gtk_ui_delegate" ]
defines = [ "IS_UI_GTK_X_IMPL" ]
diff --git a/chromium/ui/gtk/x/DEPS b/chromium/ui/gtk/x/DEPS
new file mode 100644
index 00000000000..098786a5764
--- /dev/null
+++ b/chromium/ui/gtk/x/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+ui/platform_window/x11",
+]
diff --git a/chromium/ui/gtk/x/gtk_event_loop_x11.cc b/chromium/ui/gtk/x/gtk_event_loop_x11.cc
index abda48cbf04..efec73ec9ce 100644
--- a/chromium/ui/gtk/x/gtk_event_loop_x11.cc
+++ b/chromium/ui/gtk/x/gtk_event_loop_x11.cc
@@ -96,7 +96,6 @@ void GtkEventLoopX11::ProcessGdkEventKey(const GdkEventKey& gdk_event_key) {
// XProto.
int state =
BuildXkbStateFromGdkEvent(gdk_event_key.state, gdk_event_key.group);
- event.xlib_event().xkey.state = state;
event.As<x11::KeyEvent>()->state = static_cast<x11::KeyButMask>(state);
// We want to process the gtk event; mapped to an X11 event immediately
diff --git a/chromium/ui/gtk/x/gtk_ui_delegate_x11.cc b/chromium/ui/gtk/x/gtk_ui_delegate_x11.cc
index 8ae0f44fe54..16a3ae2e7ae 100644
--- a/chromium/ui/gtk/x/gtk_ui_delegate_x11.cc
+++ b/chromium/ui/gtk/x/gtk_ui_delegate_x11.cc
@@ -8,15 +8,19 @@
#include <gtk/gtk.h>
#include "base/check.h"
+#include "ui/base/x/x11_util.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/native_widget_types.h"
-#include "ui/gfx/x/x11.h"
+#include "ui/gfx/x/xproto.h"
#include "ui/gtk/x/gtk_event_loop_x11.h"
+#include "ui/platform_window/x11/x11_window.h"
+#include "ui/platform_window/x11/x11_window_manager.h"
namespace ui {
-GtkUiDelegateX11::GtkUiDelegateX11(XDisplay* display) : xdisplay_(display) {
- DCHECK(xdisplay_);
+GtkUiDelegateX11::GtkUiDelegateX11(x11::Connection* connection)
+ : connection_(connection) {
+ DCHECK(connection_);
gdk_set_allowed_backends("x11");
}
@@ -45,16 +49,28 @@ GdkWindow* GtkUiDelegateX11::GetGdkWindow(gfx::AcceleratedWidget window_id) {
bool GtkUiDelegateX11::SetGdkWindowTransientFor(GdkWindow* window,
gfx::AcceleratedWidget parent) {
- XSetTransientForHint(xdisplay_, GDK_WINDOW_XID(window),
- static_cast<uint32_t>(parent));
+ SetProperty(static_cast<x11::Window>(GDK_WINDOW_XID(window)),
+ x11::Atom::WM_TRANSIENT_FOR, x11::Atom::WINDOW, parent);
+
+ ui::X11Window* parent_window =
+ ui::X11WindowManager::GetInstance()->GetWindow(parent);
+ parent_window->SetTransientWindow(
+ static_cast<x11::Window>(gdk_x11_window_get_xid(window)));
+
return true;
}
+void GtkUiDelegateX11::ClearTransientFor(gfx::AcceleratedWidget parent) {
+ ui::X11Window* parent_window =
+ ui::X11WindowManager::GetInstance()->GetWindow(parent);
+ // parent_window might be dead if there was a top-down window close
+ if (parent_window)
+ parent_window->SetTransientWindow(x11::Window::None);
+}
+
GdkDisplay* GtkUiDelegateX11::GetGdkDisplay() {
- if (!display_) {
- GdkDisplay* display = gdk_x11_lookup_xdisplay(xdisplay_);
- display_ = !display ? gdk_display_get_default() : display;
- }
+ if (!display_)
+ display_ = gdk_display_get_default();
return display_;
}
@@ -62,8 +78,9 @@ void GtkUiDelegateX11::ShowGtkWindow(GtkWindow* window) {
// We need to call gtk_window_present after making the widgets visible to make
// sure window gets correctly raised and gets focus.
DCHECK(X11EventSource::HasInstance());
- gtk_window_present_with_time(window,
- X11EventSource::GetInstance()->GetTimestamp());
+ gtk_window_present_with_time(
+ window,
+ static_cast<uint32_t>(X11EventSource::GetInstance()->GetTimestamp()));
}
} // namespace ui
diff --git a/chromium/ui/gtk/x/gtk_ui_delegate_x11.h b/chromium/ui/gtk/x/gtk_ui_delegate_x11.h
index e1f252df708..730af74ed73 100644
--- a/chromium/ui/gtk/x/gtk_ui_delegate_x11.h
+++ b/chromium/ui/gtk/x/gtk_ui_delegate_x11.h
@@ -7,7 +7,7 @@
#include "base/component_export.h"
#include "ui/gfx/native_widget_types.h"
-#include "ui/gfx/x/x11_types.h"
+#include "ui/gfx/x/connection.h"
#include "ui/gtk/gtk_ui_delegate.h"
using GdkDisplay = struct _GdkDisplay;
@@ -21,7 +21,7 @@ namespace ui {
// Ozone is completed.
class COMPONENT_EXPORT(UI_GTK_X) GtkUiDelegateX11 : public GtkUiDelegate {
public:
- explicit GtkUiDelegateX11(XDisplay* display);
+ explicit GtkUiDelegateX11(x11::Connection* connection);
GtkUiDelegateX11(const GtkUiDelegateX11&) = delete;
GtkUiDelegateX11& operator=(const GtkUiDelegateX11&) = delete;
~GtkUiDelegateX11() override;
@@ -32,12 +32,13 @@ class COMPONENT_EXPORT(UI_GTK_X) GtkUiDelegateX11 : public GtkUiDelegate {
GdkWindow* GetGdkWindow(gfx::AcceleratedWidget window_id) override;
bool SetGdkWindowTransientFor(GdkWindow* window,
gfx::AcceleratedWidget parent) override;
+ void ClearTransientFor(gfx::AcceleratedWidget parent) override;
void ShowGtkWindow(GtkWindow* window) override;
private:
GdkDisplay* GetGdkDisplay();
- XDisplay* const xdisplay_;
+ x11::Connection* const connection_;
GdkDisplay* display_ = nullptr;
};