| 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 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 // See Hide() for the reason why we're not calling | 1199 // See Hide() for the reason why we're not calling |
| 1200 // OnNativeWidgetVisibilityChange. | 1200 // OnNativeWidgetVisibilityChange. |
| 1201 } | 1201 } |
| 1202 } | 1202 } |
| 1203 | 1203 |
| 1204 void NativeWidgetGtk::Hide() { | 1204 void NativeWidgetGtk::Hide() { |
| 1205 if (widget_) { | 1205 if (widget_) { |
| 1206 gtk_widget_hide(widget_); | 1206 gtk_widget_hide(widget_); |
| 1207 if (widget_->window) | 1207 if (widget_->window) |
| 1208 gdk_window_lower(widget_->window); | 1208 gdk_window_lower(widget_->window); |
| 1209 // We're not calling OnNativeWidgetVisibilityChanged because it | |
| 1210 // breaks the ability to refocus to FindBar. NativeControlGtk | |
| 1211 // detaches the underlying gtk widget for optimization purpose | |
| 1212 // when it becomes invisible, which in turn breaks SetNativeFocus | |
| 1213 // because there is no gtk attached to NativeControlGtk. I'm not | |
| 1214 // fixing that part because | |
| 1215 // a) This is views/gtk only issue, which will be gone soon. | |
| 1216 // b) Alternative fix, which we can modify animator to show it | |
| 1217 // immediately, won't be necessary for non gtk implementation. | |
| 1218 } | 1209 } |
| 1219 } | 1210 } |
| 1220 | 1211 |
| 1221 void NativeWidgetGtk::ShowMaximizedWithBounds( | 1212 void NativeWidgetGtk::ShowMaximizedWithBounds( |
| 1222 const gfx::Rect& restored_bounds) { | 1213 const gfx::Rect& restored_bounds) { |
| 1223 // TODO: when we add maximization support update this. | 1214 // TODO: when we add maximization support update this. |
| 1224 Show(); | 1215 Show(); |
| 1225 } | 1216 } |
| 1226 | 1217 |
| 1227 void NativeWidgetGtk::ShowWithWindowState(ui::WindowShowState show_state) { | 1218 void NativeWidgetGtk::ShowWithWindowState(ui::WindowShowState show_state) { |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1818 widget_ = window_contents_ = NULL; | 1809 widget_ = window_contents_ = NULL; |
| 1819 } | 1810 } |
| 1820 | 1811 |
| 1821 void NativeWidgetGtk::OnDestroyed(GObject *where_the_object_was) { | 1812 void NativeWidgetGtk::OnDestroyed(GObject *where_the_object_was) { |
| 1822 delegate_->OnNativeWidgetDestroyed(); | 1813 delegate_->OnNativeWidgetDestroyed(); |
| 1823 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 1814 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
| 1824 delete this; | 1815 delete this; |
| 1825 } | 1816 } |
| 1826 | 1817 |
| 1827 void NativeWidgetGtk::OnShow(GtkWidget* widget) { | 1818 void NativeWidgetGtk::OnShow(GtkWidget* widget) { |
| 1819 delegate_->OnNativeWidgetVisibilityChanged(true); |
| 1828 } | 1820 } |
| 1829 | 1821 |
| 1830 void NativeWidgetGtk::OnMap(GtkWidget* widget) { | 1822 void NativeWidgetGtk::OnMap(GtkWidget* widget) { |
| 1831 #if defined(TOUCH_UI) | 1823 #if defined(TOUCH_UI) |
| 1832 // Force an expose event to trigger OnPaint for touch. This is | 1824 // Force an expose event to trigger OnPaint for touch. This is |
| 1833 // a workaround for a bug that X Expose event does not trigger | 1825 // a workaround for a bug that X Expose event does not trigger |
| 1834 // Gdk's expose signal. This happens when you try to open views menu | 1826 // Gdk's expose signal. This happens when you try to open views menu |
| 1835 // while a virtual keyboard gets kicked in or out. This seems to be | 1827 // while a virtual keyboard gets kicked in or out. This seems to be |
| 1836 // a bug in message_pump_x.cc as we do get X Expose event but | 1828 // a bug in message_pump_x.cc as we do get X Expose event but |
| 1837 // it doesn't trigger gtk's expose signal. We're not going to fix this | 1829 // it doesn't trigger gtk's expose signal. We're not going to fix this |
| 1838 // as we're removing gtk and migrating to new compositor. | 1830 // as we're removing gtk and migrating to new compositor. |
| 1839 gdk_window_process_all_updates(); | 1831 gdk_window_process_all_updates(); |
| 1840 #endif | 1832 #endif |
| 1841 } | 1833 } |
| 1842 | 1834 |
| 1843 void NativeWidgetGtk::OnHide(GtkWidget* widget) { | 1835 void NativeWidgetGtk::OnHide(GtkWidget* widget) { |
| 1836 delegate_->OnNativeWidgetVisibilityChanged(false); |
| 1844 } | 1837 } |
| 1845 | 1838 |
| 1846 gboolean NativeWidgetGtk::OnWindowStateEvent(GtkWidget* widget, | 1839 gboolean NativeWidgetGtk::OnWindowStateEvent(GtkWidget* widget, |
| 1847 GdkEventWindowState* event) { | 1840 GdkEventWindowState* event) { |
| 1848 if (GetWidget()->non_client_view() && | 1841 if (GetWidget()->non_client_view() && |
| 1849 !(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN)) { | 1842 !(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN)) { |
| 1850 SaveWindowPosition(); | 1843 SaveWindowPosition(); |
| 1851 } | 1844 } |
| 1852 window_state_ = event->new_window_state; | 1845 window_state_ = event->new_window_state; |
| 1853 return FALSE; | 1846 return FALSE; |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2314 button_pressed = event->type == GDK_BUTTON_PRESS || | 2307 button_pressed = event->type == GDK_BUTTON_PRESS || |
| 2315 event->type == GDK_2BUTTON_PRESS || | 2308 event->type == GDK_2BUTTON_PRESS || |
| 2316 event->type == GDK_3BUTTON_PRESS; | 2309 event->type == GDK_3BUTTON_PRESS; |
| 2317 gdk_event_free(event); | 2310 gdk_event_free(event); |
| 2318 } | 2311 } |
| 2319 return button_pressed; | 2312 return button_pressed; |
| 2320 } | 2313 } |
| 2321 | 2314 |
| 2322 } // namespace internal | 2315 } // namespace internal |
| 2323 } // namespace views | 2316 } // namespace views |
| OLD | NEW |