diff options
author | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-19 19:06:15 +0000 |
---|---|---|
committer | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-19 19:06:15 +0000 |
commit | 8647714eef4b0eb718c5b2682f14c9b0f5ecce13 (patch) | |
tree | e38a7ec5f5839f3f2ffbe5c546bac5406e09258a /views/widget/window_manager.cc | |
parent | 02fe9c2b6adab15311c621a611d2405f1ea6551b (diff) | |
download | chromium_src-8647714eef4b0eb718c5b2682f14c9b0f5ecce13.zip chromium_src-8647714eef4b0eb718c5b2682f14c9b0f5ecce13.tar.gz chromium_src-8647714eef4b0eb718c5b2682f14c9b0f5ecce13.tar.bz2 |
Simple WindowManager that can move/resize window.
Fixes TouchFrame's NonClientHitTest to ignore VirtualKeyboard area.
Move mouse capture logic to Window Manager so that nested
mouse capture with nested NWVs works correctly.
Note1: This is a tentative WM that allows us to move/resize window in views desktop until we have real window manager based on aura/layer API.
Note2: There is an compositor related issue and doesn't work well when compositor is enabled. I'll look into it after this CL.
Review URL: http://codereview.chromium.org/7530017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97492 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget/window_manager.cc')
-rw-r--r-- | views/widget/window_manager.cc | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/views/widget/window_manager.cc b/views/widget/window_manager.cc new file mode 100644 index 0000000..b02b32b --- /dev/null +++ b/views/widget/window_manager.cc @@ -0,0 +1,88 @@ +// 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 "views/widget/window_manager.h" + +#include "base/compiler_specific.h" +#include "views/events/event.h" +#include "views/widget/widget.h" + +namespace { + +views::WindowManager* window_manager = NULL; + +class NullWindowManager : public views::WindowManager { + public: + NullWindowManager() : mouse_capture_(NULL) { + } + + virtual void StartMoveDrag(views::Widget* widget, + const gfx::Point& screen_point) OVERRIDE { + NOTIMPLEMENTED(); + } + + virtual void StartResizeDrag(views::Widget* widget, + const gfx::Point& screen_point, + int hittest_code) OVERRIDE { + NOTIMPLEMENTED(); + } + + virtual bool SetMouseCapture(views::Widget* widget) OVERRIDE { + if (mouse_capture_ == widget) + return true; + if (mouse_capture_) + return false; + mouse_capture_ = widget; + return true; + } + + virtual bool ReleaseMouseCapture(views::Widget* widget) OVERRIDE { + if (widget && mouse_capture_ != widget) + return false; + mouse_capture_ = NULL; + return true; + } + + virtual bool HasMouseCapture(const views::Widget* widget) const OVERRIDE { + return mouse_capture_ == widget; + } + + virtual bool HandleMouseEvent(views::Widget* widget, + const views::MouseEvent& event) OVERRIDE { + if (mouse_capture_) { + views::MouseEvent translated(event, widget->GetRootView(), + mouse_capture_->GetRootView()); + mouse_capture_->OnMouseEvent(translated); + return true; + } + return false; + } + + private: + views::Widget* mouse_capture_; +}; + +} // namespace + +namespace views { + +WindowManager::WindowManager() { +} + +WindowManager::~WindowManager() { +} + +// static +void WindowManager::Install(WindowManager* wm) { + window_manager = wm; +} + +// static +WindowManager* WindowManager::Get() { + if (!window_manager) + window_manager = new NullWindowManager(); + return window_manager; +} + +} // namespace views |