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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/fullscreen_mac.mm ('k') | chrome/browser/idle.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/fullscreen.h"
6
7 #include <windows.h>
8 #include <shellapi.h>
9
10 static bool IsPlatformFullScreenMode() {
11 // SHQueryUserNotificationState is only available for Vista and above.
12 #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_VISTA)
13 QUERY_USER_NOTIFICATION_STATE state;
14 if (FAILED(::SHQueryUserNotificationState(&state)))
15 return false;
16 return state == QUNS_RUNNING_D3D_FULL_SCREEN ||
17 state == QUNS_PRESENTATION_MODE;
18 #else
19 return false;
20 #endif
21 }
22
23 static bool IsFullScreenWindowMode() {
24 // Get the foreground window which the user is currently working on.
25 HWND wnd = ::GetForegroundWindow();
26 if (!wnd)
27 return false;
28
29 // Get the monitor where the window is located.
30 RECT wnd_rect;
31 if (!::GetWindowRect(wnd, &wnd_rect))
32 return false;
33 HMONITOR monitor = ::MonitorFromRect(&wnd_rect, MONITOR_DEFAULTTONULL);
34 if (!monitor)
35 return false;
36 MONITORINFO monitor_info = { sizeof(monitor_info) };
37 if (!::GetMonitorInfo(monitor, &monitor_info))
38 return false;
39
40 // It should be the main monitor.
41 if (!(monitor_info.dwFlags & MONITORINFOF_PRIMARY))
42 return false;
43
44 // The window should be at least as large as the monitor.
45 if (!::IntersectRect(&wnd_rect, &wnd_rect, &monitor_info.rcMonitor))
46 return false;
47 if (!::EqualRect(&wnd_rect, &monitor_info.rcMonitor))
48 return false;
49
50 // At last, the window style should not have WS_DLGFRAME and WS_THICKFRAME and
51 // its extended style should not have WS_EX_WINDOWEDGE and WS_EX_TOOLWINDOW.
52 LONG style = ::GetWindowLong(wnd, GWL_STYLE);
53 LONG ext_style = ::GetWindowLong(wnd, GWL_EXSTYLE);
54 return !((style & (WS_DLGFRAME | WS_THICKFRAME)) ||
55 (ext_style & (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW)));
56 }
57
58 static bool IsFullScreenConsoleMode() {
59 // We detect this by attaching the current process to the console of the
60 // foreground window and then checking if it is in full screen mode.
61 DWORD pid = 0;
62 ::GetWindowThreadProcessId(::GetForegroundWindow(), &pid);
63 if (!pid)
64 return false;
65
66 if (!::AttachConsole(pid))
67 return false;
68
69 DWORD modes = 0;
70 ::GetConsoleDisplayMode(&modes);
71 ::FreeConsole();
72
73 return (modes & (CONSOLE_FULLSCREEN | CONSOLE_FULLSCREEN_HARDWARE)) != 0;
74 }
75
76 bool IsFullScreenMode() {
77 return IsPlatformFullScreenMode() ||
78 IsFullScreenWindowMode() ||
79 IsFullScreenConsoleMode();
80 }
OLDNEW
« 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