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 Panel* panel = *iter; |
| 619 GtkWindow* gtk_window = panel->GetNativeWindow(); |
| 620 // If a panel is collapsed, we make it not to take focus. For such window, |
| 621 // it cannot be brought to the top by calling gdk_window_raise. To work |
| 622 // around this issue, we make it always-on-top first and then put it back |
| 623 // to normal. Note that this trick has been done for all panels in the |
| 624 // stack, regardless of whether it is collapsed or not. |
| 625 // There is one side-effect to this approach: if the panel being pressed |
| 626 // on is collapsed, clicking on the client area of the last active |
| 627 // window will not raise it above these panels. |
| 628 gtk_window_set_keep_above(gtk_window, true); |
| 629 gtk_window_set_keep_above(gtk_window, false); |
| 630 } |
| 631 } else { |
| 632 gdk_window_raise(gtk_widget_get_window(GTK_WIDGET(window_))); |
| 633 } |
| 634 |
612 EnsureDragHelperCreated(); | 635 EnsureDragHelperCreated(); |
613 drag_helper_->InitialTitlebarMousePress(event, titlebar_->widget()); | 636 drag_helper_->InitialTitlebarMousePress(event, titlebar_->widget()); |
614 return TRUE; | 637 return TRUE; |
615 } | 638 } |
616 | 639 |
617 gboolean PanelGtk::OnTitlebarButtonReleaseEvent( | 640 gboolean PanelGtk::OnTitlebarButtonReleaseEvent( |
618 GtkWidget* widget, GdkEventButton* event) { | 641 GtkWidget* widget, GdkEventButton* event) { |
619 if (event->button != 1) | 642 if (event->button != 1) |
620 return TRUE; | 643 return TRUE; |
621 | 644 |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 default: | 1206 default: |
1184 NOTREACHED(); | 1207 NOTREACHED(); |
1185 return false; | 1208 return false; |
1186 } | 1209 } |
1187 return gtk_widget_get_visible(button->widget()); | 1210 return gtk_widget_get_visible(button->widget()); |
1188 } | 1211 } |
1189 | 1212 |
1190 panel::CornerStyle GtkNativePanelTesting::GetWindowCornerStyle() const { | 1213 panel::CornerStyle GtkNativePanelTesting::GetWindowCornerStyle() const { |
1191 return panel_gtk_->corner_style_; | 1214 return panel_gtk_->corner_style_; |
1192 } | 1215 } |
OLD | NEW |