summaryrefslogtreecommitdiffstats
path: root/ui/aura/window_tree_host_win.cc
diff options
context:
space:
mode:
authormarkusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-23 12:00:54 +0000
committermarkusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-23 12:00:54 +0000
commit0e17f877493330d09cb9b7d8738efb873a53ec7e (patch)
tree29b60b3242fdf80f83b4bb188b3a2e1eedfdd173 /ui/aura/window_tree_host_win.cc
parent8c0f03d9cc48a76de8f1391acf0111f20102d838 (diff)
downloadchromium_src-0e17f877493330d09cb9b7d8738efb873a53ec7e.zip
chromium_src-0e17f877493330d09cb9b7d8738efb873a53ec7e.tar.gz
chromium_src-0e17f877493330d09cb9b7d8738efb873a53ec7e.tar.bz2
Revert 284850 "aura: Use PlatformWindow from WindowTreeHostWin."
> aura: Use PlatformWindow from WindowTreeHostWin. > > With this patch, both Windows and Ozone implementations use PlatformWindow for > interacting with the native windowing system. Eventually, the X11 implementations > will also use this, and WindowTreeHost will have a single implementation on all > platforms. > > BUG=none > R=ben@chromium.org > > Review URL: https://codereview.chromium.org/400413002 TBR=sadrul@chromium.org Review URL: https://codereview.chromium.org/410873003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284905 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura/window_tree_host_win.cc')
-rw-r--r--ui/aura/window_tree_host_win.cc156
1 files changed, 108 insertions, 48 deletions
diff --git a/ui/aura/window_tree_host_win.cc b/ui/aura/window_tree_host_win.cc
index 51bbcc6..46b2e10 100644
--- a/ui/aura/window_tree_host_win.cc
+++ b/ui/aura/window_tree_host_win.cc
@@ -17,9 +17,7 @@
#include "ui/events/event.h"
#include "ui/gfx/display.h"
#include "ui/gfx/insets.h"
-#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/screen.h"
-#include "ui/platform_window/win/win_window.h"
using std::max;
using std::min;
@@ -43,15 +41,18 @@ gfx::Size WindowTreeHost::GetNativeScreenSize() {
}
WindowTreeHostWin::WindowTreeHostWin(const gfx::Rect& bounds)
- : has_capture_(false),
- widget_(gfx::kNullAcceleratedWidget),
- window_(new ui::WinWindow(this, bounds)) {
+ : has_capture_(false) {
+ if (use_popup_as_root_window_for_test)
+ set_window_style(WS_POPUP);
+ Init(NULL, bounds);
+ SetWindowText(hwnd(), L"aura::RootWindow!");
+ CreateCompositor(GetAcceleratedWidget());
}
WindowTreeHostWin::~WindowTreeHostWin() {
DestroyCompositor();
DestroyDispatcher();
- window_.reset();
+ DestroyWindow(hwnd());
}
ui::EventSource* WindowTreeHostWin::GetEventSource() {
@@ -59,39 +60,70 @@ ui::EventSource* WindowTreeHostWin::GetEventSource() {
}
gfx::AcceleratedWidget WindowTreeHostWin::GetAcceleratedWidget() {
- return widget_;
+ return hwnd();
}
void WindowTreeHostWin::Show() {
- window_->Show();
+ ShowWindow(hwnd(), SW_SHOWNORMAL);
}
void WindowTreeHostWin::Hide() {
- window_->Hide();
+ NOTIMPLEMENTED();
}
gfx::Rect WindowTreeHostWin::GetBounds() const {
- return window_->GetBounds();
+ RECT r;
+ GetClientRect(hwnd(), &r);
+ return gfx::Rect(r);
}
void WindowTreeHostWin::SetBounds(const gfx::Rect& bounds) {
- window_->SetBounds(bounds);
+ RECT window_rect;
+ window_rect.left = bounds.x();
+ window_rect.top = bounds.y();
+ window_rect.right = bounds.right() ;
+ window_rect.bottom = bounds.bottom();
+ AdjustWindowRectEx(&window_rect,
+ GetWindowLong(hwnd(), GWL_STYLE),
+ FALSE,
+ GetWindowLong(hwnd(), GWL_EXSTYLE));
+ SetWindowPos(
+ hwnd(),
+ NULL,
+ window_rect.left,
+ window_rect.top,
+ window_rect.right - window_rect.left,
+ window_rect.bottom - window_rect.top,
+ SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOREPOSITION);
+
+ // Explicity call OnHostResized when the scale has changed because
+ // the window size may not have changed.
+ float current_scale = compositor()->device_scale_factor();
+ float new_scale = gfx::Screen::GetScreenFor(window())->
+ GetDisplayNearestWindow(window()).device_scale_factor();
+ if (current_scale != new_scale)
+ OnHostResized(bounds.size());
}
gfx::Point WindowTreeHostWin::GetLocationOnNativeScreen() const {
- return window_->GetBounds().origin();
+ RECT r;
+ GetClientRect(hwnd(), &r);
+ return gfx::Point(r.left, r.top);
}
+
void WindowTreeHostWin::SetCapture() {
if (!has_capture_) {
has_capture_ = true;
- window_->SetCapture();
+ ::SetCapture(hwnd());
}
}
void WindowTreeHostWin::ReleaseCapture() {
- if (has_capture_)
- window_->ReleaseCapture();
+ if (has_capture_) {
+ has_capture_ = false;
+ ::ReleaseCapture();
+ }
}
void WindowTreeHostWin::SetCursorNative(gfx::NativeCursor native_cursor) {
@@ -114,60 +146,88 @@ void WindowTreeHostWin::OnCursorVisibilityChangedNative(bool show) {
void WindowTreeHostWin::PostNativeEvent(const base::NativeEvent& native_event) {
::PostMessage(
- widget_, native_event.message, native_event.wParam, native_event.lParam);
+ hwnd(), native_event.message, native_event.wParam, native_event.lParam);
}
ui::EventProcessor* WindowTreeHostWin::GetEventProcessor() {
return dispatcher();
}
-void WindowTreeHostWin::OnBoundsChanged(const gfx::Rect& new_bounds) {
- gfx::Rect old_bounds = bounds_;
- bounds_ = new_bounds;
- if (bounds_.origin() != old_bounds.origin())
- OnHostMoved(bounds_.origin());
- if (bounds_.size() != old_bounds.size())
- OnHostResized(bounds_.size());
+void WindowTreeHostWin::OnClose() {
+ // TODO: this obviously shouldn't be here.
+ base::MessageLoopForUI::current()->Quit();
}
-void WindowTreeHostWin::OnDamageRect(const gfx::Rect& damage_rect) {
- compositor()->ScheduleRedrawRect(damage_rect);
+LRESULT WindowTreeHostWin::OnKeyEvent(UINT message,
+ WPARAM w_param,
+ LPARAM l_param) {
+ MSG msg = { hwnd(), message, w_param, l_param };
+ ui::KeyEvent keyev(msg, message == WM_CHAR);
+ ui::EventDispatchDetails details = SendEventToProcessor(&keyev);
+ SetMsgHandled(keyev.handled() || details.dispatcher_destroyed);
+ return 0;
+}
+
+LRESULT WindowTreeHostWin::OnMouseRange(UINT message,
+ WPARAM w_param,
+ LPARAM l_param) {
+ MSG msg = { hwnd(), message, w_param, l_param, 0,
+ { CR_GET_X_LPARAM(l_param), CR_GET_Y_LPARAM(l_param) } };
+ ui::MouseEvent event(msg);
+ bool handled = false;
+ if (!(event.flags() & ui::EF_IS_NON_CLIENT)) {
+ ui::EventDispatchDetails details = SendEventToProcessor(&event);
+ handled = event.handled() || details.dispatcher_destroyed;
+ }
+ SetMsgHandled(handled);
+ return 0;
}
-void WindowTreeHostWin::DispatchEvent(ui::Event* event) {
- ui::EventDispatchDetails details = SendEventToProcessor(event);
- if (details.dispatcher_destroyed)
- event->SetHandled();
+LRESULT WindowTreeHostWin::OnCaptureChanged(UINT message,
+ WPARAM w_param,
+ LPARAM l_param) {
+ if (has_capture_) {
+ has_capture_ = false;
+ OnHostLostWindowCapture();
+ }
+ return 0;
}
-void WindowTreeHostWin::OnCloseRequest() {
- // TODO: this obviously shouldn't be here.
- base::MessageLoopForUI::current()->Quit();
+LRESULT WindowTreeHostWin::OnNCActivate(UINT message,
+ WPARAM w_param,
+ LPARAM l_param) {
+ if (!!w_param)
+ OnHostActivated();
+ return DefWindowProc(hwnd(), message, w_param, l_param);
}
-void WindowTreeHostWin::OnClosed() {
+void WindowTreeHostWin::OnMove(const gfx::Point& point) {
+ OnHostMoved(point);
}
-void WindowTreeHostWin::OnWindowStateChanged(
- ui::PlatformWindowState new_state) {
+void WindowTreeHostWin::OnPaint(HDC dc) {
+ gfx::Rect damage_rect;
+ RECT update_rect = {0};
+ if (GetUpdateRect(hwnd(), &update_rect, FALSE))
+ damage_rect = gfx::Rect(update_rect);
+ compositor()->ScheduleRedrawRect(damage_rect);
+ ValidateRect(hwnd(), NULL);
}
-void WindowTreeHostWin::OnLostCapture() {
- if (has_capture_) {
- has_capture_ = false;
- OnHostLostWindowCapture();
- }
+void WindowTreeHostWin::OnSize(UINT param, const gfx::Size& size) {
+ // Minimizing resizes the window to 0x0 which causes our layout to go all
+ // screwy, so we just ignore it.
+ if (dispatcher() && param != SIZE_MINIMIZED)
+ OnHostResized(size);
}
-void WindowTreeHostWin::OnAcceleratedWidgetAvailable(
- gfx::AcceleratedWidget widget) {
- widget_ = widget;
- CreateCompositor(widget);
-}
+namespace test {
-void WindowTreeHostWin::OnActivationChanged(bool active) {
- if (active)
- OnHostActivated();
+// static
+void SetUsePopupAsRootWindowForTest(bool use) {
+ use_popup_as_root_window_for_test = use;
}
+} // namespace test
+
} // namespace aura