| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 14 matching lines...) Expand all Loading... |
| 25 #include "views/widget/gtk_views_window.h" | 25 #include "views/widget/gtk_views_window.h" |
| 26 #include "views/widget/root_view.h" | 26 #include "views/widget/root_view.h" |
| 27 #include "views/widget/tooltip_manager_gtk.h" | 27 #include "views/widget/tooltip_manager_gtk.h" |
| 28 #include "views/widget/widget_delegate.h" | 28 #include "views/widget/widget_delegate.h" |
| 29 #include "views/window/window_gtk.h" | 29 #include "views/window/window_gtk.h" |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 // g_object data keys to associate a WidgetGtk object to a GtkWidget. | 33 // g_object data keys to associate a WidgetGtk object to a GtkWidget. |
| 34 const char* kWidgetKey = "__VIEWS_WIDGET__"; | 34 const char* kWidgetKey = "__VIEWS_WIDGET__"; |
| 35 const wchar_t* kWidgetWideKey = L"__VIEWS_WIDGET__"; |
| 35 // A g_object data key to associate a CompositePainter object to a GtkWidget. | 36 // A g_object data key to associate a CompositePainter object to a GtkWidget. |
| 36 const char* kCompositePainterKey = "__VIEWS_COMPOSITE_PAINTER__"; | 37 const char* kCompositePainterKey = "__VIEWS_COMPOSITE_PAINTER__"; |
| 37 // A g_object data key to associate the flag whether or not the widget | 38 // A g_object data key to associate the flag whether or not the widget |
| 38 // is composited to a GtkWidget. gtk_widget_is_composited simply tells | 39 // is composited to a GtkWidget. gtk_widget_is_composited simply tells |
| 39 // if x11 supports composition and cannot be used to tell if given widget | 40 // if x11 supports composition and cannot be used to tell if given widget |
| 40 // is composited. | 41 // is composited. |
| 41 const char* kCompositeEnabledKey = "__VIEWS_COMPOSITE_ENABLED__"; | 42 const char* kCompositeEnabledKey = "__VIEWS_COMPOSITE_ENABLED__"; |
| 42 | 43 |
| 43 // CompositePainter draws a composited child widgets image into its | 44 // CompositePainter draws a composited child widgets image into its |
| 44 // drawing area. This object is created at most once for a widget and kept | 45 // drawing area. This object is created at most once for a widget and kept |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 } | 796 } |
| 796 | 797 |
| 797 Window* WidgetGtk::GetWindow() { | 798 Window* WidgetGtk::GetWindow() { |
| 798 return GetWindowImpl(widget_); | 799 return GetWindowImpl(widget_); |
| 799 } | 800 } |
| 800 | 801 |
| 801 const Window* WidgetGtk::GetWindow() const { | 802 const Window* WidgetGtk::GetWindow() const { |
| 802 return GetWindowImpl(widget_); | 803 return GetWindowImpl(widget_); |
| 803 } | 804 } |
| 804 | 805 |
| 805 void WidgetGtk::SetNativeWindowProperty(const char* name, void* value) { | 806 void WidgetGtk::SetNativeWindowProperty(const std::wstring& name, |
| 806 g_object_set_data(G_OBJECT(widget_), name, value); | 807 void* value) { |
| 808 g_object_set_data(G_OBJECT(widget_), WideToUTF8(name).c_str(), value); |
| 807 } | 809 } |
| 808 | 810 |
| 809 void* WidgetGtk::GetNativeWindowProperty(const char* name) { | 811 void* WidgetGtk::GetNativeWindowProperty(const std::wstring& name) { |
| 810 return g_object_get_data(G_OBJECT(widget_), name); | 812 return g_object_get_data(G_OBJECT(widget_), WideToUTF8(name).c_str()); |
| 811 } | 813 } |
| 812 | 814 |
| 813 ThemeProvider* WidgetGtk::GetThemeProvider() const { | 815 ThemeProvider* WidgetGtk::GetThemeProvider() const { |
| 814 return default_theme_provider_.get(); | 816 return default_theme_provider_.get(); |
| 815 } | 817 } |
| 816 | 818 |
| 817 ThemeProvider* WidgetGtk::GetDefaultThemeProvider() const { | 819 ThemeProvider* WidgetGtk::GetDefaultThemeProvider() const { |
| 818 return default_theme_provider_.get(); | 820 return default_theme_provider_.get(); |
| 819 } | 821 } |
| 820 | 822 |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 if (ignore_events_) | 1483 if (ignore_events_) |
| 1482 ConfigureWidgetForIgnoreEvents(); | 1484 ConfigureWidgetForIgnoreEvents(); |
| 1483 | 1485 |
| 1484 SetAlwaysOnTop(always_on_top_); | 1486 SetAlwaysOnTop(always_on_top_); |
| 1485 // The widget needs to be realized before handlers like size-allocate can | 1487 // The widget needs to be realized before handlers like size-allocate can |
| 1486 // function properly. | 1488 // function properly. |
| 1487 gtk_widget_realize(widget_); | 1489 gtk_widget_realize(widget_); |
| 1488 } | 1490 } |
| 1489 // Setting the WidgetKey property to widget_, which is used by | 1491 // Setting the WidgetKey property to widget_, which is used by |
| 1490 // GetWidgetFromNativeWindow. | 1492 // GetWidgetFromNativeWindow. |
| 1491 SetNativeWindowProperty(kWidgetKey, this); | 1493 SetNativeWindowProperty(kWidgetWideKey, this); |
| 1492 } | 1494 } |
| 1493 | 1495 |
| 1494 void WidgetGtk::ConfigureWidgetForTransparentBackground(GtkWidget* parent) { | 1496 void WidgetGtk::ConfigureWidgetForTransparentBackground(GtkWidget* parent) { |
| 1495 DCHECK(widget_ && window_contents_); | 1497 DCHECK(widget_ && window_contents_); |
| 1496 | 1498 |
| 1497 GdkColormap* rgba_colormap = | 1499 GdkColormap* rgba_colormap = |
| 1498 gdk_screen_get_rgba_colormap(gtk_widget_get_screen(widget_)); | 1500 gdk_screen_get_rgba_colormap(gtk_widget_get_screen(widget_)); |
| 1499 if (!rgba_colormap) { | 1501 if (!rgba_colormap) { |
| 1500 transparent_ = false; | 1502 transparent_ = false; |
| 1501 return; | 1503 return; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1654 GtkWindow* window = GTK_WINDOW(element->data); | 1656 GtkWindow* window = GTK_WINDOW(element->data); |
| 1655 DCHECK(window); | 1657 DCHECK(window); |
| 1656 RootView *root_view = FindRootView(window); | 1658 RootView *root_view = FindRootView(window); |
| 1657 if (root_view) | 1659 if (root_view) |
| 1658 root_view->NotifyLocaleChanged(); | 1660 root_view->NotifyLocaleChanged(); |
| 1659 } | 1661 } |
| 1660 g_list_free(window_list); | 1662 g_list_free(window_list); |
| 1661 } | 1663 } |
| 1662 | 1664 |
| 1663 } // namespace views | 1665 } // namespace views |
| OLD | NEW |