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

Unified Diff: chrome/browser/fullscreen_linux.cc

Issue 6359008: Do not show notifications when in fullscreen or screensaver mode.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
Index: chrome/browser/fullscreen_linux.cc
===================================================================
--- chrome/browser/fullscreen_linux.cc (revision 0)
+++ chrome/browser/fullscreen_linux.cc (revision 0)
@@ -0,0 +1,77 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/fullscreen.h"
+
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+
+#include <algorithm>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "chrome/browser/ui/gtk/gtk_util.h"
+#include "gfx/rect.h"
+#include "ui/base/x/x11_util.h"
+
+namespace {
+
+class TopMostWindowFinder : public ui::EnumerateWindowsDelegate {
+ public:
+ TopMostWindowFinder()
+ : top_most_window_(None) {}
+
+ XID top_most_window() const { return top_most_window_; }
+
+ protected:
+ virtual bool ShouldStopIterating(XID window) {
+ if (!ui::IsWindowVisible(window))
+ return false;
+ top_most_window_ = window;
+ return true;
+ }
+
+ private:
+ XID top_most_window_;
+
+ DISALLOW_COPY_AND_ASSIGN(TopMostWindowFinder);
+};
+
+bool IsTopMostWindowFullScreen() {
+ // Find the topmost window.
+ TopMostWindowFinder finder;
+ gtk_util::EnumerateTopLevelWindows(&finder);
+ XID window = finder.top_most_window();
+ if (window == None)
+ return false;
+
+ // Make sure it is not the desktop window.
+ static Atom atom = gdk_x11_get_xatom_by_name_for_display(
+ gdk_display_get_default(), "_NET_WM_WINDOW_TYPE_DESKTOP");
+
+ std::vector<Atom> atom_properties;
+ if (ui::GetAtomArrayProperty(window,
+ "_NET_WM_WINDOW_TYPE",
+ &atom_properties) &&
+ std::find(atom_properties.begin(), atom_properties.end(), atom)
+ != atom_properties.end())
+ return false;
+
+ // If it is a GDK window, check it using gdk function.
+ GdkWindow* gwindow = gdk_window_lookup(window);
+ if (gwindow && window != GDK_ROOT_WINDOW())
+ return gdk_window_get_state(gwindow) == GDK_WINDOW_STATE_FULLSCREEN;
+
+ // Otherwise, do the check via xlib function.
+ return ui::IsX11WindowFullScreen(window);
+}
+
+}
+
+bool IsFullScreenMode() {
+ gdk_error_trap_push();
+ bool result = IsTopMostWindowFullScreen();
+ bool got_error = gdk_error_trap_pop();
+ return result && !got_error;
+}
Property changes on: chrome\browser\fullscreen_linux.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698