Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: views/widget/widget_gtk.cc

Issue 2768006: Test + Fix for GTK window resizing when using toolkit views. (Closed)
Patch Set: Return a gfx::Size instead. Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « views/widget/widget_gtk.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 void WidgetGtk::AddChild(GtkWidget* child) { 324 void WidgetGtk::AddChild(GtkWidget* child) {
325 gtk_container_add(GTK_CONTAINER(window_contents_), child); 325 gtk_container_add(GTK_CONTAINER(window_contents_), child);
326 } 326 }
327 327
328 void WidgetGtk::RemoveChild(GtkWidget* child) { 328 void WidgetGtk::RemoveChild(GtkWidget* child) {
329 // We can be called after the contents widget has been destroyed, e.g. any 329 // We can be called after the contents widget has been destroyed, e.g. any
330 // NativeViewHost not removed from the view hierarchy before the window is 330 // NativeViewHost not removed from the view hierarchy before the window is
331 // closed. 331 // closed.
332 if (GTK_IS_CONTAINER(window_contents_)) { 332 if (GTK_IS_CONTAINER(window_contents_)) {
333 gtk_container_remove(GTK_CONTAINER(window_contents_), child); 333 gtk_container_remove(GTK_CONTAINER(window_contents_), child);
334 gtk_views_fixed_set_use_allocated_size(child, false); 334 gtk_views_fixed_set_widget_size(child, 0, 0);
335 } 335 }
336 } 336 }
337 337
338 void WidgetGtk::ReparentChild(GtkWidget* child) { 338 void WidgetGtk::ReparentChild(GtkWidget* child) {
339 gtk_widget_reparent(child, window_contents_); 339 gtk_widget_reparent(child, window_contents_);
340 } 340 }
341 341
342 void WidgetGtk::PositionChild(GtkWidget* child, int x, int y, int w, int h) { 342 void WidgetGtk::PositionChild(GtkWidget* child, int x, int y, int w, int h) {
343 GtkAllocation alloc = { x, y, w, h }; 343 gtk_views_fixed_set_widget_size(child, w, h);
344 gtk_widget_size_allocate(child, &alloc);
345 gtk_views_fixed_set_use_allocated_size(child, true);
346 gtk_fixed_move(GTK_FIXED(window_contents_), child, x, y); 344 gtk_fixed_move(GTK_FIXED(window_contents_), child, x, y);
347 } 345 }
348 346
349 void WidgetGtk::DoDrag(const OSExchangeData& data, int operation) { 347 void WidgetGtk::DoDrag(const OSExchangeData& data, int operation) {
350 const OSExchangeDataProviderGtk& data_provider = 348 const OSExchangeDataProviderGtk& data_provider =
351 static_cast<const OSExchangeDataProviderGtk&>(data.provider()); 349 static_cast<const OSExchangeDataProviderGtk&>(data.provider());
352 GtkTargetList* targets = data_provider.GetTargetList(); 350 GtkTargetList* targets = data_provider.GetTargetList();
353 GdkEvent* current_event = gtk_get_current_event(); 351 GdkEvent* current_event = gtk_get_current_event();
354 const OSExchangeDataProviderGtk& provider( 352 const OSExchangeDataProviderGtk& provider(
355 static_cast<const OSExchangeDataProviderGtk&>(data.provider())); 353 static_cast<const OSExchangeDataProviderGtk&>(data.provider()));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 ignore_drag_leave_ = false; 420 ignore_drag_leave_ = false;
423 drop_target_.reset(NULL); 421 drop_target_.reset(NULL);
424 } 422 }
425 423
426 // static 424 // static
427 RootView* WidgetGtk::GetRootViewForWidget(GtkWidget* widget) { 425 RootView* WidgetGtk::GetRootViewForWidget(GtkWidget* widget) {
428 gpointer user_data = g_object_get_data(G_OBJECT(widget), "root-view"); 426 gpointer user_data = g_object_get_data(G_OBJECT(widget), "root-view");
429 return static_cast<RootView*>(user_data); 427 return static_cast<RootView*>(user_data);
430 } 428 }
431 429
430 void WidgetGtk::GetRequestedSize(gfx::Size* out) const {
431 int width, height;
432 if (GTK_IS_VIEWS_FIXED(widget_) &&
433 gtk_views_fixed_get_widget_size(GetNativeView(), &width, &height)) {
434 out->SetSize(width, height);
435 } else {
436 GtkRequisition requisition;
437 gtk_widget_get_child_requisition(GetNativeView(), &requisition);
438 out->SetSize(requisition.width, requisition.height);
439 }
440 }
441
432 //////////////////////////////////////////////////////////////////////////////// 442 ////////////////////////////////////////////////////////////////////////////////
433 // WidgetGtk, ActiveWindowWatcherX::Observer implementation: 443 // WidgetGtk, ActiveWindowWatcherX::Observer implementation:
434 444
435 void WidgetGtk::ActiveWindowChanged(GdkWindow* active_window) { 445 void WidgetGtk::ActiveWindowChanged(GdkWindow* active_window) {
436 if (!GetNativeView()) 446 if (!GetNativeView())
437 return; 447 return;
438 448
439 bool was_active = IsActive(); 449 bool was_active = IsActive();
440 is_active_ = (active_window == GTK_WIDGET(GetNativeView())->window); 450 is_active_ = (active_window == GTK_WIDGET(GetNativeView())->window);
441 if (!is_active_ && active_window && type_ != TYPE_CHILD) { 451 if (!is_active_ && active_window && type_ != TYPE_CHILD) {
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 GtkWindow* window = GTK_WINDOW(element->data); 1625 GtkWindow* window = GTK_WINDOW(element->data);
1616 DCHECK(window); 1626 DCHECK(window);
1617 RootView *root_view = FindRootView(window); 1627 RootView *root_view = FindRootView(window);
1618 if (root_view) 1628 if (root_view)
1619 root_view->NotifyLocaleChanged(); 1629 root_view->NotifyLocaleChanged();
1620 } 1630 }
1621 g_list_free(window_list); 1631 g_list_free(window_list);
1622 } 1632 }
1623 1633
1624 } // namespace views 1634 } // namespace views
OLDNEW
« no previous file with comments | « views/widget/widget_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698