]> Pileus Git - ~andy/gtk/blobdiff - gdk/x11/gdkmain-x11.c
Updated Azeri and Walloon files
[~andy/gtk] / gdk / x11 / gdkmain-x11.c
index 1f395e390d119e37444d5a8d63b744aab7f6eb75..607483402466bcc2f1158e4477484739cebad626 100644 (file)
 #include <limits.h>
 #include <errno.h>
 
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif /* HAVE_SYS_SELECT_H_ */
-
-#define XLIB_ILLEGAL_ACCESS
 #include <X11/Xatom.h>
 #include <X11/Xlib.h>
-#include <X11/Xos.h>
 #include <X11/Xutil.h>
-#include <X11/cursorfont.h>
 
 #ifdef HAVE_XKB
 #include <X11/XKBlib.h>
@@ -53,6 +46,7 @@
 
 #include "gdkprivate-x11.h"
 #include "gdkinternals.h"
+#include "gdkregion-generic.h"
 #include "gdkinputprivate.h"
 
 #include <pango/pangox.h>
@@ -109,34 +103,6 @@ static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey);
 
 #endif /* G_ENABLE_DEBUG */
 
-static void
-gdk_arg_xim_preedit_cb (const gchar *arg, const gchar *value, gpointer cb_data)
-{
-  if (strcmp ("none", value) == 0)
-    gdk_im_set_best_style (GDK_IM_PREEDIT_NONE);
-  else if (strcmp ("nothing", value) == 0)
-    gdk_im_set_best_style (GDK_IM_PREEDIT_NOTHING);
-  else if (strcmp ("area", value) == 0)
-    gdk_im_set_best_style (GDK_IM_PREEDIT_AREA);
-  else if (strcmp ("position", value) == 0)
-    gdk_im_set_best_style (GDK_IM_PREEDIT_POSITION);
-  else if (strcmp ("callbacks", value) == 0)
-    gdk_im_set_best_style (GDK_IM_PREEDIT_CALLBACKS);
-}
-
-static void
-gdk_arg_xim_status_cb (const gchar *arg, const gchar *value, gpointer cb_data)
-{
-  if (strcmp ("none", value) == 0)
-    gdk_im_set_best_style (GDK_IM_STATUS_NONE);
-  else if (strcmp ("nothing", value) == 0)
-    gdk_im_set_best_style (GDK_IM_STATUS_NOTHING);
-  else if (strcmp ("area", value) == 0)
-    gdk_im_set_best_style (GDK_IM_STATUS_AREA);
-  else if (strcmp ("callbacks", value) == 0)
-    gdk_im_set_best_style (GDK_IM_STATUS_CALLBACKS);
-}
-
 GdkArgDesc _gdk_windowing_args[] = {
   { "display",     GDK_ARG_STRING,   &gdk_display_name,    (GdkArgFunc)NULL   },
   { "sync",        GDK_ARG_BOOL,     &gdk_synchronize,     (GdkArgFunc)NULL   },
@@ -144,8 +110,6 @@ GdkArgDesc _gdk_windowing_args[] = {
   { "class",       GDK_ARG_STRING,   &gdk_progclass,       (GdkArgFunc)NULL   },
   { "gxid-host",   GDK_ARG_STRING,   &gdk_input_gxid_host, (GdkArgFunc)NULL   },
   { "gxid-port",   GDK_ARG_INT,      &gdk_input_gxid_port, (GdkArgFunc)NULL   },
-  { "xim-preedit", GDK_ARG_CALLBACK, NULL,                 gdk_arg_xim_preedit_cb },
-  { "xim-status",  GDK_ARG_CALLBACK, NULL,                 gdk_arg_xim_status_cb  },
   { NULL }
 };
 
@@ -213,12 +177,23 @@ _gdk_windowing_init_check (int argc, char **argv)
         if (XkbQueryExtension (gdk_display, NULL, NULL, NULL,
                                &xkb_major, &xkb_minor))
           {
+           Bool detectable_autorepeat_supported;
+           
             _gdk_use_xkb = TRUE;
 
             XkbSelectEvents (gdk_display,
                              XkbUseCoreKbd,
                              XkbMapNotifyMask,
                              XkbMapNotifyMask);
+
+           XkbSetDetectableAutoRepeat (gdk_display,
+                                       True,
+                                       &detectable_autorepeat_supported);
+
+           GDK_NOTE (MISC, g_message ("Detectable autorepeat %s.",
+                                      detectable_autorepeat_supported ? "supported" : "not supported"));
+           
+           _gdk_have_xkb_autorepeat = detectable_autorepeat_supported;
           }
       }
   }
@@ -642,24 +617,32 @@ gdk_x_error (Display       *display,
     {
       if (gdk_error_warnings)
        {
-         char buf[64];
-         
+         gchar buf[64];
+          gchar *msg;
+          
          XGetErrorText (display, error->error_code, buf, 63);
 
+          msg =
+            g_strdup_printf ("The program '%s' received an X Window System error.\n"
+                             "This probably reflects a bug in the program.\n"
+                             "The error was '%s'.\n"
+                             "  (Details: serial %ld error_code %d request_code %d minor_code %d)\n"
+                             "  (Note to programmers: normally, X errors are reported asynchronously;\n"
+                             "   that is, you will receive the error a while after causing it.\n"
+                             "   To debug your program, run it with the --sync command line\n"
+                             "   option to change this behavior. You can then get a meaningful\n"
+                             "   backtrace from your debugger if you break on the gdk_x_error() function.)",
+                             g_get_prgname (),
+                             buf,
+                             error->serial, 
+                             error->error_code, 
+                             error->request_code,
+                             error->minor_code);
+          
 #ifdef G_ENABLE_DEBUG    
-         g_error ("%s\n  serial %ld error_code %d request_code %d minor_code %d\n", 
-                  buf, 
-                  error->serial, 
-                  error->error_code, 
-                  error->request_code,
-                  error->minor_code);
+         g_error ("%s", msg);
 #else /* !G_ENABLE_DEBUG */
-         fprintf (stderr, "Gdk-ERROR **: %s\n  serial %ld error_code %d request_code %d minor_code %d\n",
-                  buf, 
-                  error->serial, 
-                  error->error_code, 
-                  error->request_code,
-                  error->minor_code);
+         fprintf (stderr, "%s\n", msg);
 
          exit(1);
 #endif /* G_ENABLE_DEBUG */
@@ -700,11 +683,17 @@ gdk_x_io_error (Display *display)
    */
   if (errno == EPIPE)
     {
-      fprintf (stderr, "Gdk-ERROR **: X connection to %s broken (explicit kill or server shutdown).\n", gdk_display ? DisplayString (gdk_display) : gdk_get_display());
+      fprintf (stderr,
+               "The application '%s' lost its connection to the display %s;\n"
+               "most likely the X server was shut down or you killed/destroyed\n"
+               "the application.\n",
+               g_get_prgname (),
+               gdk_display ? DisplayString (gdk_display) : gdk_get_display());
     }
   else
     {
-      fprintf (stderr, "Gdk-ERROR **: Fatal IO error %d (%s) on X server %s.\n",
+      fprintf (stderr, "%s: Fatal IO error %d (%s) on X server %s.\n",
+               g_get_prgname (),
               errno, g_strerror (errno),
               gdk_display ? DisplayString (gdk_display) : gdk_get_display());
     }
@@ -737,3 +726,26 @@ gdk_send_xevent (Window window, gboolean propagate, glong event_mask,
   
   return result && !gdk_error_code;
 }
+
+void
+_gdk_region_get_xrectangles (GdkRegion   *region,
+                             gint         x_offset,
+                             gint         y_offset,
+                             XRectangle **rects,
+                             gint        *n_rects)
+{
+  XRectangle *rectangles = g_new (XRectangle, region->numRects);
+  GdkRegionBox *boxes = region->rects;
+  gint i;
+  
+  for (i = 0; i < region->numRects; i++)
+    {
+      rectangles[i].x = CLAMP (boxes[i].x1 + x_offset, G_MINSHORT, G_MAXSHORT);
+      rectangles[i].y = CLAMP (boxes[i].y1 + y_offset, G_MINSHORT, G_MAXSHORT);
+      rectangles[i].width = CLAMP (boxes[i].x2 + x_offset, G_MINSHORT, G_MAXSHORT) - rectangles[i].x;
+      rectangles[i].height = CLAMP (boxes[i].y2 + y_offset, G_MINSHORT, G_MAXSHORT) - rectangles[i].y;
+    }
+
+  *rects = rectangles;
+  *n_rects = region->numRects;
+}