Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/gtk/panels/panel_gtk.h" | 5 #include "chrome/browser/ui/gtk/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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 gfx::Size& GetFrameSize() { | 188 gfx::Size& GetFrameSize() { |
| 189 CR_DEFINE_STATIC_LOCAL(gfx::Size, frame_size, ()); | 189 CR_DEFINE_STATIC_LOCAL(gfx::Size, frame_size, ()); |
| 190 return frame_size; | 190 return frame_size; |
| 191 } | 191 } |
| 192 | 192 |
| 193 void SetFrameSize(const gfx::Size& new_size) { | 193 void SetFrameSize(const gfx::Size& new_size) { |
| 194 gfx::Size& frame_size = GetFrameSize(); | 194 gfx::Size& frame_size = GetFrameSize(); |
| 195 frame_size.SetSize(new_size.width(), new_size.height()); | 195 frame_size.SetSize(new_size.width(), new_size.height()); |
| 196 } | 196 } |
| 197 | 197 |
| 198 } | 198 } // namespace |
| 199 | 199 |
| 200 // static | 200 // static |
| 201 NativePanel* Panel::CreateNativePanel(Panel* panel, | 201 NativePanel* Panel::CreateNativePanel(Panel* panel, |
| 202 const gfx::Rect& bounds, | 202 const gfx::Rect& bounds, |
| 203 bool always_on_top) { | 203 bool always_on_top) { |
| 204 PanelGtk* panel_gtk = new PanelGtk(panel, bounds, always_on_top); | 204 PanelGtk* panel_gtk = new PanelGtk(panel, bounds, always_on_top); |
| 205 panel_gtk->Init(); | 205 panel_gtk->Init(); |
| 206 return panel_gtk; | 206 return panel_gtk; |
| 207 } | 207 } |
| 208 | 208 |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 FALSE, FALSE, 0); | 601 FALSE, FALSE, 0); |
| 602 } | 602 } |
| 603 | 603 |
| 604 gboolean PanelGtk::OnTitlebarButtonPressEvent( | 604 gboolean PanelGtk::OnTitlebarButtonPressEvent( |
| 605 GtkWidget* widget, GdkEventButton* event) { | 605 GtkWidget* widget, GdkEventButton* event) { |
| 606 if (event->button != 1) | 606 if (event->button != 1) |
| 607 return TRUE; | 607 return TRUE; |
| 608 if (event->type != GDK_BUTTON_PRESS) | 608 if (event->type != GDK_BUTTON_PRESS) |
| 609 return TRUE; | 609 return TRUE; |
| 610 | 610 |
| 611 gdk_window_raise(gtk_widget_get_window(GTK_WIDGET(window_))); | 611 // If the panel is in a stack, bring all other panels in the stack to the |
| 612 // top. | |
| 613 StackedPanelCollection* stack = panel_->stack(); | |
| 614 if (stack) { | |
| 615 for (StackedPanelCollection::Panels::const_iterator iter = | |
| 616 stack->panels().begin(); | |
| 617 iter != stack->panels().end(); ++iter) { | |
| 618 gdk_window_raise(gtk_widget_get_window(GTK_WIDGET( | |
| 619 (*iter)->GetNativeWindow()))); | |
| 620 } | |
| 621 } else { | |
| 622 gdk_window_raise(gtk_widget_get_window(GTK_WIDGET(window_))); | |
| 623 } | |
| 624 | |
| 612 EnsureDragHelperCreated(); | 625 EnsureDragHelperCreated(); |
| 613 drag_helper_->InitialTitlebarMousePress(event, titlebar_->widget()); | 626 drag_helper_->InitialTitlebarMousePress(event, titlebar_->widget()); |
| 614 return TRUE; | 627 return TRUE; |
| 615 } | 628 } |
| 616 | 629 |
| 617 gboolean PanelGtk::OnTitlebarButtonReleaseEvent( | 630 gboolean PanelGtk::OnTitlebarButtonReleaseEvent( |
| 618 GtkWidget* widget, GdkEventButton* event) { | 631 GtkWidget* widget, GdkEventButton* event) { |
| 619 if (event->button != 1) | 632 if (event->button != 1) |
| 620 return TRUE; | 633 return TRUE; |
| 621 | 634 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 857 // No way to deactive a GTK window. Pretend panel is deactivated | 870 // No way to deactive a GTK window. Pretend panel is deactivated |
| 858 // and ignore input. | 871 // and ignore input. |
| 859 ActiveWindowChanged(NULL); | 872 ActiveWindowChanged(NULL); |
| 860 } | 873 } |
| 861 | 874 |
| 862 bool PanelGtk::IsPanelActive() const { | 875 bool PanelGtk::IsPanelActive() const { |
| 863 return is_active_; | 876 return is_active_; |
| 864 } | 877 } |
| 865 | 878 |
| 866 void PanelGtk::PreventActivationByOS(bool prevent_activation) { | 879 void PanelGtk::PreventActivationByOS(bool prevent_activation) { |
| 880 // If the GTK window is set with no focus accepted, it introduces the | |
| 881 // following issues: | |
| 882 // 1) It cannot be brought to the top by calling gdk_window_raise. | |
| 883 // 2) Even after it is forced to the top by calling gtk_window_present or | |
| 884 // gtk_window_set_keep_above, it is not lowered in the z-order when the | |
| 885 // client area of other window is clicked. | |
| 886 // When a docked panel is minimized to a few pixel lines, we do not want it | |
| 887 // to take focus since the user would have hard time to notice that. However, | |
| 888 // when a stacked panel is collapsed to the titlebar-only, focusing on it | |
| 889 // seems not to be too bad. Since we do not have other solution to solve | |
|
Dmitry Titov
2013/06/20 00:57:23
The main reason for us to avoid focusing is to pre
| |
| 890 // the two issues mentioned above for stacked panels, we choose not to | |
| 891 // prevent activation for non-docked panels. | |
| 892 if (panel_->collection()->type() != PanelCollection::DOCKED) | |
| 893 prevent_activation = false; | |
| 867 gtk_window_set_accept_focus(window_, !prevent_activation); | 894 gtk_window_set_accept_focus(window_, !prevent_activation); |
| 868 } | 895 } |
| 869 | 896 |
| 870 gfx::NativeWindow PanelGtk::GetNativePanelWindow() { | 897 gfx::NativeWindow PanelGtk::GetNativePanelWindow() { |
| 871 return window_; | 898 return window_; |
| 872 } | 899 } |
| 873 | 900 |
| 874 void PanelGtk::UpdatePanelTitleBar() { | 901 void PanelGtk::UpdatePanelTitleBar() { |
| 875 TRACE_EVENT0("ui::gtk", "PanelGtk::UpdatePanelTitleBar"); | 902 TRACE_EVENT0("ui::gtk", "PanelGtk::UpdatePanelTitleBar"); |
| 876 string16 title = panel_->GetWindowTitle(); | 903 string16 title = panel_->GetWindowTitle(); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1183 default: | 1210 default: |
| 1184 NOTREACHED(); | 1211 NOTREACHED(); |
| 1185 return false; | 1212 return false; |
| 1186 } | 1213 } |
| 1187 return gtk_widget_get_visible(button->widget()); | 1214 return gtk_widget_get_visible(button->widget()); |
| 1188 } | 1215 } |
| 1189 | 1216 |
| 1190 panel::CornerStyle GtkNativePanelTesting::GetWindowCornerStyle() const { | 1217 panel::CornerStyle GtkNativePanelTesting::GetWindowCornerStyle() const { |
| 1191 return panel_gtk_->corner_style_; | 1218 return panel_gtk_->corner_style_; |
| 1192 } | 1219 } |
| OLD | NEW |