| 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/root_window_host_linux.h" | 5 #include "ui/aura/root_window_host_linux.h" |
| 6 | 6 |
| 7 #include <X11/cursorfont.h> | 7 #include <X11/cursorfont.h> |
| 8 #include <X11/extensions/Xfixes.h> | 8 #include <X11/extensions/Xfixes.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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 } // namespace internal | 332 } // namespace internal |
| 333 | 333 |
| 334 RootWindowHostLinux::RootWindowHostLinux(RootWindowHostDelegate* delegate, | 334 RootWindowHostLinux::RootWindowHostLinux(RootWindowHostDelegate* delegate, |
| 335 const gfx::Rect& bounds) | 335 const gfx::Rect& bounds) |
| 336 : delegate_(delegate), | 336 : delegate_(delegate), |
| 337 xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), | 337 xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), |
| 338 xwindow_(0), | 338 xwindow_(0), |
| 339 x_root_window_(DefaultRootWindow(xdisplay_)), | 339 x_root_window_(DefaultRootWindow(xdisplay_)), |
| 340 current_cursor_(ui::kCursorNull), | 340 current_cursor_(ui::kCursorNull), |
| 341 window_mapped_(false), | 341 window_mapped_(false), |
| 342 cursor_shown_(true), | |
| 343 bounds_(bounds), | 342 bounds_(bounds), |
| 344 focus_when_shown_(false), | 343 focus_when_shown_(false), |
| 345 pointer_barriers_(NULL), | 344 pointer_barriers_(NULL), |
| 346 touch_calibrate_(new internal::TouchEventCalibrate), | 345 touch_calibrate_(new internal::TouchEventCalibrate), |
| 347 atom_cache_(xdisplay_, kAtomsToCache) { | 346 atom_cache_(xdisplay_, kAtomsToCache) { |
| 348 XSetWindowAttributes swa; | 347 XSetWindowAttributes swa; |
| 349 memset(&swa, 0, sizeof(swa)); | 348 memset(&swa, 0, sizeof(swa)); |
| 350 swa.background_pixmap = None; | 349 swa.background_pixmap = None; |
| 351 xwindow_ = XCreateWindow( | 350 xwindow_ = XCreateWindow( |
| 352 xdisplay_, x_root_window_, | 351 xdisplay_, x_root_window_, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 374 if (base::MessagePumpForUI::HasXInput2()) | 373 if (base::MessagePumpForUI::HasXInput2()) |
| 375 ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_); | 374 ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_); |
| 376 | 375 |
| 377 SelectEventsForRootWindow(); | 376 SelectEventsForRootWindow(); |
| 378 | 377 |
| 379 // Get the initial size of the X root window. | 378 // Get the initial size of the X root window. |
| 380 XWindowAttributes attrs; | 379 XWindowAttributes attrs; |
| 381 XGetWindowAttributes(xdisplay_, x_root_window_, &attrs); | 380 XGetWindowAttributes(xdisplay_, x_root_window_, &attrs); |
| 382 x_root_bounds_.SetRect(attrs.x, attrs.y, attrs.width, attrs.height); | 381 x_root_bounds_.SetRect(attrs.x, attrs.y, attrs.width, attrs.height); |
| 383 | 382 |
| 384 invisible_cursor_ = ui::CreateInvisibleCursor(); | |
| 385 | |
| 386 // TODO(erg): We currently only request window deletion events. We also | 383 // TODO(erg): We currently only request window deletion events. We also |
| 387 // should listen for activation events and anything else that GTK+ listens | 384 // should listen for activation events and anything else that GTK+ listens |
| 388 // for, and do something useful. | 385 // for, and do something useful. |
| 389 ::Atom protocols[2]; | 386 ::Atom protocols[2]; |
| 390 protocols[0] = atom_cache_.GetAtom("WM_DELETE_WINDOW"); | 387 protocols[0] = atom_cache_.GetAtom("WM_DELETE_WINDOW"); |
| 391 protocols[1] = atom_cache_.GetAtom("_NET_WM_PING"); | 388 protocols[1] = atom_cache_.GetAtom("_NET_WM_PING"); |
| 392 XSetWMProtocols(xdisplay_, xwindow_, protocols, 2); | 389 XSetWMProtocols(xdisplay_, xwindow_, protocols, 2); |
| 393 | 390 |
| 394 // We need a WM_CLIENT_MACHINE and WM_LOCALE_NAME value so we integrate with | 391 // We need a WM_CLIENT_MACHINE and WM_LOCALE_NAME value so we integrate with |
| 395 // the desktop environment. | 392 // the desktop environment. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 416 RRScreenChangeNotifyMask | RROutputChangeNotifyMask); | 413 RRScreenChangeNotifyMask | RROutputChangeNotifyMask); |
| 417 } | 414 } |
| 418 | 415 |
| 419 RootWindowHostLinux::~RootWindowHostLinux() { | 416 RootWindowHostLinux::~RootWindowHostLinux() { |
| 420 base::MessagePumpAuraX11::Current()->RemoveDispatcherForRootWindow(this); | 417 base::MessagePumpAuraX11::Current()->RemoveDispatcherForRootWindow(this); |
| 421 base::MessagePumpAuraX11::Current()->RemoveDispatcherForWindow(xwindow_); | 418 base::MessagePumpAuraX11::Current()->RemoveDispatcherForWindow(xwindow_); |
| 422 | 419 |
| 423 UnConfineCursor(); | 420 UnConfineCursor(); |
| 424 | 421 |
| 425 XDestroyWindow(xdisplay_, xwindow_); | 422 XDestroyWindow(xdisplay_, xwindow_); |
| 426 | |
| 427 XFreeCursor(xdisplay_, invisible_cursor_); | |
| 428 } | 423 } |
| 429 | 424 |
| 430 bool RootWindowHostLinux::Dispatch(const base::NativeEvent& event) { | 425 bool RootWindowHostLinux::Dispatch(const base::NativeEvent& event) { |
| 431 XEvent* xev = event; | 426 XEvent* xev = event; |
| 432 | 427 |
| 433 CheckXEventForConsistency(xev); | 428 CheckXEventForConsistency(xev); |
| 434 | 429 |
| 435 if (FindEventTarget(event) == x_root_window_) | 430 if (FindEventTarget(event) == x_root_window_) |
| 436 return DispatchEventForRootWindow(event); | 431 return DispatchEventForRootWindow(event); |
| 437 | 432 |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 } | 787 } |
| 793 | 788 |
| 794 void RootWindowHostLinux::ReleaseCapture() { | 789 void RootWindowHostLinux::ReleaseCapture() { |
| 795 // TODO(oshima): Release x input. | 790 // TODO(oshima): Release x input. |
| 796 } | 791 } |
| 797 | 792 |
| 798 void RootWindowHostLinux::SetCursor(gfx::NativeCursor cursor) { | 793 void RootWindowHostLinux::SetCursor(gfx::NativeCursor cursor) { |
| 799 if (cursor == current_cursor_) | 794 if (cursor == current_cursor_) |
| 800 return; | 795 return; |
| 801 current_cursor_ = cursor; | 796 current_cursor_ = cursor; |
| 802 | 797 SetCursorInternal(cursor); |
| 803 if (cursor_shown_) | |
| 804 SetCursorInternal(cursor); | |
| 805 } | |
| 806 | |
| 807 void RootWindowHostLinux::ShowCursor(bool show) { | |
| 808 if (show == cursor_shown_) | |
| 809 return; | |
| 810 cursor_shown_ = show; | |
| 811 SetCursorInternal(show ? current_cursor_ : invisible_cursor_); | |
| 812 } | 798 } |
| 813 | 799 |
| 814 bool RootWindowHostLinux::QueryMouseLocation(gfx::Point* location_return) { | 800 bool RootWindowHostLinux::QueryMouseLocation(gfx::Point* location_return) { |
| 815 ::Window root_return, child_return; | 801 ::Window root_return, child_return; |
| 816 int root_x_return, root_y_return, win_x_return, win_y_return; | 802 int root_x_return, root_y_return, win_x_return, win_y_return; |
| 817 unsigned int mask_return; | 803 unsigned int mask_return; |
| 818 XQueryPointer(xdisplay_, | 804 XQueryPointer(xdisplay_, |
| 819 xwindow_, | 805 xwindow_, |
| 820 &root_return, | 806 &root_return, |
| 821 &child_return, | 807 &child_return, |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey)); | 1007 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey)); |
| 1022 } | 1008 } |
| 1023 | 1009 |
| 1024 // static | 1010 // static |
| 1025 gfx::Size RootWindowHost::GetNativeScreenSize() { | 1011 gfx::Size RootWindowHost::GetNativeScreenSize() { |
| 1026 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); | 1012 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); |
| 1027 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); | 1013 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); |
| 1028 } | 1014 } |
| 1029 | 1015 |
| 1030 } // namespace aura | 1016 } // namespace aura |
| OLD | NEW |