From 41070c314feabcd3c8a12d685bfd9c86988ede56 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Mon, 6 Oct 2003 13:53:56 +0000 Subject: Allow dragging of tabs to a window even when the tabs bar is not shown. 2003-10-06 Christian Persch * src/ephy-notebook.c: (find_notebook_at_pointer), (ephy_notebook_init), (ephy_notebook_finalize): Allow dragging of tabs to a window even when the tabs bar is not shown. Fixes bug #123908. --- src/ephy-notebook.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'src/ephy-notebook.c') diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c index d9e48d17b..6567d12ed 100644 --- a/src/ephy-notebook.c +++ b/src/ephy-notebook.c @@ -78,7 +78,6 @@ static void move_tab_to_another_notebook (EphyNotebook *src, /* Local variables */ static GdkCursor *cursor = NULL; -static GList *notebooks = NULL; static GtkTargetEntry url_drag_types [] = { @@ -204,36 +203,36 @@ is_in_notebook_window (EphyNotebook *notebook, static EphyNotebook * find_notebook_at_pointer (gint abs_x, gint abs_y) { - GList *l; + GdkWindow *win_at_pointer, *toplevel_win; + gpointer toplevel = NULL; gint x, y; - GdkWindow *win_at_pointer = gdk_window_at_pointer (&x, &y); - GdkWindow *parent_at_pointer = NULL; + win_at_pointer = gdk_window_at_pointer (&x, &y); if (win_at_pointer == NULL) { /* We are outside all windows containing a notebook */ return NULL; } - gdk_window_get_toplevel (win_at_pointer); - /* When we are in the notebook event window, win_at_pointer will be - this event window, and the toplevel window we are interested in - will be its parent - */ - parent_at_pointer = gdk_window_get_parent (win_at_pointer); + toplevel_win = gdk_window_get_toplevel (win_at_pointer); + + /* get the GtkWidget which owns the toplevel GdkWindow */ + gdk_window_get_user_data (toplevel_win, &toplevel); - for (l = notebooks; l != NULL; l = l->next) + /* toplevel should be an EphyWindow */ + if (toplevel != NULL && EPHY_IS_WINDOW (toplevel)) { - EphyNotebook *nb = EPHY_NOTEBOOK (l->data); - GdkWindow *win = GTK_WIDGET (nb)->window; + EphyNotebook *notebook; + + notebook = EPHY_NOTEBOOK (ephy_window_get_notebook + (EPHY_WINDOW (toplevel))); - win = gdk_window_get_toplevel (win); - if (((win == win_at_pointer) || (win == parent_at_pointer)) - && is_in_notebook_window (nb, abs_x, abs_y)) + if (is_in_notebook_window (notebook, abs_x, abs_y)) { - return nb; + return notebook; } } + return NULL; } @@ -735,8 +734,6 @@ ephy_notebook_init (EphyNotebook *notebook) notebook->priv->opened_tabs = NULL; notebook->priv->show_tabs = TRUE; - notebooks = g_list_append (notebooks, notebook); - g_signal_connect (notebook, "button-press-event", (GCallback)button_press_cb, NULL); g_signal_connect (notebook, "button-release-event", @@ -766,8 +763,6 @@ ephy_notebook_finalize (GObject *object) { EphyNotebook *notebook = EPHY_NOTEBOOK (object); - notebooks = g_list_remove (notebooks, notebook); - eel_gconf_notification_remove (notebook->priv->tabs_vis_notifier_id); if (notebook->priv->focused_pages) -- cgit v1.2.3