Skip to content

Commit 4a4f807

Browse files
committed
nemo-icon-container.c: Clean up interactive-search positioning
function. This is only used in nemo-desktop windows now - all other views use the filter-bar approach. Disable interactive search in the sidebar also - focus is forced on the active view after location changes now, so the filter-bar can be invoked naturally.
1 parent fb689da commit 4a4f807

3 files changed

Lines changed: 40 additions & 57 deletions

File tree

‎libnemo-private/nemo-icon-container.c‎

Lines changed: 32 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3594,75 +3594,52 @@ static void
35943594
nemo_icon_container_search_position_func (NemoIconContainer *container,
35953595
GtkWidget *search_dialog)
35963596
{
3597-
gint x, y;
3598-
gint cont_x, cont_y;
3599-
gint cont_width, cont_height;
3600-
GdkWindow *cont_window;
3601-
GtkRequisition requisition;
3602-
gint monitor_num;
3603-
GdkRectangle monitor;
3604-
3605-
cont_window = gtk_widget_get_window (GTK_WIDGET (container));
3606-
3607-
monitor_num = nemo_desktop_utils_get_monitor_for_widget (GTK_WIDGET (container));
3608-
3609-
/* FIXME?? _NET_WORKAREA hint only provides accurate workarea geometry for the
3610-
* primary monitor. Non-primary will return the full monitor geometry instead.
3597+
gint x, y;
3598+
gint cont_x, cont_y;
3599+
gint cont_width, cont_height;
3600+
GdkWindow *cont_window;
3601+
GtkRequisition requisition;
3602+
3603+
/* Desktop containers only: every other container forwards keypresses to the
3604+
* filter bar rather than starting an interactive search, so nothing else
3605+
* reaches here - see nemo_icon_container_key_press_event ().
36113606
*/
3612-
nemo_desktop_utils_get_monitor_work_rect (monitor_num, &monitor);
3607+
cont_window = gtk_widget_get_window (GTK_WIDGET (container));
36133608

3614-
gtk_widget_realize (search_dialog);
3609+
gtk_widget_realize (search_dialog);
36153610

36163611
gdk_window_get_origin (cont_window, &cont_x, &cont_y);
36173612
cont_width = gdk_window_get_width (cont_window);
36183613
cont_height = gdk_window_get_height (cont_window);
36193614

3620-
gtk_widget_get_preferred_size (search_dialog, &requisition, NULL);
3621-
3622-
if (nemo_icon_container_get_is_desktop (container)) {
3623-
x = cont_x + cont_width - requisition.width;
3624-
y = cont_y + cont_height - requisition.height;
3615+
gtk_widget_get_preferred_size (search_dialog, &requisition, NULL);
36253616

3626-
if (eel_check_is_wayland ()) {
3627-
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (container));
3628-
GdkWindow *parent_window = gtk_widget_get_window (toplevel);
3629-
gint parent_x, parent_y;
3617+
x = cont_x + cont_width - requisition.width;
3618+
y = cont_y + cont_height - requisition.height;
36303619

3631-
gdk_window_get_origin (parent_window, &parent_x, &parent_y);
3620+
if (eel_check_is_wayland ()) {
3621+
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (container));
3622+
GdkWindow *parent_window = gtk_widget_get_window (toplevel);
3623+
gint parent_x, parent_y;
36323624

3633-
GdkRectangle anchor_rect = {
3634-
x - parent_x,
3635-
y - parent_y,
3636-
1, 1
3637-
};
3625+
gdk_window_get_origin (parent_window, &parent_x, &parent_y);
36383626

3639-
gdk_window_move_to_rect (gtk_widget_get_window (search_dialog),
3640-
&anchor_rect,
3641-
GDK_GRAVITY_NORTH_WEST,
3642-
GDK_GRAVITY_NORTH_WEST,
3643-
0,
3644-
0, 0);
3645-
return;
3646-
}
3647-
} else {
3648-
if (cont_x + cont_width > monitor.x + monitor.width) {
3649-
x = monitor.x + monitor.width - requisition.width;
3650-
} else if (cont_x + cont_width - requisition.width < 0) {
3651-
x = 0;
3652-
} else {
3653-
x = cont_x + cont_width - requisition.width;
3654-
}
3627+
GdkRectangle anchor_rect = {
3628+
x - parent_x,
3629+
y - parent_y,
3630+
1, 1
3631+
};
36553632

3656-
if (cont_y + cont_height + requisition.height > monitor.y + monitor.height) {
3657-
y = monitor.y + monitor.height - requisition.height;
3658-
} else if (cont_y + cont_height < 0) {
3659-
y = 0;
3660-
} else {
3661-
y = cont_y + cont_height;
3662-
}
3633+
gdk_window_move_to_rect (gtk_widget_get_window (search_dialog),
3634+
&anchor_rect,
3635+
GDK_GRAVITY_NORTH_WEST,
3636+
GDK_GRAVITY_NORTH_WEST,
3637+
0,
3638+
0, 0);
3639+
return;
36633640
}
36643641

3665-
gdk_window_move (gtk_widget_get_window (search_dialog), x, y);
3642+
gdk_window_move (gtk_widget_get_window (search_dialog), x, y);
36663643
}
36673644

36683645
/* Cut and paste from gtkwindow.c */

‎src/nemo-places-sidebar.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4332,7 +4332,11 @@ nemo_places_sidebar_init (NemoPlacesSidebar *sidebar)
43324332
gtk_widget_show (GTK_WIDGET (sidebar));
43334333
sidebar->tree_view = tree_view;
43344334

4335-
gtk_tree_view_set_search_column (tree_view, PLACES_SIDEBAR_COLUMN_NAME);
4335+
/* On by default, and its search window positions itself with absolute root
4336+
* coordinates - which a Wayland client cannot know, so it lands on the
4337+
* wrong monitor. */
4338+
gtk_tree_view_set_enable_search (tree_view, FALSE);
4339+
43364340
selection = gtk_tree_view_get_selection (tree_view);
43374341
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
43384342

‎src/nemo-tree-sidebar.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,9 @@ create_tree (FMTreeView *view)
14651465
(gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (view->details->child_model)));
14661466
view->details->tree_widget = GTK_TREE_VIEW
14671467
(gtk_tree_view_new_with_model (GTK_TREE_MODEL (view->details->sort_model)));
1468-
gtk_tree_view_set_search_column (GTK_TREE_VIEW (view->details->tree_widget), FM_TREE_MODEL_DISPLAY_NAME_COLUMN);
1468+
1469+
/* See nemo-places-sidebar.c */
1470+
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view->details->tree_widget), FALSE);
14691471

14701472
g_object_unref (view->details->sort_model);
14711473

0 commit comments

Comments
 (0)