OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/desktop_host.h" | 5 #include "ui/aura/root_window_host.h" |
6 | 6 |
7 #include <X11/cursorfont.h> | 7 #include <X11/cursorfont.h> |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 | 9 |
10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. | 10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. |
11 #undef RootWindow | 11 #undef RootWindow |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 | 14 |
15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
16 #include "base/message_pump_x.h" | 16 #include "base/message_pump_x.h" |
17 #include "ui/aura/cursor.h" | 17 #include "ui/aura/cursor.h" |
18 #include "ui/aura/desktop.h" | |
19 #include "ui/aura/event.h" | 18 #include "ui/aura/event.h" |
| 19 #include "ui/aura/root_window.h" |
20 #include "ui/base/keycodes/keyboard_codes.h" | 20 #include "ui/base/keycodes/keyboard_codes.h" |
21 #include "ui/base/touch/touch_factory.h" | 21 #include "ui/base/touch/touch_factory.h" |
22 #include "ui/base/x/x11_util.h" | 22 #include "ui/base/x/x11_util.h" |
23 #include "ui/gfx/compositor/layer.h" | 23 #include "ui/gfx/compositor/layer.h" |
24 | 24 |
25 #include <X11/cursorfont.h> | 25 #include <X11/cursorfont.h> |
26 #include <X11/extensions/XInput2.h> | 26 #include <X11/extensions/XInput2.h> |
27 #include <X11/Xlib.h> | 27 #include <X11/Xlib.h> |
28 | 28 |
29 using std::max; | 29 using std::max; |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 case ui::VKEY_OEM_PLUS: | 264 case ui::VKEY_OEM_PLUS: |
265 case ui::VKEY_OEM_COMMA: | 265 case ui::VKEY_OEM_COMMA: |
266 case ui::VKEY_OEM_MINUS: | 266 case ui::VKEY_OEM_MINUS: |
267 case ui::VKEY_OEM_PERIOD: | 267 case ui::VKEY_OEM_PERIOD: |
268 return true; | 268 return true; |
269 default: | 269 default: |
270 return false; | 270 return false; |
271 } | 271 } |
272 } | 272 } |
273 | 273 |
274 class DesktopHostLinux : public DesktopHost, | 274 class RootWindowHostLinux : public RootWindowHost, |
275 public MessageLoop::DestructionObserver { | 275 public MessageLoop::DestructionObserver { |
276 public: | 276 public: |
277 explicit DesktopHostLinux(const gfx::Rect& bounds); | 277 explicit RootWindowHostLinux(const gfx::Rect& bounds); |
278 virtual ~DesktopHostLinux(); | 278 virtual ~RootWindowHostLinux(); |
279 | 279 |
280 private: | 280 private: |
281 // MessageLoop::Dispatcher Override. | 281 // MessageLoop::Dispatcher Override. |
282 virtual DispatchStatus Dispatch(XEvent* xev) OVERRIDE; | 282 virtual DispatchStatus Dispatch(XEvent* xev) OVERRIDE; |
283 | 283 |
284 // DesktopHost Overrides. | 284 // RootWindowHost Overrides. |
285 virtual void SetDesktop(Desktop* desktop) OVERRIDE; | 285 virtual void SetRootWindow(RootWindow* root_window) OVERRIDE; |
286 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; | 286 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; |
287 virtual void Show() OVERRIDE; | 287 virtual void Show() OVERRIDE; |
288 virtual void ToggleFullScreen() OVERRIDE; | 288 virtual void ToggleFullScreen() OVERRIDE; |
289 virtual gfx::Size GetSize() const OVERRIDE; | 289 virtual gfx::Size GetSize() const OVERRIDE; |
290 virtual void SetSize(const gfx::Size& size) OVERRIDE; | 290 virtual void SetSize(const gfx::Size& size) OVERRIDE; |
291 virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; | 291 virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; |
292 virtual void SetCursor(gfx::NativeCursor cursor_type) OVERRIDE; | 292 virtual void SetCursor(gfx::NativeCursor cursor_type) OVERRIDE; |
293 virtual gfx::Point QueryMouseLocation() OVERRIDE; | 293 virtual gfx::Point QueryMouseLocation() OVERRIDE; |
294 virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE; | 294 virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE; |
295 | 295 |
296 // MessageLoop::DestructionObserver Overrides. | 296 // MessageLoop::DestructionObserver Overrides. |
297 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | 297 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; |
298 | 298 |
299 // Returns true if there's an X window manager present... in most cases. Some | 299 // Returns true if there's an X window manager present... in most cases. Some |
300 // window managers (notably, ion3) don't implement enough of ICCCM for us to | 300 // window managers (notably, ion3) don't implement enough of ICCCM for us to |
301 // detect that they're there. | 301 // detect that they're there. |
302 bool IsWindowManagerPresent(); | 302 bool IsWindowManagerPresent(); |
303 | 303 |
304 Desktop* desktop_; | 304 RootWindow* root_window_; |
305 | 305 |
306 // The display and the native X window hosting the desktop. | 306 // The display and the native X window hosting the root window. |
307 Display* xdisplay_; | 307 Display* xdisplay_; |
308 ::Window xwindow_; | 308 ::Window xwindow_; |
309 | 309 |
310 // The native root window. | 310 // The native root window. |
311 ::Window root_window_; | 311 ::Window x_root_window_; |
312 | 312 |
313 // Current Aura cursor. | 313 // Current Aura cursor. |
314 gfx::NativeCursor current_cursor_; | 314 gfx::NativeCursor current_cursor_; |
315 | 315 |
316 // The bounds of |xwindow_|. | 316 // The bounds of |xwindow_|. |
317 gfx::Rect bounds_; | 317 gfx::Rect bounds_; |
318 | 318 |
319 DISALLOW_COPY_AND_ASSIGN(DesktopHostLinux); | 319 DISALLOW_COPY_AND_ASSIGN(RootWindowHostLinux); |
320 }; | 320 }; |
321 | 321 |
322 DesktopHostLinux::DesktopHostLinux(const gfx::Rect& bounds) | 322 RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds) |
323 : desktop_(NULL), | 323 : root_window_(NULL), |
324 xdisplay_(base::MessagePumpX::GetDefaultXDisplay()), | 324 xdisplay_(base::MessagePumpX::GetDefaultXDisplay()), |
325 xwindow_(0), | 325 xwindow_(0), |
326 root_window_(DefaultRootWindow(xdisplay_)), | 326 x_root_window_(DefaultRootWindow(xdisplay_)), |
327 current_cursor_(aura::kCursorNull), | 327 current_cursor_(aura::kCursorNull), |
328 bounds_(bounds) { | 328 bounds_(bounds) { |
329 xwindow_ = XCreateSimpleWindow(xdisplay_, root_window_, | 329 xwindow_ = XCreateSimpleWindow(xdisplay_, x_root_window_, |
330 bounds.x(), bounds.y(), | 330 bounds.x(), bounds.y(), |
331 bounds.width(), bounds.height(), | 331 bounds.width(), bounds.height(), |
332 0, 0, 0); | 332 0, 0, 0); |
333 | 333 |
334 long event_mask = ButtonPressMask | ButtonReleaseMask | | 334 long event_mask = ButtonPressMask | ButtonReleaseMask | |
335 KeyPressMask | KeyReleaseMask | | 335 KeyPressMask | KeyReleaseMask | |
336 EnterWindowMask | LeaveWindowMask | | 336 EnterWindowMask | LeaveWindowMask | |
337 ExposureMask | VisibilityChangeMask | | 337 ExposureMask | VisibilityChangeMask | |
338 StructureNotifyMask | PropertyChangeMask | | 338 StructureNotifyMask | PropertyChangeMask | |
339 PointerMotionMask; | 339 PointerMotionMask; |
340 XSelectInput(xdisplay_, xwindow_, event_mask); | 340 XSelectInput(xdisplay_, xwindow_, event_mask); |
341 XSelectInput(xdisplay_, root_window_, StructureNotifyMask); | 341 XSelectInput(xdisplay_, x_root_window_, StructureNotifyMask); |
342 XFlush(xdisplay_); | 342 XFlush(xdisplay_); |
343 | 343 |
344 // TODO(sad): Re-enable once crbug.com/106516 is fixed. | 344 // TODO(sad): Re-enable once crbug.com/106516 is fixed. |
345 #if 0 | 345 #if 0 |
346 if (base::MessagePumpForUI::HasXInput2()) | 346 if (base::MessagePumpForUI::HasXInput2()) |
347 ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_); | 347 ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_); |
348 #endif | 348 #endif |
349 | 349 |
350 base::MessagePumpX::SetDefaultDispatcher(this); | 350 base::MessagePumpX::SetDefaultDispatcher(this); |
351 MessageLoopForUI::current()->AddDestructionObserver(this); | 351 MessageLoopForUI::current()->AddDestructionObserver(this); |
352 } | 352 } |
353 | 353 |
354 DesktopHostLinux::~DesktopHostLinux() { | 354 RootWindowHostLinux::~RootWindowHostLinux() { |
355 XDestroyWindow(xdisplay_, xwindow_); | 355 XDestroyWindow(xdisplay_, xwindow_); |
356 | 356 |
357 // Clears XCursorCache. | 357 // Clears XCursorCache. |
358 ui::GetXCursor(ui::kCursorClearXCursorCache); | 358 ui::GetXCursor(ui::kCursorClearXCursorCache); |
359 | 359 |
360 MessageLoopForUI::current()->RemoveDestructionObserver(this); | 360 MessageLoopForUI::current()->RemoveDestructionObserver(this); |
361 base::MessagePumpX::SetDefaultDispatcher(NULL); | 361 base::MessagePumpX::SetDefaultDispatcher(NULL); |
362 } | 362 } |
363 | 363 |
364 base::MessagePumpDispatcher::DispatchStatus DesktopHostLinux::Dispatch( | 364 base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( |
365 XEvent* xev) { | 365 XEvent* xev) { |
366 bool handled = false; | 366 bool handled = false; |
367 | 367 |
368 CheckXEventForConsistency(xev); | 368 CheckXEventForConsistency(xev); |
369 | 369 |
370 switch (xev->type) { | 370 switch (xev->type) { |
371 case Expose: | 371 case Expose: |
372 desktop_->ScheduleDraw(); | 372 root_window_->ScheduleDraw(); |
373 handled = true; | 373 handled = true; |
374 break; | 374 break; |
375 case KeyPress: { | 375 case KeyPress: { |
376 KeyEvent keydown_event(xev, false); | 376 KeyEvent keydown_event(xev, false); |
377 handled = desktop_->DispatchKeyEvent(&keydown_event); | 377 handled = root_window_->DispatchKeyEvent(&keydown_event); |
378 if (ShouldSendCharEventForKeyboardCode(keydown_event.key_code())) { | 378 if (ShouldSendCharEventForKeyboardCode(keydown_event.key_code())) { |
379 KeyEvent char_event(xev, true); | 379 KeyEvent char_event(xev, true); |
380 handled |= desktop_->DispatchKeyEvent(&char_event); | 380 handled |= root_window_->DispatchKeyEvent(&char_event); |
381 } | 381 } |
382 break; | 382 break; |
383 } | 383 } |
384 case KeyRelease: { | 384 case KeyRelease: { |
385 KeyEvent keyup_event(xev, false); | 385 KeyEvent keyup_event(xev, false); |
386 handled = desktop_->DispatchKeyEvent(&keyup_event); | 386 handled = root_window_->DispatchKeyEvent(&keyup_event); |
387 break; | 387 break; |
388 } | 388 } |
389 case ButtonPress: | 389 case ButtonPress: |
390 case ButtonRelease: { | 390 case ButtonRelease: { |
391 MouseEvent mouseev(xev); | 391 MouseEvent mouseev(xev); |
392 handled = desktop_->DispatchMouseEvent(&mouseev); | 392 handled = root_window_->DispatchMouseEvent(&mouseev); |
393 break; | 393 break; |
394 } | 394 } |
395 case ConfigureNotify: { | 395 case ConfigureNotify: { |
396 if (xev->xconfigure.window == root_window_) { | 396 if (xev->xconfigure.window == x_root_window_) { |
397 desktop_->OnNativeScreenResized( | 397 root_window_->OnNativeScreenResized( |
398 gfx::Size(xev->xconfigure.width, xev->xconfigure.height)); | 398 gfx::Size(xev->xconfigure.width, xev->xconfigure.height)); |
399 handled = true; | 399 handled = true; |
400 break; | 400 break; |
401 } | 401 } |
402 | 402 |
403 DCHECK_EQ(xwindow_, xev->xconfigure.window); | 403 DCHECK_EQ(xwindow_, xev->xconfigure.window); |
404 DCHECK_EQ(xwindow_, xev->xconfigure.event); | 404 DCHECK_EQ(xwindow_, xev->xconfigure.event); |
405 | 405 |
406 // It's possible that the X window may be resized by some other means than | 406 // It's possible that the X window may be resized by some other means than |
407 // from within aura (e.g. the X window manager can change the size). Make | 407 // from within aura (e.g. the X window manager can change the size). Make |
408 // sure the desktop size is maintained properly. | 408 // sure the root window size is maintained properly. |
409 gfx::Rect bounds(xev->xconfigure.x, xev->xconfigure.y, | 409 gfx::Rect bounds(xev->xconfigure.x, xev->xconfigure.y, |
410 xev->xconfigure.width, xev->xconfigure.height); | 410 xev->xconfigure.width, xev->xconfigure.height); |
411 bool size_changed = bounds_.size() != bounds.size(); | 411 bool size_changed = bounds_.size() != bounds.size(); |
412 bounds_ = bounds; | 412 bounds_ = bounds; |
413 if (size_changed) | 413 if (size_changed) |
414 desktop_->OnHostResized(bounds.size()); | 414 root_window_->OnHostResized(bounds.size()); |
415 handled = true; | 415 handled = true; |
416 break; | 416 break; |
417 } | 417 } |
418 case GenericEvent: { | 418 case GenericEvent: { |
419 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); | 419 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); |
420 if (!factory->ShouldProcessXI2Event(xev)) | 420 if (!factory->ShouldProcessXI2Event(xev)) |
421 break; | 421 break; |
422 | 422 |
423 // If this is a motion event we want to coalesce all pending motion | 423 // If this is a motion event we want to coalesce all pending motion |
424 // events that are at the top of the queue. | 424 // events that are at the top of the queue. |
425 XEvent last_event; | 425 XEvent last_event; |
426 int num_coalesced = 0; | 426 int num_coalesced = 0; |
427 if (xev->xgeneric.evtype == XI_Motion) { | 427 if (xev->xgeneric.evtype == XI_Motion) { |
428 num_coalesced = CoalescePendingXIMotionEvents(xev, &last_event); | 428 num_coalesced = CoalescePendingXIMotionEvents(xev, &last_event); |
429 if (num_coalesced > 0) | 429 if (num_coalesced > 0) |
430 xev = &last_event; | 430 xev = &last_event; |
431 } | 431 } |
432 | 432 |
433 ui::EventType type = ui::EventTypeFromNative(xev); | 433 ui::EventType type = ui::EventTypeFromNative(xev); |
434 switch (type) { | 434 switch (type) { |
435 case ui::ET_TOUCH_PRESSED: | 435 case ui::ET_TOUCH_PRESSED: |
436 case ui::ET_TOUCH_RELEASED: | 436 case ui::ET_TOUCH_RELEASED: |
437 case ui::ET_TOUCH_MOVED: { | 437 case ui::ET_TOUCH_MOVED: { |
438 TouchEvent touchev(xev); | 438 TouchEvent touchev(xev); |
439 handled = desktop_->DispatchTouchEvent(&touchev); | 439 handled = root_window_->DispatchTouchEvent(&touchev); |
440 break; | 440 break; |
441 } | 441 } |
442 case ui::ET_MOUSE_PRESSED: | 442 case ui::ET_MOUSE_PRESSED: |
443 case ui::ET_MOUSE_RELEASED: | 443 case ui::ET_MOUSE_RELEASED: |
444 case ui::ET_MOUSE_MOVED: | 444 case ui::ET_MOUSE_MOVED: |
445 case ui::ET_MOUSE_DRAGGED: | 445 case ui::ET_MOUSE_DRAGGED: |
446 case ui::ET_MOUSEWHEEL: | 446 case ui::ET_MOUSEWHEEL: |
447 case ui::ET_MOUSE_ENTERED: | 447 case ui::ET_MOUSE_ENTERED: |
448 case ui::ET_MOUSE_EXITED: { | 448 case ui::ET_MOUSE_EXITED: { |
449 MouseEvent mouseev(xev); | 449 MouseEvent mouseev(xev); |
450 handled = desktop_->DispatchMouseEvent(&mouseev); | 450 handled = root_window_->DispatchMouseEvent(&mouseev); |
451 break; | 451 break; |
452 } | 452 } |
453 case ui::ET_UNKNOWN: | 453 case ui::ET_UNKNOWN: |
454 handled = false; | 454 handled = false; |
455 break; | 455 break; |
456 default: | 456 default: |
457 NOTREACHED(); | 457 NOTREACHED(); |
458 } | 458 } |
459 | 459 |
460 // If we coalesced an event we need to free its cookie. | 460 // If we coalesced an event we need to free its cookie. |
(...skipping 27 matching lines...) Expand all Loading... |
488 next_event.xmotion.subwindow == xev->xmotion.subwindow && | 488 next_event.xmotion.subwindow == xev->xmotion.subwindow && |
489 next_event.xmotion.state == xev->xmotion.state) { | 489 next_event.xmotion.state == xev->xmotion.state) { |
490 XNextEvent(xev->xany.display, &last_event); | 490 XNextEvent(xev->xany.display, &last_event); |
491 xev = &last_event; | 491 xev = &last_event; |
492 } else { | 492 } else { |
493 break; | 493 break; |
494 } | 494 } |
495 } | 495 } |
496 | 496 |
497 MouseEvent mouseev(xev); | 497 MouseEvent mouseev(xev); |
498 handled = desktop_->DispatchMouseEvent(&mouseev); | 498 handled = root_window_->DispatchMouseEvent(&mouseev); |
499 break; | 499 break; |
500 } | 500 } |
501 } | 501 } |
502 return handled ? EVENT_PROCESSED : EVENT_IGNORED; | 502 return handled ? EVENT_PROCESSED : EVENT_IGNORED; |
503 } | 503 } |
504 | 504 |
505 void DesktopHostLinux::SetDesktop(Desktop* desktop) { | 505 void RootWindowHostLinux::SetRootWindow(RootWindow* root_window) { |
506 desktop_ = desktop; | 506 root_window_ = root_window; |
507 } | 507 } |
508 | 508 |
509 gfx::AcceleratedWidget DesktopHostLinux::GetAcceleratedWidget() { | 509 gfx::AcceleratedWidget RootWindowHostLinux::GetAcceleratedWidget() { |
510 return xwindow_; | 510 return xwindow_; |
511 } | 511 } |
512 | 512 |
513 void DesktopHostLinux::Show() { | 513 void RootWindowHostLinux::Show() { |
514 XMapWindow(xdisplay_, xwindow_); | 514 XMapWindow(xdisplay_, xwindow_); |
515 } | 515 } |
516 | 516 |
517 void DesktopHostLinux::ToggleFullScreen() { | 517 void RootWindowHostLinux::ToggleFullScreen() { |
518 NOTIMPLEMENTED(); | 518 NOTIMPLEMENTED(); |
519 } | 519 } |
520 | 520 |
521 gfx::Size DesktopHostLinux::GetSize() const { | 521 gfx::Size RootWindowHostLinux::GetSize() const { |
522 return bounds_.size(); | 522 return bounds_.size(); |
523 } | 523 } |
524 | 524 |
525 void DesktopHostLinux::SetSize(const gfx::Size& size) { | 525 void RootWindowHostLinux::SetSize(const gfx::Size& size) { |
526 if (size == bounds_.size()) | 526 if (size == bounds_.size()) |
527 return; | 527 return; |
528 | 528 |
529 XResizeWindow(xdisplay_, xwindow_, size.width(), size.height()); | 529 XResizeWindow(xdisplay_, xwindow_, size.width(), size.height()); |
530 | 530 |
531 // Assume that the resize will go through as requested, which should be the | 531 // Assume that the resize will go through as requested, which should be the |
532 // case if we're running without a window manager. If there's a window | 532 // case if we're running without a window manager. If there's a window |
533 // manager, it can modify or ignore the request, but (per ICCCM) we'll get a | 533 // manager, it can modify or ignore the request, but (per ICCCM) we'll get a |
534 // (possibly synthetic) ConfigureNotify about the actual size and correct | 534 // (possibly synthetic) ConfigureNotify about the actual size and correct |
535 // |bounds_| later. | 535 // |bounds_| later. |
536 bounds_.set_size(size); | 536 bounds_.set_size(size); |
537 desktop_->OnHostResized(size); | 537 root_window_->OnHostResized(size); |
538 } | 538 } |
539 | 539 |
540 gfx::Point DesktopHostLinux::GetLocationOnNativeScreen() const { | 540 gfx::Point RootWindowHostLinux::GetLocationOnNativeScreen() const { |
541 return bounds_.origin(); | 541 return bounds_.origin(); |
542 } | 542 } |
543 | 543 |
544 void DesktopHostLinux::SetCursor(gfx::NativeCursor cursor) { | 544 void RootWindowHostLinux::SetCursor(gfx::NativeCursor cursor) { |
545 if (current_cursor_ == cursor) | 545 if (current_cursor_ == cursor) |
546 return; | 546 return; |
547 current_cursor_ = cursor; | 547 current_cursor_ = cursor; |
548 // Custom web cursors are handled directly. | 548 // Custom web cursors are handled directly. |
549 if (cursor == kCursorCustom) | 549 if (cursor == kCursorCustom) |
550 return; | 550 return; |
551 int cursor_shape = CursorShapeFromNative(cursor); | 551 int cursor_shape = CursorShapeFromNative(cursor); |
552 ::Cursor xcursor = ui::GetXCursor(cursor_shape); | 552 ::Cursor xcursor = ui::GetXCursor(cursor_shape); |
553 XDefineCursor(xdisplay_, xwindow_, xcursor); | 553 XDefineCursor(xdisplay_, xwindow_, xcursor); |
554 } | 554 } |
555 | 555 |
556 gfx::Point DesktopHostLinux::QueryMouseLocation() { | 556 gfx::Point RootWindowHostLinux::QueryMouseLocation() { |
557 ::Window root_return, child_return; | 557 ::Window root_return, child_return; |
558 int root_x_return, root_y_return, win_x_return, win_y_return; | 558 int root_x_return, root_y_return, win_x_return, win_y_return; |
559 unsigned int mask_return; | 559 unsigned int mask_return; |
560 XQueryPointer(xdisplay_, | 560 XQueryPointer(xdisplay_, |
561 xwindow_, | 561 xwindow_, |
562 &root_return, | 562 &root_return, |
563 &child_return, | 563 &child_return, |
564 &root_x_return, &root_y_return, | 564 &root_x_return, &root_y_return, |
565 &win_x_return, &win_y_return, | 565 &win_x_return, &win_y_return, |
566 &mask_return); | 566 &mask_return); |
567 return gfx::Point(max(0, min(bounds_.width(), win_x_return)), | 567 return gfx::Point(max(0, min(bounds_.width(), win_x_return)), |
568 max(0, min(bounds_.height(), win_y_return))); | 568 max(0, min(bounds_.height(), win_y_return))); |
569 } | 569 } |
570 | 570 |
571 void DesktopHostLinux::PostNativeEvent(const base::NativeEvent& native_event) { | 571 void RootWindowHostLinux::PostNativeEvent( |
| 572 const base::NativeEvent& native_event) { |
572 DCHECK(xwindow_); | 573 DCHECK(xwindow_); |
573 DCHECK(xdisplay_); | 574 DCHECK(xdisplay_); |
574 XEvent xevent = *native_event; | 575 XEvent xevent = *native_event; |
575 xevent.xany.display = xdisplay_; | 576 xevent.xany.display = xdisplay_; |
576 xevent.xany.window = xwindow_; | 577 xevent.xany.window = xwindow_; |
577 | 578 |
578 switch (xevent.type) { | 579 switch (xevent.type) { |
579 case EnterNotify: | 580 case EnterNotify: |
580 case LeaveNotify: | 581 case LeaveNotify: |
581 case MotionNotify: | 582 case MotionNotify: |
582 case KeyPress: | 583 case KeyPress: |
583 case KeyRelease: | 584 case KeyRelease: |
584 case ButtonPress: | 585 case ButtonPress: |
585 case ButtonRelease: { | 586 case ButtonRelease: { |
586 // The fields used below are in the same place for all of events | 587 // The fields used below are in the same place for all of events |
587 // above. Using xmotion from XEvent's unions to avoid repeating | 588 // above. Using xmotion from XEvent's unions to avoid repeating |
588 // the code. | 589 // the code. |
589 xevent.xmotion.root = root_window_; | 590 xevent.xmotion.root = x_root_window_; |
590 xevent.xmotion.time = CurrentTime; | 591 xevent.xmotion.time = CurrentTime; |
591 | 592 |
592 gfx::Point point(xevent.xmotion.x, xevent.xmotion.y); | 593 gfx::Point point(xevent.xmotion.x, xevent.xmotion.y); |
593 desktop_->ConvertPointToNativeScreen(&point); | 594 root_window_->ConvertPointToNativeScreen(&point); |
594 xevent.xmotion.x_root = point.x(); | 595 xevent.xmotion.x_root = point.x(); |
595 xevent.xmotion.y_root = point.y(); | 596 xevent.xmotion.y_root = point.y(); |
596 } | 597 } |
597 default: | 598 default: |
598 break; | 599 break; |
599 } | 600 } |
600 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent); | 601 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent); |
601 } | 602 } |
602 | 603 |
603 void DesktopHostLinux::WillDestroyCurrentMessageLoop() { | 604 void RootWindowHostLinux::WillDestroyCurrentMessageLoop() { |
604 aura::Desktop::DeleteInstance(); | 605 aura::RootWindow::DeleteInstance(); |
605 } | 606 } |
606 | 607 |
607 bool DesktopHostLinux::IsWindowManagerPresent() { | 608 bool RootWindowHostLinux::IsWindowManagerPresent() { |
608 // Per ICCCM 2.8, "Manager Selections", window managers should take ownership | 609 // Per ICCCM 2.8, "Manager Selections", window managers should take ownership |
609 // of WM_Sn selections (where n is a screen number). | 610 // of WM_Sn selections (where n is a screen number). |
610 ::Atom wm_s0_atom = XInternAtom(xdisplay_, "WM_S0", False); | 611 ::Atom wm_s0_atom = XInternAtom(xdisplay_, "WM_S0", False); |
611 return XGetSelectionOwner(xdisplay_, wm_s0_atom) != None; | 612 return XGetSelectionOwner(xdisplay_, wm_s0_atom) != None; |
612 } | 613 } |
613 | 614 |
614 } // namespace | 615 } // namespace |
615 | 616 |
616 // static | 617 // static |
617 DesktopHost* DesktopHost::Create(const gfx::Rect& bounds) { | 618 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { |
618 return new DesktopHostLinux(bounds); | 619 return new RootWindowHostLinux(bounds); |
619 } | 620 } |
620 | 621 |
621 // static | 622 // static |
622 gfx::Size DesktopHost::GetNativeScreenSize() { | 623 gfx::Size RootWindowHost::GetNativeScreenSize() { |
623 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); | 624 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); |
624 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); | 625 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); |
625 } | 626 } |
626 | 627 |
627 } // namespace aura | 628 } // namespace aura |
OLD | NEW |