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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc

Issue 924853002: linux/x11: Fix setting window bounds in High DPI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 10 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
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h ('k') | no next file » | 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/views/widget/desktop_aura/desktop_window_tree_host_x11.h" 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
6 6
7 #include <X11/extensions/shape.h> 7 #include <X11/extensions/shape.h>
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <X11/Xatom.h> 9 #include <X11/Xatom.h>
10 #include <X11/Xregion.h> 10 #include <X11/Xregion.h>
(...skipping 14 matching lines...) Expand all
25 #include "ui/base/hit_test.h" 25 #include "ui/base/hit_test.h"
26 #include "ui/base/x/x11_util.h" 26 #include "ui/base/x/x11_util.h"
27 #include "ui/events/devices/x11/device_data_manager_x11.h" 27 #include "ui/events/devices/x11/device_data_manager_x11.h"
28 #include "ui/events/devices/x11/device_list_cache_x11.h" 28 #include "ui/events/devices/x11/device_list_cache_x11.h"
29 #include "ui/events/devices/x11/touch_factory_x11.h" 29 #include "ui/events/devices/x11/touch_factory_x11.h"
30 #include "ui/events/event_utils.h" 30 #include "ui/events/event_utils.h"
31 #include "ui/events/platform/platform_event_source.h" 31 #include "ui/events/platform/platform_event_source.h"
32 #include "ui/events/platform/x11/x11_event_source.h" 32 #include "ui/events/platform/x11/x11_event_source.h"
33 #include "ui/gfx/display.h" 33 #include "ui/gfx/display.h"
34 #include "ui/gfx/geometry/insets.h" 34 #include "ui/gfx/geometry/insets.h"
35 #include "ui/gfx/geometry/size_conversions.h"
35 #include "ui/gfx/image/image_skia.h" 36 #include "ui/gfx/image/image_skia.h"
36 #include "ui/gfx/image/image_skia_rep.h" 37 #include "ui/gfx/image/image_skia_rep.h"
37 #include "ui/gfx/path.h" 38 #include "ui/gfx/path.h"
38 #include "ui/gfx/path_x11.h" 39 #include "ui/gfx/path_x11.h"
39 #include "ui/gfx/screen.h" 40 #include "ui/gfx/screen.h"
40 #include "ui/native_theme/native_theme.h" 41 #include "ui/native_theme/native_theme.h"
41 #include "ui/views/corewm/tooltip_aura.h" 42 #include "ui/views/corewm/tooltip_aura.h"
42 #include "ui/views/ime/input_method.h" 43 #include "ui/views/ime/input_method.h"
43 #include "ui/views/linux_ui/linux_ui.h" 44 #include "ui/views/linux_ui/linux_ui.h"
44 #include "ui/views/views_delegate.h" 45 #include "ui/views/views_delegate.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 std::vector<aura::Window*> DesktopWindowTreeHostX11::GetAllOpenWindows() { 184 std::vector<aura::Window*> DesktopWindowTreeHostX11::GetAllOpenWindows() {
184 std::vector<aura::Window*> windows(open_windows().size()); 185 std::vector<aura::Window*> windows(open_windows().size());
185 std::transform(open_windows().begin(), 186 std::transform(open_windows().begin(),
186 open_windows().end(), 187 open_windows().end(),
187 windows.begin(), 188 windows.begin(),
188 GetContentWindowForXID); 189 GetContentWindowForXID);
189 return windows; 190 return windows;
190 } 191 }
191 192
192 gfx::Rect DesktopWindowTreeHostX11::GetX11RootWindowBounds() const { 193 gfx::Rect DesktopWindowTreeHostX11::GetX11RootWindowBounds() const {
193 return bounds_; 194 return bounds_in_pixels_;
194 } 195 }
195 196
196 gfx::Rect DesktopWindowTreeHostX11::GetX11RootWindowOuterBounds() const { 197 gfx::Rect DesktopWindowTreeHostX11::GetX11RootWindowOuterBounds() const {
197 gfx::Rect outer_bounds(bounds_); 198 gfx::Rect outer_bounds(bounds_in_pixels_);
198 outer_bounds.Inset(-native_window_frame_borders_); 199 outer_bounds.Inset(-native_window_frame_borders_);
199 return outer_bounds; 200 return outer_bounds;
200 } 201 }
201 202
202 ::Region DesktopWindowTreeHostX11::GetWindowShape() const { 203 ::Region DesktopWindowTreeHostX11::GetWindowShape() const {
203 return window_shape_; 204 return window_shape_;
204 } 205 }
205 206
206 void DesktopWindowTreeHostX11::HandleNativeWidgetActivationChanged( 207 void DesktopWindowTreeHostX11::HandleNativeWidgetActivationChanged(
207 bool active) { 208 bool active) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 Activate(); 376 Activate();
376 } 377 }
377 378
378 native_widget_delegate_->AsWidget()->SetInitialFocus(show_state); 379 native_widget_delegate_->AsWidget()->SetInitialFocus(show_state);
379 } 380 }
380 381
381 void DesktopWindowTreeHostX11::ShowMaximizedWithBounds( 382 void DesktopWindowTreeHostX11::ShowMaximizedWithBounds(
382 const gfx::Rect& restored_bounds) { 383 const gfx::Rect& restored_bounds) {
383 ShowWindowWithState(ui::SHOW_STATE_MAXIMIZED); 384 ShowWindowWithState(ui::SHOW_STATE_MAXIMIZED);
384 // Enforce |restored_bounds_| since calling Maximize() could have reset it. 385 // Enforce |restored_bounds_| since calling Maximize() could have reset it.
385 restored_bounds_ = restored_bounds; 386 restored_bounds_ = ToPixelRect(restored_bounds);
386 } 387 }
387 388
388 bool DesktopWindowTreeHostX11::IsVisible() const { 389 bool DesktopWindowTreeHostX11::IsVisible() const {
389 return window_mapped_; 390 return window_mapped_;
390 } 391 }
391 392
392 void DesktopWindowTreeHostX11::SetSize(const gfx::Size& requested_size) { 393 void DesktopWindowTreeHostX11::SetSize(const gfx::Size& requested_size) {
393 gfx::Size size = AdjustSize(requested_size); 394 gfx::Size size_in_pixels = ToPixelRect(gfx::Rect(requested_size)).size();
394 bool size_changed = bounds_.size() != size; 395 size_in_pixels = AdjustSize(size_in_pixels);
395 XResizeWindow(xdisplay_, xwindow_, size.width(), size.height()); 396 bool size_changed = bounds_in_pixels_.size() != size_in_pixels;
396 bounds_.set_size(size); 397 XResizeWindow(xdisplay_, xwindow_, size_in_pixels.width(),
398 size_in_pixels.height());
399 bounds_in_pixels_.set_size(size_in_pixels);
397 if (size_changed) { 400 if (size_changed) {
398 OnHostResized(size); 401 OnHostResized(size_in_pixels);
399 ResetWindowRegion(); 402 ResetWindowRegion();
400 } 403 }
401 } 404 }
402 405
403 void DesktopWindowTreeHostX11::StackAtTop() { 406 void DesktopWindowTreeHostX11::StackAtTop() {
404 XRaiseWindow(xdisplay_, xwindow_); 407 XRaiseWindow(xdisplay_, xwindow_);
405 } 408 }
406 409
407 void DesktopWindowTreeHostX11::CenterWindow(const gfx::Size& size) { 410 void DesktopWindowTreeHostX11::CenterWindow(const gfx::Size& size) {
408 gfx::Rect parent_bounds = GetWorkAreaBoundsInScreen(); 411 gfx::Size size_in_pixels = ToPixelRect(gfx::Rect(size)).size();
412 gfx::Rect parent_bounds_in_pixels = GetWorkAreaBoundsInPixels();
409 413
410 // If |window_|'s transient parent bounds are big enough to contain |size|, 414 // If |window_|'s transient parent bounds are big enough to contain
411 // use them instead. 415 // |size_in_pixels|, use them instead.
412 if (wm::GetTransientParent(content_window_)) { 416 if (wm::GetTransientParent(content_window_)) {
413 gfx::Rect transient_parent_rect = 417 gfx::Rect transient_parent_rect =
414 wm::GetTransientParent(content_window_)->GetBoundsInScreen(); 418 wm::GetTransientParent(content_window_)->GetBoundsInScreen();
415 if (transient_parent_rect.height() >= size.height() && 419 if (transient_parent_rect.height() >= size_in_pixels.height() &&
416 transient_parent_rect.width() >= size.width()) { 420 transient_parent_rect.width() >= size_in_pixels.width()) {
417 parent_bounds = transient_parent_rect; 421 parent_bounds_in_pixels = ToPixelRect(transient_parent_rect);
418 } 422 }
419 } 423 }
420 424
421 gfx::Rect window_bounds( 425 gfx::Rect window_bounds(
422 parent_bounds.x() + (parent_bounds.width() - size.width()) / 2, 426 parent_bounds_in_pixels.x() +
423 parent_bounds.y() + (parent_bounds.height() - size.height()) / 2, 427 (parent_bounds_in_pixels.width() - size_in_pixels.width()) / 2,
424 size.width(), 428 parent_bounds_in_pixels.y() +
425 size.height()); 429 (parent_bounds_in_pixels.height() - size_in_pixels.height()) / 2,
430 size_in_pixels.width(), size_in_pixels.height());
426 // Don't size the window bigger than the parent, otherwise the user may not be 431 // Don't size the window bigger than the parent, otherwise the user may not be
427 // able to close or move it. 432 // able to close or move it.
428 window_bounds.AdjustToFit(parent_bounds); 433 window_bounds.AdjustToFit(parent_bounds_in_pixels);
429 434
430 SetBounds(window_bounds); 435 SetBounds(window_bounds);
431 } 436 }
432 437
433 void DesktopWindowTreeHostX11::GetWindowPlacement( 438 void DesktopWindowTreeHostX11::GetWindowPlacement(
434 gfx::Rect* bounds, 439 gfx::Rect* bounds,
435 ui::WindowShowState* show_state) const { 440 ui::WindowShowState* show_state) const {
436 *bounds = GetRestoredBounds(); 441 *bounds = GetRestoredBounds();
437 442
438 if (IsFullscreen()) { 443 if (IsFullscreen()) {
439 *show_state = ui::SHOW_STATE_FULLSCREEN; 444 *show_state = ui::SHOW_STATE_FULLSCREEN;
440 } else if (IsMinimized()) { 445 } else if (IsMinimized()) {
441 *show_state = ui::SHOW_STATE_MINIMIZED; 446 *show_state = ui::SHOW_STATE_MINIMIZED;
442 } else if (IsMaximized()) { 447 } else if (IsMaximized()) {
443 *show_state = ui::SHOW_STATE_MAXIMIZED; 448 *show_state = ui::SHOW_STATE_MAXIMIZED;
444 } else if (!IsActive()) { 449 } else if (!IsActive()) {
445 *show_state = ui::SHOW_STATE_INACTIVE; 450 *show_state = ui::SHOW_STATE_INACTIVE;
446 } else { 451 } else {
447 *show_state = ui::SHOW_STATE_NORMAL; 452 *show_state = ui::SHOW_STATE_NORMAL;
448 } 453 }
449 } 454 }
450 455
451 gfx::Rect DesktopWindowTreeHostX11::GetWindowBoundsInScreen() const { 456 gfx::Rect DesktopWindowTreeHostX11::GetWindowBoundsInScreen() const {
452 return bounds_; 457 return ToDIPRect(bounds_in_pixels_);
453 } 458 }
454 459
455 gfx::Rect DesktopWindowTreeHostX11::GetClientAreaBoundsInScreen() const { 460 gfx::Rect DesktopWindowTreeHostX11::GetClientAreaBoundsInScreen() const {
456 // TODO(erg): The NativeWidgetAura version returns |bounds_|, claiming its 461 // TODO(erg): The NativeWidgetAura version returns |bounds_in_pixels_|,
457 // needed for View::ConvertPointToScreen() to work 462 // claiming it's needed for View::ConvertPointToScreen() to work correctly.
458 // correctly. DesktopWindowTreeHostWin::GetClientAreaBoundsInScreen() just 463 // DesktopWindowTreeHostWin::GetClientAreaBoundsInScreen() just asks windows
459 // asks windows what it thinks the client rect is. 464 // what it thinks the client rect is.
460 // 465 //
461 // Attempts to calculate the rect by asking the NonClientFrameView what it 466 // Attempts to calculate the rect by asking the NonClientFrameView what it
462 // thought its GetBoundsForClientView() were broke combobox drop down 467 // thought its GetBoundsForClientView() were broke combobox drop down
463 // placement. 468 // placement.
464 return bounds_; 469 return GetWindowBoundsInScreen();
465 } 470 }
466 471
467 gfx::Rect DesktopWindowTreeHostX11::GetRestoredBounds() const { 472 gfx::Rect DesktopWindowTreeHostX11::GetRestoredBounds() const {
468 // We can't reliably track the restored bounds of a window, but we can get 473 // We can't reliably track the restored bounds of a window, but we can get
469 // the 90% case down. When *chrome* is the process that requests maximizing 474 // the 90% case down. When *chrome* is the process that requests maximizing
470 // or restoring bounds, we can record the current bounds before we request 475 // or restoring bounds, we can record the current bounds before we request
471 // maximization, and clear it when we detect a state change. 476 // maximization, and clear it when we detect a state change.
472 if (!restored_bounds_.IsEmpty()) 477 if (!restored_bounds_.IsEmpty())
473 return restored_bounds_; 478 return ToDIPRect(restored_bounds_);
474 479
475 return GetWindowBoundsInScreen(); 480 return GetWindowBoundsInScreen();
476 } 481 }
477 482
478 gfx::Rect DesktopWindowTreeHostX11::GetWorkAreaBoundsInScreen() const { 483 gfx::Rect DesktopWindowTreeHostX11::GetWorkAreaBoundsInScreen() const {
479 std::vector<int> value; 484 return ToDIPRect(GetWorkAreaBoundsInPixels());
480 if (ui::GetIntArrayProperty(x_root_window_, "_NET_WORKAREA", &value) &&
481 value.size() >= 4) {
482 return gfx::Rect(value[0], value[1], value[2], value[3]);
483 }
484
485 // Fetch the geometry of the root window.
486 Window root;
487 int x, y;
488 unsigned int width, height;
489 unsigned int border_width, depth;
490 if (!XGetGeometry(xdisplay_, x_root_window_, &root, &x, &y,
491 &width, &height, &border_width, &depth)) {
492 NOTIMPLEMENTED();
493 return gfx::Rect(0, 0, 10, 10);
494 }
495
496 return gfx::Rect(x, y, width, height);
497 } 485 }
498 486
499 void DesktopWindowTreeHostX11::SetShape(gfx::NativeRegion native_region) { 487 void DesktopWindowTreeHostX11::SetShape(gfx::NativeRegion native_region) {
500 if (window_shape_) 488 if (window_shape_)
501 XDestroyRegion(window_shape_); 489 XDestroyRegion(window_shape_);
502 custom_window_shape_ = false; 490 custom_window_shape_ = false;
503 window_shape_ = NULL; 491 window_shape_ = NULL;
504 492
505 if (native_region) { 493 if (native_region) {
506 custom_window_shape_ = true; 494 custom_window_shape_ = true;
(...skipping 25 matching lines...) Expand all
532 void DesktopWindowTreeHostX11::Maximize() { 520 void DesktopWindowTreeHostX11::Maximize() {
533 if (HasWMSpecProperty("_NET_WM_STATE_FULLSCREEN")) { 521 if (HasWMSpecProperty("_NET_WM_STATE_FULLSCREEN")) {
534 // Unfullscreen the window if it is fullscreen. 522 // Unfullscreen the window if it is fullscreen.
535 SetWMSpecState(false, 523 SetWMSpecState(false,
536 atom_cache_.GetAtom("_NET_WM_STATE_FULLSCREEN"), 524 atom_cache_.GetAtom("_NET_WM_STATE_FULLSCREEN"),
537 None); 525 None);
538 526
539 // Resize the window so that it does not have the same size as a monitor. 527 // Resize the window so that it does not have the same size as a monitor.
540 // (Otherwise, some window managers immediately put the window back in 528 // (Otherwise, some window managers immediately put the window back in
541 // fullscreen mode). 529 // fullscreen mode).
542 gfx::Rect adjusted_bounds(bounds_.origin(), AdjustSize(bounds_.size())); 530 gfx::Rect adjusted_bounds(bounds_in_pixels_.origin(),
543 if (adjusted_bounds != bounds_) 531 AdjustSize(bounds_in_pixels_.size()));
532 if (adjusted_bounds != bounds_in_pixels_)
544 SetBounds(adjusted_bounds); 533 SetBounds(adjusted_bounds);
545 } 534 }
546 535
547 // Some WMs do not respect maximization hints on unmapped windows, so we 536 // Some WMs do not respect maximization hints on unmapped windows, so we
548 // save this one for later too. 537 // save this one for later too.
549 should_maximize_after_map_ = !window_mapped_; 538 should_maximize_after_map_ = !window_mapped_;
550 539
551 // When we are in the process of requesting to maximize a window, we can 540 // When we are in the process of requesting to maximize a window, we can
552 // accurately keep track of our restored bounds instead of relying on the 541 // accurately keep track of our restored bounds instead of relying on the
553 // heuristics that are in the PropertyNotify and ConfigureNotify handlers. 542 // heuristics that are in the PropertyNotify and ConfigureNotify handlers.
554 restored_bounds_ = bounds_; 543 restored_bounds_ = bounds_in_pixels_;
555 544
556 SetWMSpecState(true, 545 SetWMSpecState(true,
557 atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"), 546 atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"),
558 atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ")); 547 atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ"));
559 if (IsMinimized()) 548 if (IsMinimized())
560 ShowWindowWithState(ui::SHOW_STATE_NORMAL); 549 ShowWindowWithState(ui::SHOW_STATE_NORMAL);
561 } 550 }
562 551
563 void DesktopWindowTreeHostX11::Minimize() { 552 void DesktopWindowTreeHostX11::Minimize() {
564 ReleaseCapture(); 553 ReleaseCapture();
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 None); 719 None);
731 if (unmaximize_and_remaximize) 720 if (unmaximize_and_remaximize)
732 Maximize(); 721 Maximize();
733 722
734 // Try to guess the size we will have after the switch to/from fullscreen: 723 // Try to guess the size we will have after the switch to/from fullscreen:
735 // - (may) avoid transient states 724 // - (may) avoid transient states
736 // - works around Flash content which expects to have the size updated 725 // - works around Flash content which expects to have the size updated
737 // synchronously. 726 // synchronously.
738 // See https://crbug.com/361408 727 // See https://crbug.com/361408
739 if (fullscreen) { 728 if (fullscreen) {
740 restored_bounds_ = bounds_; 729 restored_bounds_ = bounds_in_pixels_;
741 const gfx::Display display = 730 const gfx::Display display =
742 gfx::Screen::GetScreenFor(NULL)->GetDisplayNearestWindow(window()); 731 gfx::Screen::GetScreenFor(NULL)->GetDisplayNearestWindow(window());
743 bounds_ = display.bounds(); 732 bounds_in_pixels_ = ToPixelRect(display.bounds());
744 } else { 733 } else {
745 bounds_ = restored_bounds_; 734 bounds_in_pixels_ = restored_bounds_;
746 } 735 }
747 OnHostMoved(bounds_.origin()); 736 OnHostMoved(bounds_in_pixels_.origin());
748 OnHostResized(bounds_.size()); 737 OnHostResized(bounds_in_pixels_.size());
749 738
750 if (HasWMSpecProperty("_NET_WM_STATE_FULLSCREEN") == fullscreen) { 739 if (HasWMSpecProperty("_NET_WM_STATE_FULLSCREEN") == fullscreen) {
751 Relayout(); 740 Relayout();
752 ResetWindowRegion(); 741 ResetWindowRegion();
753 } 742 }
754 // Else: the widget will be relaid out either when the window bounds change or 743 // Else: the widget will be relaid out either when the window bounds change or
755 // when |xwindow_|'s fullscreen state changes. 744 // when |xwindow_|'s fullscreen state changes.
756 } 745 }
757 746
758 bool DesktopWindowTreeHostX11::IsFullscreen() const { 747 bool DesktopWindowTreeHostX11::IsFullscreen() const {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 return false; 844 return false;
856 } 845 }
857 846
858 void DesktopWindowTreeHostX11::SizeConstraintsChanged() { 847 void DesktopWindowTreeHostX11::SizeConstraintsChanged() {
859 UpdateMinAndMaxSize(); 848 UpdateMinAndMaxSize();
860 } 849 }
861 850
862 //////////////////////////////////////////////////////////////////////////////// 851 ////////////////////////////////////////////////////////////////////////////////
863 // DesktopWindowTreeHostX11, aura::WindowTreeHost implementation: 852 // DesktopWindowTreeHostX11, aura::WindowTreeHost implementation:
864 853
854 gfx::Transform DesktopWindowTreeHostX11::GetRootTransform() const {
pkotwicz 2015/02/18 22:58:50 Nit: I would be tempted to query the device scale
sadrul 2015/02/18 23:33:58 Done.
855 float scale = gfx::Display::GetForcedDeviceScaleFactor();
856 if (window_mapped_) {
857 const gfx::Display display =
858 gfx::Screen::GetNativeScreen()->GetDisplayNearestPoint(
859 bounds_in_pixels_.origin());
pkotwicz 2015/02/18 22:58:50 tldr: If you plan on making ToPixelRect() / ToDIPR
sadrul 2015/02/18 23:33:58 Changed to use DisplayNearestWindow() instead.
860 scale = display.device_scale_factor();
861 }
862
863 gfx::Transform transform;
864 transform.Scale(scale, scale);
865 return transform;
866 }
867
865 ui::EventSource* DesktopWindowTreeHostX11::GetEventSource() { 868 ui::EventSource* DesktopWindowTreeHostX11::GetEventSource() {
866 return this; 869 return this;
867 } 870 }
868 871
869 gfx::AcceleratedWidget DesktopWindowTreeHostX11::GetAcceleratedWidget() { 872 gfx::AcceleratedWidget DesktopWindowTreeHostX11::GetAcceleratedWidget() {
870 return xwindow_; 873 return xwindow_;
871 } 874 }
872 875
873 void DesktopWindowTreeHostX11::Show() { 876 void DesktopWindowTreeHostX11::Show() {
874 ShowWindowWithState(ui::SHOW_STATE_NORMAL); 877 ShowWindowWithState(ui::SHOW_STATE_NORMAL);
875 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); 878 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true);
876 } 879 }
877 880
878 void DesktopWindowTreeHostX11::Hide() { 881 void DesktopWindowTreeHostX11::Hide() {
879 if (window_mapped_) { 882 if (window_mapped_) {
880 XWithdrawWindow(xdisplay_, xwindow_, 0); 883 XWithdrawWindow(xdisplay_, xwindow_, 0);
881 window_mapped_ = false; 884 window_mapped_ = false;
882 } 885 }
883 native_widget_delegate_->OnNativeWidgetVisibilityChanged(false); 886 native_widget_delegate_->OnNativeWidgetVisibilityChanged(false);
884 } 887 }
885 888
886 gfx::Rect DesktopWindowTreeHostX11::GetBounds() const { 889 gfx::Rect DesktopWindowTreeHostX11::GetBounds() const {
887 return bounds_; 890 return bounds_in_pixels_;
888 } 891 }
889 892
890 void DesktopWindowTreeHostX11::SetBounds(const gfx::Rect& requested_bounds) { 893 void DesktopWindowTreeHostX11::SetBounds(
891 gfx::Rect bounds(requested_bounds.origin(), 894 const gfx::Rect& requested_bounds_in_pixel) {
892 AdjustSize(requested_bounds.size())); 895 gfx::Rect bounds(requested_bounds_in_pixel.origin(),
893 bool origin_changed = bounds_.origin() != bounds.origin(); 896 AdjustSize(requested_bounds_in_pixel.size()));
894 bool size_changed = bounds_.size() != bounds.size(); 897 bool origin_changed = bounds_in_pixels_.origin() != bounds.origin();
898 bool size_changed = bounds_in_pixels_.size() != bounds.size();
895 XWindowChanges changes = {0}; 899 XWindowChanges changes = {0};
896 unsigned value_mask = 0; 900 unsigned value_mask = 0;
897 901
898 if (size_changed) { 902 if (size_changed) {
899 if (bounds.width() < min_size_.width() || 903 if (bounds.width() < min_size_.width() ||
900 bounds.height() < min_size_.height() || 904 bounds.height() < min_size_.height() ||
901 (!max_size_.IsEmpty() && 905 (!max_size_.IsEmpty() &&
902 (bounds.width() > max_size_.width() || 906 (bounds.width() > max_size_.width() ||
903 bounds.height() > max_size_.height()))) { 907 bounds.height() > max_size_.height()))) {
904 // Update the minimum and maximum sizes in case they have changed. 908 // Update the minimum and maximum sizes in case they have changed.
(...skipping 15 matching lines...) Expand all
920 changes.y = bounds.y(); 924 changes.y = bounds.y();
921 value_mask |= CWX | CWY; 925 value_mask |= CWX | CWY;
922 } 926 }
923 if (value_mask) 927 if (value_mask)
924 XConfigureWindow(xdisplay_, xwindow_, value_mask, &changes); 928 XConfigureWindow(xdisplay_, xwindow_, value_mask, &changes);
925 929
926 // Assume that the resize will go through as requested, which should be the 930 // Assume that the resize will go through as requested, which should be the
927 // case if we're running without a window manager. If there's a window 931 // case if we're running without a window manager. If there's a window
928 // manager, it can modify or ignore the request, but (per ICCCM) we'll get a 932 // manager, it can modify or ignore the request, but (per ICCCM) we'll get a
929 // (possibly synthetic) ConfigureNotify about the actual size and correct 933 // (possibly synthetic) ConfigureNotify about the actual size and correct
930 // |bounds_| later. 934 // |bounds_in_pixels_| later.
931 bounds_ = bounds; 935 bounds_in_pixels_ = bounds;
932 936
933 if (origin_changed) 937 if (origin_changed)
934 native_widget_delegate_->AsWidget()->OnNativeWidgetMove(); 938 native_widget_delegate_->AsWidget()->OnNativeWidgetMove();
935 if (size_changed) { 939 if (size_changed) {
936 OnHostResized(bounds.size()); 940 OnHostResized(bounds.size());
937 ResetWindowRegion(); 941 ResetWindowRegion();
938 } 942 }
939 } 943 }
940 944
941 gfx::Point DesktopWindowTreeHostX11::GetLocationOnNativeScreen() const { 945 gfx::Point DesktopWindowTreeHostX11::GetLocationOnNativeScreen() const {
942 return bounds_.origin(); 946 return bounds_in_pixels_.origin();
943 } 947 }
944 948
945 void DesktopWindowTreeHostX11::SetCapture() { 949 void DesktopWindowTreeHostX11::SetCapture() {
946 if (HasCapture()) 950 if (HasCapture())
947 return; 951 return;
948 952
949 // Grabbing the mouse is asynchronous. However, we synchronously start 953 // Grabbing the mouse is asynchronous. However, we synchronously start
950 // forwarding all mouse events received by Chrome to the 954 // forwarding all mouse events received by Chrome to the
951 // aura::WindowEventDispatcher which has capture. This makes capture 955 // aura::WindowEventDispatcher which has capture. This makes capture
952 // synchronous for all intents and purposes if either: 956 // synchronous for all intents and purposes if either:
(...skipping 22 matching lines...) Expand all
975 OnHostLostWindowCapture(); 979 OnHostLostWindowCapture();
976 } 980 }
977 } 981 }
978 982
979 void DesktopWindowTreeHostX11::SetCursorNative(gfx::NativeCursor cursor) { 983 void DesktopWindowTreeHostX11::SetCursorNative(gfx::NativeCursor cursor) {
980 XDefineCursor(xdisplay_, xwindow_, cursor.platform()); 984 XDefineCursor(xdisplay_, xwindow_, cursor.platform());
981 } 985 }
982 986
983 void DesktopWindowTreeHostX11::MoveCursorToNative(const gfx::Point& location) { 987 void DesktopWindowTreeHostX11::MoveCursorToNative(const gfx::Point& location) {
984 XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0, 988 XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0,
985 bounds_.x() + location.x(), bounds_.y() + location.y()); 989 bounds_in_pixels_.x() + location.x(),
990 bounds_in_pixels_.y() + location.y());
986 } 991 }
987 992
988 void DesktopWindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) { 993 void DesktopWindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) {
989 // TODO(erg): Conditional on us enabling touch on desktop linux builds, do 994 // TODO(erg): Conditional on us enabling touch on desktop linux builds, do
990 // the same tap-to-click disabling here that chromeos does. 995 // the same tap-to-click disabling here that chromeos does.
991 } 996 }
992 997
993 //////////////////////////////////////////////////////////////////////////////// 998 ////////////////////////////////////////////////////////////////////////////////
994 // DesktopWindowTreeHostX11, ui::EventSource implementation: 999 // DesktopWindowTreeHostX11, ui::EventSource implementation:
995 1000
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 1056
1052 // x.org will BadMatch if we don't set a border when the depth isn't the 1057 // x.org will BadMatch if we don't set a border when the depth isn't the
1053 // same as the parent depth. 1058 // same as the parent depth.
1054 attribute_mask |= CWBorderPixel; 1059 attribute_mask |= CWBorderPixel;
1055 swa.border_pixel = 0; 1060 swa.border_pixel = 0;
1056 1061
1057 use_argb_visual_ = true; 1062 use_argb_visual_ = true;
1058 } 1063 }
1059 } 1064 }
1060 1065
1061 bounds_ = gfx::Rect(params.bounds.origin(), 1066 bounds_in_pixels_ = ToPixelRect(params.bounds);
1062 AdjustSize(params.bounds.size())); 1067 bounds_in_pixels_ = gfx::Rect(bounds_in_pixels_.origin(),
1063 xwindow_ = XCreateWindow( 1068 AdjustSize(bounds_in_pixels_.size()));
1064 xdisplay_, x_root_window_, 1069 xwindow_ = XCreateWindow(xdisplay_, x_root_window_, bounds_in_pixels_.x(),
1065 bounds_.x(), bounds_.y(), 1070 bounds_in_pixels_.y(), bounds_in_pixels_.width(),
1066 bounds_.width(), bounds_.height(), 1071 bounds_in_pixels_.height(),
1067 0, // border width 1072 0, // border width
1068 depth, 1073 depth, InputOutput, visual, attribute_mask, &swa);
1069 InputOutput,
1070 visual,
1071 attribute_mask,
1072 &swa);
1073 if (ui::PlatformEventSource::GetInstance()) 1074 if (ui::PlatformEventSource::GetInstance())
1074 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); 1075 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
1075 open_windows().push_back(xwindow_); 1076 open_windows().push_back(xwindow_);
1076 1077
1077 // TODO(erg): Maybe need to set a ViewProp here like in RWHL::RWHL(). 1078 // TODO(erg): Maybe need to set a ViewProp here like in RWHL::RWHL().
1078 1079
1079 long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask | 1080 long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask |
1080 KeyPressMask | KeyReleaseMask | 1081 KeyPressMask | KeyReleaseMask |
1081 EnterWindowMask | LeaveWindowMask | 1082 EnterWindowMask | LeaveWindowMask |
1082 ExposureMask | VisibilityChangeMask | 1083 ExposureMask | VisibilityChangeMask |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 // icon. 1202 // icon.
1202 gfx::ImageSkia* window_icon = ViewsDelegate::views_delegate ? 1203 gfx::ImageSkia* window_icon = ViewsDelegate::views_delegate ?
1203 ViewsDelegate::views_delegate->GetDefaultWindowIcon() : NULL; 1204 ViewsDelegate::views_delegate->GetDefaultWindowIcon() : NULL;
1204 if (window_icon) { 1205 if (window_icon) {
1205 SetWindowIcons(gfx::ImageSkia(), *window_icon); 1206 SetWindowIcons(gfx::ImageSkia(), *window_icon);
1206 } 1207 }
1207 CreateCompositor(GetAcceleratedWidget()); 1208 CreateCompositor(GetAcceleratedWidget());
1208 } 1209 }
1209 1210
1210 gfx::Size DesktopWindowTreeHostX11::AdjustSize( 1211 gfx::Size DesktopWindowTreeHostX11::AdjustSize(
1211 const gfx::Size& requested_size) { 1212 const gfx::Size& requested_size_in_pixels) {
1212 std::vector<gfx::Display> displays = 1213 std::vector<gfx::Display> displays =
1213 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)->GetAllDisplays(); 1214 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)->GetAllDisplays();
1214 // Compare against all monitor sizes. The window manager can move the window 1215 // Compare against all monitor sizes. The window manager can move the window
1215 // to whichever monitor it wants. 1216 // to whichever monitor it wants.
1216 for (size_t i = 0; i < displays.size(); ++i) { 1217 for (size_t i = 0; i < displays.size(); ++i) {
1217 if (requested_size == displays[i].size()) { 1218 if (requested_size_in_pixels == displays[i].GetSizeInPixel()) {
1218 return gfx::Size(requested_size.width() - 1, 1219 return gfx::Size(requested_size_in_pixels.width() - 1,
1219 requested_size.height() - 1); 1220 requested_size_in_pixels.height() - 1);
1220 } 1221 }
1221 } 1222 }
1222 1223
1223 // Do not request a 0x0 window size. It causes an XError. 1224 // Do not request a 0x0 window size. It causes an XError.
1224 gfx::Size size = requested_size; 1225 gfx::Size size = requested_size_in_pixels;
1225 size.SetToMax(gfx::Size(1,1)); 1226 size.SetToMax(gfx::Size(1,1));
1226 return size; 1227 return size;
1227 } 1228 }
1228 1229
1229 void DesktopWindowTreeHostX11::OnWMStateUpdated() { 1230 void DesktopWindowTreeHostX11::OnWMStateUpdated() {
1230 std::vector< ::Atom> atom_list; 1231 std::vector< ::Atom> atom_list;
1231 // Ignore the return value of ui::GetAtomArrayProperty(). Fluxbox removes the 1232 // Ignore the return value of ui::GetAtomArrayProperty(). Fluxbox removes the
1232 // _NET_WM_STATE property when no _NET_WM_STATE atoms are set. 1233 // _NET_WM_STATE property when no _NET_WM_STATE atoms are set.
1233 ui::GetAtomArrayProperty(xwindow_, "_NET_WM_STATE", &atom_list); 1234 ui::GetAtomArrayProperty(xwindow_, "_NET_WM_STATE", &atom_list);
1234 1235
(...skipping 23 matching lines...) Expand all
1258 } else { 1259 } else {
1259 content_window_->Show(); 1260 content_window_->Show();
1260 compositor()->SetVisible(true); 1261 compositor()->SetVisible(true);
1261 } 1262 }
1262 } 1263 }
1263 1264
1264 if (restored_bounds_.IsEmpty()) { 1265 if (restored_bounds_.IsEmpty()) {
1265 DCHECK(!IsFullscreen()); 1266 DCHECK(!IsFullscreen());
1266 if (IsMaximized()) { 1267 if (IsMaximized()) {
1267 // The request that we become maximized originated from a different 1268 // The request that we become maximized originated from a different
1268 // process. |bounds_| already contains our maximized bounds. Do a best 1269 // process. |bounds_in_pixels_| already contains our maximized bounds. Do
1269 // effort attempt to get restored bounds by setting it to our previously 1270 // a best effort attempt to get restored bounds by setting it to our
1270 // set bounds (and if we get this wrong, we aren't any worse off since 1271 // previously set bounds (and if we get this wrong, we aren't any worse
1271 // we'd otherwise be returning our maximized bounds). 1272 // off since we'd otherwise be returning our maximized bounds).
1272 restored_bounds_ = previous_bounds_; 1273 restored_bounds_ = previous_bounds_;
1273 } 1274 }
1274 } else if (!IsMaximized() && !IsFullscreen()) { 1275 } else if (!IsMaximized() && !IsFullscreen()) {
1275 // If we have restored bounds, but WM_STATE no longer claims to be 1276 // If we have restored bounds, but WM_STATE no longer claims to be
1276 // maximized or fullscreen, we should clear our restored bounds. 1277 // maximized or fullscreen, we should clear our restored bounds.
1277 restored_bounds_ = gfx::Rect(); 1278 restored_bounds_ = gfx::Rect();
1278 } 1279 }
1279 1280
1280 // Ignore requests by the window manager to enter or exit fullscreen (e.g. as 1281 // Ignore requests by the window manager to enter or exit fullscreen (e.g. as
1281 // a result of pressing a window manager accelerator key). Chrome does not 1282 // a result of pressing a window manager accelerator key). Chrome does not
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 if (window_shape_) 1475 if (window_shape_)
1475 XDestroyRegion(window_shape_); 1476 XDestroyRegion(window_shape_);
1476 window_shape_ = NULL; 1477 window_shape_ = NULL;
1477 1478
1478 if (!IsMaximized() && !IsFullscreen()) { 1479 if (!IsMaximized() && !IsFullscreen()) {
1479 gfx::Path window_mask; 1480 gfx::Path window_mask;
1480 views::Widget* widget = native_widget_delegate_->AsWidget(); 1481 views::Widget* widget = native_widget_delegate_->AsWidget();
1481 if (widget->non_client_view()) { 1482 if (widget->non_client_view()) {
1482 // Some frame views define a custom (non-rectangular) window mask. If 1483 // Some frame views define a custom (non-rectangular) window mask. If
1483 // so, use it to define the window shape. If not, fall through. 1484 // so, use it to define the window shape. If not, fall through.
1484 widget->non_client_view()->GetWindowMask(bounds_.size(), &window_mask); 1485 widget->non_client_view()->GetWindowMask(bounds_in_pixels_.size(),
1486 &window_mask);
1485 if (window_mask.countPoints() > 0) { 1487 if (window_mask.countPoints() > 0) {
1486 window_shape_ = gfx::CreateRegionFromSkPath(window_mask); 1488 window_shape_ = gfx::CreateRegionFromSkPath(window_mask);
1487 XShapeCombineRegion(xdisplay_, xwindow_, ShapeBounding, 1489 XShapeCombineRegion(xdisplay_, xwindow_, ShapeBounding,
1488 0, 0, window_shape_, false); 1490 0, 0, window_shape_, false);
1489 return; 1491 return;
1490 } 1492 }
1491 } 1493 }
1492 } 1494 }
1493 1495
1494 // If we didn't set the shape for any reason, reset the shaping information. 1496 // If we didn't set the shape for any reason, reset the shaping information.
1495 // How this is done depends on the border style, due to quirks and bugs in 1497 // How this is done depends on the border style, due to quirks and bugs in
1496 // various window managers. 1498 // various window managers.
1497 if (ShouldUseNativeFrame()) { 1499 if (ShouldUseNativeFrame()) {
1498 // If the window has system borders, the mask must be set to null (not a 1500 // If the window has system borders, the mask must be set to null (not a
1499 // rectangle), because several window managers (eg, KDE, XFCE, XMonad) will 1501 // rectangle), because several window managers (eg, KDE, XFCE, XMonad) will
1500 // not put borders on a window with a custom shape. 1502 // not put borders on a window with a custom shape.
1501 XShapeCombineMask(xdisplay_, xwindow_, ShapeBounding, 0, 0, None, ShapeSet); 1503 XShapeCombineMask(xdisplay_, xwindow_, ShapeBounding, 0, 0, None, ShapeSet);
1502 } else { 1504 } else {
1503 // Conversely, if the window does not have system borders, the mask must be 1505 // Conversely, if the window does not have system borders, the mask must be
1504 // manually set to a rectangle that covers the whole window (not null). This 1506 // manually set to a rectangle that covers the whole window (not null). This
1505 // is due to a bug in KWin <= 4.11.5 (KDE bug #330573) where setting a null 1507 // is due to a bug in KWin <= 4.11.5 (KDE bug #330573) where setting a null
1506 // shape causes the hint to disable system borders to be ignored (resulting 1508 // shape causes the hint to disable system borders to be ignored (resulting
1507 // in a double border). 1509 // in a double border).
1508 XRectangle r = {0, 0, static_cast<unsigned short>(bounds_.width()), 1510 XRectangle r = {0,
1509 static_cast<unsigned short>(bounds_.height())}; 1511 0,
1512 static_cast<unsigned short>(bounds_in_pixels_.width()),
1513 static_cast<unsigned short>(bounds_in_pixels_.height())};
1510 XShapeCombineRectangles( 1514 XShapeCombineRectangles(
1511 xdisplay_, xwindow_, ShapeBounding, 0, 0, &r, 1, ShapeSet, YXBanded); 1515 xdisplay_, xwindow_, ShapeBounding, 0, 0, &r, 1, ShapeSet, YXBanded);
1512 } 1516 }
1513 } 1517 }
1514 1518
1515 void DesktopWindowTreeHostX11::SerializeImageRepresentation( 1519 void DesktopWindowTreeHostX11::SerializeImageRepresentation(
1516 const gfx::ImageSkiaRep& rep, 1520 const gfx::ImageSkiaRep& rep,
1517 std::vector<unsigned long>* data) { 1521 std::vector<unsigned long>* data) {
1518 int width = rep.GetWidth(); 1522 int width = rep.GetWidth();
1519 data->push_back(width); 1523 data->push_back(width);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 show_state != ui::SHOW_STATE_INACTIVE && 1578 show_state != ui::SHOW_STATE_INACTIVE &&
1575 show_state != ui::SHOW_STATE_MAXIMIZED) { 1579 show_state != ui::SHOW_STATE_MAXIMIZED) {
1576 // It will behave like SHOW_STATE_NORMAL. 1580 // It will behave like SHOW_STATE_NORMAL.
1577 NOTIMPLEMENTED(); 1581 NOTIMPLEMENTED();
1578 } 1582 }
1579 1583
1580 // Before we map the window, set size hints. Otherwise, some window managers 1584 // Before we map the window, set size hints. Otherwise, some window managers
1581 // will ignore toplevel XMoveWindow commands. 1585 // will ignore toplevel XMoveWindow commands.
1582 XSizeHints size_hints; 1586 XSizeHints size_hints;
1583 size_hints.flags = PPosition; 1587 size_hints.flags = PPosition;
1584 size_hints.x = bounds_.x(); 1588 size_hints.x = bounds_in_pixels_.x();
1585 size_hints.y = bounds_.y(); 1589 size_hints.y = bounds_in_pixels_.y();
1586 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); 1590 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints);
1587 1591
1588 // If SHOW_STATE_INACTIVE, tell the window manager not to focus the window 1592 // If SHOW_STATE_INACTIVE, tell the window manager not to focus the window
1589 // when mapping. This is done by setting the _NET_WM_USER_TIME to 0. See e.g. 1593 // when mapping. This is done by setting the _NET_WM_USER_TIME to 0. See e.g.
1590 // http://standards.freedesktop.org/wm-spec/latest/ar01s05.html 1594 // http://standards.freedesktop.org/wm-spec/latest/ar01s05.html
1591 unsigned long wm_user_time_ms = (show_state == ui::SHOW_STATE_INACTIVE) ? 1595 unsigned long wm_user_time_ms = (show_state == ui::SHOW_STATE_INACTIVE) ?
1592 0 : X11DesktopHandler::get()->wm_user_time_ms(); 1596 0 : X11DesktopHandler::get()->wm_user_time_ms();
1593 if (show_state == ui::SHOW_STATE_INACTIVE || wm_user_time_ms != 0) { 1597 if (show_state == ui::SHOW_STATE_INACTIVE || wm_user_time_ms != 0) {
1594 XChangeProperty(xdisplay_, 1598 XChangeProperty(xdisplay_,
1595 xwindow_, 1599 xwindow_,
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1735 // sure the root window size is maintained properly. 1739 // sure the root window size is maintained properly.
1736 int translated_x = xev->xconfigure.x; 1740 int translated_x = xev->xconfigure.x;
1737 int translated_y = xev->xconfigure.y; 1741 int translated_y = xev->xconfigure.y;
1738 if (!xev->xconfigure.send_event && !xev->xconfigure.override_redirect) { 1742 if (!xev->xconfigure.send_event && !xev->xconfigure.override_redirect) {
1739 Window unused; 1743 Window unused;
1740 XTranslateCoordinates(xdisplay_, xwindow_, x_root_window_, 1744 XTranslateCoordinates(xdisplay_, xwindow_, x_root_window_,
1741 0, 0, &translated_x, &translated_y, &unused); 1745 0, 0, &translated_x, &translated_y, &unused);
1742 } 1746 }
1743 gfx::Rect bounds(translated_x, translated_y, 1747 gfx::Rect bounds(translated_x, translated_y,
1744 xev->xconfigure.width, xev->xconfigure.height); 1748 xev->xconfigure.width, xev->xconfigure.height);
1745 bool size_changed = bounds_.size() != bounds.size(); 1749 bool size_changed = bounds_in_pixels_.size() != bounds.size();
1746 bool origin_changed = bounds_.origin() != bounds.origin(); 1750 bool origin_changed = bounds_in_pixels_.origin() != bounds.origin();
1747 previous_bounds_ = bounds_; 1751 previous_bounds_ = bounds_in_pixels_;
1748 bounds_ = bounds; 1752 bounds_in_pixels_ = bounds;
1749 1753
1750 if (origin_changed) 1754 if (origin_changed)
1751 OnHostMoved(bounds_.origin()); 1755 OnHostMoved(bounds_in_pixels_.origin());
1752 1756
1753 if (size_changed) { 1757 if (size_changed) {
1754 delayed_resize_task_.Reset(base::Bind( 1758 delayed_resize_task_.Reset(base::Bind(
1755 &DesktopWindowTreeHostX11::DelayedResize, 1759 &DesktopWindowTreeHostX11::DelayedResize,
1756 close_widget_factory_.GetWeakPtr(), 1760 close_widget_factory_.GetWeakPtr(),
1757 bounds.size())); 1761 bounds.size()));
1758 base::MessageLoop::current()->PostTask( 1762 base::MessageLoop::current()->PostTask(
1759 FROM_HERE, delayed_resize_task_.callback()); 1763 FROM_HERE, delayed_resize_task_.callback());
1760 } 1764 }
1761 break; 1765 break;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 } 1927 }
1924 return ui::POST_DISPATCH_STOP_PROPAGATION; 1928 return ui::POST_DISPATCH_STOP_PROPAGATION;
1925 } 1929 }
1926 1930
1927 void DesktopWindowTreeHostX11::DelayedResize(const gfx::Size& size) { 1931 void DesktopWindowTreeHostX11::DelayedResize(const gfx::Size& size) {
1928 OnHostResized(size); 1932 OnHostResized(size);
1929 ResetWindowRegion(); 1933 ResetWindowRegion();
1930 delayed_resize_task_.Cancel(); 1934 delayed_resize_task_.Cancel();
1931 } 1935 }
1932 1936
1937 gfx::Rect DesktopWindowTreeHostX11::GetWorkAreaBoundsInPixels() const {
1938 std::vector<int> value;
1939 if (ui::GetIntArrayProperty(x_root_window_, "_NET_WORKAREA", &value) &&
1940 value.size() >= 4) {
1941 return gfx::Rect(value[0], value[1], value[2], value[3]);
1942 }
1943
1944 // Fetch the geometry of the root window.
1945 Window root;
1946 int x, y;
1947 unsigned int width, height;
1948 unsigned int border_width, depth;
1949 if (!XGetGeometry(xdisplay_, x_root_window_, &root, &x, &y, &width, &height,
1950 &border_width, &depth)) {
1951 NOTIMPLEMENTED();
1952 return gfx::Rect(0, 0, 10, 10);
1953 }
1954
1955 return gfx::Rect(x, y, width, height);
1956 }
1957
1958 gfx::Rect DesktopWindowTreeHostX11::ToDIPRect(
1959 const gfx::Rect& rect_in_pixels) const {
1960 gfx::RectF rect_in_dip = rect_in_pixels;
1961 GetRootTransform().TransformRectReverse(&rect_in_dip);
1962 return gfx::ToEnclosingRect(rect_in_dip);
1963 }
1964
1965 gfx::Rect DesktopWindowTreeHostX11::ToPixelRect(
1966 const gfx::Rect& rect_in_dip) const {
1967 gfx::RectF rect_in_pixels = rect_in_dip;
1968 GetRootTransform().TransformRect(&rect_in_pixels);
1969 return gfx::ToEnclosingRect(rect_in_pixels);
1970 }
1971
1933 //////////////////////////////////////////////////////////////////////////////// 1972 ////////////////////////////////////////////////////////////////////////////////
1934 // DesktopWindowTreeHost, public: 1973 // DesktopWindowTreeHost, public:
1935 1974
1936 // static 1975 // static
1937 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( 1976 DesktopWindowTreeHost* DesktopWindowTreeHost::Create(
1938 internal::NativeWidgetDelegate* native_widget_delegate, 1977 internal::NativeWidgetDelegate* native_widget_delegate,
1939 DesktopNativeWidgetAura* desktop_native_widget_aura) { 1978 DesktopNativeWidgetAura* desktop_native_widget_aura) {
1940 return new DesktopWindowTreeHostX11(native_widget_delegate, 1979 return new DesktopWindowTreeHostX11(native_widget_delegate,
1941 desktop_native_widget_aura); 1980 desktop_native_widget_aura);
1942 } 1981 }
1943 1982
1944 // static 1983 // static
1945 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) { 1984 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) {
1946 const views::LinuxUI* linux_ui = views::LinuxUI::instance(); 1985 const views::LinuxUI* linux_ui = views::LinuxUI::instance();
1947 if (linux_ui) { 1986 if (linux_ui) {
1948 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); 1987 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window);
1949 if (native_theme) 1988 if (native_theme)
1950 return native_theme; 1989 return native_theme;
1951 } 1990 }
1952 1991
1953 return ui::NativeTheme::instance(); 1992 return ui::NativeTheme::instance();
1954 } 1993 }
1955 1994
1956 } // namespace views 1995 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698