| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 #ifndef WINDOW_MANAGER_WINDOW_H_ | 5 #ifndef WINDOW_MANAGER_WINDOW_H_ |
| 6 #define WINDOW_MANAGER_WINDOW_H_ | 6 #define WINDOW_MANAGER_WINDOW_H_ |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <ctime> | 9 #include <ctime> |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 const char* type_str() const { | 99 const char* type_str() const { |
| 100 return chromeos::WmIpcWindowTypeToString(type_); | 100 return chromeos::WmIpcWindowTypeToString(type_); |
| 101 } | 101 } |
| 102 bool mapped() const { return mapped_; } | 102 bool mapped() const { return mapped_; } |
| 103 bool shaped() const { return shaped_; } | 103 bool shaped() const { return shaped_; } |
| 104 bool is_rgba() const { return client_depth_ == 32; } | 104 bool is_rgba() const { return client_depth_ == 32; } |
| 105 bool client_has_redrawn_after_last_resize() const { | 105 bool client_has_redrawn_after_last_resize() const { |
| 106 return client_has_redrawn_after_last_resize_; | 106 return client_has_redrawn_after_last_resize_; |
| 107 } | 107 } |
| 108 | 108 |
| 109 int client_x() const { return client_x_; } | 109 int client_x() const { return client_bounds_.x; } |
| 110 int client_y() const { return client_y_; } | 110 int client_y() const { return client_bounds_.y; } |
| 111 int client_width() const { return client_width_; } | 111 int client_width() const { return client_bounds_.width; } |
| 112 int client_height() const { return client_height_; } | 112 int client_height() const { return client_bounds_.height; } |
| 113 int client_depth() const { return client_depth_; } | 113 int client_depth() const { return client_depth_; } |
| 114 Rect client_bounds() const { | 114 Point client_origin() const { return client_bounds_.position(); } |
| 115 return Rect(client_x_, client_y_, client_width_, client_height_); | 115 Size client_size() const { return client_bounds_.size(); } |
| 116 } | 116 const Rect& client_bounds() const { return client_bounds_; } |
| 117 | 117 |
| 118 bool composited_shown() const { return composited_shown_; } | 118 bool composited_shown() const { return composited_shown_; } |
| 119 int composited_x() const { return composited_x_; } | 119 int composited_x() const { return composited_origin_.x; } |
| 120 int composited_y() const { return composited_y_; } | 120 int composited_y() const { return composited_origin_.y; } |
| 121 const Point& composited_origin() const { return composited_origin_; } |
| 121 int composited_width() const { | 122 int composited_width() const { |
| 122 return static_cast<int>(round(client_width_ * composited_scale_x_)); | 123 return static_cast<int>(round(client_width() * composited_scale_x_)); |
| 123 } | 124 } |
| 124 int composited_height() const { | 125 int composited_height() const { |
| 125 return static_cast<int>(round(client_height_ * composited_scale_y_)); | 126 return static_cast<int>(round(client_height() * composited_scale_y_)); |
| 127 } |
| 128 Size composited_size() const { |
| 129 return Size(composited_width(), composited_height()); |
| 126 } | 130 } |
| 127 double composited_scale_x() const { return composited_scale_x_; } | 131 double composited_scale_x() const { return composited_scale_x_; } |
| 128 double composited_scale_y() const { return composited_scale_y_; } | 132 double composited_scale_y() const { return composited_scale_y_; } |
| 129 double composited_opacity() const { return composited_opacity_; } | 133 double composited_opacity() const { return composited_opacity_; } |
| 130 | 134 |
| 131 // The client might've already requested that the window be translucent, | 135 // The client might've already requested that the window be translucent, |
| 132 // in addition to whatever level has been set on the composited window. | 136 // in addition to whatever level has been set on the composited window. |
| 133 double combined_opacity() const { | 137 double combined_opacity() const { |
| 134 return composited_opacity_ * client_opacity_; | 138 return composited_opacity_ * client_opacity_; |
| 135 } | 139 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // behavior. | 266 // behavior. |
| 263 // | 267 // |
| 264 // Most callers should use FocusManager::UseClickToFocusForWindow(), | 268 // Most callers should use FocusManager::UseClickToFocusForWindow(), |
| 265 // which will handle all of this for them. | 269 // which will handle all of this for them. |
| 266 bool AddButtonGrab(); | 270 bool AddButtonGrab(); |
| 267 bool RemoveButtonGrab(); | 271 bool RemoveButtonGrab(); |
| 268 | 272 |
| 269 // Get the largest possible size for this window smaller than or equal to | 273 // Get the largest possible size for this window smaller than or equal to |
| 270 // the passed-in desired dimensions (while respecting any sizing hints it | 274 // the passed-in desired dimensions (while respecting any sizing hints it |
| 271 // supplied via the WM_NORMAL_HINTS property). | 275 // supplied via the WM_NORMAL_HINTS property). |
| 272 void GetMaxSize(int desired_width, int desired_height, | 276 void GetMaxSize(const Size& desired_size, Size* size_out) const; |
| 273 int* width_out, int* height_out) const; | |
| 274 | 277 |
| 275 // Tell the X server to map or unmap this window. | 278 // Tell the X server to map or unmap this window. |
| 276 bool MapClient(); | 279 bool MapClient(); |
| 277 bool UnmapClient(); | 280 bool UnmapClient(); |
| 278 | 281 |
| 279 // Update our internal copy of the client window's position or size. | |
| 280 // External callers should only use these methods to record position and | |
| 281 // size changes that they hear about for override-redirect windows; | |
| 282 // non-override-redirect windows can be moved or resized using | |
| 283 // MoveClient() and ResizeClient(). | |
| 284 void SaveClientPosition(int x, int y) { | |
| 285 client_x_ = x; | |
| 286 client_y_ = y; | |
| 287 } | |
| 288 void SaveClientSize(int width, int height) { | |
| 289 client_width_ = width; | |
| 290 client_height_ = height; | |
| 291 } | |
| 292 | |
| 293 // Set the window's visibility and input policy. Once this method has been | 282 // Set the window's visibility and input policy. Once this method has been |
| 294 // called, the Move() method (as opposed to MoveClient() / MoveComposited()) | 283 // called, the Move() method (as opposed to MoveClient() / MoveComposited()) |
| 295 // must be used to move the window. | 284 // must be used to move the window. |
| 296 void SetVisibility(Visibility visibility); | 285 void SetVisibility(Visibility visibility); |
| 297 | 286 |
| 298 // Start or stop updating the client window's position in response to calls to | 287 // Start or stop updating the client window's position in response to calls to |
| 299 // Move(). Disabling client window updates while moving the window repeatedly | 288 // Move(). Disabling client window updates while moving the window repeatedly |
| 300 // (e.g. if the user is dragging it around) can be useful to limit the number | 289 // (e.g. if the user is dragging it around) can be useful to limit the number |
| 301 // of requests sent to and ConfigureNotify events received from the X server. | 290 // of requests sent to and ConfigureNotify events received from the X server. |
| 302 // When updates are turned back on, the client window will be moved it its | 291 // When updates are turned back on, the client window will be moved it its |
| (...skipping 23 matching lines...) Expand all Loading... |
| 326 | 315 |
| 327 // Move the client window to the same position as the composited window. | 316 // Move the client window to the same position as the composited window. |
| 328 bool MoveClientToComposited(); | 317 bool MoveClientToComposited(); |
| 329 | 318 |
| 330 // Center the client window over the passed-in window. | 319 // Center the client window over the passed-in window. |
| 331 bool CenterClientOverWindow(Window* owner); | 320 bool CenterClientOverWindow(Window* owner); |
| 332 | 321 |
| 333 // Resize the client window. A southeast gravity means that the | 322 // Resize the client window. A southeast gravity means that the |
| 334 // bottom-right corner of the window will remain fixed while the | 323 // bottom-right corner of the window will remain fixed while the |
| 335 // upper-left corner will move to accomodate the new size. | 324 // upper-left corner will move to accomodate the new size. |
| 336 bool ResizeClient(int width, int height, Gravity gravity); | 325 bool Resize(const Size& new_size, Gravity gravity); |
| 337 | 326 |
| 338 // Stack the client window directly above or below another window. | 327 // Stack the client window directly above or below another window. |
| 339 bool StackClientAbove(XWindow sibling_xid); | 328 bool StackClientAbove(XWindow sibling_xid); |
| 340 bool StackClientBelow(XWindow sibling_xid); | 329 bool StackClientBelow(XWindow sibling_xid); |
| 341 | 330 |
| 342 // Make various changes to the composited window (and its shadow). | 331 // Make various changes to the composited window (and its shadow). |
| 343 void MoveComposited(int x, int y, int anim_ms); | 332 void MoveComposited(int x, int y, int anim_ms); |
| 344 void MoveCompositedX(int x, int anim_ms); | 333 void MoveCompositedX(int x, int anim_ms); |
| 345 void MoveCompositedY(int y, int anim_ms); | 334 void MoveCompositedY(int y, int anim_ms); |
| 346 void MoveCompositedToClient(); // no animation | 335 void MoveCompositedToClient(); // no animation |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 // This method is called when this window is redirected for compositing | 380 // This method is called when this window is redirected for compositing |
| 392 // after it has been unredirected. The previously stored pixmap is no longer | 381 // after it has been unredirected. The previously stored pixmap is no longer |
| 393 // valid, so it updates the pixmap by calling ResetPixmap. The content of | 382 // valid, so it updates the pixmap by calling ResetPixmap. The content of |
| 394 // the root window is copied to the new pixmap, so that the new pixmap's | 383 // the root window is copied to the new pixmap, so that the new pixmap's |
| 395 // uninitialized contents are not briefly visible. This method can only be | 384 // uninitialized contents are not briefly visible. This method can only be |
| 396 // called if this window's contents are currently painted on the entire root | 385 // called if this window's contents are currently painted on the entire root |
| 397 // window at (0, 0). | 386 // window at (0, 0). |
| 398 void HandleRedirect(); | 387 void HandleRedirect(); |
| 399 | 388 |
| 400 // Handle a ConfigureNotify event about this window. | 389 // Handle a ConfigureNotify event about this window. |
| 401 // Currently, we just pass the window's width and height so we can resize | 390 // We fetch a new pixmap for the window if its size has changed and |
| 402 // the actor if needed. | 391 // update its composited position if it's an override-redirect window. |
| 403 void HandleConfigureNotify(int width, int height); | 392 void HandleConfigureNotify(const Rect& bounds, XWindow above_xid); |
| 404 | 393 |
| 405 // Handle the window's contents being changed. | 394 // Handle the window's contents being changed. |
| 406 void HandleDamageNotify(const Rect& bounding_box); | 395 void HandleDamageNotify(const Rect& bounding_box); |
| 407 | 396 |
| 408 // Handle the _CHROME_FREEZE_UPDATES property getting set or unset on this | 397 // Handle the _CHROME_FREEZE_UPDATES property getting set or unset on this |
| 409 // window. See |updates_frozen_| for details. | 398 // window. See |updates_frozen_| for details. |
| 410 void HandleFreezeUpdatesPropertyChange(bool frozen); | 399 void HandleFreezeUpdatesPropertyChange(bool frozen); |
| 411 | 400 |
| 412 // Handle the underlying X window being destroyed. If this method is | 401 // Handle the underlying X window being destroyed. If this method is |
| 413 // invoked before destroying this Window object, a few | 402 // invoked before destroying this Window object, a few |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 // Move the actor to its correct position over |anim_ms|, given | 544 // Move the actor to its correct position over |anim_ms|, given |
| 556 // |composited_x_| and |composited_y_|, the composited scale, and the actor's | 545 // |composited_x_| and |composited_y_|, the composited scale, and the actor's |
| 557 // current size versus the client window's size. |dimensions| can be used to | 546 // current size versus the client window's size. |dimensions| can be used to |
| 558 // limit the dimension over which the actor is moved to just X or Y (when | 547 // limit the dimension over which the actor is moved to just X or Y (when |
| 559 // invoked by MoveCompositedX() or MoveCompositedY()). | 548 // invoked by MoveCompositedX() or MoveCompositedY()). |
| 560 // | 549 // |
| 561 // Way more background than you want to know: resizing a client window can be | 550 // Way more background than you want to know: resizing a client window can be |
| 562 // tricky for compositing window managers. Suppose that we have a 20x20 | 551 // tricky for compositing window managers. Suppose that we have a 20x20 |
| 563 // window located at (10, 10) and we want to make it bigger so that its | 552 // window located at (10, 10) and we want to make it bigger so that its |
| 564 // upper-left corner goes to (5, 10) while the right edge remains fixed, | 553 // upper-left corner goes to (5, 10) while the right edge remains fixed, |
| 565 // resulting in a 25x20 window. ResizeClient() asks the X server to | 554 // resulting in a 25x20 window. Resize() asks the X server to atomically move |
| 566 // atomically move and resize the window to the new bounds, but the window | 555 // and resize the window to the new bounds, but the window can't be drawn at |
| 567 // can't be drawn at the new size until the client has received the | 556 // the new size until the client has received the ConfigureNotify event and |
| 568 // ConfigureNotify event and finished painting the new pixmap. If we move the | 557 // finished painting the new pixmap. If we move the actor to (5, 10) |
| 569 // actor to (5, 10) immediately and then update its pixmap later, the window | 558 // immediately and then update its pixmap later, the window will initially |
| 570 // will initially appear to jump to the left by 5 pixels; once we get the new | 559 // appear to jump to the left by 5 pixels; once we get the new pixmap, the |
| 571 // pixmap, the right edge will expand by 5 pixels. | 560 // right edge will expand by 5 pixels. |
| 572 // | 561 // |
| 573 // To avoid this jank, we update |composited_x_| and |composited_y_| | 562 // To avoid this jank, we update |composited_x_| and |composited_y_| |
| 574 // immediately in ResizeClient() if the window's origin moved due to the | 563 // immediately in Resize() if the window's origin moved due to the resize |
| 575 // resize gravity but hold off on actually moving the actor until its size | 564 // gravity but hold off on actually moving the actor until its size changes. |
| 576 // changes. Similarly, methods like MoveComposited() may not actually move | 565 // Similarly, methods like MoveComposited() may not actually move the actor to |
| 577 // the actor to the requested position immediately -- if we're waiting for the | 566 // the requested position immediately -- if we're waiting for the pixmap to be |
| 578 // pixmap to be resized, we take the difference between its current size and | 567 // resized, we take the difference between its current size and the |
| 579 // the newly-requested size into account. | 568 // newly-requested size into account. |
| 580 void MoveActorToAdjustedPosition(MoveDimensions dimensions, int anim_ms); | 569 void MoveActorToAdjustedPosition(MoveDimensions dimensions, int anim_ms); |
| 581 | 570 |
| 582 // Free |pixmap_|, store a new offscreen pixmap containing the window's | 571 // Free |pixmap_|, store a new offscreen pixmap containing the window's |
| 583 // contents in it, and notify |actor_| that the pixmap has changed. | 572 // contents in it, and notify |actor_| that the pixmap has changed. |
| 584 void ResetPixmap(); | 573 void ResetPixmap(); |
| 585 | 574 |
| 586 // Update the visibility of |shadow_| if it's non-NULL. This window's | 575 // Update the visibility of |shadow_| if it's non-NULL. This window's |
| 587 // shadow can be enabled or disabled via SetShouldUseShadow(), but there | 576 // shadow can be enabled or disabled via SetShouldUseShadow(), but there |
| 588 // are still other reasons that we may not draw the shadow (e.g. the | 577 // are still other reasons that we may not draw the shadow (e.g. the |
| 589 // window is shaped or not yet mapped). This method is called when | 578 // window is shaped or not yet mapped). This method is called when |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 // details. | 624 // details. |
| 636 std::vector<int> type_params_; | 625 std::vector<int> type_params_; |
| 637 | 626 |
| 638 Visibility visibility_; | 627 Visibility visibility_; |
| 639 | 628 |
| 640 // Should we update the client window's position in response to calls to | 629 // Should we update the client window's position in response to calls to |
| 641 // Move()? | 630 // Move()? |
| 642 bool update_client_position_for_moves_; | 631 bool update_client_position_for_moves_; |
| 643 | 632 |
| 644 // Position and size of the client window. | 633 // Position and size of the client window. |
| 645 int client_x_; | 634 Rect client_bounds_; |
| 646 int client_y_; | |
| 647 int client_width_; | |
| 648 int client_height_; | |
| 649 | 635 |
| 650 // Bit depth of the client window. | 636 // Bit depth of the client window. |
| 651 int client_depth_; | 637 int client_depth_; |
| 652 | 638 |
| 653 // Client-requested opacity (via _NET_WM_WINDOW_OPACITY). | 639 // Client-requested opacity (via _NET_WM_WINDOW_OPACITY). |
| 654 double client_opacity_; | 640 double client_opacity_; |
| 655 | 641 |
| 656 bool composited_shown_; | 642 bool composited_shown_; |
| 657 int composited_x_; | 643 Point composited_origin_; |
| 658 int composited_y_; | |
| 659 double composited_scale_x_; | 644 double composited_scale_x_; |
| 660 double composited_scale_y_; | 645 double composited_scale_y_; |
| 661 double composited_opacity_; | 646 double composited_opacity_; |
| 662 | 647 |
| 663 // Gravity used to position the actor in the case where the actor's size | 648 // Gravity used to position the actor in the case where the actor's size |
| 664 // differs from that of the client window. See MoveActorToAdjustedPosition() | 649 // differs from that of the client window. See MoveActorToAdjustedPosition() |
| 665 // for details. | 650 // for details. |
| 666 Gravity actor_gravity_; | 651 Gravity actor_gravity_; |
| 667 | 652 |
| 668 // Current opacity requested for the window's shadow. | 653 // Current opacity requested for the window's shadow. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 // earlier? The actor is displaying a GL texture bound to a GLX pixmap | 794 // earlier? The actor is displaying a GL texture bound to a GLX pixmap |
| 810 // that was created from this X pixmap. | 795 // that was created from this X pixmap. |
| 811 XID pixmap_; | 796 XID pixmap_; |
| 812 | 797 |
| 813 DISALLOW_COPY_AND_ASSIGN(DestroyedWindow); | 798 DISALLOW_COPY_AND_ASSIGN(DestroyedWindow); |
| 814 }; | 799 }; |
| 815 | 800 |
| 816 } // namespace window_manager | 801 } // namespace window_manager |
| 817 | 802 |
| 818 #endif // WINDOW_MANAGER_WINDOW_H_ | 803 #endif // WINDOW_MANAGER_WINDOW_H_ |
| OLD | NEW |