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

Side by Side Diff: chrome/browser/tab_contents/tab_contents_view_gtk.cc

Issue 1118005: GTK: More transitions to thunk definition macros. (Closed)
Patch Set: Created 10 years, 9 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 | « chrome/browser/tab_contents/tab_contents_view_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 "chrome/browser/tab_contents/tab_contents_view_gtk.h" 5 #include "chrome/browser/tab_contents/tab_contents_view_gtk.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 return new TabContentsViewGtk(tab_contents); 107 return new TabContentsViewGtk(tab_contents);
108 } 108 }
109 109
110 TabContentsViewGtk::TabContentsViewGtk(TabContents* tab_contents) 110 TabContentsViewGtk::TabContentsViewGtk(TabContents* tab_contents)
111 : TabContentsView(tab_contents), 111 : TabContentsView(tab_contents),
112 floating_(gtk_floating_container_new()), 112 floating_(gtk_floating_container_new()),
113 expanded_(gtk_expanded_container_new()), 113 expanded_(gtk_expanded_container_new()),
114 constrained_window_(NULL) { 114 constrained_window_(NULL) {
115 gtk_widget_set_name(expanded_, "chrome-tab-contents-view"); 115 gtk_widget_set_name(expanded_, "chrome-tab-contents-view");
116 g_signal_connect(expanded_, "size-allocate", 116 g_signal_connect(expanded_, "size-allocate",
117 G_CALLBACK(OnSizeAllocate), this); 117 G_CALLBACK(OnSizeAllocateThunk), this);
118 g_signal_connect(expanded_, "child-size-request", 118 g_signal_connect(expanded_, "child-size-request",
119 G_CALLBACK(OnChildSizeRequest), this); 119 G_CALLBACK(OnChildSizeRequestThunk), this);
120 g_signal_connect(floating_.get(), "set-floating-position", 120 g_signal_connect(floating_.get(), "set-floating-position",
121 G_CALLBACK(OnSetFloatingPosition), this); 121 G_CALLBACK(OnSetFloatingPositionThunk), this);
122 122
123 gtk_container_add(GTK_CONTAINER(floating_.get()), expanded_); 123 gtk_container_add(GTK_CONTAINER(floating_.get()), expanded_);
124 gtk_widget_show(expanded_); 124 gtk_widget_show(expanded_);
125 gtk_widget_show(floating_.get()); 125 gtk_widget_show(floating_.get());
126 registrar_.Add(this, NotificationType::TAB_CONTENTS_CONNECTED, 126 registrar_.Add(this, NotificationType::TAB_CONTENTS_CONNECTED,
127 Source<TabContents>(tab_contents)); 127 Source<TabContents>(tab_contents));
128 drag_source_.reset(new TabContentsDragSource(this)); 128 drag_source_.reset(new TabContentsDragSource(this));
129 } 129 }
130 130
131 TabContentsViewGtk::~TabContentsViewGtk() { 131 TabContentsViewGtk::~TabContentsViewGtk() {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 G_CALLBACK(OnFocus), tab_contents()); 174 G_CALLBACK(OnFocus), tab_contents());
175 g_signal_connect(content_view, "leave-notify-event", 175 g_signal_connect(content_view, "leave-notify-event",
176 G_CALLBACK(OnLeaveNotify), tab_contents()); 176 G_CALLBACK(OnLeaveNotify), tab_contents());
177 g_signal_connect(content_view, "motion-notify-event", 177 g_signal_connect(content_view, "motion-notify-event",
178 G_CALLBACK(OnMouseMove), tab_contents()); 178 G_CALLBACK(OnMouseMove), tab_contents());
179 g_signal_connect(content_view, "scroll-event", 179 g_signal_connect(content_view, "scroll-event",
180 G_CALLBACK(OnMouseScroll), tab_contents()); 180 G_CALLBACK(OnMouseScroll), tab_contents());
181 gtk_widget_add_events(content_view, GDK_LEAVE_NOTIFY_MASK | 181 gtk_widget_add_events(content_view, GDK_LEAVE_NOTIFY_MASK |
182 GDK_POINTER_MOTION_MASK); 182 GDK_POINTER_MOTION_MASK);
183 g_signal_connect(content_view, "button-press-event", 183 g_signal_connect(content_view, "button-press-event",
184 G_CALLBACK(OnMouseDown), this); 184 G_CALLBACK(OnMouseDownThunk), this);
185 InsertIntoContentArea(content_view); 185 InsertIntoContentArea(content_view);
186 186
187 // Renderer target DnD. 187 // Renderer target DnD.
188 drag_dest_.reset(new WebDragDestGtk(tab_contents(), content_view)); 188 drag_dest_.reset(new WebDragDestGtk(tab_contents(), content_view));
189 189
190 return view; 190 return view;
191 } 191 }
192 192
193 gfx::NativeView TabContentsViewGtk::GetNativeView() const { 193 gfx::NativeView TabContentsViewGtk::GetNativeView() const {
194 return floating_.get(); 194 return floating_.get();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // TODO(snej): Make use of the WebDragOperationsMask somehow 330 // TODO(snej): Make use of the WebDragOperationsMask somehow
331 } 331 }
332 332
333 // ----------------------------------------------------------------------------- 333 // -----------------------------------------------------------------------------
334 334
335 void TabContentsViewGtk::InsertIntoContentArea(GtkWidget* widget) { 335 void TabContentsViewGtk::InsertIntoContentArea(GtkWidget* widget) {
336 gtk_container_add(GTK_CONTAINER(expanded_), widget); 336 gtk_container_add(GTK_CONTAINER(expanded_), widget);
337 } 337 }
338 338
339 gboolean TabContentsViewGtk::OnMouseDown(GtkWidget* widget, 339 gboolean TabContentsViewGtk::OnMouseDown(GtkWidget* widget,
340 GdkEventButton* event, TabContentsViewGtk* view) { 340 GdkEventButton* event) {
341 view->last_mouse_down_ = *event; 341 last_mouse_down_ = *event;
342 return FALSE; 342 return FALSE;
343 } 343 }
344 344
345 void TabContentsViewGtk::OnChildSizeRequest(GtkWidget* widget, 345 void TabContentsViewGtk::OnChildSizeRequest(GtkWidget* widget,
346 GtkWidget* child, 346 GtkWidget* child,
347 GtkRequisition* requisition, 347 GtkRequisition* requisition) {
348 TabContentsViewGtk* view) { 348 if (tab_contents()->delegate()) {
349 if (view->tab_contents()->delegate()) {
350 requisition->height += 349 requisition->height +=
351 view->tab_contents()->delegate()->GetExtraRenderViewHeight(); 350 tab_contents()->delegate()->GetExtraRenderViewHeight();
352 } 351 }
353 } 352 }
354 353
355 void TabContentsViewGtk::OnSizeAllocate(GtkWidget* widget, 354 void TabContentsViewGtk::OnSizeAllocate(GtkWidget* widget,
356 GtkAllocation* allocation, 355 GtkAllocation* allocation) {
357 TabContentsViewGtk* view) {
358 int width = allocation->width; 356 int width = allocation->width;
359 int height = allocation->height; 357 int height = allocation->height;
360 // |delegate()| can be NULL here during browser teardown. 358 // |delegate()| can be NULL here during browser teardown.
361 if (view->tab_contents()->delegate()) 359 if (tab_contents()->delegate())
362 height += view->tab_contents()->delegate()->GetExtraRenderViewHeight(); 360 height += tab_contents()->delegate()->GetExtraRenderViewHeight();
363 gfx::Size size(width, height); 361 gfx::Size size(width, height);
364 view->requested_size_ = size; 362 requested_size_ = size;
365 363
366 // We manually tell our RWHV to resize the renderer content. This avoids 364 // We manually tell our RWHV to resize the renderer content. This avoids
367 // spurious resizes from GTK+. 365 // spurious resizes from GTK+.
368 RenderWidgetHostView* rwhv = view->tab_contents()->GetRenderWidgetHostView(); 366 RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView();
369 if (rwhv) 367 if (rwhv)
370 rwhv->SetSize(size); 368 rwhv->SetSize(size);
371 if (view->tab_contents()->interstitial_page()) 369 if (tab_contents()->interstitial_page())
372 view->tab_contents()->interstitial_page()->SetSize(size); 370 tab_contents()->interstitial_page()->SetSize(size);
373 } 371 }
374 372
375 // static
376 void TabContentsViewGtk::OnSetFloatingPosition( 373 void TabContentsViewGtk::OnSetFloatingPosition(
377 GtkFloatingContainer* floating_container, GtkAllocation* allocation, 374 GtkWidget* floating_container, GtkAllocation* allocation) {
378 TabContentsViewGtk* tab_contents_view) {
379 // Place each ConstrainedWindow in the center of the view. 375 // Place each ConstrainedWindow in the center of the view.
380 int half_view_width = std::max((allocation->x + allocation->width) / 2, 0); 376 int half_view_width = std::max((allocation->x + allocation->width) / 2, 0);
381 int half_view_height = std::max((allocation->y + allocation->height) / 2, 0); 377 int half_view_height = std::max((allocation->y + allocation->height) / 2, 0);
382 if (tab_contents_view->constrained_window_) { 378 if (constrained_window_) {
383 GtkWidget* widget = tab_contents_view->constrained_window_->widget(); 379 GtkWidget* widget = constrained_window_->widget();
384 DCHECK(widget->parent == tab_contents_view->floating_.get()); 380 DCHECK(widget->parent == floating_.get());
385 381
386 GtkRequisition requisition; 382 GtkRequisition requisition;
387 gtk_widget_size_request(widget, &requisition); 383 gtk_widget_size_request(widget, &requisition);
388 384
389 GValue value = { 0, }; 385 GValue value = { 0, };
390 g_value_init(&value, G_TYPE_INT); 386 g_value_init(&value, G_TYPE_INT);
391 387
392 int child_x = std::max(half_view_width - (requisition.width / 2), 0); 388 int child_x = std::max(half_view_width - (requisition.width / 2), 0);
393 g_value_set_int(&value, child_x); 389 g_value_set_int(&value, child_x);
394 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 390 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
395 widget, "x", &value); 391 widget, "x", &value);
396 392
397 int child_y = std::max(half_view_height - (requisition.height / 2), 0); 393 int child_y = std::max(half_view_height - (requisition.height / 2), 0);
398 g_value_set_int(&value, child_y); 394 g_value_set_int(&value, child_y);
399 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 395 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
400 widget, "y", &value); 396 widget, "y", &value);
401 g_value_unset(&value); 397 g_value_unset(&value);
402 } 398 }
403 } 399 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents_view_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698