diff options
-rw-r--r-- | app/gtk_signal.h | 20 | ||||
-rw-r--r-- | chrome/browser/debugger/devtools_manager.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 7 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 27 | ||||
-rw-r--r-- | chrome/browser/views/tab_contents/tab_contents_view_gtk.cc | 11 | ||||
-rw-r--r-- | chrome/browser/views/tab_contents/tab_contents_view_gtk.h | 4 | ||||
-rw-r--r-- | views/widget/widget_gtk.cc | 327 | ||||
-rw-r--r-- | views/widget/widget_gtk.h | 149 | ||||
-rw-r--r-- | views/window/window_gtk.cc | 4 | ||||
-rw-r--r-- | views/window/window_gtk.h | 2 |
10 files changed, 414 insertions, 139 deletions
diff --git a/app/gtk_signal.h b/app/gtk_signal.h index c21ef81..e56c75d 100644 --- a/app/gtk_signal.h +++ b/app/gtk_signal.h @@ -26,7 +26,7 @@ typedef struct _GtkWidget GtkWidget; return reinterpret_cast<TYPE*>(userdata)->METHOD(widget); \ } \ \ - virtual RETURN METHOD(GtkWidget* widget); + RETURN METHOD(GtkWidget* widget); #define CHROMEGTK_CALLBACK_1(TYPE, RETURN, METHOD, ARG1) \ static RETURN METHOD ## Thunk(GtkWidget* widget, ARG1 one, \ @@ -34,7 +34,7 @@ typedef struct _GtkWidget GtkWidget; return reinterpret_cast<TYPE*>(userdata)->METHOD(widget, one); \ } \ \ - virtual RETURN METHOD(GtkWidget* widget, ARG1 one); + RETURN METHOD(GtkWidget* widget, ARG1 one); #define CHROMEGTK_CALLBACK_2(TYPE, RETURN, METHOD, ARG1, ARG2) \ static RETURN METHOD ## Thunk(GtkWidget* widget, ARG1 one, ARG2 two, \ @@ -42,7 +42,7 @@ typedef struct _GtkWidget GtkWidget; return reinterpret_cast<TYPE*>(userdata)->METHOD(widget, one, two); \ } \ \ - virtual RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two); + RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two); #define CHROMEGTK_CALLBACK_3(TYPE, RETURN, METHOD, ARG1, ARG2, ARG3) \ static RETURN METHOD ## Thunk(GtkWidget* widget, ARG1 one, ARG2 two, \ @@ -51,7 +51,7 @@ typedef struct _GtkWidget GtkWidget; METHOD(widget, one, two, three); \ } \ \ - virtual RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two, ARG3 three); + RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two, ARG3 three); #define CHROMEGTK_CALLBACK_4(TYPE, RETURN, METHOD, ARG1, ARG2, ARG3, ARG4) \ static RETURN METHOD ## Thunk(GtkWidget* widget, ARG1 one, ARG2 two, \ @@ -61,8 +61,8 @@ typedef struct _GtkWidget GtkWidget; METHOD(widget, one, two, three, four); \ } \ \ - virtual RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two, \ - ARG3 three, ARG4 four); + RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two, ARG3 three, \ + ARG4 four); #define CHROMEGTK_CALLBACK_5(TYPE, RETURN, METHOD, ARG1, ARG2, ARG3, ARG4, \ ARG5) \ @@ -73,8 +73,8 @@ typedef struct _GtkWidget GtkWidget; METHOD(widget, one, two, three, four, five); \ } \ \ - virtual RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two, \ - ARG3 three, ARG4 four, ARG5 five); + RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two, ARG3 three, \ + ARG4 four, ARG5 five); #define CHROMEGTK_CALLBACK_6(TYPE, RETURN, METHOD, ARG1, ARG2, ARG3, ARG4, \ ARG5, ARG6) \ @@ -85,7 +85,7 @@ typedef struct _GtkWidget GtkWidget; METHOD(widget, one, two, three, four, five, six); \ } \ \ - virtual RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two, \ - ARG3 three, ARG4 four, ARG5 five, ARG6 six); + RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two, ARG3 three, \ + ARG4 four, ARG5 five, ARG6 six); #endif // APP_GTK_SIGNAL_H_ diff --git a/chrome/browser/debugger/devtools_manager.cc b/chrome/browser/debugger/devtools_manager.cc index 1cc3a3e..f55dbba 100644 --- a/chrome/browser/debugger/devtools_manager.cc +++ b/chrome/browser/debugger/devtools_manager.cc @@ -29,7 +29,7 @@ DevToolsManager* DevToolsManager::GetInstance() { // static void DevToolsManager::RegisterUserPrefs(PrefService* prefs) { - prefs->RegisterBooleanPref(prefs::kDevToolsOpenDocked, true); + prefs->RegisterBooleanPref(prefs::kDevToolsOpenDocked, false); } DevToolsManager::DevToolsManager() diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index de825c1..b49d501 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -1178,6 +1178,13 @@ void BrowserWindowGtk::UpdateDevToolsForContents(TabContents* contents) { TabContents* devtools_contents = contents ? DevToolsWindow::GetDevToolsContents(contents) : NULL; devtools_container_->SetTabContents(devtools_contents); + if (devtools_contents) { + // TabContentsViewGtk::WasShown is not called when tab contents is shown by + // anything other than user selecting a Tab. + // See TabContentsViewWin::OnWindowPosChanged for reference on how it should + // be implemented. + devtools_contents->ShowContents(); + } bool should_show = old_devtools == NULL && devtools_contents != NULL; bool should_hide = old_devtools != NULL && devtools_contents == NULL; diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 53b058c..3a05746 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -678,6 +678,19 @@ void BrowserView::Show() { // that should be added and this should be removed. RestoreFocus(); + // Restore split offset. + int split_offset = g_browser_process->local_state()->GetInteger( + prefs::kDevToolsSplitLocation); + if (split_offset == -1) { + // Initial load, set to default value. + split_offset = 2 * contents_split_->height() / 3; + } + // Make sure user can see both panes. + int min_split_size = contents_split_->height() / 10; + split_offset = std::min(contents_split_->height() - min_split_size, + std::max(min_split_size, split_offset)); + contents_split_->set_divider_offset(split_offset); + frame_->GetWindow()->Show(); } @@ -1802,20 +1815,6 @@ void BrowserView::UpdateDevToolsForContents(TabContents* tab_contents) { new views::ExternalFocusTracker(devtools_container_, GetFocusManager())); } - - // Restore split offset. - int split_offset = g_browser_process->local_state()->GetInteger( - prefs::kDevToolsSplitLocation); - if (split_offset == -1) { - // Initial load, set to default value. - split_offset = 2 * contents_split_->height() / 3; - } - // Make sure user can see both panes. - int min_split_size = contents_split_->height() / 10; - split_offset = std::min(contents_split_->height() - min_split_size, - std::max(min_split_size, split_offset)); - contents_split_->set_divider_offset(split_offset); - devtools_container_->SetVisible(true); contents_split_->Layout(); } else if (should_hide) { diff --git a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc index 282dafb..91b25ce 100644 --- a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc +++ b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc @@ -364,7 +364,7 @@ void TabContentsViewGtk::OnSizeAllocate(GtkWidget* widget, WasSized(new_size); } -gboolean TabContentsViewGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { +void TabContentsViewGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { if (tab_contents()->render_view_host() && !tab_contents()->render_view_host()->IsRenderViewLive()) { if (sad_tab_ == NULL) { @@ -377,15 +377,6 @@ gboolean TabContentsViewGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { gfx::CanvasPaint canvas(event); sad_tab_->ProcessPaint(&canvas); } - return false; // False indicates other widgets should get the event as well. -} - -void TabContentsViewGtk::OnShow(GtkWidget* widget) { - WasShown(); -} - -void TabContentsViewGtk::OnHide(GtkWidget* widget) { - WasHidden(); } void TabContentsViewGtk::WasHidden() { diff --git a/chrome/browser/views/tab_contents/tab_contents_view_gtk.h b/chrome/browser/views/tab_contents/tab_contents_view_gtk.h index 95d7426..3439ec5 100644 --- a/chrome/browser/views/tab_contents/tab_contents_view_gtk.h +++ b/chrome/browser/views/tab_contents/tab_contents_view_gtk.h @@ -72,9 +72,7 @@ class TabContentsViewGtk : public TabContentsView, // Overridden from views::WidgetGtk: virtual gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event); virtual void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation); - virtual gboolean OnPaint(GtkWidget* widget, GdkEventExpose* event); - virtual void OnShow(GtkWidget* widget); - virtual void OnHide(GtkWidget* widget); + virtual void OnPaint(GtkWidget* widget, GdkEventExpose* event); // Handles notifying the TabContents and other operations when the window was // shown or hidden. diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index 2c4c80a..ac78404 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -317,75 +317,72 @@ void WidgetGtk::Init(GtkWidget* parent, MessageLoopForUI::current()->AddObserver(this); + // TODO(beng): make these take this rather than NULL. g_signal_connect_after(G_OBJECT(window_contents_), "size_allocate", - G_CALLBACK(&OnSizeAllocateThunk), this); + G_CALLBACK(CallSizeAllocate), NULL); g_signal_connect(window_contents_, "expose_event", - G_CALLBACK(&OnPaintThunk), this); + G_CALLBACK(CallPaint), NULL); g_signal_connect(window_contents_, "enter_notify_event", - G_CALLBACK(&OnEnterNotifyThunk), this); + G_CALLBACK(CallEnterNotify), NULL); g_signal_connect(window_contents_, "leave_notify_event", - G_CALLBACK(&OnLeaveNotifyThunk), this); + G_CALLBACK(CallLeaveNotify), NULL); g_signal_connect(window_contents_, "motion_notify_event", - G_CALLBACK(&OnMotionNotifyThunk), this); + G_CALLBACK(CallMotionNotify), NULL); g_signal_connect(window_contents_, "button_press_event", - G_CALLBACK(&OnButtonPressThunk), this); + G_CALLBACK(CallButtonPress), NULL); g_signal_connect(window_contents_, "button_release_event", - G_CALLBACK(&OnButtonReleaseThunk), this); + G_CALLBACK(CallButtonRelease), NULL); g_signal_connect(window_contents_, "grab_broken_event", - G_CALLBACK(&OnGrabBrokeEventThunk), this); + G_CALLBACK(CallGrabBrokeEvent), NULL); g_signal_connect(window_contents_, "grab_notify", - G_CALLBACK(&OnGrabNotifyThunk), this); + G_CALLBACK(CallGrabNotify), NULL); g_signal_connect(window_contents_, "key_press_event", - G_CALLBACK(&OnKeyPressThunk), this); + G_CALLBACK(CallKeyPress), NULL); g_signal_connect(window_contents_, "key_release_event", - G_CALLBACK(&OnKeyReleaseThunk), this); + G_CALLBACK(CallKeyRelease), NULL); g_signal_connect(window_contents_, "scroll_event", - G_CALLBACK(&OnScrollThunk), this); + G_CALLBACK(CallScroll), NULL); g_signal_connect(window_contents_, "visibility_notify_event", - G_CALLBACK(&OnVisibilityNotifyThunk), this); + G_CALLBACK(CallVisibilityNotify), NULL); // In order to receive notification when the window is no longer the front // window, we need to install these on the widget. // NOTE: this doesn't work with focus follows mouse. g_signal_connect(widget_, "focus_in_event", - G_CALLBACK(&OnFocusInThunk), this); + G_CALLBACK(CallFocusIn), NULL); g_signal_connect(widget_, "focus_out_event", - G_CALLBACK(&OnFocusOutThunk), this); + G_CALLBACK(CallFocusOut), NULL); g_signal_connect(widget_, "destroy", - G_CALLBACK(&OnDestroyThunk), this); - g_signal_connect(widget_, "show", - G_CALLBACK(&OnShowThunk), this); - g_signal_connect(widget_, "hide", - G_CALLBACK(&OnHideThunk), this); + G_CALLBACK(CallDestroy), NULL); if (transparent_) { g_signal_connect(widget_, "expose_event", - G_CALLBACK(&OnWindowPaintThunk), this); + G_CALLBACK(CallWindowPaint), this); } // Drag and drop. gtk_drag_dest_set(window_contents_, static_cast<GtkDestDefaults>(0), NULL, 0, GDK_ACTION_COPY); g_signal_connect(window_contents_, "drag_motion", - G_CALLBACK(&OnDragMotionThunk), this); + G_CALLBACK(CallDragMotion), this); g_signal_connect(window_contents_, "drag_data_received", - G_CALLBACK(&OnDragDataReceivedThunk), this); + G_CALLBACK(CallDragDataReceived), this); g_signal_connect(window_contents_, "drag_drop", - G_CALLBACK(&OnDragDropThunk), this); + G_CALLBACK(CallDragDrop), this); g_signal_connect(window_contents_, "drag_leave", - G_CALLBACK(&OnDragLeaveThunk), this); + G_CALLBACK(CallDragLeave), this); g_signal_connect(window_contents_, "drag_data_get", - G_CALLBACK(&OnDragDataGetThunk), this); + G_CALLBACK(CallDragDataGet), this); g_signal_connect(window_contents_, "drag_end", - G_CALLBACK(&OnDragEndThunk), this); + G_CALLBACK(CallDragEnd), this); g_signal_connect(window_contents_, "drag_failed", - G_CALLBACK(&OnDragFailedThunk), this); + G_CALLBACK(CallDragFailed), this); tooltip_manager_.reset(new TooltipManagerGtk(this)); // Register for tooltips. g_object_set(G_OBJECT(window_contents_), "has-tooltip", TRUE, NULL); g_signal_connect(window_contents_, "query_tooltip", - G_CALLBACK(&OnQueryTooltipThunk), this); + G_CALLBACK(CallQueryTooltip), this); if (type_ == TYPE_CHILD) { if (parent) { @@ -705,13 +702,11 @@ void WidgetGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { root_view_->SchedulePaint(); } -gboolean WidgetGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { +void WidgetGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { root_view_->OnPaint(event); - return false; // False indicates other widgets should get the event as well. } -void WidgetGtk::OnDragDataGet(GtkWidget* widget, - GdkDragContext* context, +void WidgetGtk::OnDragDataGet(GdkDragContext* context, GtkSelectionData* data, guint info, guint time) { @@ -722,8 +717,7 @@ void WidgetGtk::OnDragDataGet(GtkWidget* widget, drag_data_->WriteFormatToSelection(info, data); } -void WidgetGtk::OnDragDataReceived(GtkWidget* widget, - GdkDragContext* context, +void WidgetGtk::OnDragDataReceived(GdkDragContext* context, gint x, gint y, GtkSelectionData* data, @@ -733,8 +727,7 @@ void WidgetGtk::OnDragDataReceived(GtkWidget* widget, drop_target_->OnDragDataReceived(context, x, y, data, info, time); } -gboolean WidgetGtk::OnDragDrop(GtkWidget* widget, - GdkDragContext* context, +gboolean WidgetGtk::OnDragDrop(GdkDragContext* context, gint x, gint y, guint time) { @@ -744,7 +737,7 @@ gboolean WidgetGtk::OnDragDrop(GtkWidget* widget, return FALSE; } -void WidgetGtk::OnDragEnd(GtkWidget* widget, GdkDragContext* context) { +void WidgetGtk::OnDragEnd(GdkDragContext* context) { if (!drag_data_) { // This indicates we didn't start a drag operation, and should never // happen. @@ -755,14 +748,12 @@ void WidgetGtk::OnDragEnd(GtkWidget* widget, GdkDragContext* context) { MessageLoop::current()->Quit(); } -gboolean WidgetGtk::OnDragFailed(GtkWidget* widget, - GdkDragContext* context, +gboolean WidgetGtk::OnDragFailed(GdkDragContext* context, GtkDragResult result) { return FALSE; } -void WidgetGtk::OnDragLeave(GtkWidget* widget, - GdkDragContext* context, +void WidgetGtk::OnDragLeave(GdkDragContext* context, guint time) { if (ignore_drag_leave_) { ignore_drag_leave_ = false; @@ -774,8 +765,7 @@ void WidgetGtk::OnDragLeave(GtkWidget* widget, } } -gboolean WidgetGtk::OnDragMotion(GtkWidget* widget, - GdkDragContext* context, +gboolean WidgetGtk::OnDragMotion(GdkDragContext* context, gint x, gint y, guint time) { @@ -903,19 +893,13 @@ gboolean WidgetGtk::OnKeyRelease(GtkWidget* widget, GdkEventKey* event) { return root_view_->ProcessKeyEvent(key_event); } -gboolean WidgetGtk::OnQueryTooltip(GtkWidget* widget, - gint x, +gboolean WidgetGtk::OnQueryTooltip(gint x, gint y, gboolean keyboard_mode, GtkTooltip* tooltip) { return tooltip_manager_->ShowTooltip(x, y, keyboard_mode, tooltip); } -gboolean WidgetGtk::OnVisibilityNotify(GtkWidget* widget, - GdkEventVisibility* event) { - return false; -} - gboolean WidgetGtk::OnGrabBrokeEvent(GtkWidget* widget, GdkEvent* event) { HandleGrabBroke(); return false; // To let other widgets get the event. @@ -926,8 +910,7 @@ void WidgetGtk::OnGrabNotify(GtkWidget* widget, gboolean was_grabbed) { HandleGrabBroke(); } -void WidgetGtk::OnDestroy(GtkWidget* object) { - // Note that this handler is hooked to GtkObject::destroy. +void WidgetGtk::OnDestroy() { widget_ = window_contents_ = NULL; if (delete_on_destroy_) { // Delays the deletion of this WidgetGtk as we want its children to have @@ -936,12 +919,6 @@ void WidgetGtk::OnDestroy(GtkWidget* object) { } } -void WidgetGtk::OnShow(GtkWidget* widget) { -} - -void WidgetGtk::OnHide(GtkWidget* widget) { -} - void WidgetGtk::DoGrab() { has_capture_ = true; gtk_grab_add(window_contents_); @@ -966,7 +943,7 @@ RootView* WidgetGtk::CreateRootView() { return new RootView(this); } -gboolean WidgetGtk::OnWindowPaint(GtkWidget* widget, GdkEventExpose* event) { +void WidgetGtk::OnWindowPaint(GtkWidget* widget, GdkEventExpose* event) { // NOTE: for reasons I don't understand this code is never hit. It should // be hit when transparent_, but we never get the expose-event for the // window in this case, even though a stand alone test case triggers it. I'm @@ -982,7 +959,6 @@ gboolean WidgetGtk::OnWindowPaint(GtkWidget* widget, GdkEventExpose* event) { cairo_set_source_rgba(cr, 0, 0, 0, 0); cairo_rectangle(cr, 0, 0, width, height); cairo_fill(cr); - return false; } bool WidgetGtk::ProcessMousePressed(GdkEventButton* event) { @@ -1072,6 +1048,235 @@ void WidgetGtk::SetRootViewForWidget(GtkWidget* widget, RootView* root_view) { } // static +gboolean WidgetGtk::CallButtonPress(GtkWidget* widget, GdkEventButton* event) { + WidgetGtk* widget_gtk = GetViewForNative(widget); + if (!widget_gtk) + return false; + + return widget_gtk->OnButtonPress(widget, event); +} + +// static +gboolean WidgetGtk::CallButtonRelease(GtkWidget* widget, + GdkEventButton* event) { + WidgetGtk* widget_gtk = GetViewForNative(widget); + if (!widget_gtk) + return false; + + return widget_gtk->OnButtonRelease(widget, event); +} + +// static +gboolean WidgetGtk::CallDragDrop(GtkWidget* widget, + GdkDragContext* context, + gint x, + gint y, + guint time, + WidgetGtk* host) { + return host->OnDragDrop(context, x, y, time); +} + +// static +gboolean WidgetGtk::CallDragFailed(GtkWidget* widget, + GdkDragContext* context, + GtkDragResult result, + WidgetGtk* host) { + return host->OnDragFailed(context, result); +} + +// static +gboolean WidgetGtk::CallDragMotion(GtkWidget* widget, + GdkDragContext* context, + gint x, + gint y, + guint time, + WidgetGtk* host) { + return host->OnDragMotion(context, x, y, time); +} + +// static +gboolean WidgetGtk::CallEnterNotify(GtkWidget* widget, + GdkEventCrossing* event) { + WidgetGtk* widget_gtk = GetViewForNative(widget); + if (!widget_gtk) + return false; + + return widget_gtk->OnEnterNotify(widget, event); +} + +// static +gboolean WidgetGtk::CallFocusIn(GtkWidget* widget, GdkEventFocus* event) { + WidgetGtk* widget_gtk = GetViewForNative(widget); + if (!widget_gtk) + return false; + + return widget_gtk->OnFocusIn(widget, event); +} + +// static +gboolean WidgetGtk::CallFocusOut(GtkWidget* widget, GdkEventFocus* event) { + WidgetGtk* widget_gtk = GetViewForNative(widget); + if (!widget_gtk) + return false; + + return widget_gtk->OnFocusOut(widget, event); +} + +// static +gboolean WidgetGtk::CallGrabBrokeEvent(GtkWidget* widget, GdkEvent* event) { + WidgetGtk* widget_gtk = GetViewForNative(widget); + if (!widget_gtk) + return false; + + return widget_gtk->OnGrabBrokeEvent(widget, event); +} + +// static +gboolean WidgetGtk::CallKeyPress(GtkWidget* widget, GdkEventKey* event) { + WidgetGtk* widget_gtk = GetViewForNative(widget); + if (!widget_gtk) + return false; + + return widget_gtk->OnKeyPress(widget, event); +} + +// static +gboolean WidgetGtk::CallKeyRelease(GtkWidget* widget, GdkEventKey* event) { + WidgetGtk* widget_gtk = GetViewForNative(widget); + if (!widget_gtk) + return false; + + return widget_gtk->OnKeyRelease(widget, event); +} + +// static +gboolean WidgetGtk::CallLeaveNotify(GtkWidget* widget, + GdkEventCrossing* event) { + WidgetGtk* widget_gtk = GetViewForNative(widget); + if (!widget_gtk) + return false; + + return widget_gtk->OnLeaveNotify(widget, event); +} + +// static +gboolean WidgetGtk::CallMotionNotify(GtkWidget* widget, GdkEventMotion* event) { + WidgetGtk* widget_gtk = GetViewForNative(widget); + if (!widget_gtk) + return false; + + return widget_gtk->OnMotionNotify(widget, event); +} + +// static +gboolean WidgetGtk::CallPaint(GtkWidget* widget, GdkEventExpose* event) { + WidgetGtk* widget_gtk = GetViewForNative(widget); + if (widget_gtk) + widget_gtk->OnPaint(widget, event); + return false; // False indicates other widgets should get the event as well. +} + +// static +gboolean WidgetGtk::CallQueryTooltip(GtkWidget* widget, + gint x, + gint y, + gboolean keyboard_mode, + GtkTooltip* tooltip, + WidgetGtk* host) { + return host->OnQueryTooltip(static_cast<int>(x), static_cast<int>(y), + keyboard_mode, tooltip); +} + +// static +gboolean WidgetGtk::CallScroll(GtkWidget* widget, GdkEventScroll* event) { + WidgetGtk* widget_gtk = GetViewForNative(widget); + if (!widget_gtk) + return false; + + return widget_gtk->OnScroll(widget, event); +} + +// static +gboolean WidgetGtk::CallVisibilityNotify(GtkWidget* widget, + GdkEventVisibility* event) { + WidgetGtk* widget_gtk = GetViewForNative(widget); + if (!widget_gtk) + return false; + + return widget_gtk->OnVisibilityNotify(widget, event); +} + +// static +gboolean WidgetGtk::CallWindowPaint(GtkWidget* widget, + GdkEventExpose* event, + WidgetGtk* widget_gtk) { + widget_gtk->OnWindowPaint(widget, event); + return false; // False indicates other widgets should get the event as well. +} + +// static +void WidgetGtk::CallDestroy(GtkObject* object) { + WidgetGtk* widget_gtk = GetViewForNative(GTK_WIDGET(object)); + if (widget_gtk) + widget_gtk->OnDestroy(); +} + +// static +void WidgetGtk::CallDragDataGet(GtkWidget* widget, + GdkDragContext* context, + GtkSelectionData* data, + guint info, + guint time, + WidgetGtk* host) { + host->OnDragDataGet(context, data, info, time); +} + +// static +void WidgetGtk::CallDragDataReceived(GtkWidget* widget, + GdkDragContext* context, + gint x, + gint y, + GtkSelectionData* data, + guint info, + guint time, + WidgetGtk* host) { + return host->OnDragDataReceived(context, x, y, data, info, time); +} + +// static +void WidgetGtk::CallDragEnd(GtkWidget* widget, + GdkDragContext* context, + WidgetGtk* host) { + host->OnDragEnd(context); +} + +// static +void WidgetGtk::CallDragLeave(GtkWidget* widget, + GdkDragContext* context, + guint time, + WidgetGtk* host) { + host->OnDragLeave(context, time); +} + +// static +void WidgetGtk::CallGrabNotify(GtkWidget* widget, gboolean was_grabbed) { + WidgetGtk* widget_gtk = GetViewForNative(widget); + if (!widget_gtk) + return; + + return widget_gtk->OnGrabNotify(widget, was_grabbed); +} + +// static +void WidgetGtk::CallSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { + WidgetGtk* widget_gtk = GetViewForNative(widget); + if (!widget_gtk) + return; + + widget_gtk->OnSizeAllocate(widget, allocation); +} + +// static Window* WidgetGtk::GetWindowImpl(GtkWidget* widget) { GtkWidget* parent = widget; while (parent) { diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h index 075d873..b317367 100644 --- a/views/widget/widget_gtk.h +++ b/views/widget/widget_gtk.h @@ -8,7 +8,6 @@ #include <gtk/gtk.h> #include "app/active_window_watcher_x.h" -#include "app/gtk_signal.h" #include "base/message_loop.h" #include "gfx/size.h" #include "views/focus/focus_manager.h" @@ -225,41 +224,52 @@ class WidgetGtk static int GetFlagsForEventButton(const GdkEventButton& event); // Event handlers: - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnButtonPress, GdkEventButton*); - CHROMEGTK_CALLBACK_1(WidgetGtk, void, OnSizeAllocate, GtkAllocation*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnPaint, GdkEventExpose*); - CHROMEGTK_CALLBACK_4(WidgetGtk, void, OnDragDataGet, - GdkDragContext*, GtkSelectionData*, guint, guint); - CHROMEGTK_CALLBACK_6(WidgetGtk, void, OnDragDataReceived, - GdkDragContext*, gint, gint, GtkSelectionData*, - guint, guint); - CHROMEGTK_CALLBACK_4(WidgetGtk, gboolean, OnDragDrop, - GdkDragContext*, gint, gint, guint); - CHROMEGTK_CALLBACK_1(WidgetGtk, void, OnDragEnd, GdkDragContext*); - CHROMEGTK_CALLBACK_2(WidgetGtk, gboolean, OnDragFailed, - GdkDragContext*, GtkDragResult); - CHROMEGTK_CALLBACK_2(WidgetGtk, void, OnDragLeave, - GdkDragContext*, guint); - CHROMEGTK_CALLBACK_4(WidgetGtk, gboolean, OnDragMotion, - GdkDragContext*, gint, gint, guint); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnEnterNotify, GdkEventCrossing*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnLeaveNotify, GdkEventCrossing*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnMotionNotify, GdkEventMotion*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnButtonRelease, GdkEventButton*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnFocusIn, GdkEventFocus*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnFocusOut, GdkEventFocus*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnKeyPress, GdkEventKey*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnKeyRelease, GdkEventKey*); - CHROMEGTK_CALLBACK_4(WidgetGtk, gboolean, OnQueryTooltip, - gint, gint, gboolean, GtkTooltip*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnScroll, GdkEventScroll*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnVisibilityNotify, - GdkEventVisibility*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnGrabBrokeEvent, GdkEvent*); - CHROMEGTK_CALLBACK_1(WidgetGtk, void, OnGrabNotify, gboolean); - CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnDestroy); - CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnShow); - CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnHide); + virtual void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation); + virtual void OnPaint(GtkWidget* widget, GdkEventExpose* event); + virtual void OnDragDataGet(GdkDragContext* context, + GtkSelectionData* data, + guint info, + guint time); + virtual void OnDragDataReceived(GdkDragContext* context, + gint x, + gint y, + GtkSelectionData* data, + guint info, + guint time); + virtual gboolean OnDragDrop(GdkDragContext* context, + gint x, + gint y, + guint time); + virtual void OnDragEnd(GdkDragContext* context); + virtual gboolean OnDragFailed(GdkDragContext* context, + GtkDragResult result); + virtual void OnDragLeave(GdkDragContext* context, + guint time); + virtual gboolean OnDragMotion(GdkDragContext* context, + gint x, + gint y, + guint time); + virtual gboolean OnEnterNotify(GtkWidget* widget, GdkEventCrossing* event); + virtual gboolean OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event); + virtual gboolean OnMotionNotify(GtkWidget* widget, GdkEventMotion* event); + virtual gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event); + virtual gboolean OnButtonRelease(GtkWidget* widget, GdkEventButton* event); + virtual gboolean OnFocusIn(GtkWidget* widget, GdkEventFocus* event); + virtual gboolean OnFocusOut(GtkWidget* widget, GdkEventFocus* event); + virtual gboolean OnKeyPress(GtkWidget* widget, GdkEventKey* event); + virtual gboolean OnKeyRelease(GtkWidget* widget, GdkEventKey* event); + virtual gboolean OnQueryTooltip(gint x, + gint y, + gboolean keyboard_mode, + GtkTooltip* tooltip); + virtual gboolean OnScroll(GtkWidget* widget, GdkEventScroll* event); + virtual gboolean OnVisibilityNotify(GtkWidget* widget, + GdkEventVisibility* event) { + return false; + } + virtual gboolean OnGrabBrokeEvent(GtkWidget* widget, GdkEvent* event); + virtual void OnGrabNotify(GtkWidget* widget, gboolean was_grabbed); + virtual void OnDestroy(); void set_mouse_down(bool mouse_down) { is_mouse_down_ = mouse_down; } @@ -288,7 +298,7 @@ class WidgetGtk virtual RootView* CreateRootView(); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnWindowPaint, GdkEventExpose*); + void OnWindowPaint(GtkWidget* widget, GdkEventExpose* event); // Process a mouse click. bool ProcessMousePressed(GdkEventButton* event); @@ -298,6 +308,71 @@ class WidgetGtk static void SetRootViewForWidget(GtkWidget* widget, RootView* root_view); + // A set of static signal handlers that bridge. + static gboolean CallButtonPress(GtkWidget* widget, GdkEventButton* event); + static gboolean CallButtonRelease(GtkWidget* widget, GdkEventButton* event); + static gboolean CallDragDrop(GtkWidget* widget, + GdkDragContext* context, + gint x, + gint y, + guint time, + WidgetGtk* host); + static gboolean CallDragFailed(GtkWidget* widget, + GdkDragContext* context, + GtkDragResult result, + WidgetGtk* host); + static gboolean CallDragMotion(GtkWidget* widget, + GdkDragContext* context, + gint x, + gint y, + guint time, + WidgetGtk* host); + static gboolean CallEnterNotify(GtkWidget* widget, GdkEventCrossing* event); + static gboolean CallFocusIn(GtkWidget* widget, GdkEventFocus* event); + static gboolean CallFocusOut(GtkWidget* widget, GdkEventFocus* event); + static gboolean CallGrabBrokeEvent(GtkWidget* widget, GdkEvent* event); + static gboolean CallKeyPress(GtkWidget* widget, GdkEventKey* event); + static gboolean CallKeyRelease(GtkWidget* widget, GdkEventKey* event); + static gboolean CallLeaveNotify(GtkWidget* widget, GdkEventCrossing* event); + static gboolean CallMotionNotify(GtkWidget* widget, GdkEventMotion* event); + static gboolean CallPaint(GtkWidget* widget, GdkEventExpose* event); + static gboolean CallQueryTooltip(GtkWidget* widget, + gint x, + gint y, + gboolean keyboard_mode, + GtkTooltip* tooltip, + WidgetGtk* host); + static gboolean CallScroll(GtkWidget* widget, GdkEventScroll* event); + static gboolean CallVisibilityNotify(GtkWidget* widget, + GdkEventVisibility* event); + static gboolean CallWindowPaint(GtkWidget* widget, + GdkEventExpose* event, + WidgetGtk* widget_gtk); + static void CallDestroy(GtkObject* object); + static void CallDragDataGet(GtkWidget* widget, + GdkDragContext* context, + GtkSelectionData* data, + guint info, + guint time, + WidgetGtk* host); + static void CallDragDataReceived(GtkWidget* widget, + GdkDragContext* context, + gint x, + gint y, + GtkSelectionData* data, + guint info, + guint time, + WidgetGtk* host); + static void CallDragEnd(GtkWidget* widget, + GdkDragContext* context, + WidgetGtk* host); + static void CallDragLeave(GtkWidget* widget, + GdkDragContext* context, + guint time, + WidgetGtk* host); + static void CallGrabNotify(GtkWidget* widget, gboolean was_grabbed); + static void CallSizeAllocate(GtkWidget* widget, GtkAllocation* allocation); + // Returns the first ancestor of |widget| that is a window. static Window* GetWindowImpl(GtkWidget* widget); diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc index 1c7fd88..171f222 100644 --- a/views/window/window_gtk.cc +++ b/views/window/window_gtk.cc @@ -476,9 +476,9 @@ void WindowGtk::SizeWindowToDefault(GtkWindow* parent) { SetBounds(bounds, NULL); } -void WindowGtk::OnDestroy(GtkWidget* widget) { +void WindowGtk::OnDestroy() { non_client_view_->WindowClosing(); - WidgetGtk::OnDestroy(widget); + WidgetGtk::OnDestroy(); } } // namespace views diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h index 865ac81..a9457af 100644 --- a/views/window/window_gtk.h +++ b/views/window/window_gtk.h @@ -79,7 +79,7 @@ class WindowGtk : public WidgetGtk, public Window { // Initializes the window to the passed in bounds. void Init(GtkWindow* parent, const gfx::Rect& bounds); - virtual void OnDestroy(GtkWidget* widget); + virtual void OnDestroy(); private: static gboolean CallConfigureEvent(GtkWidget* widget, |