| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/widget/native_widget_gtk.h" | 5 #include "ui/views/widget/native_widget_gtk.h" |
| 6 | 6 |
| 7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 #include <X11/extensions/shape.h> | 9 #include <X11/extensions/shape.h> |
| 10 #include <gdk/gdk.h> | 10 #include <gdk/gdk.h> |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 | 641 |
| 642 // Make container here. | 642 // Make container here. |
| 643 CreateGtkWidget(modified_params); | 643 CreateGtkWidget(modified_params); |
| 644 | 644 |
| 645 if (params.type == Widget::InitParams::TYPE_MENU) { | 645 if (params.type == Widget::InitParams::TYPE_MENU) { |
| 646 gtk_window_set_destroy_with_parent(GTK_WINDOW(GetNativeView()), TRUE); | 646 gtk_window_set_destroy_with_parent(GTK_WINDOW(GetNativeView()), TRUE); |
| 647 gtk_window_set_type_hint(GTK_WINDOW(GetNativeView()), | 647 gtk_window_set_type_hint(GTK_WINDOW(GetNativeView()), |
| 648 GDK_WINDOW_TYPE_HINT_MENU); | 648 GDK_WINDOW_TYPE_HINT_MENU); |
| 649 } | 649 } |
| 650 | 650 |
| 651 if (View::get_use_acceleration_when_possible()) { | |
| 652 gint width, height; | |
| 653 gdk_drawable_get_size(window_contents_->window, &width, &height); | |
| 654 compositor_ = ui::Compositor::Create(this, | |
| 655 GDK_WINDOW_XID(window_contents_->window), | |
| 656 gfx::Size(width, height)); | |
| 657 if (compositor_.get()) { | |
| 658 View* root_view = delegate_->AsWidget()->GetRootView(); | |
| 659 root_view->SetPaintToLayer(true); | |
| 660 compositor_->SetRootLayer(root_view->layer()); | |
| 661 root_view->SetFillsBoundsOpaquely(!transparent_); | |
| 662 } | |
| 663 } | |
| 664 | |
| 665 delegate_->OnNativeWidgetCreated(); | 651 delegate_->OnNativeWidgetCreated(); |
| 666 | 652 |
| 667 if (opacity_ != 255) | 653 if (opacity_ != 255) |
| 668 SetOpacity(opacity_); | 654 SetOpacity(opacity_); |
| 669 | 655 |
| 670 // Make sure we receive our motion events. | 656 // Make sure we receive our motion events. |
| 671 | 657 |
| 672 // In general we register most events on the parent of all widgets. At a | 658 // In general we register most events on the parent of all widgets. At a |
| 673 // minimum we need painting to happen on the parent (otherwise painting | 659 // minimum we need painting to happen on the parent (otherwise painting |
| 674 // doesn't work at all), and similarly we need mouse release events on the | 660 // doesn't work at all), and similarly we need mouse release events on the |
| (...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2204 button_pressed = event->type == GDK_BUTTON_PRESS || | 2190 button_pressed = event->type == GDK_BUTTON_PRESS || |
| 2205 event->type == GDK_2BUTTON_PRESS || | 2191 event->type == GDK_2BUTTON_PRESS || |
| 2206 event->type == GDK_3BUTTON_PRESS; | 2192 event->type == GDK_3BUTTON_PRESS; |
| 2207 gdk_event_free(event); | 2193 gdk_event_free(event); |
| 2208 } | 2194 } |
| 2209 return button_pressed; | 2195 return button_pressed; |
| 2210 } | 2196 } |
| 2211 | 2197 |
| 2212 } // namespace internal | 2198 } // namespace internal |
| 2213 } // namespace views | 2199 } // namespace views |
| OLD | NEW |