| 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 17 matching lines...) Expand all Loading... |
| 370 return gfx::Insets( | 374 return gfx::Insets( |
| 371 top_inset, | 375 top_inset, |
| 372 left_inset, | 376 left_inset, |
| 373 rect_with_decorations.height - current_height - top_inset, | 377 rect_with_decorations.height - current_height - top_inset, |
| 374 rect_with_decorations.width - current_width - left_inset); | 378 rect_with_decorations.width - current_width - left_inset); |
| 375 } | 379 } |
| 376 | 380 |
| 377 void NativeAppWindowGtk::HideWithApp() {} | 381 void NativeAppWindowGtk::HideWithApp() {} |
| 378 void NativeAppWindowGtk::ShowWithApp() {} | 382 void NativeAppWindowGtk::ShowWithApp() {} |
| 379 | 383 |
| 384 void NativeAppWindowGtk::SetAlwaysOnTop(bool always_on_top) { |
| 385 if (always_on_top_ != always_on_top) { |
| 386 // gdk_window_get_state() does not give us the correct value for the |
| 387 // GDK_WINDOW_STATE_ABOVE bit. Cache the current state. |
| 388 always_on_top_ = always_on_top; |
| 389 gtk_window_set_keep_above(window_, always_on_top_ ? TRUE : FALSE); |
| 390 shell_window_->OnNativeWindowChanged(); |
| 391 } |
| 392 } |
| 393 |
| 380 gfx::NativeView NativeAppWindowGtk::GetHostView() const { | 394 gfx::NativeView NativeAppWindowGtk::GetHostView() const { |
| 381 NOTIMPLEMENTED(); | 395 NOTIMPLEMENTED(); |
| 382 return NULL; | 396 return NULL; |
| 383 } | 397 } |
| 384 | 398 |
| 385 gfx::Point NativeAppWindowGtk::GetDialogPosition(const gfx::Size& size) { | 399 gfx::Point NativeAppWindowGtk::GetDialogPosition(const gfx::Size& size) { |
| 386 gint current_width = 0; | 400 gint current_width = 0; |
| 387 gint current_height = 0; | 401 gint current_height = 0; |
| 388 gtk_window_get_size(window_, ¤t_width, ¤t_height); | 402 gtk_window_get_size(window_, ¤t_width, ¤t_height); |
| 389 return gfx::Point(current_width / 2 - size.width() / 2, | 403 return gfx::Point(current_width / 2 - size.width() / 2, |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 } | 652 } |
| 639 | 653 |
| 640 void NativeAppWindowGtk::UpdateDraggableRegions( | 654 void NativeAppWindowGtk::UpdateDraggableRegions( |
| 641 const std::vector<extensions::DraggableRegion>& regions) { | 655 const std::vector<extensions::DraggableRegion>& regions) { |
| 642 // Draggable region is not supported for non-frameless window. | 656 // Draggable region is not supported for non-frameless window. |
| 643 if (!frameless_) | 657 if (!frameless_) |
| 644 return; | 658 return; |
| 645 | 659 |
| 646 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); | 660 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); |
| 647 } | 661 } |
| OLD | NEW |