Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Unified Diff: chrome/browser/ui/gtk/extensions/native_app_window_gtk.cc

Issue 18741006: [GTK] Report isMinimized and correctly restore app windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ignore PlatformAppBrowserTest.WindowsApiProperties. It can pass in local. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/gtk/extensions/native_app_window_gtk.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/extensions/native_app_window_gtk.cc
diff --git a/chrome/browser/ui/gtk/extensions/native_app_window_gtk.cc b/chrome/browser/ui/gtk/extensions/native_app_window_gtk.cc
index e96e322bcb66b627003f07e7302ff2aa96be3260..1537cc89f123620adf6e9459ab0eaf7f2f906e26 100644
--- a/chrome/browser/ui/gtk/extensions/native_app_window_gtk.cc
+++ b/chrome/browser/ui/gtk/extensions/native_app_window_gtk.cc
@@ -4,6 +4,10 @@
#include "chrome/browser/ui/gtk/extensions/native_app_window_gtk.h"
+#include <gdk/gdkx.h>
+#include <vector>
+
+#include "base/message_loop/message_pump_gtk.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h"
@@ -28,6 +32,12 @@ namespace {
// gtk_window_get_position() after the last GTK configure-event signal.
const int kDebounceTimeoutMilliseconds = 100;
+const char* kAtomsToCache[] = {
+ "_NET_WM_STATE",
+ "_NET_WM_STATE_HIDDEN",
+ NULL
+};
+
} // namespace
NativeAppWindowGtk::NativeAppWindowGtk(ShellWindow* shell_window,
@@ -38,7 +48,8 @@ NativeAppWindowGtk::NativeAppWindowGtk(ShellWindow* shell_window,
is_active_(false),
content_thinks_its_fullscreen_(false),
frameless_(params.frame == ShellWindow::FRAME_NONE),
- frame_cursor_(NULL) {
+ frame_cursor_(NULL),
+ atom_cache_(base::MessagePumpGtk::GetDefaultXDisplay(), kAtomsToCache) {
window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
gfx::NativeView native_view =
@@ -127,6 +138,10 @@ NativeAppWindowGtk::NativeAppWindowGtk(ShellWindow* shell_window,
g_signal_connect(window_, "motion-notify-event",
G_CALLBACK(OnMouseMoveEventThunk), this);
}
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(window_));
+ gdk_window_add_filter(window,
+ &NativeAppWindowGtk::OnXEventThunk,
+ this);
// Add the keybinding registry.
extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryGtk(
@@ -140,6 +155,9 @@ NativeAppWindowGtk::NativeAppWindowGtk(ShellWindow* shell_window,
NativeAppWindowGtk::~NativeAppWindowGtk() {
ui::ActiveWindowWatcherX::RemoveObserver(this);
+ gdk_window_remove_filter(NULL,
+ &NativeAppWindowGtk::OnXEventThunk,
+ this);
}
bool NativeAppWindowGtk::IsActive() const {
@@ -224,6 +242,10 @@ void NativeAppWindowGtk::Deactivate() {
}
void NativeAppWindowGtk::Maximize() {
+ // Represent the window first in order to keep the maximization behavior
+ // consistency with Windows platform. Otherwise the window will be hidden if
+ // it has been minimized.
+ gtk_window_present(window_);
gtk_window_maximize(window_);
}
@@ -236,6 +258,12 @@ void NativeAppWindowGtk::Restore() {
gtk_window_unmaximize(window_);
else if (IsMinimized())
gtk_window_deiconify(window_);
+
+ // Represent the window to keep restoration behavior consistency with Windows
+ // platform.
+ // TODO(zhchbin): verify whether we need this until http://crbug.com/261013 is
+ // fixed.
+ gtk_window_present(window_);
Daniel Erat 2013/07/18 20:18:39 i don't understand this call. http://crbug.com/261
zhchbin 2013/07/19 02:12:29 From our API docs, "Restore" means: "Restore the w
}
void NativeAppWindowGtk::SetBounds(const gfx::Rect& bounds) {
@@ -257,6 +285,36 @@ void NativeAppWindowGtk::SetBounds(const gfx::Rect& bounds) {
}
}
+GdkFilterReturn NativeAppWindowGtk::OnXEvent(GdkXEvent* gdk_x_event,
+ GdkEvent* gdk_event) {
+ // Work around for gtk+ not reporting minimize state changes, by listening for
+ // property notify events for state and checking to see if the state includes
+ // hidden. Then from that setting or clearing the iconified bit.
Daniel Erat 2013/07/18 20:18:39 nit: reword this as: Work around GTK+ not repor
zhchbin 2013/07/19 02:12:29 Done.
+ // http://crbug.com/162794.
+ XEvent* x_event = static_cast<XEvent*>(gdk_x_event);
+ std::vector< ::Atom> atom_list;
+
+ if (x_event->type == PropertyNotify &&
+ x_event->xproperty.atom == atom_cache_.GetAtom("_NET_WM_STATE") &&
+ ui::GetAtomArrayProperty(GDK_WINDOW_XWINDOW(GTK_WIDGET(window_)->window),
+ "_NET_WM_STATE",
+ &atom_list)) {
+ std::vector< ::Atom>::iterator it =
+ std::find(atom_list.begin(),
+ atom_list.end(),
+ atom_cache_.GetAtom("_NET_WM_STATE_HIDDEN"));
+ if (it != atom_list.end())
Evan Stade 2013/07/18 18:08:26 I prefer use of the ternary operator here. If no t
Daniel Erat 2013/07/18 20:18:39 agreed
zhchbin 2013/07/19 02:12:29 Done.
+ state_ = GDK_WINDOW_STATE_ICONIFIED;
+ else
+ state_ =
+ static_cast<GdkWindowState>(state_ & ~GDK_WINDOW_STATE_ICONIFIED);
+
+ shell_window_->OnNativeWindowChanged();
+ }
+
+ return GDK_FILTER_CONTINUE;
+}
+
void NativeAppWindowGtk::FlashFrame(bool flash) {
gtk_window_set_urgency_hint(window_, flash);
}
« no previous file with comments | « chrome/browser/ui/gtk/extensions/native_app_window_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698