| 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/aura/window_tree_host_x11.h" | 5 #include "ui/aura/window_tree_host_x11.h" |
| 6 | 6 |
| 7 #include <strings.h> | 7 #include <strings.h> |
| 8 #include <X11/cursorfont.h> | 8 #include <X11/cursorfont.h> |
| 9 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
| 10 #include <X11/extensions/Xrandr.h> | 10 #include <X11/extensions/Xrandr.h> |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // It's possible that the X window may be resized by some other means | 305 // It's possible that the X window may be resized by some other means |
| 306 // than from within aura (e.g. the X window manager can change the | 306 // than from within aura (e.g. the X window manager can change the |
| 307 // size). Make sure the root window size is maintained properly. | 307 // size). Make sure the root window size is maintained properly. |
| 308 gfx::Rect bounds(xev->xconfigure.x, xev->xconfigure.y, | 308 gfx::Rect bounds(xev->xconfigure.x, xev->xconfigure.y, |
| 309 xev->xconfigure.width, xev->xconfigure.height); | 309 xev->xconfigure.width, xev->xconfigure.height); |
| 310 bool size_changed = bounds_.size() != bounds.size(); | 310 bool size_changed = bounds_.size() != bounds.size(); |
| 311 bool origin_changed = bounds_.origin() != bounds.origin(); | 311 bool origin_changed = bounds_.origin() != bounds.origin(); |
| 312 bounds_ = bounds; | 312 bounds_ = bounds; |
| 313 OnConfigureNotify(); | 313 OnConfigureNotify(); |
| 314 if (size_changed) | 314 if (size_changed) |
| 315 OnHostResized(bounds.size()); | 315 OnHostResizedInPixels(bounds.size()); |
| 316 if (origin_changed) | 316 if (origin_changed) |
| 317 OnHostMoved(bounds_.origin()); | 317 OnHostMovedInPixels(bounds_.origin()); |
| 318 break; | 318 break; |
| 319 } | 319 } |
| 320 case GenericEvent: | 320 case GenericEvent: |
| 321 DispatchXI2Event(xev); | 321 DispatchXI2Event(xev); |
| 322 break; | 322 break; |
| 323 case ClientMessage: { | 323 case ClientMessage: { |
| 324 Atom message_type = static_cast<Atom>(xev->xclient.data.l[0]); | 324 Atom message_type = static_cast<Atom>(xev->xclient.data.l[0]); |
| 325 if (message_type == atom_cache_.GetAtom("WM_DELETE_WINDOW")) { | 325 if (message_type == atom_cache_.GetAtom("WM_DELETE_WINDOW")) { |
| 326 // We have received a close message from the window manager. | 326 // We have received a close message from the window manager. |
| 327 OnHostCloseRequested(); | 327 OnHostCloseRequested(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 if (value_mask) | 426 if (value_mask) |
| 427 XConfigureWindow(xdisplay_, xwindow_, value_mask, &changes); | 427 XConfigureWindow(xdisplay_, xwindow_, value_mask, &changes); |
| 428 | 428 |
| 429 // Assume that the resize will go through as requested, which should be the | 429 // Assume that the resize will go through as requested, which should be the |
| 430 // case if we're running without a window manager. If there's a window | 430 // case if we're running without a window manager. If there's a window |
| 431 // manager, it can modify or ignore the request, but (per ICCCM) we'll get a | 431 // manager, it can modify or ignore the request, but (per ICCCM) we'll get a |
| 432 // (possibly synthetic) ConfigureNotify about the actual size and correct | 432 // (possibly synthetic) ConfigureNotify about the actual size and correct |
| 433 // |bounds_| later. | 433 // |bounds_| later. |
| 434 bounds_ = bounds; | 434 bounds_ = bounds; |
| 435 if (origin_changed) | 435 if (origin_changed) |
| 436 OnHostMoved(bounds.origin()); | 436 OnHostMovedInPixels(bounds.origin()); |
| 437 if (size_changed || current_scale != new_scale) { | 437 if (size_changed || current_scale != new_scale) { |
| 438 OnHostResized(bounds.size()); | 438 OnHostResizedInPixels(bounds.size()); |
| 439 } else { | 439 } else { |
| 440 window()->SchedulePaintInRect(window()->bounds()); | 440 window()->SchedulePaintInRect(window()->bounds()); |
| 441 } | 441 } |
| 442 } | 442 } |
| 443 | 443 |
| 444 gfx::Point WindowTreeHostX11::GetLocationOnNativeScreen() const { | 444 gfx::Point WindowTreeHostX11::GetLocationOnNativeScreenInPixels() const { |
| 445 return bounds_.origin(); | 445 return bounds_.origin(); |
| 446 } | 446 } |
| 447 | 447 |
| 448 void WindowTreeHostX11::SetCapture() { | 448 void WindowTreeHostX11::SetCapture() { |
| 449 // Do not grab X11 input. Grabbing X11 input is asynchronous and this method | 449 // Do not grab X11 input. Grabbing X11 input is asynchronous and this method |
| 450 // is expected to be synchronous. Grabbing X11 input is unnecessary on | 450 // is expected to be synchronous. Grabbing X11 input is unnecessary on |
| 451 // ChromeOS because ChromeOS manages all of the X windows. When running | 451 // ChromeOS because ChromeOS manages all of the X windows. When running |
| 452 // ChromeOS on the desktop for the sake of debugging: | 452 // ChromeOS on the desktop for the sake of debugging: |
| 453 // - Implicit pointer grab as a result of pressing a mouse button | 453 // - Implicit pointer grab as a result of pressing a mouse button |
| 454 // - Releasing capture as a result of losing activation (FocusOut) | 454 // - Releasing capture as a result of losing activation (FocusOut) |
| 455 // is sufficient. | 455 // is sufficient. |
| 456 } | 456 } |
| 457 | 457 |
| 458 void WindowTreeHostX11::ReleaseCapture() { | 458 void WindowTreeHostX11::ReleaseCapture() { |
| 459 } | 459 } |
| 460 | 460 |
| 461 void WindowTreeHostX11::SetCursorNative(gfx::NativeCursor cursor) { | 461 void WindowTreeHostX11::SetCursorNative(gfx::NativeCursor cursor) { |
| 462 if (cursor == current_cursor_) | 462 if (cursor == current_cursor_) |
| 463 return; | 463 return; |
| 464 current_cursor_ = cursor; | 464 current_cursor_ = cursor; |
| 465 SetCursorInternal(cursor); | 465 SetCursorInternal(cursor); |
| 466 } | 466 } |
| 467 | 467 |
| 468 void WindowTreeHostX11::MoveCursorToNative(const gfx::Point& location) { | 468 void WindowTreeHostX11::MoveCursorToNativeInPixels( |
| 469 const gfx::Point& location_in_pixels) { |
| 469 XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0, | 470 XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0, |
| 470 bounds_.x() + location.x(), | 471 bounds_.x() + location_in_pixels.x(), |
| 471 bounds_.y() + location.y()); | 472 bounds_.y() + location_in_pixels.y()); |
| 472 } | 473 } |
| 473 | 474 |
| 474 void WindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) { | 475 void WindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) { |
| 475 } | 476 } |
| 476 | 477 |
| 477 void WindowTreeHostX11::DisableInput() { | 478 void WindowTreeHostX11::DisableInput() { |
| 478 xwindow_events_.reset( | 479 xwindow_events_.reset( |
| 479 new ui::XScopedEventSelector(xwindow_, kEventMask & ~kInputEventMask)); | 480 new ui::XScopedEventSelector(xwindow_, kEventMask & ~kInputEventMask)); |
| 480 unsigned char mask[XIMaskLen(XI_LASTEVENT)] = {0}; | 481 unsigned char mask[XIMaskLen(XI_LASTEVENT)] = {0}; |
| 481 XIEventMask evmask; | 482 XIEventMask evmask; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 } | 564 } |
| 564 | 565 |
| 565 void WindowTreeHostX11::OnConfigureNotify() {} | 566 void WindowTreeHostX11::OnConfigureNotify() {} |
| 566 | 567 |
| 567 void WindowTreeHostX11::TranslateAndDispatchLocatedEvent( | 568 void WindowTreeHostX11::TranslateAndDispatchLocatedEvent( |
| 568 ui::LocatedEvent* event) { | 569 ui::LocatedEvent* event) { |
| 569 SendEventToProcessor(event); | 570 SendEventToProcessor(event); |
| 570 } | 571 } |
| 571 | 572 |
| 572 // static | 573 // static |
| 573 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) { | 574 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds_in_pixels) { |
| 574 return new WindowTreeHostX11(bounds); | 575 return new WindowTreeHostX11(bounds_in_pixels); |
| 575 } | 576 } |
| 576 | 577 |
| 577 namespace test { | 578 namespace test { |
| 578 | 579 |
| 579 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { | 580 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { |
| 580 default_override_redirect = override_redirect; | 581 default_override_redirect = override_redirect; |
| 581 } | 582 } |
| 582 | 583 |
| 583 } // namespace test | 584 } // namespace test |
| 584 } // namespace aura | 585 } // namespace aura |
| OLD | NEW |