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

Unified Diff: trunk/src/ui/aura/window_tree_host_win.cc

Issue 410873003: Revert 284850 "aura: Use PlatformWindow from WindowTreeHostWin." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 5 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 | « trunk/src/ui/aura/window_tree_host_win.h ('k') | trunk/src/ui/ozone/demo/egl_demo.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/ui/aura/window_tree_host_win.cc
===================================================================
--- trunk/src/ui/aura/window_tree_host_win.cc (revision 284904)
+++ trunk/src/ui/aura/window_tree_host_win.cc (working copy)
@@ -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 @@
}
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 @@
}
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::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::OnDamageRect(const gfx::Rect& damage_rect) {
- compositor()->ScheduleRedrawRect(damage_rect);
-}
-
-void WindowTreeHostWin::DispatchEvent(ui::Event* event) {
- ui::EventDispatchDetails details = SendEventToProcessor(event);
- if (details.dispatcher_destroyed)
- event->SetHandled();
-}
-
-void WindowTreeHostWin::OnCloseRequest() {
+void WindowTreeHostWin::OnClose() {
// TODO: this obviously shouldn't be here.
base::MessageLoopForUI::current()->Quit();
}
-void WindowTreeHostWin::OnClosed() {
+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;
}
-void WindowTreeHostWin::OnWindowStateChanged(
- ui::PlatformWindowState new_state) {
+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::OnLostCapture() {
+LRESULT WindowTreeHostWin::OnCaptureChanged(UINT message,
+ WPARAM w_param,
+ LPARAM l_param) {
if (has_capture_) {
has_capture_ = false;
OnHostLostWindowCapture();
}
+ return 0;
}
-void WindowTreeHostWin::OnAcceleratedWidgetAvailable(
- gfx::AcceleratedWidget widget) {
- widget_ = widget;
- CreateCompositor(widget);
+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::OnActivationChanged(bool active) {
- if (active)
- OnHostActivated();
+void WindowTreeHostWin::OnMove(const gfx::Point& point) {
+ OnHostMoved(point);
}
+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::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);
+}
+
+namespace test {
+
+// static
+void SetUsePopupAsRootWindowForTest(bool use) {
+ use_popup_as_root_window_for_test = use;
+}
+
+} // namespace test
+
} // namespace aura
« no previous file with comments | « trunk/src/ui/aura/window_tree_host_win.h ('k') | trunk/src/ui/ozone/demo/egl_demo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698