diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-15 21:57:03 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-15 21:57:03 +0000 |
commit | f54af0416c4462df0cdb8b05f807262acb9f1016 (patch) | |
tree | 1d6d06fa22e72898ffed9a6234f14a66b18b637c | |
parent | 9e2d898dd3fdb84ed742947fbcb88400904a4a5b (diff) | |
download | chromium_src-f54af0416c4462df0cdb8b05f807262acb9f1016.zip chromium_src-f54af0416c4462df0cdb8b05f807262acb9f1016.tar.gz chromium_src-f54af0416c4462df0cdb8b05f807262acb9f1016.tar.bz2 |
Make DevTools open docked by default for chrome os.
- Change prefs::kDevToolsOpenDocked default to "true" for chrome os;
- Fix a problem on chrome os that DevTools occupies the whole client area.
This is because BrowserView::Show is called before gtk size allocated
event and thus divider offset is calculated wrongly to 0. The fix is
to move the "restore split offset" logic to UpdateDevToolsForContents
before we do contents_split_ layout for show up DevTools;
- Fix a problem that DevTools becomes invisible after undock then dock
for linux toolkit_view/chromeos build. This is because
browser/views/tab_contents/TabContentsViewGtk does not show/hide its
contained TabContents like TabContentsViewWin. As mentioned in
BrowserWindowGtk::UpdateDevToolsForContents, the fix is to hook up
gtk show/hide signal and notify the contained TabContents about the
visibility change. After the fix, remove the manual ShowContents for
DevTools in BrowserWindowGtk::UpdateDevToolsForContents.
<http://crosbug.com/333>
BUG=333
TEST=Verify that DevTools show up as docked by default.
Review URL: http://codereview.chromium.org/880003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41641 0039d316-1c4b-4281-b951-d872f2087c98
-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, 139 insertions, 414 deletions
diff --git a/app/gtk_signal.h b/app/gtk_signal.h index e56c75d..c21ef81 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); \ } \ \ - RETURN METHOD(GtkWidget* widget); + virtual 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); \ } \ \ - RETURN METHOD(GtkWidget* widget, ARG1 one); + virtual 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); \ } \ \ - RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two); + virtual 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); \ } \ \ - RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two, ARG3 three); + virtual 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); \ } \ \ - RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two, ARG3 three, \ - ARG4 four); + virtual 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); \ } \ \ - RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two, ARG3 three, \ - ARG4 four, ARG5 five); + virtual 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); \ } \ \ - RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two, ARG3 three, \ - ARG4 four, ARG5 five, ARG6 six); + virtual 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 f55dbba..1cc3a3e 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, false); + prefs->RegisterBooleanPref(prefs::kDevToolsOpenDocked, true); } DevToolsManager::DevToolsManager() diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index b49d501..de825c1 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -1178,13 +1178,6 @@ 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 232d99f..eb678c7 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -678,19 +678,6 @@ 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(); } @@ -1814,6 +1801,20 @@ 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 91b25ce..282dafb 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); } -void TabContentsViewGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { +gboolean TabContentsViewGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { if (tab_contents()->render_view_host() && !tab_contents()->render_view_host()->IsRenderViewLive()) { if (sad_tab_ == NULL) { @@ -377,6 +377,15 @@ void 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 3439ec5..95d7426 100644 --- a/chrome/browser/views/tab_contents/tab_contents_view_gtk.h +++ b/chrome/browser/views/tab_contents/tab_contents_view_gtk.h @@ -72,7 +72,9 @@ class TabContentsViewGtk : public TabContentsView, // Overridden from views::WidgetGtk: virtual gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event); virtual void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation); - virtual void OnPaint(GtkWidget* widget, GdkEventExpose* event); + virtual gboolean OnPaint(GtkWidget* widget, GdkEventExpose* event); + virtual void OnShow(GtkWidget* widget); + virtual void OnHide(GtkWidget* widget); // 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 60422d7..91726afe 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -317,72 +317,75 @@ 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(CallSizeAllocate), NULL); + G_CALLBACK(&OnSizeAllocateThunk), this); g_signal_connect(window_contents_, "expose_event", - G_CALLBACK(CallPaint), NULL); + G_CALLBACK(&OnPaintThunk), this); g_signal_connect(window_contents_, "enter_notify_event", - G_CALLBACK(CallEnterNotify), NULL); + G_CALLBACK(&OnEnterNotifyThunk), this); g_signal_connect(window_contents_, "leave_notify_event", - G_CALLBACK(CallLeaveNotify), NULL); + G_CALLBACK(&OnLeaveNotifyThunk), this); g_signal_connect(window_contents_, "motion_notify_event", - G_CALLBACK(CallMotionNotify), NULL); + G_CALLBACK(&OnMotionNotifyThunk), this); g_signal_connect(window_contents_, "button_press_event", - G_CALLBACK(CallButtonPress), NULL); + G_CALLBACK(&OnButtonPressThunk), this); g_signal_connect(window_contents_, "button_release_event", - G_CALLBACK(CallButtonRelease), NULL); + G_CALLBACK(&OnButtonReleaseThunk), this); g_signal_connect(window_contents_, "grab_broken_event", - G_CALLBACK(CallGrabBrokeEvent), NULL); + G_CALLBACK(&OnGrabBrokeEventThunk), this); g_signal_connect(window_contents_, "grab_notify", - G_CALLBACK(CallGrabNotify), NULL); + G_CALLBACK(&OnGrabNotifyThunk), this); g_signal_connect(window_contents_, "key_press_event", - G_CALLBACK(CallKeyPress), NULL); + G_CALLBACK(&OnKeyPressThunk), this); g_signal_connect(window_contents_, "key_release_event", - G_CALLBACK(CallKeyRelease), NULL); + G_CALLBACK(&OnKeyReleaseThunk), this); g_signal_connect(window_contents_, "scroll_event", - G_CALLBACK(CallScroll), NULL); + G_CALLBACK(&OnScrollThunk), this); g_signal_connect(window_contents_, "visibility_notify_event", - G_CALLBACK(CallVisibilityNotify), NULL); + G_CALLBACK(&OnVisibilityNotifyThunk), this); // 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(CallFocusIn), NULL); + G_CALLBACK(&OnFocusInThunk), this); g_signal_connect(widget_, "focus_out_event", - G_CALLBACK(CallFocusOut), NULL); + G_CALLBACK(&OnFocusOutThunk), this); g_signal_connect(widget_, "destroy", - G_CALLBACK(CallDestroy), NULL); + G_CALLBACK(&OnDestroyThunk), this); + g_signal_connect(widget_, "show", + G_CALLBACK(&OnShowThunk), this); + g_signal_connect(widget_, "hide", + G_CALLBACK(&OnHideThunk), this); if (transparent_) { g_signal_connect(widget_, "expose_event", - G_CALLBACK(CallWindowPaint), this); + G_CALLBACK(&OnWindowPaintThunk), 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(CallDragMotion), this); + G_CALLBACK(&OnDragMotionThunk), this); g_signal_connect(window_contents_, "drag_data_received", - G_CALLBACK(CallDragDataReceived), this); + G_CALLBACK(&OnDragDataReceivedThunk), this); g_signal_connect(window_contents_, "drag_drop", - G_CALLBACK(CallDragDrop), this); + G_CALLBACK(&OnDragDropThunk), this); g_signal_connect(window_contents_, "drag_leave", - G_CALLBACK(CallDragLeave), this); + G_CALLBACK(&OnDragLeaveThunk), this); g_signal_connect(window_contents_, "drag_data_get", - G_CALLBACK(CallDragDataGet), this); + G_CALLBACK(&OnDragDataGetThunk), this); g_signal_connect(window_contents_, "drag_end", - G_CALLBACK(CallDragEnd), this); + G_CALLBACK(&OnDragEndThunk), this); g_signal_connect(window_contents_, "drag_failed", - G_CALLBACK(CallDragFailed), this); + G_CALLBACK(&OnDragFailedThunk), 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(CallQueryTooltip), this); + G_CALLBACK(&OnQueryTooltipThunk), this); if (type_ == TYPE_CHILD) { if (parent) { @@ -702,11 +705,13 @@ void WidgetGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { root_view_->SchedulePaint(); } -void WidgetGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { +gboolean 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(GdkDragContext* context, +void WidgetGtk::OnDragDataGet(GtkWidget* widget, + GdkDragContext* context, GtkSelectionData* data, guint info, guint time) { @@ -717,7 +722,8 @@ void WidgetGtk::OnDragDataGet(GdkDragContext* context, drag_data_->WriteFormatToSelection(info, data); } -void WidgetGtk::OnDragDataReceived(GdkDragContext* context, +void WidgetGtk::OnDragDataReceived(GtkWidget* widget, + GdkDragContext* context, gint x, gint y, GtkSelectionData* data, @@ -727,7 +733,8 @@ void WidgetGtk::OnDragDataReceived(GdkDragContext* context, drop_target_->OnDragDataReceived(context, x, y, data, info, time); } -gboolean WidgetGtk::OnDragDrop(GdkDragContext* context, +gboolean WidgetGtk::OnDragDrop(GtkWidget* widget, + GdkDragContext* context, gint x, gint y, guint time) { @@ -737,7 +744,7 @@ gboolean WidgetGtk::OnDragDrop(GdkDragContext* context, return FALSE; } -void WidgetGtk::OnDragEnd(GdkDragContext* context) { +void WidgetGtk::OnDragEnd(GtkWidget* widget, GdkDragContext* context) { if (!drag_data_) { // This indicates we didn't start a drag operation, and should never // happen. @@ -748,12 +755,14 @@ void WidgetGtk::OnDragEnd(GdkDragContext* context) { MessageLoop::current()->Quit(); } -gboolean WidgetGtk::OnDragFailed(GdkDragContext* context, +gboolean WidgetGtk::OnDragFailed(GtkWidget* widget, + GdkDragContext* context, GtkDragResult result) { return FALSE; } -void WidgetGtk::OnDragLeave(GdkDragContext* context, +void WidgetGtk::OnDragLeave(GtkWidget* widget, + GdkDragContext* context, guint time) { if (ignore_drag_leave_) { ignore_drag_leave_ = false; @@ -765,7 +774,8 @@ void WidgetGtk::OnDragLeave(GdkDragContext* context, } } -gboolean WidgetGtk::OnDragMotion(GdkDragContext* context, +gboolean WidgetGtk::OnDragMotion(GtkWidget* widget, + GdkDragContext* context, gint x, gint y, guint time) { @@ -886,13 +896,19 @@ gboolean WidgetGtk::OnKeyRelease(GtkWidget* widget, GdkEventKey* event) { return root_view_->ProcessKeyEvent(key_event); } -gboolean WidgetGtk::OnQueryTooltip(gint x, +gboolean WidgetGtk::OnQueryTooltip(GtkWidget* widget, + 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. @@ -903,7 +919,8 @@ void WidgetGtk::OnGrabNotify(GtkWidget* widget, gboolean was_grabbed) { HandleGrabBroke(); } -void WidgetGtk::OnDestroy() { +void WidgetGtk::OnDestroy(GtkWidget* object) { + // Note that this handler is hooked to GtkObject::destroy. widget_ = window_contents_ = NULL; if (delete_on_destroy_) { // Delays the deletion of this WidgetGtk as we want its children to have @@ -912,6 +929,12 @@ void WidgetGtk::OnDestroy() { } } +void WidgetGtk::OnShow(GtkWidget* widget) { +} + +void WidgetGtk::OnHide(GtkWidget* widget) { +} + void WidgetGtk::DoGrab() { has_capture_ = true; gtk_grab_add(window_contents_); @@ -936,7 +959,7 @@ RootView* WidgetGtk::CreateRootView() { return new RootView(this); } -void WidgetGtk::OnWindowPaint(GtkWidget* widget, GdkEventExpose* event) { +gboolean 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 @@ -952,6 +975,7 @@ void 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) { @@ -1037,235 +1061,6 @@ 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 b317367..075d873 100644 --- a/views/widget/widget_gtk.h +++ b/views/widget/widget_gtk.h @@ -8,6 +8,7 @@ #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" @@ -224,52 +225,41 @@ class WidgetGtk static int GetFlagsForEventButton(const GdkEventButton& event); // Event handlers: - 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(); + 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); void set_mouse_down(bool mouse_down) { is_mouse_down_ = mouse_down; } @@ -298,7 +288,7 @@ class WidgetGtk virtual RootView* CreateRootView(); - void OnWindowPaint(GtkWidget* widget, GdkEventExpose* event); + CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnWindowPaint, GdkEventExpose*); // Process a mouse click. bool ProcessMousePressed(GdkEventButton* event); @@ -308,71 +298,6 @@ 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 8f5571d..fbfa3ce 100644 --- a/views/window/window_gtk.cc +++ b/views/window/window_gtk.cc @@ -468,9 +468,9 @@ void WindowGtk::SizeWindowToDefault(GtkWindow* parent) { SetBounds(bounds, NULL); } -void WindowGtk::OnDestroy() { +void WindowGtk::OnDestroy(GtkWidget* widget) { non_client_view_->WindowClosing(); - WidgetGtk::OnDestroy(); + WidgetGtk::OnDestroy(widget); } } // namespace views diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h index a9457af..865ac81 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(); + virtual void OnDestroy(GtkWidget* widget); private: static gboolean CallConfigureEvent(GtkWidget* widget, |