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/desktop_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. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 // The display and the native X window hosting the desktop. | 206 // The display and the native X window hosting the desktop. |
207 Display* xdisplay_; | 207 Display* xdisplay_; |
208 ::Window xwindow_; | 208 ::Window xwindow_; |
209 | 209 |
210 // Current Aura cursor. | 210 // Current Aura cursor. |
211 gfx::NativeCursor current_cursor_; | 211 gfx::NativeCursor current_cursor_; |
212 | 212 |
213 // The size of |xwindow_|. | 213 // The size of |xwindow_|. |
214 gfx::Rect bounds_; | 214 gfx::Rect bounds_; |
215 | 215 |
| 216 // True while we requested configure, but haven't recieved configure event |
| 217 // yet. |
| 218 bool expect_configure_event_; |
| 219 |
216 DISALLOW_COPY_AND_ASSIGN(DesktopHostLinux); | 220 DISALLOW_COPY_AND_ASSIGN(DesktopHostLinux); |
217 }; | 221 }; |
218 | 222 |
219 DesktopHostLinux::DesktopHostLinux(const gfx::Rect& bounds) | 223 DesktopHostLinux::DesktopHostLinux(const gfx::Rect& bounds) |
220 : desktop_(NULL), | 224 : desktop_(NULL), |
221 xdisplay_(NULL), | 225 xdisplay_(NULL), |
222 xwindow_(0), | 226 xwindow_(0), |
223 current_cursor_(aura::kCursorNull), | 227 current_cursor_(aura::kCursorNull), |
224 bounds_(bounds) { | 228 bounds_(bounds) { |
225 // This assumes that the message-pump creates and owns the display. | 229 // This assumes that the message-pump creates and owns the display. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 } | 306 } |
303 case ConfigureNotify: { | 307 case ConfigureNotify: { |
304 DCHECK_EQ(xdisplay_, xev->xconfigure.display); | 308 DCHECK_EQ(xdisplay_, xev->xconfigure.display); |
305 DCHECK_EQ(xwindow_, xev->xconfigure.window); | 309 DCHECK_EQ(xwindow_, xev->xconfigure.window); |
306 DCHECK_EQ(xwindow_, xev->xconfigure.event); | 310 DCHECK_EQ(xwindow_, xev->xconfigure.event); |
307 | 311 |
308 // It's possible that the X window may be resized by some other means than | 312 // It's possible that the X window may be resized by some other means than |
309 // from within aura (e.g. the X window manager can change the size). Make | 313 // from within aura (e.g. the X window manager can change the size). Make |
310 // sure the desktop size is maintained properly. | 314 // sure the desktop size is maintained properly. |
311 gfx::Size size(xev->xconfigure.width, xev->xconfigure.height); | 315 gfx::Size size(xev->xconfigure.width, xev->xconfigure.height); |
312 if (bounds_.size() != size) | 316 if (bounds_.size() != size || expect_configure_event_) { |
| 317 expect_configure_event_ = false; |
313 bounds_.set_size(size); | 318 bounds_.set_size(size); |
314 desktop_->OnHostResized(size); | 319 desktop_->OnHostResized(size); |
| 320 } |
315 handled = true; | 321 handled = true; |
316 break; | 322 break; |
317 } | 323 } |
318 | 324 |
319 case GenericEvent: { | 325 case GenericEvent: { |
320 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); | 326 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); |
321 if (!factory->ShouldProcessXI2Event(xev)) | 327 if (!factory->ShouldProcessXI2Event(xev)) |
322 break; | 328 break; |
323 | 329 |
324 // If this is a motion event we want to coalesce all pending motion | 330 // If this is a motion event we want to coalesce all pending motion |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 XFlush(xdisplay_); | 393 XFlush(xdisplay_); |
388 } | 394 } |
389 | 395 |
390 gfx::Size DesktopHostLinux::GetSize() const { | 396 gfx::Size DesktopHostLinux::GetSize() const { |
391 return bounds_.size(); | 397 return bounds_.size(); |
392 } | 398 } |
393 | 399 |
394 void DesktopHostLinux::SetSize(const gfx::Size& size) { | 400 void DesktopHostLinux::SetSize(const gfx::Size& size) { |
395 if (bounds_.size() == size) | 401 if (bounds_.size() == size) |
396 return; | 402 return; |
| 403 expect_configure_event_ = true; |
397 bounds_.set_size(size); | 404 bounds_.set_size(size); |
398 XResizeWindow(xdisplay_, xwindow_, size.width(), size.height()); | 405 XResizeWindow(xdisplay_, xwindow_, size.width(), size.height()); |
399 } | 406 } |
400 | 407 |
401 void DesktopHostLinux::SetCursor(gfx::NativeCursor cursor) { | 408 void DesktopHostLinux::SetCursor(gfx::NativeCursor cursor) { |
402 if (current_cursor_ == cursor) | 409 if (current_cursor_ == cursor) |
403 return; | 410 return; |
404 current_cursor_ = cursor; | 411 current_cursor_ = cursor; |
405 // Custom web cursors are handled directly. | 412 // Custom web cursors are handled directly. |
406 if (cursor == kCursorCustom) | 413 if (cursor == kCursorCustom) |
(...skipping 26 matching lines...) Expand all Loading... |
433 } | 440 } |
434 | 441 |
435 } // namespace | 442 } // namespace |
436 | 443 |
437 // static | 444 // static |
438 DesktopHost* DesktopHost::Create(const gfx::Rect& bounds) { | 445 DesktopHost* DesktopHost::Create(const gfx::Rect& bounds) { |
439 return new DesktopHostLinux(bounds); | 446 return new DesktopHostLinux(bounds); |
440 } | 447 } |
441 | 448 |
442 } // namespace aura | 449 } // namespace aura |
OLD | NEW |