emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r117553: * frame.h (struct frame) [USE_X_TOOLKIT]: N


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r117553: * frame.h (struct frame) [USE_X_TOOLKIT]: New member shell_position.
Date: Sun, 20 Jul 2014 16:15:27 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117553
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Sun 2014-07-20 20:14:58 +0400
message:
  * frame.h (struct frame) [USE_X_TOOLKIT]: New member shell_position.
  * xfns.c (x_window): Use it to allow xfree later.
  (x_encode_text): Drop 3rd arg; unused.  Tweak comment and adjust users
  where appropriate.  Use bool for booleans and remove redundant checks.
  (Fx_backspace_delete_keys_p): Use XkbFreeKeyboard; explain why.
  * xterm.c (x_free_frame_resources): Free shell_position.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/frame.h                    frame.h-20091113204419-o5vbwnq5f7feedwu-229
  src/xfns.c                     xfns.c-20091113204419-o5vbwnq5f7feedwu-274
  src/xterm.c                    xterm.c-20091113204419-o5vbwnq5f7feedwu-244
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-07-19 15:18:23 +0000
+++ b/src/ChangeLog     2014-07-20 16:14:58 +0000
@@ -1,3 +1,12 @@
+2014-07-20  Dmitry Antipov  <address@hidden>
+
+       * frame.h (struct frame) [USE_X_TOOLKIT]: New member shell_position.
+       * xfns.c (x_window): Use it to allow xfree later.
+       (x_encode_text): Drop 3rd arg; unused.  Tweak comment and adjust users
+       where appropriate.  Use bool for booleans and remove redundant checks.
+       (Fx_backspace_delete_keys_p): Use XkbFreeKeyboard; explain why.
+       * xterm.c (x_free_frame_resources): Free shell_position.
+
 2014-07-19  K. Handa  <address@hidden>
 
        * xfaces.c (realize_x_face): Call font_load_for_lface with no

=== modified file 'src/frame.h'
--- a/src/frame.h       2014-07-18 06:02:19 +0000
+++ b/src/frame.h       2014-07-20 16:14:58 +0000
@@ -192,6 +192,11 @@
   char *namebuf;
 #endif
 
+#ifdef USE_X_TOOLKIT
+  /* Used to pass geometry parameters to toolkit functions.  */
+  char *shell_position;
+#endif
+
   /* Glyph pool and matrix.  */
   struct glyph_pool *current_pool;
   struct glyph_pool *desired_pool;

=== modified file 'src/xfns.c'
--- a/src/xfns.c        2014-07-17 10:18:19 +0000
+++ b/src/xfns.c        2014-07-20 16:14:58 +0000
@@ -1260,10 +1260,6 @@
    CODING_SYSTEM, and return a newly allocated memory area which
    should be freed by `xfree' by a caller.
 
-   SELECTIONP non-zero means the string is being encoded for an X
-   selection, so it is safe to run pre-write conversions (which
-   may run Lisp code).
-
    Store the byte length of resulting text in *TEXT_BYTES.
 
    If the text contains only ASCII and Latin-1, store 1 in *STRING_P,
@@ -1272,8 +1268,8 @@
    the result should be `COMPOUND_TEXT'.  */
 
 static unsigned char *
-x_encode_text (Lisp_Object string, Lisp_Object coding_system, int selectionp,
-              ptrdiff_t *text_bytes, int *stringp, int *freep)
+x_encode_text (Lisp_Object string, Lisp_Object coding_system,
+              ptrdiff_t *text_bytes, int *stringp, bool *freep)
 {
   int result = string_xstring_p (string);
   struct coding_system coding;
@@ -1316,7 +1312,7 @@
        XTextProperty text, icon;
        ptrdiff_t bytes;
        int stringp;
-        int do_free_icon_value = 0, do_free_text_value = 0;
+       bool do_free_icon_value = 0, do_free_text_value = 0;
        Lisp_Object coding_system;
        Lisp_Object encoded_name;
        Lisp_Object encoded_icon_name;
@@ -1348,14 +1344,12 @@
           properties.  Per the EWMH specification, those two properties
           are always UTF8_STRING.  This matches what gtk_window_set_title()
           does in the USE_GTK case. */
-       text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp,
-                                   &do_free_text_value);
+       text.value = x_encode_text (name, coding_system, &bytes,
+                                   &stringp, &do_free_text_value);
        text.encoding = (stringp ? XA_STRING
                         : FRAME_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
        text.format = 8;
        text.nitems = bytes;
-       if (text.nitems != bytes)
-         error ("Window name too large");
 
        if (!STRINGP (f->icon_name))
          {
@@ -1365,14 +1359,12 @@
        else
          {
            /* See the above comment "Note: Encoding strategy".  */
-           icon.value = x_encode_text (f->icon_name, coding_system, 0,
-                                       &bytes, &stringp, &do_free_icon_value);
+           icon.value = x_encode_text (f->icon_name, coding_system, &bytes,
+                                       &stringp, &do_free_icon_value);
            icon.encoding = (stringp ? XA_STRING
                             : FRAME_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
            icon.format = 8;
            icon.nitems = bytes;
-           if (icon.nitems != bytes)
-             error ("Icon name too large");
 
            encoded_icon_name = ENCODE_UTF_8 (f->icon_name);
          }
@@ -1410,16 +1402,16 @@
 /* Change the name of frame F to NAME.  If NAME is nil, set F's name to
        x_id_name.
 
-   If EXPLICIT is non-zero, that indicates that lisp code is setting the
+   If EXPLICIT is true, that indicates that lisp code is setting the
        name; if NAME is a string, set F's name to NAME and set
        F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
 
-   If EXPLICIT is zero, that indicates that Emacs redisplay code is
+   If EXPLICIT is false, that indicates that Emacs redisplay code is
        suggesting a new name, which lisp code should override; if
        F->explicit_name is set, ignore the new name; otherwise, set it.  */
 
 static void
-x_set_name (struct frame *f, Lisp_Object name, int explicit)
+x_set_name (struct frame *f, Lisp_Object name, bool explicit)
 {
   /* Make sure that requests from lisp code override requests from
      Emacs redisplay code.  */
@@ -2263,8 +2255,7 @@
 
   /* Do some needed geometry management.  */
   {
-    char *tem, shell_position[sizeof "=x++" + 4 * INT_STRLEN_BOUND (int)];
-    Arg gal[10];
+    Arg gal[3];
     int gac = 0;
     int extra_borders = 0;
     int menubar_size
@@ -2294,6 +2285,8 @@
     extra_borders *= 2;
 #endif
 
+    f->shell_position = xmalloc (sizeof "=x++" + 4 * INT_STRLEN_BOUND (int));
+
     /* Convert our geometry parameters into a geometry string
        and specify it.
        Note that we do not specify here whether the position
@@ -2310,14 +2303,14 @@
        top = -top;
 
       if (window_prompting & USPosition)
-       sprintf (shell_position, "=%dx%d%c%d%c%d",
+       sprintf (f->shell_position, "=%dx%d%c%d%c%d",
                 FRAME_PIXEL_WIDTH (f) + extra_borders,
                 FRAME_PIXEL_HEIGHT (f) + menubar_size + extra_borders,
                 (xneg ? '-' : '+'), left,
                 (yneg ? '-' : '+'), top);
       else
         {
-          sprintf (shell_position, "=%dx%d",
+          sprintf (f->shell_position, "=%dx%d",
                    FRAME_PIXEL_WIDTH (f) + extra_borders,
                    FRAME_PIXEL_HEIGHT (f) + menubar_size + extra_borders);
 
@@ -2331,12 +2324,7 @@
         }
     }
 
-    /* We don't free this because we don't know whether
-       it is safe to free it while the frame exists.
-       It isn't worth the trouble of arranging to free it
-       when the frame is deleted.  */
-    tem = xstrdup (shell_position);
-    XtSetArg (gal[gac], XtNgeometry, tem); gac++;
+    XtSetArg (gal[gac], XtNgeometry, f->shell_position); gac++;
     XtSetValues (shell_widget, gal, gac);
   }
 
@@ -2405,7 +2393,7 @@
      the X server hasn't been told.  */
   {
     Lisp_Object name;
-    int explicit = f->explicit_name;
+    bool explicit = f->explicit_name;
 
     f->explicit_name = 0;
     name = f->name;
@@ -2548,7 +2536,7 @@
      the X server hasn't been told.  */
   {
     Lisp_Object name;
-    int explicit = f->explicit_name;
+    bool explicit = f->explicit_name;
 
     f->explicit_name = 0;
     name = f->name;
@@ -6091,7 +6079,11 @@
          XkbFreeNames (kb, 0, True);
        }
 
-      XkbFreeClientMap (kb, 0, True);
+      /* As of libX11-1.6.2, XkbGetMap manual says that you should use
+        XkbFreeClientMap to free the data returned by XkbGetMap.  But
+        this function just frees the data referenced from KB and not
+        KB itself.  To free KB as well, call XkbFreeKeyboard.  */
+      XkbFreeKeyboard (kb, XkbAllMapComponentsMask, True);
 
       if (delete_keycode
          && backspace_keycode

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2014-07-18 11:04:37 +0000
+++ b/src/xterm.c       2014-07-20 16:14:58 +0000
@@ -9245,6 +9245,9 @@
        XDestroyWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
 
       free_frame_menubar (f);
+
+      if (f->shell_position)
+       xfree (f->shell_position);
 #else  /* !USE_X_TOOLKIT */
 
 #ifdef USE_GTK


reply via email to

[Prev in Thread] Current Thread [Next in Thread]