diff options
| author | Po Lu | 2022-02-13 09:34:12 +0800 |
|---|---|---|
| committer | Po Lu | 2022-02-13 09:34:12 +0800 |
| commit | e79f5574c543340059bfb67dc937129f1e684a90 (patch) | |
| tree | 386277167def4bd676cfbd43a2eead01ce695745 /src | |
| parent | d72e7c4fd41c0ab400d9eb748e3b4f8d545ea948 (diff) | |
| download | emacs-e79f5574c543340059bfb67dc937129f1e684a90.tar.gz emacs-e79f5574c543340059bfb67dc937129f1e684a90.zip | |
Use better GC for visible bell on colormapped visuals
* src/xterm.c (XTflash): Use normal_gc if the visual is not
TrueColor.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 150 |
1 files changed, 74 insertions, 76 deletions
diff --git a/src/xterm.c b/src/xterm.c index ee026529eba..e45d3e8f07a 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -5088,16 +5088,13 @@ x_hide_hourglass (struct frame *f) | |||
| 5088 | static void | 5088 | static void |
| 5089 | XTflash (struct frame *f) | 5089 | XTflash (struct frame *f) |
| 5090 | { | 5090 | { |
| 5091 | block_input (); | 5091 | GC gc; |
| 5092 | XGCValues values; | ||
| 5092 | 5093 | ||
| 5093 | { | 5094 | block_input (); |
| 5094 | GC gc; | ||
| 5095 | 5095 | ||
| 5096 | /* Create a GC that will use the GXxor function to flip foreground | 5096 | if (FRAME_X_VISUAL (f)->class == TrueColor) |
| 5097 | pixels into background pixels. */ | ||
| 5098 | { | 5097 | { |
| 5099 | XGCValues values; | ||
| 5100 | |||
| 5101 | values.function = GXxor; | 5098 | values.function = GXxor; |
| 5102 | values.foreground = (FRAME_FOREGROUND_PIXEL (f) | 5099 | values.foreground = (FRAME_FOREGROUND_PIXEL (f) |
| 5103 | ^ FRAME_BACKGROUND_PIXEL (f)); | 5100 | ^ FRAME_BACKGROUND_PIXEL (f)); |
| @@ -5105,85 +5102,86 @@ XTflash (struct frame *f) | |||
| 5105 | gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | 5102 | gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), |
| 5106 | GCFunction | GCForeground, &values); | 5103 | GCFunction | GCForeground, &values); |
| 5107 | } | 5104 | } |
| 5105 | else | ||
| 5106 | gc = FRAME_X_OUTPUT (f)->normal_gc; | ||
| 5107 | |||
| 5108 | |||
| 5109 | /* Get the height not including a menu bar widget. */ | ||
| 5110 | int height = FRAME_PIXEL_HEIGHT (f); | ||
| 5111 | /* Height of each line to flash. */ | ||
| 5112 | int flash_height = FRAME_LINE_HEIGHT (f); | ||
| 5113 | /* These will be the left and right margins of the rectangles. */ | ||
| 5114 | int flash_left = FRAME_INTERNAL_BORDER_WIDTH (f); | ||
| 5115 | int flash_right = FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH (f); | ||
| 5116 | int width = flash_right - flash_left; | ||
| 5117 | |||
| 5118 | /* If window is tall, flash top and bottom line. */ | ||
| 5119 | if (height > 3 * FRAME_LINE_HEIGHT (f)) | ||
| 5108 | { | 5120 | { |
| 5109 | /* Get the height not including a menu bar widget. */ | 5121 | XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc, |
| 5110 | int height = FRAME_PIXEL_HEIGHT (f); | 5122 | flash_left, |
| 5111 | /* Height of each line to flash. */ | 5123 | (FRAME_INTERNAL_BORDER_WIDTH (f) |
| 5112 | int flash_height = FRAME_LINE_HEIGHT (f); | 5124 | + FRAME_TOP_MARGIN_HEIGHT (f)), |
| 5113 | /* These will be the left and right margins of the rectangles. */ | 5125 | width, flash_height); |
| 5114 | int flash_left = FRAME_INTERNAL_BORDER_WIDTH (f); | 5126 | XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc, |
| 5115 | int flash_right = FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH (f); | 5127 | flash_left, |
| 5116 | int width = flash_right - flash_left; | 5128 | (height - flash_height |
| 5117 | 5129 | - FRAME_INTERNAL_BORDER_WIDTH (f)), | |
| 5118 | /* If window is tall, flash top and bottom line. */ | 5130 | width, flash_height); |
| 5119 | if (height > 3 * FRAME_LINE_HEIGHT (f)) | ||
| 5120 | { | ||
| 5121 | XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc, | ||
| 5122 | flash_left, | ||
| 5123 | (FRAME_INTERNAL_BORDER_WIDTH (f) | ||
| 5124 | + FRAME_TOP_MARGIN_HEIGHT (f)), | ||
| 5125 | width, flash_height); | ||
| 5126 | XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc, | ||
| 5127 | flash_left, | ||
| 5128 | (height - flash_height | ||
| 5129 | - FRAME_INTERNAL_BORDER_WIDTH (f)), | ||
| 5130 | width, flash_height); | ||
| 5131 | 5131 | ||
| 5132 | } | 5132 | } |
| 5133 | else | 5133 | else |
| 5134 | /* If it is short, flash it all. */ | 5134 | /* If it is short, flash it all. */ |
| 5135 | XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc, | 5135 | XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc, |
| 5136 | flash_left, FRAME_INTERNAL_BORDER_WIDTH (f), | 5136 | flash_left, FRAME_INTERNAL_BORDER_WIDTH (f), |
| 5137 | width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)); | 5137 | width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)); |
| 5138 | 5138 | ||
| 5139 | x_flush (f); | 5139 | x_flush (f); |
| 5140 | 5140 | ||
| 5141 | { | 5141 | struct timespec delay = make_timespec (0, 150 * 1000 * 1000); |
| 5142 | struct timespec delay = make_timespec (0, 150 * 1000 * 1000); | 5142 | struct timespec wakeup = timespec_add (current_timespec (), delay); |
| 5143 | struct timespec wakeup = timespec_add (current_timespec (), delay); | ||
| 5144 | 5143 | ||
| 5145 | /* Keep waiting until past the time wakeup or any input gets | 5144 | /* Keep waiting until past the time wakeup or any input gets |
| 5146 | available. */ | 5145 | available. */ |
| 5147 | while (! detect_input_pending ()) | 5146 | while (! detect_input_pending ()) |
| 5148 | { | 5147 | { |
| 5149 | struct timespec current = current_timespec (); | 5148 | struct timespec current = current_timespec (); |
| 5150 | struct timespec timeout; | 5149 | struct timespec timeout; |
| 5151 | 5150 | ||
| 5152 | /* Break if result would not be positive. */ | 5151 | /* Break if result would not be positive. */ |
| 5153 | if (timespec_cmp (wakeup, current) <= 0) | 5152 | if (timespec_cmp (wakeup, current) <= 0) |
| 5154 | break; | 5153 | break; |
| 5155 | 5154 | ||
| 5156 | /* How long `select' should wait. */ | 5155 | /* How long `select' should wait. */ |
| 5157 | timeout = make_timespec (0, 10 * 1000 * 1000); | 5156 | timeout = make_timespec (0, 10 * 1000 * 1000); |
| 5158 | 5157 | ||
| 5159 | /* Try to wait that long--but we might wake up sooner. */ | 5158 | /* Try to wait that long--but we might wake up sooner. */ |
| 5160 | pselect (0, NULL, NULL, NULL, &timeout, NULL); | 5159 | pselect (0, NULL, NULL, NULL, &timeout, NULL); |
| 5161 | } | 5160 | } |
| 5162 | } | ||
| 5163 | 5161 | ||
| 5164 | /* If window is tall, flash top and bottom line. */ | 5162 | /* If window is tall, flash top and bottom line. */ |
| 5165 | if (height > 3 * FRAME_LINE_HEIGHT (f)) | 5163 | if (height > 3 * FRAME_LINE_HEIGHT (f)) |
| 5166 | { | 5164 | { |
| 5167 | XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc, | 5165 | XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc, |
| 5168 | flash_left, | 5166 | flash_left, |
| 5169 | (FRAME_INTERNAL_BORDER_WIDTH (f) | 5167 | (FRAME_INTERNAL_BORDER_WIDTH (f) |
| 5170 | + FRAME_TOP_MARGIN_HEIGHT (f)), | 5168 | + FRAME_TOP_MARGIN_HEIGHT (f)), |
| 5171 | width, flash_height); | 5169 | width, flash_height); |
| 5172 | XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc, | 5170 | XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc, |
| 5173 | flash_left, | 5171 | flash_left, |
| 5174 | (height - flash_height | 5172 | (height - flash_height |
| 5175 | - FRAME_INTERNAL_BORDER_WIDTH (f)), | 5173 | - FRAME_INTERNAL_BORDER_WIDTH (f)), |
| 5176 | width, flash_height); | 5174 | width, flash_height); |
| 5177 | } | ||
| 5178 | else | ||
| 5179 | /* If it is short, flash it all. */ | ||
| 5180 | XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc, | ||
| 5181 | flash_left, FRAME_INTERNAL_BORDER_WIDTH (f), | ||
| 5182 | width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)); | ||
| 5183 | XFreeGC (FRAME_X_DISPLAY (f), gc); | ||
| 5184 | x_flush (f); | ||
| 5185 | } | 5175 | } |
| 5186 | } | 5176 | else |
| 5177 | /* If it is short, flash it all. */ | ||
| 5178 | XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc, | ||
| 5179 | flash_left, FRAME_INTERNAL_BORDER_WIDTH (f), | ||
| 5180 | width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)); | ||
| 5181 | |||
| 5182 | if (FRAME_X_VISUAL (f)->class == TrueColor) | ||
| 5183 | XFreeGC (FRAME_X_DISPLAY (f), gc); | ||
| 5184 | x_flush (f); | ||
| 5187 | 5185 | ||
| 5188 | unblock_input (); | 5186 | unblock_input (); |
| 5189 | } | 5187 | } |