Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: chrome/browser/ui/panels/panel_gtk.cc

Issue 10908153: [Panel refactor] Deprecate old panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linux_chromeos test failure Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/panels/panel_gtk.h ('k') | chrome/browser/ui/panels/panel_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/panels/panel_gtk.h" 5 #include "chrome/browser/ui/panels/panel_gtk.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 #include <X11/XF86keysym.h> 9 #include <X11/XF86keysym.h>
10 10
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 g_signal_connect(window_, "button-press-event", 257 g_signal_connect(window_, "button-press-event",
258 G_CALLBACK(OnButtonPressEventThunk), this); 258 G_CALLBACK(OnButtonPressEventThunk), this);
259 259
260 // This vbox contains the titlebar and the render area, but not 260 // This vbox contains the titlebar and the render area, but not
261 // the custom frame border. 261 // the custom frame border.
262 window_vbox_ = gtk_vbox_new(FALSE, 0); 262 window_vbox_ = gtk_vbox_new(FALSE, 0);
263 gtk_widget_show(window_vbox_); 263 gtk_widget_show(window_vbox_);
264 264
265 // TODO(jennb): add GlobalMenuBar after refactoring out Browser. 265 // TODO(jennb): add GlobalMenuBar after refactoring out Browser.
266 266
267 // The window container draws the custom browser frame. 267 // The window container draws the custom window frame.
268 window_container_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); 268 window_container_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
269 gtk_widget_set_name(window_container_, "chrome-custom-frame-border"); 269 gtk_widget_set_name(window_container_, "chrome-custom-frame-border");
270 gtk_widget_set_app_paintable(window_container_, TRUE); 270 gtk_widget_set_app_paintable(window_container_, TRUE);
271 gtk_widget_set_double_buffered(window_container_, FALSE); 271 gtk_widget_set_double_buffered(window_container_, FALSE);
272 gtk_widget_set_redraw_on_allocate(window_container_, TRUE); 272 gtk_widget_set_redraw_on_allocate(window_container_, TRUE);
273 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 1, 273 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 1,
274 kFrameBorderThickness, kFrameBorderThickness, kFrameBorderThickness); 274 kFrameBorderThickness, kFrameBorderThickness, kFrameBorderThickness);
275 g_signal_connect(window_container_, "expose-event", 275 g_signal_connect(window_container_, "expose-event",
276 G_CALLBACK(OnCustomFrameExposeThunk), this); 276 G_CALLBACK(OnCustomFrameExposeThunk), this);
277 gtk_container_add(GTK_CONTAINER(window_container_), window_vbox_); 277 gtk_container_add(GTK_CONTAINER(window_container_), window_vbox_);
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 GdkCursor* cursor = 666 GdkCursor* cursor =
667 gdk_window_get_cursor(gtk_widget_get_window(GTK_WIDGET(window_))); 667 gdk_window_get_cursor(gtk_widget_get_window(GTK_WIDGET(window_)));
668 drag_helper_->InitialWindowEdgeMousePress(event, cursor, edge); 668 drag_helper_->InitialWindowEdgeMousePress(event, cursor, edge);
669 return TRUE; 669 return TRUE;
670 } 670 }
671 671
672 return FALSE; // Continue to propagate the event. 672 return FALSE; // Continue to propagate the event.
673 } 673 }
674 674
675 void PanelGtk::ActiveWindowChanged(GdkWindow* active_window) { 675 void PanelGtk::ActiveWindowChanged(GdkWindow* active_window) {
676 // Do nothing if we're in the process of closing the browser window. 676 // Do nothing if we're in the process of closing the panel window.
677 if (!window_) 677 if (!window_)
678 return; 678 return;
679 679
680 bool is_active = gtk_widget_get_window(GTK_WIDGET(window_)) == active_window; 680 bool is_active = gtk_widget_get_window(GTK_WIDGET(window_)) == active_window;
681 if (is_active == is_active_) 681 if (is_active == is_active_)
682 return; // State did not change. 682 return; // State did not change.
683 683
684 if (is_active) { 684 if (is_active) {
685 // If there's an app modal dialog (e.g., JS alert), try to redirect 685 // If there's an app modal dialog (e.g., JS alert), try to redirect
686 // the user's attention to the window owning the dialog. 686 // the user's attention to the window owning the dialog.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 // Loads are now complete, update the state if a task was scheduled. 849 // Loads are now complete, update the state if a task was scheduled.
850 LoadingAnimationCallback(); 850 LoadingAnimationCallback();
851 } 851 }
852 } 852 }
853 } 853 }
854 854
855 void PanelGtk::LoadingAnimationCallback() { 855 void PanelGtk::LoadingAnimationCallback() {
856 titlebar_->UpdateThrobber(panel_->GetWebContents()); 856 titlebar_->UpdateThrobber(panel_->GetWebContents());
857 } 857 }
858 858
859 FindBar* PanelGtk::CreatePanelFindBar() {
860 return NULL; // legacy
861 }
862
863 void PanelGtk::NotifyPanelOnUserChangedTheme() { 859 void PanelGtk::NotifyPanelOnUserChangedTheme() {
864 titlebar_->UpdateTextColor(); 860 titlebar_->UpdateTextColor();
865 InvalidateWindow(); 861 InvalidateWindow();
866 } 862 }
867 863
868 void PanelGtk::PanelCut() { 864 void PanelGtk::PanelCut() {
869 gtk_window_util::DoCut(window_, panel_->GetWebContents()); 865 gtk_window_util::DoCut(window_, panel_->GetWebContents());
870 } 866 }
871 867
872 void PanelGtk::PanelCopy() { 868 void PanelGtk::PanelCopy() {
(...skipping 18 matching lines...) Expand all
891 if ((panel_->attention_mode() & Panel::USE_SYSTEM_ATTENTION) != 0) { 887 if ((panel_->attention_mode() & Panel::USE_SYSTEM_ATTENTION) != 0) {
892 // May not be respected by all window managers. 888 // May not be respected by all window managers.
893 gtk_window_set_urgency_hint(window_, draw_attention); 889 gtk_window_set_urgency_hint(window_, draw_attention);
894 } 890 }
895 } 891 }
896 892
897 bool PanelGtk::IsDrawingAttention() const { 893 bool PanelGtk::IsDrawingAttention() const {
898 return is_drawing_attention_; 894 return is_drawing_attention_;
899 } 895 }
900 896
901 bool PanelGtk::PreHandlePanelKeyboardEvent(
902 const NativeWebKeyboardEvent& event,
903 bool* is_keyboard_shortcut) {
904 // No need to prehandle as no keys are reserved.
905 return false;
906 }
907
908 void PanelGtk::HandlePanelKeyboardEvent( 897 void PanelGtk::HandlePanelKeyboardEvent(
909 const NativeWebKeyboardEvent& event) { 898 const NativeWebKeyboardEvent& event) {
910 GdkEventKey* os_event = &event.os_event->key; 899 GdkEventKey* os_event = &event.os_event->key;
911 if (os_event && event.type == WebKit::WebInputEvent::RawKeyDown) 900 if (os_event && event.type == WebKit::WebInputEvent::RawKeyDown)
912 gtk_window_activate_key(window_, os_event); 901 gtk_window_activate_key(window_, os_event);
913 } 902 }
914 903
915 void PanelGtk::FullScreenModeChanged(bool is_full_screen) { 904 void PanelGtk::FullScreenModeChanged(bool is_full_screen) {
916 // Nothing to do here as z-order rules for panels ensures that they're below 905 // Nothing to do here as z-order rules for panels ensures that they're below
917 // any app running in full screen mode. 906 // any app running in full screen mode.
(...skipping 18 matching lines...) Expand all
936 gfx::NativeView widget = contents->GetNativeView(); 925 gfx::NativeView widget = contents->GetNativeView();
937 if (widget) { 926 if (widget) {
938 GtkWidget* parent = gtk_widget_get_parent(widget); 927 GtkWidget* parent = gtk_widget_get_parent(widget);
939 if (parent) { 928 if (parent) {
940 DCHECK_EQ(parent, contents_expanded_); 929 DCHECK_EQ(parent, contents_expanded_);
941 gtk_container_remove(GTK_CONTAINER(contents_expanded_), widget); 930 gtk_container_remove(GTK_CONTAINER(contents_expanded_), widget);
942 } 931 }
943 } 932 }
944 } 933 }
945 934
946 Browser* PanelGtk::GetPanelBrowser() const {
947 return NULL; // legacy
948 }
949
950 gfx::Size PanelGtk::WindowSizeFromContentSize( 935 gfx::Size PanelGtk::WindowSizeFromContentSize(
951 const gfx::Size& content_size) const { 936 const gfx::Size& content_size) const {
952 gfx::Size& frame_size = GetFrameSize(); 937 gfx::Size& frame_size = GetFrameSize();
953 return gfx::Size(content_size.width() + frame_size.width(), 938 return gfx::Size(content_size.width() + frame_size.width(),
954 content_size.height() + frame_size.height()); 939 content_size.height() + frame_size.height());
955 } 940 }
956 941
957 gfx::Size PanelGtk::ContentSizeFromWindowSize( 942 gfx::Size PanelGtk::ContentSizeFromWindowSize(
958 const gfx::Size& window_size) const { 943 const gfx::Size& window_size) const {
959 gfx::Size& frame_size = GetFrameSize(); 944 gfx::Size& frame_size = GetFrameSize();
960 return gfx::Size(window_size.width() - frame_size.width(), 945 return gfx::Size(window_size.width() - frame_size.width(),
961 window_size.height() - frame_size.height()); 946 window_size.height() - frame_size.height());
962 } 947 }
963 948
964 int PanelGtk::TitleOnlyHeight() const { 949 int PanelGtk::TitleOnlyHeight() const {
965 GtkAllocation allocation; 950 GtkAllocation allocation;
966 gtk_widget_get_allocation(titlebar_->widget(), &allocation); 951 gtk_widget_get_allocation(titlebar_->widget(), &allocation);
967 return allocation.height; 952 return allocation.height;
968 } 953 }
969 954
970 void PanelGtk::EnsurePanelFullyVisible() {
971 gtk_window_present(window_);
972 }
973
974 void PanelGtk::SetPanelAlwaysOnTop(bool on_top) { 955 void PanelGtk::SetPanelAlwaysOnTop(bool on_top) {
975 gtk_window_set_keep_above(window_, on_top); 956 gtk_window_set_keep_above(window_, on_top);
976 957
977 // Do not show an icon in the task bar for always-on-top windows. 958 // Do not show an icon in the task bar for always-on-top windows.
978 // Window operations such as close, minimize etc. can only be done 959 // Window operations such as close, minimize etc. can only be done
979 // from the panel UI. 960 // from the panel UI.
980 gtk_window_set_skip_taskbar_hint(window_, on_top); 961 gtk_window_set_skip_taskbar_hint(window_, on_top);
981 962
982 // Show always-on-top windows on all the virtual desktops. 963 // Show always-on-top windows on all the virtual desktops.
983 if (on_top) 964 if (on_top)
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 break; 1114 break;
1134 case panel::RESTORE_BUTTON: 1115 case panel::RESTORE_BUTTON:
1135 button = titlebar->restore_button(); 1116 button = titlebar->restore_button();
1136 break; 1117 break;
1137 default: 1118 default:
1138 NOTREACHED(); 1119 NOTREACHED();
1139 return false; 1120 return false;
1140 } 1121 }
1141 return gtk_widget_get_visible(button->widget()); 1122 return gtk_widget_get_visible(button->widget());
1142 } 1123 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_gtk.h ('k') | chrome/browser/ui/panels/panel_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698