]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkmain.c
gtk: Only set widget under device on non-virtual crossing events
[~andy/gtk] / gtk / gtkmain.c
index 415faac8e0245b2fcfe689e0e40dda073437ff10..962656950ed5b1bf79a39a82e04195fba9358817 100644 (file)
@@ -91,9 +91,6 @@
 
 #include "config.h"
 
-#include "gtkmainprivate.h"
-
-#include <glib.h>
 #include "gdk/gdk.h"
 
 #include <locale.h>
 
 #include "gtkintl.h"
 
-#include "gtkaccelmap.h"
+#include "gtkaccelmapprivate.h"
 #include "gtkbox.h"
 #include "gtkclipboard.h"
+#include "gtkdebug.h"
 #include "gtkdnd.h"
-#include "gtkversion.h"
+#include "gtkmain.h"
+#include "gtkmenu.h"
 #include "gtkmodules.h"
+#include "gtkmodulesprivate.h"
+#include "gtkprivate.h"
 #include "gtkrecentmanager.h"
+#include "gtkresources.h"
 #include "gtkselectionprivate.h"
 #include "gtksettingsprivate.h"
+#include "gtktooltip.h"
+#include "gtkversion.h"
 #include "gtkwidgetprivate.h"
 #include "gtkwindowprivate.h"
-#include "gtktooltip.h"
-#include "gtkdebug.h"
-#include "gtkmenu.h"
-
-#ifdef G_OS_WIN32
-
-static HMODULE gtk_dll;
-
-BOOL WINAPI
-DllMain (HINSTANCE hinstDLL,
-         DWORD     fdwReason,
-         LPVOID    lpvReserved)
-{
-  switch (fdwReason)
-    {
-    case DLL_PROCESS_ATTACH:
-      gtk_dll = (HMODULE) hinstDLL;
-      break;
-    }
-
-  return TRUE;
-}
-
-/* These here before inclusion of gtkprivate.h so that the original
- * GTK_LIBDIR and GTK_LOCALEDIR definitions are seen. Yeah, this is a
- * bit sucky.
- */
-const gchar *
-_gtk_get_libdir (void)
-{
-  static char *gtk_libdir = NULL;
-  if (gtk_libdir == NULL)
-    {
-      gchar *root = g_win32_get_package_installation_directory_of_module (gtk_dll);
-      gchar *slash = strrchr (root, '\\');
-      if (g_ascii_strcasecmp (slash + 1, ".libs") == 0)
-        gtk_libdir = GTK_LIBDIR;
-      else
-        gtk_libdir = g_build_filename (root, "lib", NULL);
-      g_free (root);
-    }
-
-  return gtk_libdir;
-}
-
-const gchar *
-_gtk_get_localedir (void)
-{
-  static char *gtk_localedir = NULL;
-  if (gtk_localedir == NULL)
-    {
-      const gchar *p;
-      gchar *root, *temp;
-      
-      /* GTK_LOCALEDIR ends in either /lib/locale or
-       * /share/locale. Scan for that slash.
-       */
-      p = GTK_LOCALEDIR + strlen (GTK_LOCALEDIR);
-      while (*--p != '/')
-        ;
-      while (*--p != '/')
-        ;
-
-      root = g_win32_get_package_installation_directory_of_module (gtk_dll);
-      temp = g_build_filename (root, p, NULL);
-      g_free (root);
-
-      /* gtk_localedir is passed to bindtextdomain() which isn't
-       * UTF-8-aware.
-       */
-      gtk_localedir = g_win32_locale_filename_from_utf8 (temp);
-      g_free (temp);
-    }
-  return gtk_localedir;
-}
-
-#endif
 
-#include "gtkprivate.h"
+#include "a11y/gailutil.h"
 
 /* Private type definitions
  */
@@ -447,48 +374,6 @@ check_setugid (void)
   return TRUE;
 }
 
-#ifdef G_OS_WIN32
-
-const gchar *
-_gtk_get_datadir (void)
-{
-  static char *gtk_datadir = NULL;
-  if (gtk_datadir == NULL)
-    {
-      gchar *root = g_win32_get_package_installation_directory_of_module (gtk_dll);
-      gtk_datadir = g_build_filename (root, "share", NULL);
-      g_free (root);
-    }
-
-  return gtk_datadir;
-}
-
-const gchar *
-_gtk_get_sysconfdir (void)
-{
-  static char *gtk_sysconfdir = NULL;
-  if (gtk_sysconfdir == NULL)
-    {
-      gchar *root = g_win32_get_package_installation_directory_of_module (gtk_dll);
-      gtk_sysconfdir = g_build_filename (root, "etc", NULL);
-      g_free (root);
-    }
-
-  return gtk_sysconfdir;
-}
-
-const gchar *
-_gtk_get_data_prefix (void)
-{
-  static char *gtk_data_prefix = NULL;
-  if (gtk_data_prefix == NULL)
-    gtk_data_prefix = g_win32_get_package_installation_directory_of_module (gtk_dll);
-
-  return gtk_data_prefix;
-}
-
-#endif /* G_OS_WIN32 */
-
 static gboolean do_setlocale = TRUE;
 
 /**
@@ -737,32 +622,6 @@ setlocale_initialization (void)
     }
 }
 
-/* Return TRUE if module_to_check causes version conflicts.
- * If module_to_check is NULL, check the main module.
- */
-gboolean
-_gtk_module_has_mixed_deps (GModule *module_to_check)
-{
-  GModule *module;
-  gpointer func;
-  gboolean result;
-
-  if (!module_to_check)
-    module = g_module_open (NULL, 0);
-  else
-    module = module_to_check;
-
-  if (g_module_symbol (module, "gtk_progress_get_type", &func))
-    result = TRUE;
-  else
-    result = FALSE;
-
-  if (!module_to_check)
-    g_module_close (module);
-
-  return result;
-}
-
 static void
 do_pre_parse_initialization (int    *argc,
                              char ***argv)
@@ -802,8 +661,8 @@ gettext_initialization (void)
   setlocale_initialization ();
 
 #ifdef ENABLE_NLS
-  bindtextdomain (GETTEXT_PACKAGE, GTK_LOCALEDIR);
-  bindtextdomain (GETTEXT_PACKAGE "-properties", GTK_LOCALEDIR);
+  bindtextdomain (GETTEXT_PACKAGE, _gtk_get_localedir ());
+  bindtextdomain (GETTEXT_PACKAGE "-properties", _gtk_get_localedir ());
 #    ifdef HAVE_BIND_TEXTDOMAIN_CODESET
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
   bind_textdomain_codeset (GETTEXT_PACKAGE "-properties", "UTF-8");
@@ -812,7 +671,7 @@ gettext_initialization (void)
 }
 
 /* XXX: Remove me after getting rid of gail */
-extern void gail_accessibility_module_init (void);
+extern void _gtk_accessibility_init (void);
 
 static void
 do_post_parse_initialization (int    *argc,
@@ -852,6 +711,8 @@ do_post_parse_initialization (int    *argc,
       g_warning ("Whoever translated default:LTR did so wrongly.\n");
   }
 
+  _gtk_register_resource ();
+
   /* do what the call to gtk_type_init() used to do */
   g_type_init ();
 
@@ -872,7 +733,7 @@ do_post_parse_initialization (int    *argc,
       _gtk_modules_init (argc, argv, NULL);
     }
 
-  gail_accessibility_module_init ();
+  _gtk_accessibility_init ();
 }
 
 
@@ -1257,66 +1118,6 @@ gtk_init_check_abi_check (int *argc, char ***argv, int num_checks, size_t sizeof
 
 #endif
 
-/*
- * _gtk_get_lc_ctype:
- *
- * Return the Unix-style locale string for the language currently in
- * effect. On Unix systems, this is the return value from
- * <literal>setlocale(LC_CTYPE, NULL)</literal>, and the user can
- * affect this through the environment variables LC_ALL, LC_CTYPE or
- * LANG (checked in that order). The locale strings typically is in
- * the form lang_COUNTRY, where lang is an ISO-639 language code, and
- * COUNTRY is an ISO-3166 country code. For instance, sv_FI for
- * Swedish as written in Finland or pt_BR for Portuguese as written in
- * Brazil.
- *
- * On Windows, the C library doesn't use any such environment
- * variables, and setting them won't affect the behaviour of functions
- * like ctime(). The user sets the locale through the Regional Options
- * in the Control Panel. The C library (in the setlocale() function)
- * does not use country and language codes, but country and language
- * names spelled out in English.
- * However, this function does check the above environment
- * variables, and does return a Unix-style locale string based on
- * either said environment variables or the thread's current locale.
- *
- * Return value: a dynamically allocated string, free with g_free().
- */
-
-gchar *
-_gtk_get_lc_ctype (void)
-{
-#ifdef G_OS_WIN32
-  /* Somebody might try to set the locale for this process using the
-   * LANG or LC_ environment variables. The Microsoft C library
-   * doesn't know anything about them. You set the locale in the
-   * Control Panel. Setting these env vars won't have any affect on
-   * locale-dependent C library functions like ctime(). But just for
-   * kicks, do obey LC_ALL, LC_CTYPE and LANG in GTK. (This also makes
-   * it easier to test GTK and Pango in various default languages, you
-   * don't have to clickety-click in the Control Panel, you can simply
-   * start the program with LC_ALL=something on the command line.)
-   */
-  gchar *p;
-
-  p = getenv ("LC_ALL");
-  if (p != NULL)
-    return g_strdup (p);
-
-  p = getenv ("LC_CTYPE");
-  if (p != NULL)
-    return g_strdup (p);
-
-  p = getenv ("LANG");
-  if (p != NULL)
-    return g_strdup (p);
-
-  return g_win32_getlocale ();
-#else
-  return g_strdup (setlocale (LC_CTYPE, NULL));
-#endif
-}
-
 /**
  * gtk_get_default_language:
  *
@@ -1839,11 +1640,19 @@ gtk_main_do_event (GdkEvent *event)
 
     case GDK_KEY_PRESS:
     case GDK_KEY_RELEASE:
-      if (key_snoopers)
-        {
-          if (gtk_invoke_key_snoopers (grab_widget, event))
-            break;
-        }
+      if (gtk_invoke_key_snoopers (grab_widget, event))
+        break;
+
+      /* make focus visible in a window that receives a key event */
+      {
+        GtkWidget *window;
+        GtkPolicyType visible_focus;
+
+        window = gtk_widget_get_toplevel (grab_widget);
+        g_object_get (gtk_widget_get_settings (grab_widget), "gtk-visible-focus", &visible_focus, NULL);
+        if (GTK_IS_WINDOW (window) && visible_focus != GTK_POLICY_NEVER)
+          gtk_window_set_focus_visible (GTK_WINDOW (window), TRUE);
+      }
 
       /* Catch alt press to enable auto-mnemonics;
        * menus are handled elsewhere
@@ -1866,7 +1675,6 @@ gtk_main_do_event (GdkEvent *event)
               mnemonics_visible = (event->type == GDK_KEY_PRESS);
 
               window = gtk_widget_get_toplevel (grab_widget);
-
               if (GTK_IS_WINDOW (window))
                 gtk_window_set_mnemonics_visible (GTK_WINDOW (window), mnemonics_visible);
             }
@@ -1880,17 +1688,21 @@ gtk_main_do_event (GdkEvent *event)
       break;
 
     case GDK_ENTER_NOTIFY:
-      _gtk_widget_set_device_window (event_widget,
-                                     gdk_event_get_device (event),
-                                     event->any.window);
+      if (event->crossing.detail != GDK_NOTIFY_VIRTUAL &&
+          event->crossing.detail != GDK_NOTIFY_NONLINEAR_VIRTUAL)
+        _gtk_widget_set_device_window (event_widget,
+                                       gdk_event_get_device (event),
+                                       event->any.window);
       if (gtk_widget_is_sensitive (grab_widget))
         gtk_widget_event (grab_widget, event);
       break;
 
     case GDK_LEAVE_NOTIFY:
-      _gtk_widget_set_device_window (event_widget,
-                                     gdk_event_get_device (event),
-                                     NULL);
+      if (event->crossing.detail != GDK_NOTIFY_VIRTUAL &&
+          event->crossing.detail != GDK_NOTIFY_NONLINEAR_VIRTUAL)
+        _gtk_widget_set_device_window (event_widget,
+                                       gdk_event_get_device (event),
+                                       NULL);
       if (gtk_widget_is_sensitive (grab_widget))
         gtk_widget_event (grab_widget, event);
       break;
@@ -2335,6 +2147,9 @@ gtk_device_grab_remove (GtkWidget *widget,
  *
  * Returns: a unique id for this key snooper for use with
  *    gtk_key_snooper_remove().
+ *
+ * Deprecated: 3.4: Key snooping should not be done. Events should
+ *     be handled by widgets.
  */
 guint
 gtk_key_snooper_install (GtkKeySnoopFunc snooper,
@@ -2359,6 +2174,9 @@ gtk_key_snooper_install (GtkKeySnoopFunc snooper,
  * @snooper_handler_id: Identifies the key snooper to remove
  *
  * Removes the key snooper function with the given id.
+ *
+ * Deprecated: 3.4: Key snooping should not be done. Events should
+ *     be handled by widgets.
  */
 void
 gtk_key_snooper_remove (guint snooper_id)
@@ -2390,6 +2208,8 @@ gtk_invoke_key_snoopers (GtkWidget *grab_widget,
   GSList *slist;
   gint return_val = FALSE;
 
+  return_val = _gail_util_key_snooper (grab_widget, (GdkEventKey *) event);
+
   slist = key_snoopers;
   while (slist && !return_val)
     {
@@ -2617,19 +2437,3 @@ gtk_propagate_event (GtkWidget *widget,
   else
     g_object_unref (widget);
 }
-
-gboolean
-_gtk_boolean_handled_accumulator (GSignalInvocationHint *ihint,
-                                  GValue                *return_accu,
-                                  const GValue          *handler_return,
-                                  gpointer               dummy)
-{
-  gboolean continue_emission;
-  gboolean signal_handled;
-
-  signal_handled = g_value_get_boolean (handler_return);
-  g_value_set_boolean (return_accu, signal_handled);
-  continue_emission = !signal_handled;
-
-  return continue_emission;
-}