static gint find_tab_num_at_pos (NautilusNotebook *notebook, gint abs_x, gint abs_y) { GtkPositionType tab_pos; int page_num = 0; GtkNotebook *nb = GTK_NOTEBOOK (notebook); GtkWidget *page; tab_pos = gtk_notebook_get_tab_pos (GTK_NOTEBOOK (notebook)); if (GTK_NOTEBOOK (notebook)->first_tab == NULL) { return AFTER_ALL_TABS; } /* For some reason unfullscreen + quick click can cause a wrong click event to be reported to the tab */ if (!is_in_notebook_window(notebook, abs_x, abs_y)) { return NOT_IN_APP_WINDOWS; } while ((page = gtk_notebook_get_nth_page (nb, page_num))) { GtkWidget *tab; gint max_x, max_y; gint x_root, y_root; tab = gtk_notebook_get_tab_label (nb, page); g_return_val_if_fail (tab != NULL, -1); if (!GTK_WIDGET_MAPPED (GTK_WIDGET (tab))) { page_num++; continue; } gdk_window_get_origin (GDK_WINDOW (tab->window), &x_root, &y_root); max_x = x_root + tab->allocation.x + tab->allocation.width; max_y = y_root + tab->allocation.y + tab->allocation.height; if (((tab_pos == GTK_POS_TOP) || (tab_pos == GTK_POS_BOTTOM)) &&(abs_x<=max_x)) { return page_num; } else if (((tab_pos == GTK_POS_LEFT) || (tab_pos == GTK_POS_RIGHT)) && (abs_y<=max_y)) { return page_num; } page_num++; } return AFTER_ALL_TABS; }
static gboolean button_release_cb (CeditNotebook *notebook, GdkEventButton *event, gpointer data) { if (notebook->priv->drag_in_progress) { gint cur_page_num; GtkWidget *cur_page; cur_page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)); cur_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), cur_page_num); /* CHECK: I don't follow the code here -- Paolo */ if (!is_in_notebook_window (notebook, event->x_root, event->y_root) && (gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) > 1)) { /* Tab was detached */ g_signal_emit (G_OBJECT (notebook), signals[TAB_DETACHED], 0, cur_page); } /* ungrab the pointer if it's grabbed */ if (gdk_pointer_is_grabbed ()) { gdk_pointer_ungrab (event->time); } gtk_grab_remove (GTK_WIDGET (notebook)); } /* This must be called even if a drag isn't happening */ drag_stop (notebook); return FALSE; }
static gint find_tab_num_at_pos (CeditNotebook *notebook, gint abs_x, gint abs_y) { GtkPositionType tab_pos; int page_num = 0; GtkNotebook *nb = GTK_NOTEBOOK (notebook); GtkWidget *page; tab_pos = gtk_notebook_get_tab_pos (GTK_NOTEBOOK (notebook)); /* For some reason unfullscreen + quick click can cause a wrong click event to be reported to the tab */ if (!is_in_notebook_window (notebook, abs_x, abs_y)) { return NOT_IN_APP_WINDOWS; } while ((page = gtk_notebook_get_nth_page (nb, page_num)) != NULL) { GtkAllocation allocation; GtkWidget *tab; gint max_x, max_y; gint x_root, y_root; tab = gtk_notebook_get_tab_label (nb, page); g_return_val_if_fail (tab != NULL, AFTER_ALL_TABS); if (!gtk_widget_get_mapped (tab)) { ++page_num; continue; } gdk_window_get_origin (GDK_WINDOW (gtk_widget_get_window (tab)), &x_root, &y_root); gtk_widget_get_allocation(tab, &allocation); max_x = x_root + allocation.x + allocation.width; max_y = y_root + allocation.y + allocation.height; if (((tab_pos == GTK_POS_TOP) || (tab_pos == GTK_POS_BOTTOM)) && (abs_x <= max_x)) { return page_num; } else if (((tab_pos == GTK_POS_LEFT) || (tab_pos == GTK_POS_RIGHT)) && (abs_y <= max_y)) { return page_num; } ++page_num; } return AFTER_ALL_TABS; }
static gint find_tab_num_at_pos (EphyNotebook *notebook, gint abs_x, gint abs_y) { GtkPositionType tab_pos; int page_num = 0; GtkNotebook *nb = GTK_NOTEBOOK (notebook); GtkWidget *page; /* For some reason unfullscreen + quick click can cause a wrong click event to be reported to the tab */ if (!is_in_notebook_window (notebook, abs_x, abs_y)) { return -1; } tab_pos = gtk_notebook_get_tab_pos (nb); while ((page = gtk_notebook_get_nth_page (nb, page_num))) { GtkWidget *tab; GtkAllocation allocation; gint max_x, max_y; gint x_root, y_root; tab = gtk_notebook_get_tab_label (nb, page); g_return_val_if_fail (tab != NULL, -1); if (!GTK_WIDGET_MAPPED (GTK_WIDGET (tab))) { page_num++; continue; } gdk_window_get_origin (gtk_widget_get_window (tab), &x_root, &y_root); gtk_widget_get_allocation (tab, &allocation); max_x = x_root + allocation.x + allocation.width; max_y = y_root + allocation.y + allocation.height; if ((tab_pos == GTK_POS_TOP || tab_pos == GTK_POS_BOTTOM) && abs_x <= max_x && abs_y <= max_y) { return page_num; } else if ((tab_pos == GTK_POS_LEFT || tab_pos == GTK_POS_RIGHT) && abs_x <= max_x && abs_y <= max_y) { return page_num; } page_num++; } return -1; }