Chromium Code Reviews| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 | 173 |
| 174 void RemoveExposeHandlerIfExists(GtkWidget* widget) { | 174 void RemoveExposeHandlerIfExists(GtkWidget* widget) { |
| 175 gulong id = reinterpret_cast<gulong>(g_object_get_data(G_OBJECT(widget), | 175 gulong id = reinterpret_cast<gulong>(g_object_get_data(G_OBJECT(widget), |
| 176 kExposeHandlerIdKey)); | 176 kExposeHandlerIdKey)); |
| 177 if (id) { | 177 if (id) { |
| 178 g_signal_handler_disconnect(G_OBJECT(widget), id); | 178 g_signal_handler_disconnect(G_OBJECT(widget), id); |
| 179 g_object_set_data(G_OBJECT(widget), kExposeHandlerIdKey, 0); | 179 g_object_set_data(G_OBJECT(widget), kExposeHandlerIdKey, 0); |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 GtkWindowType WindowTypeToGtkWindowType(Widget::InitParams::Type type) { | |
| 184 switch (type) { | |
| 185 case Widget::InitParams::TYPE_WINDOW: | |
| 186 case Widget::InitParams::TYPE_WINDOW_FRAMELESS: | |
| 187 return GTK_WINDOW_TOPLEVEL; | |
| 188 default: | |
|
Daniel Erat
2011/06/09 05:40:22
mind changing this to:
case Widget::InitParams::T
| |
| 189 return GTK_WINDOW_POPUP; | |
| 190 } | |
| 191 NOTREACHED(); | |
| 192 return GTK_WINDOW_TOPLEVEL; | |
| 193 } | |
| 194 | |
| 183 } // namespace | 195 } // namespace |
| 184 | 196 |
| 185 // During drag and drop GTK sends a drag-leave during a drop. This means we | 197 // During drag and drop GTK sends a drag-leave during a drop. This means we |
| 186 // have no way to tell the difference between a normal drag leave and a drop. | 198 // have no way to tell the difference between a normal drag leave and a drop. |
| 187 // To work around that we listen for DROP_START, then ignore the subsequent | 199 // To work around that we listen for DROP_START, then ignore the subsequent |
| 188 // drag-leave that GTK generates. | 200 // drag-leave that GTK generates. |
| 189 class NativeWidgetGtk::DropObserver : public MessageLoopForUI::Observer { | 201 class NativeWidgetGtk::DropObserver : public MessageLoopForUI::Observer { |
| 190 public: | 202 public: |
| 191 DropObserver() {} | 203 DropObserver() {} |
| 192 | 204 |
| (...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1669 | 1681 |
| 1670 // This can't be done without a parent present, or stale data | 1682 // This can't be done without a parent present, or stale data |
| 1671 // might show up on the screen as seen in | 1683 // might show up on the screen as seen in |
| 1672 // http://code.google.com/p/chromium/issues/detail?id=53870 | 1684 // http://code.google.com/p/chromium/issues/detail?id=53870 |
| 1673 GtkAllocation alloc = | 1685 GtkAllocation alloc = |
| 1674 { 0, 0, params.bounds.width(), params.bounds.height() }; | 1686 { 0, 0, params.bounds.width(), params.bounds.height() }; |
| 1675 gtk_widget_size_allocate(widget_, &alloc); | 1687 gtk_widget_size_allocate(widget_, &alloc); |
| 1676 } | 1688 } |
| 1677 } else { | 1689 } else { |
| 1678 // Use our own window class to override GtkWindow's move_focus method. | 1690 // Use our own window class to override GtkWindow's move_focus method. |
| 1679 widget_ = gtk_views_window_new( | 1691 widget_ = gtk_views_window_new(WindowTypeToGtkWindowType(params.type)); |
| 1680 params.type == Widget::InitParams::TYPE_WINDOW ? GTK_WINDOW_TOPLEVEL | |
| 1681 : GTK_WINDOW_POPUP); | |
| 1682 gtk_widget_set_name(widget_, "views-gtkwidget-window"); | 1692 gtk_widget_set_name(widget_, "views-gtkwidget-window"); |
| 1683 if (transient_to_parent_) { | 1693 if (transient_to_parent_) { |
| 1684 gtk_window_set_transient_for(GTK_WINDOW(widget_), | 1694 gtk_window_set_transient_for(GTK_WINDOW(widget_), |
| 1685 GTK_WINDOW(params.parent)); | 1695 GTK_WINDOW(params.parent)); |
| 1686 } | 1696 } |
| 1687 GTK_WIDGET_UNSET_FLAGS(widget_, GTK_DOUBLE_BUFFERED); | 1697 GTK_WIDGET_UNSET_FLAGS(widget_, GTK_DOUBLE_BUFFERED); |
| 1688 | 1698 |
| 1689 // Gtk determines the size for windows based on the requested size of the | 1699 // Gtk determines the size for windows based on the requested size of the |
| 1690 // child. For NativeWidgetGtk the child is a fixed. If the fixed ends up | 1700 // child. For NativeWidgetGtk the child is a fixed. If the fixed ends up |
| 1691 // with a child widget it's possible the child widget will drive the | 1701 // with a child widget it's possible the child widget will drive the |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1945 | 1955 |
| 1946 // And now, notify them that they have a brand new parent. | 1956 // And now, notify them that they have a brand new parent. |
| 1947 for (NativeWidgets::iterator it = widgets.begin(); | 1957 for (NativeWidgets::iterator it = widgets.begin(); |
| 1948 it != widgets.end(); ++it) { | 1958 it != widgets.end(); ++it) { |
| 1949 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true, | 1959 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true, |
| 1950 new_parent); | 1960 new_parent); |
| 1951 } | 1961 } |
| 1952 } | 1962 } |
| 1953 | 1963 |
| 1954 } // namespace views | 1964 } // namespace views |
| OLD | NEW |