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/widget_gtk.h" | 5 #include "views/widget/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 | 10 |
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 GList *window_list = gtk_window_list_toplevels(); | 1558 GList *window_list = gtk_window_list_toplevels(); |
1559 for (GList* element = window_list; element; element = g_list_next(element)) { | 1559 for (GList* element = window_list; element; element = g_list_next(element)) { |
1560 NativeWidget* native_widget = | 1560 NativeWidget* native_widget = |
1561 NativeWidget::GetNativeWidgetForNativeWindow(GTK_WINDOW(element->data)); | 1561 NativeWidget::GetNativeWidgetForNativeWindow(GTK_WINDOW(element->data)); |
1562 if (native_widget) | 1562 if (native_widget) |
1563 native_widget->GetWidget()->LocaleChanged(); | 1563 native_widget->GetWidget()->LocaleChanged(); |
1564 } | 1564 } |
1565 g_list_free(window_list); | 1565 g_list_free(window_list); |
1566 } | 1566 } |
1567 | 1567 |
| 1568 // static |
| 1569 bool Widget::ConvertRect(const Widget* source, |
| 1570 const Widget* target, |
| 1571 gfx::Rect* rect) { |
| 1572 DCHECK(source); |
| 1573 DCHECK(target); |
| 1574 DCHECK(rect); |
| 1575 |
| 1576 GtkWidget* source_widget = source->GetNativeView(); |
| 1577 GtkWidget* target_widget = target->GetNativeView(); |
| 1578 if (source_widget == target_widget) |
| 1579 return true; |
| 1580 |
| 1581 if (!source_widget || !target_widget) |
| 1582 return false; |
| 1583 |
| 1584 GdkRectangle gdk_rect = rect->ToGdkRectangle(); |
| 1585 if (gtk_widget_translate_coordinates(source_widget, target_widget, |
| 1586 gdk_rect.x, gdk_rect.y, |
| 1587 &gdk_rect.x, &gdk_rect.y)) { |
| 1588 *rect = gdk_rect; |
| 1589 return true; |
| 1590 } |
| 1591 return false; |
| 1592 } |
| 1593 |
1568 //////////////////////////////////////////////////////////////////////////////// | 1594 //////////////////////////////////////////////////////////////////////////////// |
1569 // NativeWidget, public: | 1595 // NativeWidget, public: |
1570 | 1596 |
1571 // static | 1597 // static |
1572 NativeWidget* NativeWidget::GetNativeWidgetForNativeView( | 1598 NativeWidget* NativeWidget::GetNativeWidgetForNativeView( |
1573 gfx::NativeView native_view) { | 1599 gfx::NativeView native_view) { |
1574 if (!native_view) | 1600 if (!native_view) |
1575 return NULL; | 1601 return NULL; |
1576 return reinterpret_cast<WidgetGtk*>( | 1602 return reinterpret_cast<WidgetGtk*>( |
1577 g_object_get_data(G_OBJECT(native_view), kNativeWidgetKey)); | 1603 g_object_get_data(G_OBJECT(native_view), kNativeWidgetKey)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 | 1640 |
1615 NativeWidget* native_widget = GetNativeWidgetForNativeView(native_view); | 1641 NativeWidget* native_widget = GetNativeWidgetForNativeView(native_view); |
1616 if (native_widget) | 1642 if (native_widget) |
1617 children->insert(native_widget); | 1643 children->insert(native_widget); |
1618 gtk_container_foreach(GTK_CONTAINER(native_view), | 1644 gtk_container_foreach(GTK_CONTAINER(native_view), |
1619 EnumerateChildWidgetsForNativeWidgets, | 1645 EnumerateChildWidgetsForNativeWidgets, |
1620 reinterpret_cast<gpointer>(children)); | 1646 reinterpret_cast<gpointer>(children)); |
1621 } | 1647 } |
1622 | 1648 |
1623 } // namespace views | 1649 } // namespace views |
OLD | NEW |