Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: ui/aura/root_window_host_linux.cc

Issue 9535025: Remove the singleton instance get/delete methods from RootWindow (yay) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/root_window_host_linux.h ('k') | ui/aura/test/aura_test_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 ExposureMask | VisibilityChangeMask | 298 ExposureMask | VisibilityChangeMask |
299 StructureNotifyMask | PropertyChangeMask | 299 StructureNotifyMask | PropertyChangeMask |
300 PointerMotionMask; 300 PointerMotionMask;
301 XSelectInput(xdisplay_, xwindow_, event_mask); 301 XSelectInput(xdisplay_, xwindow_, event_mask);
302 XSelectInput(xdisplay_, x_root_window_, StructureNotifyMask); 302 XSelectInput(xdisplay_, x_root_window_, StructureNotifyMask);
303 XFlush(xdisplay_); 303 XFlush(xdisplay_);
304 304
305 if (base::MessagePumpForUI::HasXInput2()) 305 if (base::MessagePumpForUI::HasXInput2())
306 ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_); 306 ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_);
307 307
308 MessageLoopForUI::current()->AddDestructionObserver(this);
309
310 // Initialize invisible cursor. 308 // Initialize invisible cursor.
311 char nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 309 char nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
312 XColor black; 310 XColor black;
313 black.red = black.green = black.blue = 0; 311 black.red = black.green = black.blue = 0;
314 Pixmap blank = XCreateBitmapFromData(xdisplay_, xwindow_, 312 Pixmap blank = XCreateBitmapFromData(xdisplay_, xwindow_,
315 nodata, 8, 8); 313 nodata, 8, 8);
316 invisible_cursor_ = XCreatePixmapCursor(xdisplay_, blank, blank, 314 invisible_cursor_ = XCreatePixmapCursor(xdisplay_, blank, blank,
317 &black, &black, 0, 0); 315 &black, &black, 0, 0);
318 if (RootWindow::hide_host_cursor()) 316 if (RootWindow::hide_host_cursor())
319 XDefineCursor(xdisplay_, x_root_window_, invisible_cursor_); 317 XDefineCursor(xdisplay_, x_root_window_, invisible_cursor_);
320 } 318 }
321 319
322 RootWindowHostLinux::~RootWindowHostLinux() { 320 RootWindowHostLinux::~RootWindowHostLinux() {
323 static_cast<DispatcherLinux*>(Env::GetInstance()->GetDispatcher())-> 321 static_cast<DispatcherLinux*>(Env::GetInstance()->GetDispatcher())->
324 RootWindowHostDestroying(xwindow_, x_root_window_); 322 RootWindowHostDestroying(xwindow_, x_root_window_);
325 XDestroyWindow(xdisplay_, xwindow_); 323 XDestroyWindow(xdisplay_, xwindow_);
326 324
327 // Clears XCursorCache. 325 // Clears XCursorCache.
328 ui::GetXCursor(ui::kCursorClearXCursorCache); 326 ui::GetXCursor(ui::kCursorClearXCursorCache);
329 327
330 XFreeCursor(xdisplay_, invisible_cursor_); 328 XFreeCursor(xdisplay_, invisible_cursor_);
331
332 MessageLoopForUI::current()->RemoveDestructionObserver(this);
333 } 329 }
334 330
335 base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( 331 base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch(
336 XEvent* xev) { 332 XEvent* xev) {
337 bool handled = false; 333 bool handled = false;
338 334
339 // See crbug.com/109884. 335 // See crbug.com/109884.
340 // CheckXEventForConsistency(xev); 336 // CheckXEventForConsistency(xev);
341 337
342 switch (xev->type) { 338 switch (xev->type) {
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 root_window_->ConvertPointToNativeScreen(&point); 613 root_window_->ConvertPointToNativeScreen(&point);
618 xevent.xmotion.x_root = point.x(); 614 xevent.xmotion.x_root = point.x();
619 xevent.xmotion.y_root = point.y(); 615 xevent.xmotion.y_root = point.y();
620 } 616 }
621 default: 617 default:
622 break; 618 break;
623 } 619 }
624 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent); 620 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent);
625 } 621 }
626 622
627 void RootWindowHostLinux::WillDestroyCurrentMessageLoop() {
628 aura::RootWindow::DeleteInstance();
629 }
630
631 bool RootWindowHostLinux::IsWindowManagerPresent() { 623 bool RootWindowHostLinux::IsWindowManagerPresent() {
632 // Per ICCCM 2.8, "Manager Selections", window managers should take ownership 624 // Per ICCCM 2.8, "Manager Selections", window managers should take ownership
633 // of WM_Sn selections (where n is a screen number). 625 // of WM_Sn selections (where n is a screen number).
634 ::Atom wm_s0_atom = XInternAtom(xdisplay_, "WM_S0", False); 626 ::Atom wm_s0_atom = XInternAtom(xdisplay_, "WM_S0", False);
635 return XGetSelectionOwner(xdisplay_, wm_s0_atom) != None; 627 return XGetSelectionOwner(xdisplay_, wm_s0_atom) != None;
636 } 628 }
637 629
638 void RootWindowHostLinux::SetCursorInternal(gfx::NativeCursor cursor) { 630 void RootWindowHostLinux::SetCursorInternal(gfx::NativeCursor cursor) {
639 ::Cursor xcursor = 631 ::Cursor xcursor =
640 cursor == kCursorNone ? 632 cursor == kCursorNone ?
641 invisible_cursor_ : 633 invisible_cursor_ :
642 ui::GetXCursor(CursorShapeFromNative(cursor)); 634 ui::GetXCursor(CursorShapeFromNative(cursor));
643 XDefineCursor(xdisplay_, xwindow_, xcursor); 635 XDefineCursor(xdisplay_, xwindow_, xcursor);
644 } 636 }
645 637
646 // static 638 // static
647 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { 639 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) {
648 return new RootWindowHostLinux(bounds); 640 return new RootWindowHostLinux(bounds);
649 } 641 }
650 642
651 // static 643 // static
652 gfx::Size RootWindowHost::GetNativeScreenSize() { 644 gfx::Size RootWindowHost::GetNativeScreenSize() {
653 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); 645 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay();
654 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); 646 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
655 } 647 }
656 648
657 } // namespace aura 649 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window_host_linux.h ('k') | ui/aura/test/aura_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698