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

Unified Diff: content/browser/renderer_host/render_widget_host_view_gtk.cc

Issue 10542134: Rely on losing focus, not on becoming unfullscreened, to destroy a fullscreen window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits Created 8 years, 6 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 | « content/browser/renderer_host/render_widget_host_view_gtk.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_gtk.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.cc b/content/browser/renderer_host/render_widget_host_view_gtk.cc
index c6999c26f79c112fe8d29e036bd98b4c31dcca4c..859ecfff17ea5bb4d366b45081aa981ea3e2414a 100644
--- a/content/browser/renderer_host/render_widget_host_view_gtk.cc
+++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc
@@ -43,6 +43,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/x11/WebScreenInfoFactory.h"
#include "ui/base/gtk/gtk_compat.h"
#include "ui/base/text/text_elider.h"
+#include "ui/base/x/active_window_watcher_x.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/gtk_native_view_id_manager.h"
#include "ui/gfx/gtk_preserve_window.h"
@@ -574,6 +575,7 @@ RenderWidgetHostViewGtk::RenderWidgetHostViewGtk(
was_imcontext_focused_before_grab_(false),
do_x_grab_(false),
is_fullscreen_(false),
+ made_active_(false),
Daniel Erat 2012/06/13 19:18:43 actually, having this variable contain false infor
destroy_handler_id_(0),
dragged_at_horizontal_edge_(0),
dragged_at_vertical_edge_(0),
@@ -659,16 +661,14 @@ void RenderWidgetHostViewGtk::InitAsFullscreen(
GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
gtk_window_set_decorated(window, FALSE);
gtk_window_fullscreen(window);
- g_signal_connect(GTK_WIDGET(window),
- "window-state-event",
- G_CALLBACK(&OnWindowStateEventThunk),
- this);
destroy_handler_id_ = g_signal_connect(GTK_WIDGET(window),
"destroy",
G_CALLBACK(OnDestroyThunk),
this);
gtk_container_add(GTK_CONTAINER(window), view_.get());
+ ui::ActiveWindowWatcherX::AddObserver(this);
+
// Try to move and resize the window to cover the screen in case the window
// manager doesn't support _NET_WM_STATE_FULLSCREEN.
GdkScreen* screen = gtk_window_get_screen(window);
@@ -766,6 +766,17 @@ bool RenderWidgetHostViewGtk::HasFocus() const {
return gtk_widget_is_focus(view_.get());
}
+void RenderWidgetHostViewGtk::ActiveWindowChanged(GdkWindow *window) {
+ DCHECK(is_fullscreen_);
+ GdkWindow* our_window = gtk_widget_get_parent_window(view_.get());
+ // If the window was previously active, but isn't active anymore, shut it
+ // down.
+ if (our_window == window)
+ made_active_ = true;
+ else if (made_active_)
+ host_->Shutdown();
+}
+
bool RenderWidgetHostViewGtk::IsSurfaceAvailableForCopy() const {
return !!host_->GetBackingStore(false);
}
@@ -877,8 +888,10 @@ void RenderWidgetHostViewGtk::Destroy() {
GtkWidget* window = gtk_widget_get_parent(view_.get());
// Disconnect the destroy handler so that we don't try to shutdown twice.
- if (is_fullscreen_)
+ if (is_fullscreen_) {
g_signal_handler_disconnect(window, destroy_handler_id_);
+ ui::ActiveWindowWatcherX::RemoveObserver(this);
+ }
gtk_widget_destroy(window);
}
@@ -951,24 +964,6 @@ gfx::NativeView RenderWidgetHostViewGtk::BuildInputMethodsGtkMenu() {
return im_context_->BuildInputMethodsGtkMenu();
}
-gboolean RenderWidgetHostViewGtk::OnWindowStateEvent(
- GtkWidget* widget,
- GdkEventWindowState* event) {
- if (is_fullscreen_) {
- // If a fullscreen widget got unfullscreened (e.g. by the window manager),
- // close it.
- bool unfullscreened =
- (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) &&
- !(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN);
- if (unfullscreened) {
- host_->Shutdown();
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
void RenderWidgetHostViewGtk::OnDestroy(GtkWidget* widget) {
DCHECK(is_fullscreen_);
host_->Shutdown();
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698