Fix #911: can't rename or create directories, while file name outside the window
[geeqie.git] / src / ui_tree_edit.c
index afb5686..b572c1d 100644 (file)
@@ -1,13 +1,22 @@
 /*
- * (SLIK) SimpLIstic sKin functions
- * (C) 2004 John Ellis
- * Copyright (C) 2008 - 2012 The Geeqie Team
+ * Copyright (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
  *
  * Author: John Ellis
  *
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -151,7 +160,7 @@ static gboolean tree_edit_by_path_idle_cb(gpointer data)
                w = MAX(w - sx, sw);
                }
 
-       gdk_window_get_origin(gtk_tree_view_get_bin_window(ted->tree), &wx, &wy);
+       gdk_window_get_origin(gtk_widget_get_window(gtk_widget_get_parent(GTK_WIDGET(ted->tree))), &wx, &wy);
 
        x += wx - 2; /* the -val is to 'fix' alignment of entry position */
        y += wy - 2;
@@ -165,7 +174,7 @@ static gboolean tree_edit_by_path_idle_cb(gpointer data)
 
        /* grab it */
        gtk_widget_grab_focus(ted->entry);
-       /* explicitely set the focus flag for the entry, for some reason on popup windows this
+       /* explicitly set the focus flag for the entry, for some reason on popup windows this
         * is not set, and causes no edit cursor to appear ( popups not allowed focus? )
         */
        gtk_widget_grab_focus(ted->entry);
@@ -222,7 +231,7 @@ gboolean tree_edit_by_path(GtkTreeView *tree, GtkTreePath *tpath, gint column, c
        ted->column = tcolumn;
        ted->cell = cell;
 
-       gtk_tree_view_scroll_to_cell(ted->tree, ted->path, ted->column, FALSE, 0.0, 0.0);
+       gtk_tree_view_scroll_to_cell(ted->tree, ted->path, ted->column, TRUE, 0.5, 0.0);
 
        /* create the window */
 
@@ -566,6 +575,10 @@ static gboolean widget_auto_scroll_cb(gpointer data)
        gint x, y;
        gint w, h;
        gint amt = 0;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDeviceManager *device_manager;
+       GdkDevice *device;
+#endif
 
        if (sd->max_step < sd->region_size)
                {
@@ -573,7 +586,13 @@ static gboolean widget_auto_scroll_cb(gpointer data)
                }
 
        window = gtk_widget_get_window(sd->widget);
+#if GTK_CHECK_VERSION(3,0,0)
+       device_manager = gdk_display_get_device_manager(gdk_window_get_display(window));
+       device = gdk_device_manager_get_client_pointer(device_manager);
+       gdk_window_get_device_position(window, device, &x, &y, NULL);
+#else
        gdk_window_get_pointer(window, &x, &y, NULL);
+#endif
        w = gdk_window_get_width(window);
        h = gdk_window_get_height(window);