OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/widget/native_widget_gtk.h" | 5 #include "views/widget/native_widget_gtk.h" |
6 | 6 |
7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
9 #include <X11/extensions/shape.h> | 9 #include <X11/extensions/shape.h> |
10 #include <X11/Xatom.h> | 10 #include <X11/Xatom.h> |
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 } else { | 996 } else { |
997 // We have no parent window, center over the screen. | 997 // We have no parent window, center over the screen. |
998 center_rect = gfx::Screen::GetMonitorWorkAreaNearestWindow(GetNativeView()); | 998 center_rect = gfx::Screen::GetMonitorWorkAreaNearestWindow(GetNativeView()); |
999 } | 999 } |
1000 gfx::Rect bounds(center_rect.x() + (center_rect.width() - size.width()) / 2, | 1000 gfx::Rect bounds(center_rect.x() + (center_rect.width() - size.width()) / 2, |
1001 center_rect.y() + (center_rect.height() - size.height()) / 2, | 1001 center_rect.y() + (center_rect.height() - size.height()) / 2, |
1002 size.width(), size.height()); | 1002 size.width(), size.height()); |
1003 SetBoundsConstrained(bounds, NULL); | 1003 SetBoundsConstrained(bounds, NULL); |
1004 } | 1004 } |
1005 | 1005 |
1006 void NativeWidgetGtk::GetWindowBoundsAndMaximizedState(gfx::Rect* bounds, | 1006 void NativeWidgetGtk::GetWindowBoundsAndShowState( |
1007 bool* maximized) const { | 1007 gfx::Rect* bounds, |
| 1008 ui::WindowShowState* show_state) const { |
1008 // Do nothing for now. ChromeOS isn't yet saving window placement. | 1009 // Do nothing for now. ChromeOS isn't yet saving window placement. |
1009 } | 1010 } |
1010 | 1011 |
1011 void NativeWidgetGtk::SetWindowTitle(const std::wstring& title) { | 1012 void NativeWidgetGtk::SetWindowTitle(const std::wstring& title) { |
1012 // We don't have a window title on ChromeOS (right now). | 1013 // We don't have a window title on ChromeOS (right now). |
1013 } | 1014 } |
1014 | 1015 |
1015 void NativeWidgetGtk::SetWindowIcons(const SkBitmap& window_icon, | 1016 void NativeWidgetGtk::SetWindowIcons(const SkBitmap& window_icon, |
1016 const SkBitmap& app_icon) { | 1017 const SkBitmap& app_icon) { |
1017 // We don't have window icons on ChromeOS. | 1018 // We don't have window icons on ChromeOS. |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 delegate_->OnNativeWidgetVisibilityChanged(false); | 1179 delegate_->OnNativeWidgetVisibilityChanged(false); |
1179 } | 1180 } |
1180 } | 1181 } |
1181 | 1182 |
1182 void NativeWidgetGtk::ShowMaximizedWithBounds( | 1183 void NativeWidgetGtk::ShowMaximizedWithBounds( |
1183 const gfx::Rect& restored_bounds) { | 1184 const gfx::Rect& restored_bounds) { |
1184 // TODO: when we add maximization support update this. | 1185 // TODO: when we add maximization support update this. |
1185 Show(); | 1186 Show(); |
1186 } | 1187 } |
1187 | 1188 |
1188 void NativeWidgetGtk::ShowWithState(ShowState state) { | 1189 void NativeWidgetGtk::ShowWithWindowState(ui::WindowShowState show_state) { |
1189 // No concept of maximization (yet) on ChromeOS. | 1190 // No concept of maximization (yet) on ChromeOS. |
1190 if (state == internal::NativeWidgetPrivate::SHOW_INACTIVE) | 1191 if (show_state == ui::SHOW_STATE_INACTIVE) |
1191 gtk_window_set_focus_on_map(GetNativeWindow(), false); | 1192 gtk_window_set_focus_on_map(GetNativeWindow(), false); |
1192 gtk_widget_show(GetNativeView()); | 1193 gtk_widget_show(GetNativeView()); |
1193 } | 1194 } |
1194 | 1195 |
1195 bool NativeWidgetGtk::IsVisible() const { | 1196 bool NativeWidgetGtk::IsVisible() const { |
1196 return GTK_WIDGET_VISIBLE(GetNativeView()); | 1197 return GTK_WIDGET_VISIBLE(GetNativeView()); |
1197 } | 1198 } |
1198 | 1199 |
1199 void NativeWidgetGtk::Activate() { | 1200 void NativeWidgetGtk::Activate() { |
1200 gtk_window_present(GetNativeWindow()); | 1201 gtk_window_present(GetNativeWindow()); |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2068 gdk_cairo_region(cr, event->region); | 2069 gdk_cairo_region(cr, event->region); |
2069 cairo_fill(cr); | 2070 cairo_fill(cr); |
2070 cairo_destroy(cr); | 2071 cairo_destroy(cr); |
2071 } | 2072 } |
2072 | 2073 |
2073 void NativeWidgetGtk::SaveWindowPosition() { | 2074 void NativeWidgetGtk::SaveWindowPosition() { |
2074 // The delegate may have gone away on us. | 2075 // The delegate may have gone away on us. |
2075 if (!GetWidget()->widget_delegate()) | 2076 if (!GetWidget()->widget_delegate()) |
2076 return; | 2077 return; |
2077 | 2078 |
2078 bool maximized = window_state_ & GDK_WINDOW_STATE_MAXIMIZED; | 2079 ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL; |
| 2080 if (IsMaximized()) |
| 2081 show_state = ui::SHOW_STATE_MAXIMIZED; |
| 2082 else if (IsMinimized()) |
| 2083 show_state = ui::SHOW_STATE_MINIMIZED; |
2079 GetWidget()->widget_delegate()->SaveWindowPlacement( | 2084 GetWidget()->widget_delegate()->SaveWindowPlacement( |
2080 GetWidget()->GetWindowScreenBounds(), | 2085 GetWidget()->GetWindowScreenBounds(), |
2081 maximized); | 2086 show_state); |
2082 } | 2087 } |
2083 | 2088 |
2084 //////////////////////////////////////////////////////////////////////////////// | 2089 //////////////////////////////////////////////////////////////////////////////// |
2085 // Widget, public: | 2090 // Widget, public: |
2086 | 2091 |
2087 // static | 2092 // static |
2088 void Widget::NotifyLocaleChanged() { | 2093 void Widget::NotifyLocaleChanged() { |
2089 GList *window_list = gtk_window_list_toplevels(); | 2094 GList *window_list = gtk_window_list_toplevels(); |
2090 for (GList* element = window_list; element; element = g_list_next(element)) { | 2095 for (GList* element = window_list; element; element = g_list_next(element)) { |
2091 Widget* widget = | 2096 Widget* widget = |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2243 button_pressed = event->type == GDK_BUTTON_PRESS || | 2248 button_pressed = event->type == GDK_BUTTON_PRESS || |
2244 event->type == GDK_2BUTTON_PRESS || | 2249 event->type == GDK_2BUTTON_PRESS || |
2245 event->type == GDK_3BUTTON_PRESS; | 2250 event->type == GDK_3BUTTON_PRESS; |
2246 gdk_event_free(event); | 2251 gdk_event_free(event); |
2247 } | 2252 } |
2248 return button_pressed; | 2253 return button_pressed; |
2249 } | 2254 } |
2250 | 2255 |
2251 } // namespace internal | 2256 } // namespace internal |
2252 } // namespace views | 2257 } // namespace views |
OLD | NEW |