Chromium Code Reviews| Index: ui/views/widget/desktop_aura/x11_window_event_filter.cc |
| diff --git a/ui/views/widget/desktop_aura/x11_window_event_filter.cc b/ui/views/widget/desktop_aura/x11_window_event_filter.cc |
| index 9cb6834313d55bfa5f575810145ea3fa7b34c289..e59670c68bdac3b2932bedf6fa3b1c9dadc68bd2 100644 |
| --- a/ui/views/widget/desktop_aura/x11_window_event_filter.cc |
| +++ b/ui/views/widget/desktop_aura/x11_window_event_filter.cc |
| @@ -67,7 +67,8 @@ X11WindowEventFilter::X11WindowEventFilter( |
| x_root_window_(DefaultRootWindow(xdisplay_)), |
| atom_cache_(xdisplay_, kAtomsToCache), |
| window_tree_host_(window_tree_host), |
| - is_active_(false) { |
| + is_active_(false), |
| + double_click_component_(HTNOWHERE) { |
| } |
| X11WindowEventFilter::~X11WindowEventFilter() { |
| @@ -101,8 +102,13 @@ void X11WindowEventFilter::OnMouseEvent(ui::MouseEvent* event) { |
| if (!target->delegate()) |
| return; |
| + int previous_target_component = HTNOWHERE; |
|
flackr
2014/04/08 21:11:39
why do you need this? You can just compare current
jonross
2014/04/08 22:29:08
It felt cleaner when dealing with early exits. Thi
|
| int component = |
| target->delegate()->GetNonClientComponent(event->location()); |
| + if (event->IsLeftMouseButton()) { |
| + previous_target_component = double_click_component_; |
| + double_click_component_ = component; |
| + } |
| if (component == HTCLIENT) |
| return; |
| @@ -113,18 +119,22 @@ void X11WindowEventFilter::OnMouseEvent(ui::MouseEvent* event) { |
| } |
| // Left button case. |
| - if (event->flags() & ui::EF_IS_DOUBLE_CLICK && |
| - component == HTCAPTION && |
| - target->GetProperty(aura::client::kCanMaximizeKey)) { |
| - // Our event is a double click in the caption area in a window that can be |
| - // maximized. We are responsible for dispatching this as a minimize/ |
| - // maximize on X11 (Windows converts this to min/max events for us). |
| - if (window_tree_host_->IsMaximized()) |
| - window_tree_host_->Restore(); |
| - else |
| - window_tree_host_->Maximize(); |
| - event->SetHandled(); |
| - return; |
| + if (event->flags() & ui::EF_IS_DOUBLE_CLICK) { |
| + double_click_component_ = HTNOWHERE; |
| + if (component == HTCAPTION && |
| + target->GetProperty(aura::client::kCanMaximizeKey) && |
| + previous_target_component == component) { |
| + // Our event is a double click, with both clicks in the caption area of a |
| + // window that can be maximized. We are responsible for dispatching this |
| + // as a restore/maximize on X11 (Windows converts this to restore/max |
| + // events for us). |
| + if (window_tree_host_->IsMaximized()) |
| + window_tree_host_->Restore(); |
| + else |
| + window_tree_host_->Maximize(); |
| + event->SetHandled(); |
| + return; |
| + } |
| } |
| // Get the |x_root_window_| location out of the native event. |