emacs-diffs
[Top][All Lists]
Advanced

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

master eb86a375e8: Reduce synchronization setting frame alpha


From: Po Lu
Subject: master eb86a375e8: Reduce synchronization setting frame alpha
Date: Fri, 8 Jul 2022 01:43:34 -0400 (EDT)

branch: master
commit eb86a375e8ca75c297a1408aa6aa918f92914614
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Reduce synchronization setting frame alpha
    
    * src/xterm.c (x_set_frame_alpha): Don't synchronize while
    setting alpha property, and don't ask for the current value of
    the opacity property, which is much more expensive than changing
    it.
---
 src/xterm.c | 92 ++++++++-----------------------------------------------------
 1 file changed, 11 insertions(+), 81 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index 094449e1d5..9651c4e119 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -6450,20 +6450,6 @@ x_set_frame_alpha (struct frame *f)
   unsigned long opac;
   Window parent;
 
-#ifndef USE_XCB
-  unsigned char *data = NULL;
-  Atom actual;
-  int rc, format;
-  unsigned long n, left;
-  unsigned long value;
-#else
-  xcb_get_property_cookie_t opacity_cookie;
-  xcb_get_property_reply_t *opacity_reply;
-  xcb_generic_error_t *error;
-  bool rc;
-  uint32_t value;
-#endif
-
   if (dpyinfo->highlight_frame == f)
     alpha = f->alpha[0];
   else
@@ -6484,8 +6470,6 @@ x_set_frame_alpha (struct frame *f)
 
   opac = alpha * OPAQUE;
 
-  x_catch_errors (dpy);
-
   /* If there is a parent from the window manager, put the property there
      also, to work around broken window managers that fail to do that.
      Do this unconditionally as this function is called on reparent when
@@ -6494,77 +6478,23 @@ x_set_frame_alpha (struct frame *f)
   if (!FRAME_PARENT_FRAME (f))
     {
       parent = x_find_topmost_parent (f);
+
       if (parent != None)
-       XChangeProperty (dpy, parent, dpyinfo->Xatom_net_wm_window_opacity,
-                        XA_CARDINAL, 32, PropModeReplace,
-                        (unsigned char *) &opac, 1);
+       {
+         x_ignore_errors_for_next_request (dpyinfo);
+         XChangeProperty (dpy, parent,
+                          dpyinfo->Xatom_net_wm_window_opacity,
+                          XA_CARDINAL, 32, PropModeReplace,
+                          (unsigned char *) &opac, 1);
+         x_stop_ignoring_errors (dpyinfo);
+       }
     }
 
-  /* return unless necessary */
-  {
-#ifndef USE_XCB
-    rc = XGetWindowProperty (dpy, win, dpyinfo->Xatom_net_wm_window_opacity,
-                            0, 1, False, XA_CARDINAL,
-                            &actual, &format, &n, &left,
-                            &data);
-
-    if (rc == Success && actual != None
-       && n && format == XA_CARDINAL && data)
-      {
-        value = *(unsigned long *) data;
-
-       /* Xlib sign-extends values greater than 0x7fffffff on 64-bit
-          machines.  Get the low bits by ourself.  */
-
-       value &= 0xffffffff;
-
-       if (value == opac)
-         {
-           x_uncatch_errors ();
-           XFree (data);
-           return;
-         }
-      }
-
-    if (data)
-      XFree (data);
-#else
-    /* Avoid the confusing Xlib sign-extension mess by using XCB
-       instead.  */
-    opacity_cookie
-      = xcb_get_property (dpyinfo->xcb_connection, 0, (xcb_window_t) win,
-                         (xcb_atom_t) dpyinfo->Xatom_net_wm_window_opacity,
-                         XCB_ATOM_CARDINAL, 0, 1);
-    opacity_reply
-      = xcb_get_property_reply (dpyinfo->xcb_connection,
-                               opacity_cookie, &error);
-
-    rc = opacity_reply;
-
-    if (!opacity_reply)
-      free (error);
-    else
-      {
-       rc = (opacity_reply->format == 32
-             && opacity_reply->type == XCB_ATOM_CARDINAL
-             && (xcb_get_property_value_length (opacity_reply) >= 4));
-
-       if (rc)
-         value = *(uint32_t *) xcb_get_property_value (opacity_reply);
-      }
-
-    if (opacity_reply)
-      free (opacity_reply);
-
-    if (rc && value == opac)
-      return;
-#endif
-  }
-
+  x_ignore_errors_for_next_request (dpyinfo);
   XChangeProperty (dpy, win, dpyinfo->Xatom_net_wm_window_opacity,
                   XA_CARDINAL, 32, PropModeReplace,
                   (unsigned char *) &opac, 1);
-  x_uncatch_errors ();
+  x_stop_ignoring_errors (dpyinfo);
 }
 
 /***********************************************************************



reply via email to

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