emacs-diffs
[Top][All Lists]
Advanced

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

master e79f5574c5: Use better GC for visible bell on colormapped visuals


From: Po Lu
Subject: master e79f5574c5: Use better GC for visible bell on colormapped visuals
Date: Sat, 12 Feb 2022 20:34:56 -0500 (EST)

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

    Use better GC for visible bell on colormapped visuals
    
    * src/xterm.c (XTflash): Use normal_gc if the visual is not
    TrueColor.
---
 src/xterm.c | 150 ++++++++++++++++++++++++++++++------------------------------
 1 file changed, 74 insertions(+), 76 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index ee026529eb..e45d3e8f07 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -5088,16 +5088,13 @@ x_hide_hourglass (struct frame *f)
 static void
 XTflash (struct frame *f)
 {
-  block_input ();
+  GC gc;
+  XGCValues values;
 
-  {
-    GC gc;
+  block_input ();
 
-    /* Create a GC that will use the GXxor function to flip foreground
-       pixels into background pixels.  */
+  if (FRAME_X_VISUAL (f)->class == TrueColor)
     {
-      XGCValues values;
-
       values.function = GXxor;
       values.foreground = (FRAME_FOREGROUND_PIXEL (f)
                           ^ FRAME_BACKGROUND_PIXEL (f));
@@ -5105,85 +5102,86 @@ XTflash (struct frame *f)
       gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                      GCFunction | GCForeground, &values);
     }
+  else
+    gc = FRAME_X_OUTPUT (f)->normal_gc;
+
+
+  /* Get the height not including a menu bar widget.  */
+  int height = FRAME_PIXEL_HEIGHT (f);
+  /* Height of each line to flash.  */
+  int flash_height = FRAME_LINE_HEIGHT (f);
+  /* These will be the left and right margins of the rectangles.  */
+  int flash_left = FRAME_INTERNAL_BORDER_WIDTH (f);
+  int flash_right = FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH (f);
+  int width = flash_right - flash_left;
+
+  /* If window is tall, flash top and bottom line.  */
+  if (height > 3 * FRAME_LINE_HEIGHT (f))
     {
-      /* Get the height not including a menu bar widget.  */
-      int height = FRAME_PIXEL_HEIGHT (f);
-      /* Height of each line to flash.  */
-      int flash_height = FRAME_LINE_HEIGHT (f);
-      /* These will be the left and right margins of the rectangles.  */
-      int flash_left = FRAME_INTERNAL_BORDER_WIDTH (f);
-      int flash_right = FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH 
(f);
-      int width = flash_right - flash_left;
-
-      /* If window is tall, flash top and bottom line.  */
-      if (height > 3 * FRAME_LINE_HEIGHT (f))
-       {
-         XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
-                         flash_left,
-                         (FRAME_INTERNAL_BORDER_WIDTH (f)
-                          + FRAME_TOP_MARGIN_HEIGHT (f)),
-                         width, flash_height);
-         XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
-                         flash_left,
-                         (height - flash_height
-                          - FRAME_INTERNAL_BORDER_WIDTH (f)),
-                         width, flash_height);
+      XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
+                     flash_left,
+                     (FRAME_INTERNAL_BORDER_WIDTH (f)
+                      + FRAME_TOP_MARGIN_HEIGHT (f)),
+                     width, flash_height);
+      XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
+                     flash_left,
+                     (height - flash_height
+                      - FRAME_INTERNAL_BORDER_WIDTH (f)),
+                     width, flash_height);
 
-       }
-      else
-       /* If it is short, flash it all.  */
-       XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
-                       flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
-                       width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
+    }
+  else
+    /* If it is short, flash it all.  */
+    XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
+                   flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
+                   width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
 
-      x_flush (f);
+  x_flush (f);
 
-      {
-       struct timespec delay = make_timespec (0, 150 * 1000 * 1000);
-       struct timespec wakeup = timespec_add (current_timespec (), delay);
+  struct timespec delay = make_timespec (0, 150 * 1000 * 1000);
+  struct timespec wakeup = timespec_add (current_timespec (), delay);
 
-       /* Keep waiting until past the time wakeup or any input gets
-          available.  */
-       while (! detect_input_pending ())
-         {
-           struct timespec current = current_timespec ();
-           struct timespec timeout;
+  /* Keep waiting until past the time wakeup or any input gets
+     available.  */
+  while (! detect_input_pending ())
+    {
+      struct timespec current = current_timespec ();
+      struct timespec timeout;
 
-           /* Break if result would not be positive.  */
-           if (timespec_cmp (wakeup, current) <= 0)
-             break;
+      /* Break if result would not be positive.  */
+      if (timespec_cmp (wakeup, current) <= 0)
+       break;
 
-           /* How long `select' should wait.  */
-           timeout = make_timespec (0, 10 * 1000 * 1000);
+      /* How long `select' should wait.  */
+      timeout = make_timespec (0, 10 * 1000 * 1000);
 
-           /* Try to wait that long--but we might wake up sooner.  */
-           pselect (0, NULL, NULL, NULL, &timeout, NULL);
-         }
-      }
+      /* Try to wait that long--but we might wake up sooner.  */
+      pselect (0, NULL, NULL, NULL, &timeout, NULL);
+    }
 
-      /* If window is tall, flash top and bottom line.  */
-      if (height > 3 * FRAME_LINE_HEIGHT (f))
-       {
-         XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
-                         flash_left,
-                         (FRAME_INTERNAL_BORDER_WIDTH (f)
-                          + FRAME_TOP_MARGIN_HEIGHT (f)),
-                         width, flash_height);
-         XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
-                         flash_left,
-                         (height - flash_height
-                          - FRAME_INTERNAL_BORDER_WIDTH (f)),
-                         width, flash_height);
-       }
-      else
-       /* If it is short, flash it all.  */
-       XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
-                       flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
-                       width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
-      XFreeGC (FRAME_X_DISPLAY (f), gc);
-      x_flush (f);
+  /* If window is tall, flash top and bottom line.  */
+  if (height > 3 * FRAME_LINE_HEIGHT (f))
+    {
+      XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
+                     flash_left,
+                     (FRAME_INTERNAL_BORDER_WIDTH (f)
+                      + FRAME_TOP_MARGIN_HEIGHT (f)),
+                     width, flash_height);
+      XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
+                     flash_left,
+                     (height - flash_height
+                      - FRAME_INTERNAL_BORDER_WIDTH (f)),
+                     width, flash_height);
     }
-  }
+  else
+    /* If it is short, flash it all.  */
+    XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
+                   flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
+                   width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
+
+  if (FRAME_X_VISUAL (f)->class == TrueColor)
+    XFreeGC (FRAME_X_DISPLAY (f), gc);
+  x_flush (f);
 
   unblock_input ();
 }



reply via email to

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