summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/browser/renderer_host/render_widget_host_view_win.cc33
-rw-r--r--content/browser/renderer_host/render_widget_host_view_win.h7
-rw-r--r--ui/surface/accelerated_surface_win.cc25
-rw-r--r--ui/surface/accelerated_surface_win.h9
4 files changed, 73 insertions, 1 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc
index 152a51f..b68f98e 100644
--- a/content/browser/renderer_host/render_widget_host_view_win.cc
+++ b/content/browser/renderer_host/render_widget_host_view_win.cc
@@ -9,6 +9,8 @@
#include <algorithm>
#include <map>
#include <stack>
+#include <wtsapi32.h>
+#pragma comment(lib, "wtsapi32.lib")
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -1132,6 +1134,8 @@ LRESULT RenderWidgetHostViewWin::OnCreate(CREATESTRUCT* create_struct) {
// scrolled when under the mouse pointer even if inactive.
props_.push_back(ui::SetWindowSupportsRerouteMouseWheel(m_hWnd));
+ WTSRegisterSessionNotification(m_hWnd, NOTIFY_FOR_THIS_SESSION);
+
UpdateDesiredTouchMode();
UpdateIMEState();
@@ -1163,6 +1167,8 @@ void RenderWidgetHostViewWin::OnDestroy() {
CleanupCompositorWindow();
+ WTSUnRegisterSessionNotification(m_hWnd);
+
ResetTooltip();
TrackMouseLeave(false);
}
@@ -2620,6 +2626,33 @@ void RenderWidgetHostViewWin::OnFinalMessage(HWND window) {
delete this;
}
+LRESULT RenderWidgetHostViewWin::OnSessionChange(UINT message,
+ WPARAM wparam,
+ LPARAM lparam,
+ BOOL& handled) {
+ handled = FALSE;
+ TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnSessionChange");
+
+ if (!accelerated_surface_.get())
+ return 0;
+
+ switch (wparam) {
+ case WTS_SESSION_LOCK:
+ accelerated_surface_->SetIsSessionLocked(true);
+ break;
+ case WTS_SESSION_UNLOCK:
+ // Force a repaint to update the window contents.
+ if (!is_hidden_)
+ InvalidateRect(NULL, FALSE);
+ accelerated_surface_->SetIsSessionLocked(false);
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
void RenderWidgetHostViewWin::TrackMouseLeave(bool track) {
if (track == track_mouse_leave_)
return;
diff --git a/content/browser/renderer_host/render_widget_host_view_win.h b/content/browser/renderer_host/render_widget_host_view_win.h
index 0abe1a6..8c26459 100644
--- a/content/browser/renderer_host/render_widget_host_view_win.h
+++ b/content/browser/renderer_host/render_widget_host_view_win.h
@@ -143,6 +143,7 @@ class RenderWidgetHostViewWin
MESSAGE_HANDLER(WM_GESTURE, OnGestureEvent)
MESSAGE_HANDLER(WM_MOVE, OnMoveOrSize)
MESSAGE_HANDLER(WM_SIZE, OnMoveOrSize)
+ MESSAGE_HANDLER(WM_WTSSESSION_CHANGE, OnSessionChange)
END_MSG_MAP()
// RenderWidgetHostView implementation.
@@ -335,6 +336,12 @@ class RenderWidgetHostViewWin
LRESULT OnMoveOrSize(UINT message, WPARAM wparam, LPARAM lparam,
BOOL& handled);
+ // Handle transitioning in and out of screensaver mode.
+ LRESULT OnSessionChange(UINT message,
+ WPARAM wparam,
+ LPARAM lparam,
+ BOOL& handled);
+
void OnFinalMessage(HWND window);
private:
diff --git a/ui/surface/accelerated_surface_win.cc b/ui/surface/accelerated_surface_win.cc
index 8e6e809..abd0745 100644
--- a/ui/surface/accelerated_surface_win.cc
+++ b/ui/surface/accelerated_surface_win.cc
@@ -24,6 +24,7 @@
#include "base/time.h"
#include "base/win/wrapped_window_proc.h"
#include "ui/base/win/hwnd_util.h"
+#include "ui/base/win/shell.h"
#include "ui/gfx/rect.h"
#include "ui/gl/gl_switches.h"
#include "ui/surface/accelerated_surface_transformer_win.h"
@@ -253,7 +254,8 @@ AcceleratedPresenter::AcceleratedPresenter(gfx::PluginWindowHandle window)
event_(false, false),
hidden_(true),
do_present_with_GDI_(DoAllShowPresentWithGDI() ||
- DoFirstShowPresentWithGDI()) {
+ DoFirstShowPresentWithGDI()),
+ is_session_locked_(false) {
}
// static
@@ -434,6 +436,10 @@ void AcceleratedPresenter::ReleaseSurface() {
this));
}
+void AcceleratedPresenter::SetIsSessionLocked(bool locked) {
+ is_session_locked_ = locked;
+}
+
void AcceleratedPresenter::Invalidate() {
// Make any pending or future presentation tasks do nothing. Once the last
// last pending task has been ignored, the reference count on the presenter
@@ -752,6 +758,19 @@ gfx::Size AcceleratedPresenter::GetWindowSize() {
}
bool AcceleratedPresenter::CheckDirect3DWillWork() {
+ // On a composited desktop, when the screen saver or logon screen are
+ // active, D3D presents never make it to the window but GDI presents
+ // do. If the session is locked GDI presents can be avoided since
+ // the window gets a message on unlock and forces a repaint.
+ if (!is_session_locked_ && ui::win::IsAeroGlassEnabled()) {
+ // Failure to open the input desktop is a sign of running with a non-default
+ // desktop.
+ HDESK input_desktop = ::OpenInputDesktop(0, 0, GENERIC_READ);
+ if (!input_desktop)
+ return false;
+ ::CloseDesktop(input_desktop);
+ }
+
gfx::Size window_size = GetWindowSize();
if (window_size != last_window_size_ && last_window_size_.GetArea() != 0) {
last_window_size_ = window_size;
@@ -799,3 +818,7 @@ void AcceleratedSurface::Suspend() {
void AcceleratedSurface::WasHidden() {
presenter_->WasHidden();
}
+
+void AcceleratedSurface::SetIsSessionLocked(bool locked) {
+ presenter_->SetIsSessionLocked(locked);
+}
diff --git a/ui/surface/accelerated_surface_win.h b/ui/surface/accelerated_surface_win.h
index 67a4542..4dacb87 100644
--- a/ui/surface/accelerated_surface_win.h
+++ b/ui/surface/accelerated_surface_win.h
@@ -54,6 +54,9 @@ class SURFACE_EXPORT AcceleratedPresenter
// Indicates that the presenter has become invisible.
void WasHidden();
+ // Called when the Windows session is locked or unlocked.
+ void SetIsSessionLocked(bool locked);
+
// Schedule the presenter to release its reference to the shared surface.
void ReleaseSurface();
@@ -143,6 +146,9 @@ class SURFACE_EXPORT AcceleratedPresenter
// with GDI.
bool do_present_with_GDI_;
+ // Set to true when the Windows session is locked.
+ bool is_session_locked_;
+
// These are used to detect when the window is resizing. For some reason,
// presenting with D3D while the window resizes causes those parts not
// drawn with D3D (e.g. with GDI) to flicker visible / invisible.
@@ -179,6 +185,9 @@ class SURFACE_EXPORT AcceleratedSurface {
// Indicates that the surface has become invisible.
void WasHidden();
+ // Called when the Windows session in locked or unlocked.
+ void SetIsSessionLocked(bool locked);
+
private:
const scoped_refptr<AcceleratedPresenter> presenter_;
DISALLOW_COPY_AND_ASSIGN(AcceleratedSurface);