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

Unified Diff: chrome/browser/fullscreen_win.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
« no previous file with comments | « chrome/browser/fullscreen_mac.mm ('k') | chrome/browser/idle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/fullscreen_win.cc
===================================================================
--- chrome/browser/fullscreen_win.cc (revision 0)
+++ chrome/browser/fullscreen_win.cc (revision 0)
@@ -0,0 +1,84 @@
+// 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 <windows.h>
+#include <shellapi.h>
+
+static bool IsPlatformFullScreenMode() {
+ // SHQueryUserNotificationState is only available for Vista and above.
+#if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_VISTA)
+ QUERY_USER_NOTIFICATION_STATE state;
+ if (FAILED(SHQueryUserNotificationState(&state)))
levin 2011/01/21 20:41:08 Seems like you'd want to put a :: here since you p
+ return false;
+ return state == QUNS_RUNNING_D3D_FULL_SCREEN ||
+ state == QUNS_PRESENTATION_MODE;
+#else
+ return false;
+#endif
+}
+
+static bool IsFullScreenWindowMode() {
+ // Get the foreground window which the user is currently working on.
+ HWND wnd = ::GetForegroundWindow();
+ if (!wnd)
+ return false;
+
+ // Get the monitor where the window is located.
+ RECT wnd_rc;
levin 2011/01/21 20:41:08 Whenever I see "rc", I think resource compiler. r
+ if (!::GetWindowRect(wnd, &wnd_rc))
+ return false;
+ HMONITOR monitor = ::MonitorFromRect(&wnd_rc, MONITOR_DEFAULTTONULL);
+ if (!monitor)
+ return false;
+ MONITORINFO monitor_info = { sizeof(monitor_info) };
+ if (!::GetMonitorInfo(monitor, &monitor_info))
+ return false;
+
+ // It should be the main monitor.
+ if (!(monitor_info.dwFlags & MONITORINFOF_PRIMARY))
+ return false;
+
+ // The window should be at least as large as the monitor.
+ if (!::IntersectRect(&wnd_rc, &wnd_rc, &monitor_info.rcMonitor))
+ return false;
+ if (!::EqualRect(&wnd_rc, &monitor_info.rcMonitor))
+ return false;
+
+ // At last, the window style should not have WS_DLGFRAME and WS_THICKFRAME and
+ // its extended style should not have WS_EX_WINDOWEDGE and WS_EX_TOOLWINDOW.
+ LONG style = ::GetWindowLong(wnd, GWL_STYLE);
+ LONG ext_style = ::GetWindowLong(wnd, GWL_EXSTYLE);
+ return !((style & (WS_DLGFRAME | WS_THICKFRAME)) ||
+ (ext_style & (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW)));
+}
+
+static bool IsFullScreenConsoleMode() {
+ // We detect this by attaching the current process to the console of the
+ // foreground window and then checking if it is in full screen mode.
+ DWORD pid = 0;
+ ::GetWindowThreadProcessId(::GetForegroundWindow(), &pid);
+ if (!pid)
+ return false;
+
+ if (!::AttachConsole(pid))
+ return false;
+
+ DWORD modes = 0;
+ ::GetConsoleDisplayMode(&modes);
+ ::FreeConsole();
+
+ return (modes & (CONSOLE_FULLSCREEN | CONSOLE_FULLSCREEN_HARDWARE)) != 0;
+}
+
+bool IsFullScreenMode() {
+ if (IsPlatformFullScreenMode())
+ return true;
+ if (IsFullScreenWindowMode())
+ return true;
+ if (IsFullScreenConsoleMode())
+ return true;
+ return false;
levin 2011/01/21 20:41:08 Or just return IsPlatformFullScreenMode() || Is
+}
Property changes on: chrome\browser\fullscreen_win.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/fullscreen_mac.mm ('k') | chrome/browser/idle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698