Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h" | 5 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h" |
| 6 | 6 |
| 7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
| 8 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. | 8 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. |
| 9 #undef RootWindow | 9 #undef RootWindow |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
| 16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/aura/window_event_dispatcher.h" | 17 #include "ui/aura/window_event_dispatcher.h" |
| 18 #include "ui/aura/window_tree_host.h" | 18 #include "ui/aura/window_tree_host.h" |
| 19 #include "ui/base/x/x11_util.h" | 19 #include "ui/base/x/x11_util.h" |
| 20 #include "ui/events/event.h" | 20 #include "ui/events/event.h" |
| 21 #include "ui/events/event_utils.h" | 21 #include "ui/events/event_utils.h" |
| 22 #include "ui/events/keycodes/keyboard_code_conversion_x.h" | 22 #include "ui/events/keycodes/keyboard_code_conversion_x.h" |
| 23 #include "ui/events/platform/scoped_event_dispatcher.h" | 23 #include "ui/events/platform/scoped_event_dispatcher.h" |
| 24 #include "ui/events/platform/x11/x11_event_source.h" | 24 #include "ui/events/platform/x11/x11_event_source.h" |
| 25 #include "ui/gfx/point_conversions.h" | 25 #include "ui/gfx/point_conversions.h" |
| 26 #include "ui/gfx/screen.h" | 26 #include "ui/gfx/screen.h" |
| 27 #include "ui/views/controls/image_view.h" | 27 #include "ui/views/controls/image_view.h" |
| 28 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" | |
| 28 #include "ui/views/widget/widget.h" | 29 #include "ui/views/widget/widget.h" |
| 29 | 30 |
| 30 namespace views { | 31 namespace views { |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 // The minimum alpha before we declare a pixel transparent when searching in | 35 // The minimum alpha before we declare a pixel transparent when searching in |
| 35 // our source image. | 36 // our source image. |
| 36 const uint32 kMinAlpha = 32; | 37 const uint32 kMinAlpha = 32; |
| 37 const unsigned char kDragWidgetOpacity = 0xc0; | 38 const unsigned char kDragWidgetOpacity = 0xc0; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 } | 129 } |
| 129 return ui::POST_DISPATCH_NONE; | 130 return ui::POST_DISPATCH_NONE; |
| 130 } | 131 } |
| 131 case KeyPress: { | 132 case KeyPress: { |
| 132 if (ui::KeyboardCodeFromXKeyEvent(xev) == ui::VKEY_ESCAPE) { | 133 if (ui::KeyboardCodeFromXKeyEvent(xev) == ui::VKEY_ESCAPE) { |
| 133 canceled_ = true; | 134 canceled_ = true; |
| 134 EndMoveLoop(); | 135 EndMoveLoop(); |
| 135 return ui::POST_DISPATCH_NONE; | 136 return ui::POST_DISPATCH_NONE; |
| 136 } | 137 } |
| 137 break; | 138 break; |
| 138 } | 139 } |
|
sadrul
2014/05/05 19:43:33
Can we look at the FocusOut event received here to
varkha
2014/05/06 22:22:12
Maybe, I was trying though to make this CL simple
sadrul
2014/05/07 14:10:46
I think keeping track of FocusOut in here would be
varkha
2014/05/07 20:17:54
Yes, I think I now get what you mean.
| |
| 139 case GenericEvent: { | 140 case GenericEvent: { |
| 140 ui::EventType type = ui::EventTypeFromNative(xev); | 141 ui::EventType type = ui::EventTypeFromNative(xev); |
| 141 switch (type) { | 142 switch (type) { |
| 142 case ui::ET_MOUSE_MOVED: | 143 case ui::ET_MOUSE_MOVED: |
| 143 case ui::ET_MOUSE_DRAGGED: | 144 case ui::ET_MOUSE_DRAGGED: |
| 144 case ui::ET_MOUSE_RELEASED: { | 145 case ui::ET_MOUSE_RELEASED: { |
| 145 XEvent xevent = {0}; | 146 XEvent xevent = {0}; |
| 146 if (type == ui::ET_MOUSE_RELEASED) { | 147 if (type == ui::ET_MOUSE_RELEASED) { |
| 147 xevent.type = ButtonRelease; | 148 xevent.type = ButtonRelease; |
| 148 xevent.xbutton.button = ui::EventButtonFromNative(xev); | 149 xevent.xbutton.button = ui::EventButtonFromNative(xev); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 aura::Env::GetInstance()->set_mouse_button_flags(0); | 247 aura::Env::GetInstance()->set_mouse_button_flags(0); |
| 247 should_reset_mouse_flags_ = false; | 248 should_reset_mouse_flags_ = false; |
| 248 } | 249 } |
| 249 | 250 |
| 250 // TODO(erg): Is this ungrab the cause of having to click to give input focus | 251 // TODO(erg): Is this ungrab the cause of having to click to give input focus |
| 251 // on drawn out windows? Not ungrabbing here screws the X server until I kill | 252 // on drawn out windows? Not ungrabbing here screws the X server until I kill |
| 252 // the chrome process. | 253 // the chrome process. |
| 253 | 254 |
| 254 // Ungrab before we let go of the window. | 255 // Ungrab before we let go of the window. |
| 255 XDisplay* display = gfx::GetXDisplay(); | 256 XDisplay* display = gfx::GetXDisplay(); |
| 256 XUngrabPointer(display, CurrentTime); | 257 // Only ungrab pointer if capture was not switched to another window. |
| 258 if (!DesktopWindowTreeHostX11::AnyHostHasCapture()) | |
| 259 XUngrabPointer(display, CurrentTime); | |
| 257 XUngrabKeyboard(display, CurrentTime); | 260 XUngrabKeyboard(display, CurrentTime); |
|
sadrul
2014/05/05 19:43:33
I assume we wouldn't want to do this either?
varkha
2014/05/06 22:22:12
Since we still grab the keyboard in this class we
sadrul
2014/05/07 14:10:46
I meant perhaps we don't want to ungrab the keyboa
varkha
2014/05/07 20:17:54
Done.
| |
| 258 | 261 |
| 259 // Restore the previous dispatcher. | 262 // Restore the previous dispatcher. |
| 260 nested_dispatcher_.reset(); | 263 nested_dispatcher_.reset(); |
| 261 drag_widget_.reset(); | 264 drag_widget_.reset(); |
| 262 delegate_->OnMoveLoopEnded(); | 265 delegate_->OnMoveLoopEnded(); |
| 263 XDestroyWindow(display, grab_input_window_); | 266 XDestroyWindow(display, grab_input_window_); |
| 264 grab_input_window_ = None; | 267 grab_input_window_ = None; |
| 265 | 268 |
| 266 in_move_loop_ = false; | 269 in_move_loop_ = false; |
| 267 quit_closure_.Run(); | 270 quit_closure_.Run(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 for (int x = 0; x < in_bitmap->width(); ++x) { | 385 for (int x = 0; x < in_bitmap->width(); ++x) { |
| 383 if (SkColorGetA(in_row[x]) > kMinAlpha) | 386 if (SkColorGetA(in_row[x]) > kMinAlpha) |
| 384 return true; | 387 return true; |
| 385 } | 388 } |
| 386 } | 389 } |
| 387 | 390 |
| 388 return false; | 391 return false; |
| 389 } | 392 } |
| 390 | 393 |
| 391 } // namespace views | 394 } // namespace views |
| OLD | NEW |