OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "views/fill_layout.h" | 8 #include "views/fill_layout.h" |
9 #include "views/widget/default_theme_provider.h" | 9 #include "views/widget/default_theme_provider.h" |
10 #include "views/widget/root_view.h" | 10 #include "views/widget/root_view.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // g_signal_connect(G_OBJECT(widget_), "drag_data_received", | 156 // g_signal_connect(G_OBJECT(widget_), "drag_data_received", |
157 // G_CALLBACK(drag_data_received_event_cb), NULL); | 157 // G_CALLBACK(drag_data_received_event_cb), NULL); |
158 | 158 |
159 tooltip_manager_.reset(new TooltipManagerGtk(this)); | 159 tooltip_manager_.reset(new TooltipManagerGtk(this)); |
160 | 160 |
161 if (type_ == TYPE_CHILD) { | 161 if (type_ == TYPE_CHILD) { |
162 WidgetGtk* parent_widget = GetViewForNative(parent); | 162 WidgetGtk* parent_widget = GetViewForNative(parent); |
163 parent_widget->AddChild(widget_); | 163 parent_widget->AddChild(widget_); |
164 parent_widget->PositionChild(widget_, bounds.x(), bounds.y(), | 164 parent_widget->PositionChild(widget_, bounds.x(), bounds.y(), |
165 bounds.width(), bounds.height()); | 165 bounds.width(), bounds.height()); |
| 166 } else { |
| 167 if (bounds.width() > 0 && bounds.height() > 0) |
| 168 gtk_window_resize(GTK_WINDOW(widget_), bounds.width(), bounds.height()); |
| 169 gtk_window_move(GTK_WINDOW(widget_), bounds.x(), bounds.y()); |
166 } | 170 } |
167 } | 171 } |
168 | 172 |
169 void WidgetGtk::AddChild(GtkWidget* child) { | 173 void WidgetGtk::AddChild(GtkWidget* child) { |
170 gtk_container_add(GTK_CONTAINER(child_widget_parent_), child); | 174 gtk_container_add(GTK_CONTAINER(child_widget_parent_), child); |
171 } | 175 } |
172 | 176 |
173 void WidgetGtk::RemoveChild(GtkWidget* child) { | 177 void WidgetGtk::RemoveChild(GtkWidget* child) { |
174 gtk_container_remove(GTK_CONTAINER(child_widget_parent_), child); | 178 gtk_container_remove(GTK_CONTAINER(child_widget_parent_), child); |
175 } | 179 } |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 SetWindowForNative(widget_, static_cast<WindowGtk*>(this)); | 361 SetWindowForNative(widget_, static_cast<WindowGtk*>(this)); |
358 SetViewForNative(widget_, this); | 362 SetViewForNative(widget_, this); |
359 | 363 |
360 child_widget_parent_ = gtk_fixed_new(); | 364 child_widget_parent_ = gtk_fixed_new(); |
361 gtk_fixed_set_has_window(GTK_FIXED(child_widget_parent_), true); | 365 gtk_fixed_set_has_window(GTK_FIXED(child_widget_parent_), true); |
362 gtk_container_add(GTK_CONTAINER(widget_), child_widget_parent_); | 366 gtk_container_add(GTK_CONTAINER(widget_), child_widget_parent_); |
363 gtk_widget_show(child_widget_parent_); | 367 gtk_widget_show(child_widget_parent_); |
364 | 368 |
365 SetViewForNative(child_widget_parent_, this); | 369 SetViewForNative(child_widget_parent_, this); |
366 } | 370 } |
367 gtk_widget_show(widget_); | |
368 } | 371 } |
369 | 372 |
370 void WidgetGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { | 373 void WidgetGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { |
371 root_view_->SetBounds(0, 0, allocation->width, allocation->height); | 374 root_view_->SetBounds(0, 0, allocation->width, allocation->height); |
372 root_view_->Layout(); | 375 root_view_->Layout(); |
373 root_view_->SchedulePaint(); | 376 root_view_->SchedulePaint(); |
374 } | 377 } |
375 | 378 |
376 gboolean WidgetGtk::OnMotionNotify(GtkWidget* widget, GdkEventMotion* event) { | 379 gboolean WidgetGtk::OnMotionNotify(GtkWidget* widget, GdkEventMotion* event) { |
377 if (has_capture_ && is_mouse_down_) { | 380 if (has_capture_ && is_mouse_down_) { |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 void WidgetGtk::HandleGrabBroke() { | 690 void WidgetGtk::HandleGrabBroke() { |
688 if (has_capture_) { | 691 if (has_capture_) { |
689 if (is_mouse_down_) | 692 if (is_mouse_down_) |
690 root_view_->ProcessMouseDragCanceled(); | 693 root_view_->ProcessMouseDragCanceled(); |
691 is_mouse_down_ = false; | 694 is_mouse_down_ = false; |
692 has_capture_ = false; | 695 has_capture_ = false; |
693 } | 696 } |
694 } | 697 } |
695 | 698 |
696 } // namespace views | 699 } // namespace views |
OLD | NEW |