| 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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 gtk_window_util::UpdateWindowPosition(this, &bounds_, &restored_bounds_); | 447 gtk_window_util::UpdateWindowPosition(this, &bounds_, &restored_bounds_); |
| 448 shell_window_->OnNativeWindowChanged(); | 448 shell_window_->OnNativeWindowChanged(); |
| 449 | 449 |
| 450 FOR_EACH_OBSERVER(web_modal::ModalDialogHostObserver, | 450 FOR_EACH_OBSERVER(web_modal::ModalDialogHostObserver, |
| 451 observer_list_, | 451 observer_list_, |
| 452 OnPositionRequiresUpdate()); | 452 OnPositionRequiresUpdate()); |
| 453 | 453 |
| 454 // Fullscreen of non-resizable windows requires them to be made resizable | 454 // Fullscreen of non-resizable windows requires them to be made resizable |
| 455 // first. After that takes effect and OnConfigure is called we transition | 455 // first. After that takes effect and OnConfigure is called we transition |
| 456 // to fullscreen. | 456 // to fullscreen. |
| 457 if (!IsFullscreen() && IsFullscreenOrPending()) { | 457 if (!IsFullscreen() && content_thinks_its_fullscreen_) { |
| 458 gtk_window_fullscreen(window_); | 458 gtk_window_fullscreen(window_); |
| 459 } | 459 } |
| 460 | 460 |
| 461 // maximize_pending_ is the boolean that lets us know that the window is in | 461 // maximize_pending_ is the boolean that lets us know that the window is in |
| 462 // the process of being maximized but was set as not resizable. | 462 // the process of being maximized but was set as not resizable. |
| 463 // This function will be called twice during the maximization process: | 463 // This function will be called twice during the maximization process: |
| 464 // 1. gtk_window_maximize() is called to maximize the window; | 464 // 1. gtk_window_maximize() is called to maximize the window; |
| 465 // 2. gtk_set_resizable(, FALSE) is called to make the window no longer | 465 // 2. gtk_set_resizable(, FALSE) is called to make the window no longer |
| 466 // resizable. | 466 // resizable. |
| 467 // gtk_window_maximize() will cause ::OnConfigureDebounced to be called | 467 // gtk_window_maximize() will cause ::OnConfigureDebounced to be called |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 if (has_hit_titlebar || has_hit_edge) | 585 if (has_hit_titlebar || has_hit_edge) |
| 586 gdk_window_lower(gdk_window); | 586 gdk_window_lower(gdk_window); |
| 587 return TRUE; | 587 return TRUE; |
| 588 } | 588 } |
| 589 | 589 |
| 590 return FALSE; | 590 return FALSE; |
| 591 } | 591 } |
| 592 | 592 |
| 593 // NativeAppWindow implementation: | 593 // NativeAppWindow implementation: |
| 594 | 594 |
| 595 void NativeAppWindowGtk::SetFullscreen(bool fullscreen) { | 595 void NativeAppWindowGtk::SetFullscreen(ShellWindow::FullscreenType type) { |
| 596 bool fullscreen = (type != ShellWindow::FULLSCREEN_TYPE_NONE); |
| 596 content_thinks_its_fullscreen_ = fullscreen; | 597 content_thinks_its_fullscreen_ = fullscreen; |
| 597 if (fullscreen){ | 598 if (fullscreen) { |
| 598 if (resizable_) { | 599 if (resizable_) { |
| 599 gtk_window_fullscreen(window_); | 600 gtk_window_fullscreen(window_); |
| 600 } else { | 601 } else { |
| 601 // We must first make the window resizable. That won't take effect | 602 // We must first make the window resizable. That won't take effect |
| 602 // immediately, so OnConfigureDebounced completes the fullscreen call. | 603 // immediately, so OnConfigureDebounced completes the fullscreen call. |
| 603 gtk_window_set_resizable(window_, TRUE); | 604 gtk_window_set_resizable(window_, TRUE); |
| 604 } | 605 } |
| 605 } else { | 606 } else { |
| 606 gtk_window_unfullscreen(window_); | 607 gtk_window_unfullscreen(window_); |
| 607 if (!resizable_) | 608 if (!resizable_) |
| 608 gtk_window_set_resizable(window_, FALSE); | 609 gtk_window_set_resizable(window_, FALSE); |
| 609 } | 610 } |
| 610 } | 611 } |
| 611 | 612 |
| 612 bool NativeAppWindowGtk::IsFullscreenOrPending() const { | 613 bool NativeAppWindowGtk::SupportsImmersiveFullscreen() const { |
| 613 // |content_thinks_its_fullscreen_| is used when transitioning, and when | 614 return false; |
| 614 // the state change will not be made for some time. However, it is possible | |
| 615 // for a state update to be made before the final fullscreen state comes. | |
| 616 // In that case, |content_thinks_its_fullscreen_| will be cleared, but we | |
| 617 // will fall back to |IsFullscreen| which will soon have the correct state. | |
| 618 return content_thinks_its_fullscreen_ || IsFullscreen(); | |
| 619 } | 615 } |
| 620 | 616 |
| 621 bool NativeAppWindowGtk::IsDetached() const { | 617 bool NativeAppWindowGtk::IsDetached() const { |
| 622 return false; | 618 return false; |
| 623 } | 619 } |
| 624 | 620 |
| 625 void NativeAppWindowGtk::UpdateWindowIcon() { | 621 void NativeAppWindowGtk::UpdateWindowIcon() { |
| 626 Profile* profile = shell_window_->profile(); | 622 Profile* profile = shell_window_->profile(); |
| 627 gfx::Image app_icon = shell_window_->app_icon(); | 623 gfx::Image app_icon = shell_window_->app_icon(); |
| 628 if (!app_icon.IsEmpty()) | 624 if (!app_icon.IsEmpty()) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 hints_mask |= GDK_HINT_MAX_SIZE; | 706 hints_mask |= GDK_HINT_MAX_SIZE; |
| 711 } | 707 } |
| 712 if (hints_mask) { | 708 if (hints_mask) { |
| 713 gtk_window_set_geometry_hints( | 709 gtk_window_set_geometry_hints( |
| 714 window_, | 710 window_, |
| 715 GTK_WIDGET(window_), | 711 GTK_WIDGET(window_), |
| 716 &hints, | 712 &hints, |
| 717 static_cast<GdkWindowHints>(hints_mask)); | 713 static_cast<GdkWindowHints>(hints_mask)); |
| 718 } | 714 } |
| 719 } | 715 } |
| OLD | NEW |