| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/gtk/apps/native_app_window_gtk.h" | 5 #include "chrome/browser/ui/gtk/apps/native_app_window_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkx.h> | 7 #include <gdk/gdkx.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/message_loop/message_pump_gtk.h" | 10 #include "base/message_loop/message_pump_gtk.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 NativeAppWindowGtk::NativeAppWindowGtk(ShellWindow* shell_window, | 43 NativeAppWindowGtk::NativeAppWindowGtk(ShellWindow* shell_window, |
| 44 const ShellWindow::CreateParams& params) | 44 const ShellWindow::CreateParams& params) |
| 45 : shell_window_(shell_window), | 45 : shell_window_(shell_window), |
| 46 window_(NULL), | 46 window_(NULL), |
| 47 state_(GDK_WINDOW_STATE_WITHDRAWN), | 47 state_(GDK_WINDOW_STATE_WITHDRAWN), |
| 48 is_active_(false), | 48 is_active_(false), |
| 49 content_thinks_its_fullscreen_(false), | 49 content_thinks_its_fullscreen_(false), |
| 50 frameless_(params.frame == ShellWindow::FRAME_NONE), | 50 frameless_(params.frame == ShellWindow::FRAME_NONE), |
| 51 always_on_top_(params.always_on_top), |
| 51 frame_cursor_(NULL), | 52 frame_cursor_(NULL), |
| 52 atom_cache_(base::MessagePumpGtk::GetDefaultXDisplay(), kAtomsToCache), | 53 atom_cache_(base::MessagePumpGtk::GetDefaultXDisplay(), kAtomsToCache), |
| 53 is_x_event_listened_(false) { | 54 is_x_event_listened_(false) { |
| 54 Observe(web_contents()); | 55 Observe(web_contents()); |
| 55 | 56 |
| 56 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); | 57 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); |
| 57 | 58 |
| 58 gfx::NativeView native_view = | 59 gfx::NativeView native_view = |
| 59 web_contents()->GetView()->GetNativeView(); | 60 web_contents()->GetView()->GetNativeView(); |
| 60 gtk_container_add(GTK_CONTAINER(window_), native_view); | 61 gtk_container_add(GTK_CONTAINER(window_), native_view); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 84 // get our first configure-event | 85 // get our first configure-event |
| 85 bounds_ = restored_bounds_ = params.bounds; | 86 bounds_ = restored_bounds_ = params.bounds; |
| 86 gint x, y; | 87 gint x, y; |
| 87 gtk_window_get_position(window_, &x, &y); | 88 gtk_window_get_position(window_, &x, &y); |
| 88 bounds_.set_origin(gfx::Point(x, y)); | 89 bounds_.set_origin(gfx::Point(x, y)); |
| 89 | 90 |
| 90 // Hide titlebar when {frame: 'none'} specified on ShellWindow. | 91 // Hide titlebar when {frame: 'none'} specified on ShellWindow. |
| 91 if (frameless_) | 92 if (frameless_) |
| 92 gtk_window_set_decorated(window_, false); | 93 gtk_window_set_decorated(window_, false); |
| 93 | 94 |
| 95 if (always_on_top_) |
| 96 gtk_window_set_keep_above(window_, TRUE); |
| 97 |
| 94 int min_width = params.minimum_size.width(); | 98 int min_width = params.minimum_size.width(); |
| 95 int min_height = params.minimum_size.height(); | 99 int min_height = params.minimum_size.height(); |
| 96 int max_width = params.maximum_size.width(); | 100 int max_width = params.maximum_size.width(); |
| 97 int max_height = params.maximum_size.height(); | 101 int max_height = params.maximum_size.height(); |
| 98 GdkGeometry hints; | 102 GdkGeometry hints; |
| 99 int hints_mask = 0; | 103 int hints_mask = 0; |
| 100 if (min_width || min_height) { | 104 if (min_width || min_height) { |
| 101 hints.min_height = min_height; | 105 hints.min_height = min_height; |
| 102 hints.min_width = min_width; | 106 hints.min_width = min_width; |
| 103 hints_mask |= GDK_HINT_MIN_SIZE; | 107 hints_mask |= GDK_HINT_MIN_SIZE; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 } | 336 } |
| 333 | 337 |
| 334 return GDK_FILTER_CONTINUE; | 338 return GDK_FILTER_CONTINUE; |
| 335 } | 339 } |
| 336 | 340 |
| 337 void NativeAppWindowGtk::FlashFrame(bool flash) { | 341 void NativeAppWindowGtk::FlashFrame(bool flash) { |
| 338 gtk_window_set_urgency_hint(window_, flash); | 342 gtk_window_set_urgency_hint(window_, flash); |
| 339 } | 343 } |
| 340 | 344 |
| 341 bool NativeAppWindowGtk::IsAlwaysOnTop() const { | 345 bool NativeAppWindowGtk::IsAlwaysOnTop() const { |
| 342 return false; | 346 return always_on_top_; |
| 343 } | 347 } |
| 344 | 348 |
| 345 void NativeAppWindowGtk::RenderViewHostChanged( | 349 void NativeAppWindowGtk::RenderViewHostChanged( |
| 346 content::RenderViewHost* old_host, | 350 content::RenderViewHost* old_host, |
| 347 content::RenderViewHost* new_host) { | 351 content::RenderViewHost* new_host) { |
| 348 web_contents()->GetView()->Focus(); | 352 web_contents()->GetView()->Focus(); |
| 349 } | 353 } |
| 350 | 354 |
| 351 gfx::Insets NativeAppWindowGtk::GetFrameInsets() const { | 355 gfx::Insets NativeAppWindowGtk::GetFrameInsets() const { |
| 352 if (frameless_) | 356 if (frameless_) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 374 rect_with_decorations.width - current_width - left_inset); | 378 rect_with_decorations.width - current_width - left_inset); |
| 375 } | 379 } |
| 376 | 380 |
| 377 bool NativeAppWindowGtk::IsVisible() const { | 381 bool NativeAppWindowGtk::IsVisible() const { |
| 378 return gtk_widget_get_visible(GTK_WIDGET(window_)); | 382 return gtk_widget_get_visible(GTK_WIDGET(window_)); |
| 379 } | 383 } |
| 380 | 384 |
| 381 void NativeAppWindowGtk::HideWithApp() {} | 385 void NativeAppWindowGtk::HideWithApp() {} |
| 382 void NativeAppWindowGtk::ShowWithApp() {} | 386 void NativeAppWindowGtk::ShowWithApp() {} |
| 383 | 387 |
| 388 void NativeAppWindowGtk::SetAlwaysOnTop(bool always_on_top) { |
| 389 if (always_on_top_ != always_on_top) { |
| 390 // gdk_window_get_state() does not give us the correct value for the |
| 391 // GDK_WINDOW_STATE_ABOVE bit. Cache the current state. |
| 392 always_on_top_ = always_on_top; |
| 393 gtk_window_set_keep_above(window_, always_on_top_ ? TRUE : FALSE); |
| 394 shell_window_->OnNativeWindowChanged(); |
| 395 } |
| 396 } |
| 397 |
| 384 gfx::NativeView NativeAppWindowGtk::GetHostView() const { | 398 gfx::NativeView NativeAppWindowGtk::GetHostView() const { |
| 385 NOTIMPLEMENTED(); | 399 NOTIMPLEMENTED(); |
| 386 return NULL; | 400 return NULL; |
| 387 } | 401 } |
| 388 | 402 |
| 389 gfx::Point NativeAppWindowGtk::GetDialogPosition(const gfx::Size& size) { | 403 gfx::Point NativeAppWindowGtk::GetDialogPosition(const gfx::Size& size) { |
| 390 gint current_width = 0; | 404 gint current_width = 0; |
| 391 gint current_height = 0; | 405 gint current_height = 0; |
| 392 gtk_window_get_size(window_, ¤t_width, ¤t_height); | 406 gtk_window_get_size(window_, ¤t_width, ¤t_height); |
| 393 return gfx::Point(current_width / 2 - size.width() / 2, | 407 return gfx::Point(current_width / 2 - size.width() / 2, |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 } | 658 } |
| 645 | 659 |
| 646 void NativeAppWindowGtk::UpdateDraggableRegions( | 660 void NativeAppWindowGtk::UpdateDraggableRegions( |
| 647 const std::vector<extensions::DraggableRegion>& regions) { | 661 const std::vector<extensions::DraggableRegion>& regions) { |
| 648 // Draggable region is not supported for non-frameless window. | 662 // Draggable region is not supported for non-frameless window. |
| 649 if (!frameless_) | 663 if (!frameless_) |
| 650 return; | 664 return; |
| 651 | 665 |
| 652 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); | 666 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); |
| 653 } | 667 } |
| OLD | NEW |