OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/platform_window/x11/x11_window_base.h" | 5 #include "ui/platform_window/x11/x11_window_base.h" |
6 | 6 |
7 #include <X11/extensions/XInput2.h> | 7 #include <X11/extensions/XInput2.h> |
8 #include <X11/Xatom.h> | 8 #include <X11/Xatom.h> |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 #include <X11/Xutil.h> | 10 #include <X11/Xutil.h> |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 return; | 170 return; |
171 XWithdrawWindow(xdisplay_, xwindow_, 0); | 171 XWithdrawWindow(xdisplay_, xwindow_, 0); |
172 window_mapped_ = false; | 172 window_mapped_ = false; |
173 } | 173 } |
174 | 174 |
175 void X11WindowBase::Close() { | 175 void X11WindowBase::Close() { |
176 Destroy(); | 176 Destroy(); |
177 } | 177 } |
178 | 178 |
179 void X11WindowBase::SetBounds(const gfx::Rect& bounds) { | 179 void X11WindowBase::SetBounds(const gfx::Rect& bounds) { |
180 if (bounds == bounds_) | |
181 return; | |
182 | |
183 if (window_mapped_) { | 180 if (window_mapped_) { |
184 XWindowChanges changes = {0}; | 181 XWindowChanges changes = {0}; |
185 unsigned value_mask = CWX | CWY | CWWidth | CWHeight; | 182 unsigned value_mask = 0; |
186 changes.x = bounds.x(); | 183 |
187 changes.y = bounds.y(); | 184 if (bounds_.size() != bounds.size()) { |
188 changes.width = bounds.width(); | 185 changes.width = bounds.width(); |
189 changes.height = bounds.height(); | 186 changes.height = bounds.height(); |
190 XConfigureWindow(xdisplay_, xwindow_, value_mask, &changes); | 187 value_mask |= CWHeight | CWWidth; |
| 188 } |
| 189 |
| 190 if (bounds_.origin() != bounds.origin()) { |
| 191 changes.x = bounds.x(); |
| 192 changes.y = bounds.y(); |
| 193 value_mask |= CWX | CWY; |
| 194 } |
| 195 |
| 196 if (value_mask) |
| 197 XConfigureWindow(xdisplay_, xwindow_, value_mask, &changes); |
191 } | 198 } |
192 | 199 |
193 // Assume that the resize will go through as requested, which should be the | 200 // Assume that the resize will go through as requested, which should be the |
194 // case if we're running without a window manager. If there's a window | 201 // case if we're running without a window manager. If there's a window |
195 // manager, it can modify or ignore the request, but (per ICCCM) we'll get a | 202 // manager, it can modify or ignore the request, but (per ICCCM) we'll get a |
196 // (possibly synthetic) ConfigureNotify about the actual size and correct | 203 // (possibly synthetic) ConfigureNotify about the actual size and correct |
197 // |bounds_| later. | 204 // |bounds_| later. |
198 bounds_ = bounds; | 205 bounds_ = bounds; |
| 206 |
| 207 // Even if the pixel bounds didn't change this call to the delegate should |
| 208 // still happen. The device scale factor may have changed which effectively |
| 209 // changes the bounds. |
199 delegate_->OnBoundsChanged(bounds_); | 210 delegate_->OnBoundsChanged(bounds_); |
200 } | 211 } |
201 | 212 |
202 gfx::Rect X11WindowBase::GetBounds() { | 213 gfx::Rect X11WindowBase::GetBounds() { |
203 return bounds_; | 214 return bounds_; |
204 } | 215 } |
205 | 216 |
206 void X11WindowBase::SetTitle(const base::string16& title) { | 217 void X11WindowBase::SetTitle(const base::string16& title) { |
207 if (window_title_ == title) | 218 if (window_title_ == title) |
208 return; | 219 return; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 SubstructureRedirectMask | SubstructureNotifyMask, | 308 SubstructureRedirectMask | SubstructureNotifyMask, |
298 &reply_event); | 309 &reply_event); |
299 XFlush(xdisplay_); | 310 XFlush(xdisplay_); |
300 } | 311 } |
301 break; | 312 break; |
302 } | 313 } |
303 } | 314 } |
304 } | 315 } |
305 | 316 |
306 } // namespace ui | 317 } // namespace ui |
OLD | NEW |