comparison src/xterm.c @ 1821:04fb1d3d6992

JimB's changes since January 18th
author Jim Blandy <jimb@redhat.com>
date Tue, 26 Jan 1993 01:58:16 +0000
parents bf618128d973
children 338e4ffdb54b
comparison
equal deleted inserted replaced
1820:b95bdb97c3e8 1821:04fb1d3d6992
655 f->phys_cursor_x = -1; /* Cursor not visible. */ 655 f->phys_cursor_x = -1; /* Cursor not visible. */
656 curs_x = 0; /* Nominal cursor position is top left. */ 656 curs_x = 0; /* Nominal cursor position is top left. */
657 curs_y = 0; 657 curs_y = 0;
658 658
659 BLOCK_INPUT; 659 BLOCK_INPUT;
660
660 XClear (FRAME_X_WINDOW (f)); 661 XClear (FRAME_X_WINDOW (f));
662
663 /* We have to clear the scrollbars, too. If we have changed
664 colors or something like that, then they should be notified. */
665 x_scrollbar_clear (f);
666
661 #ifndef HAVE_X11 667 #ifndef HAVE_X11
662 dumpborder (f, 0); 668 dumpborder (f, 0);
663 #endif /* HAVE_X11 */ 669 #endif /* HAVE_X11 */
670
664 XFlushQueue (); 671 XFlushQueue ();
665 UNBLOCK_INPUT; 672 UNBLOCK_INPUT;
666 } 673 }
667 674
668 /* Paint horzontal bars down the frame for a visible bell. 675 /* Invert the middle quarter of the frame for .15 sec. */
669 Note that this may be way too slow on some machines. */ 676
677 /* We use the select system call to do the waiting, so we have to make sure
678 it's avaliable. If it isn't, we just won't do visual bells. */
679 #if defined (HAVE_TIMEVAL) && defined (HAVE_SELECT)
680
681 /* Subtract the `struct timeval' values X and Y,
682 storing the result in RESULT.
683 Return 1 if the difference is negative, otherwise 0. */
684
685 static int
686 timeval_subtract (result, x, y)
687 struct timeval *result, x, y;
688 {
689 /* Perform the carry for the later subtraction by updating y.
690 This is safer because on some systems
691 the tv_sec member is unsigned. */
692 if (x.tv_usec < y.tv_usec)
693 {
694 int nsec = (y.tv_usec - x.tv_usec) / 1000000 + 1;
695 y.tv_usec -= 1000000 * nsec;
696 y.tv_sec += nsec;
697 }
698 if (x.tv_usec - y.tv_usec > 1000000)
699 {
700 int nsec = (y.tv_usec - x.tv_usec) / 1000000;
701 y.tv_usec += 1000000 * nsec;
702 y.tv_sec -= nsec;
703 }
704
705 /* Compute the time remaining to wait. tv_usec is certainly positive. */
706 result->tv_sec = x.tv_sec - y.tv_sec;
707 result->tv_usec = x.tv_usec - y.tv_usec;
708
709 /* Return indication of whether the result should be considered negative. */
710 return x.tv_sec < y.tv_sec;
711 }
670 712
671 XTflash (f) 713 XTflash (f)
672 struct frame *f; 714 struct frame *f;
673 { 715 {
674 register struct frame_glyphs *active_frame = FRAME_CURRENT_GLYPHS (f);
675 register int i;
676 int x, y;
677
678 if (updating_frame != 0)
679 abort ();
680
681 BLOCK_INPUT; 716 BLOCK_INPUT;
682 #ifdef HAVE_X11 717
683 #if 0 718 {
684 for (i = f->height * FONT_HEIGHT (f->display.x->font) - 10; 719 GC gc;
685 i >= 0; 720
686 i -= 100) /* Should be NO LOWER than 75 for speed reasons. */ 721 /* Create a GC that will use the GXxor function to flip foreground pixels
687 XFillRectangle (x_current_display, FRAME_X_WINDOW (f), 722 into background pixels. */
688 f->display.x->cursor_gc, 723 {
689 0, i, f->width * FONT_WIDTH (f->display.x->font) 724 XGCValues values;
690 + 2 * f->display.x->internal_border_width, 25); 725
691 #endif /* ! 0 */ 726 values.function = GXxor;
692 727 values.foreground = (f->display.x->foreground_pixel
693 x = (f->width * FONT_WIDTH (f->display.x->font)) / 4; 728 ^ f->display.x->background_pixel);
694 y = (f->height * FONT_HEIGHT (f->display.x->font)) / 4; 729
695 XFillRectangle (x_current_display, FRAME_X_WINDOW (f), 730 gc = XCreateGC (x_current_display, FRAME_X_WINDOW (f),
696 f->display.x->cursor_gc, 731 GCFunction | GCForeground, &values);
697 x, y, 2 * x, 2 * y); 732 }
698 dumpglyphs (f, (x + f->display.x->internal_border_width), 733
699 (y + f->display.x->internal_border_width), 734 {
700 &active_frame->glyphs[(f->height / 4) + 1][(f->width / 4)], 735 int width = PIXEL_WIDTH (f);
701 1, 0, f->display.x->font); 736 int height = PIXEL_HEIGHT (f);
702 737
703 #else /* ! defined (HAVE_X11) */ 738 XFillRectangle (x_current_display, FRAME_X_WINDOW (f), gc,
704 for (i = f->height * FONT_HEIGHT (f->display.x->font) - 10; 739 width/4, height/4, width/2, height/2);
705 i >= 0; 740 XFlush (x_current_display);
706 i -= 50) 741
707 XPixFill (FRAME_X_WINDOW (f), 0, i, 742 {
708 f->width * FONT_WIDTH (f->display.x->font) 743 struct timeval wakeup, now;
709 + 2 * f->display.x->internal_border_width, 10, 744
710 WHITE_PIX_DEFAULT, ClipModeClipped, GXinvert, AllPlanes); 745 gettimeofday (&wakeup, (struct timezone *) 0);
711 #endif /* ! defined (HAVE_X11) */ 746
712 747 /* Compute time to wait until, propagating carry from usecs. */
713 XFlushQueue (); 748 wakeup.tv_usec += 150000;
749 wakeup.tv_sec += (wakeup.tv_usec / 1000000);
750 wakeup.tv_usec %= 1000000;
751
752 /* Keep waiting until past the time wakeup. */
753 while (1)
754 {
755 struct timeval timeout;
756
757 gettimeofday (&timeout, (struct timezone *)0);
758
759 /* In effect, timeout = wakeup - timeout.
760 Break if result would be negative. */
761 if (timeval_subtract (&timeout, wakeup, timeout))
762 break;
763
764 /* Try to wait that long--but we might wake up sooner. */
765 select (0, 0, 0, 0, &timeout);
766 }
767 }
768
769 XFillRectangle (x_current_display, FRAME_X_WINDOW (f), gc,
770 width/4, height/4, width/2, height/2);
771 XFreeGC (x_current_display, gc);
772 XFlush (x_current_display);
773 }
774 }
775
714 UNBLOCK_INPUT; 776 UNBLOCK_INPUT;
715 } 777 }
716 778
717 /* Flip background and forground colors of the frame. */ 779 #endif
718 780
719 x_invert_frame (f)
720 struct frame *f;
721 {
722 #ifdef HAVE_X11
723 GC temp;
724 unsigned long pix_temp;
725
726 x_display_cursor (f, 0);
727 XClearWindow (x_current_display, FRAME_X_WINDOW (f));
728 temp = f->display.x->normal_gc;
729 f->display.x->normal_gc = f->display.x->reverse_gc;
730 f->display.x->reverse_gc = temp;
731 pix_temp = f->display.x->foreground_pixel;
732 f->display.x->foreground_pixel = f->display.x->background_pixel;
733 f->display.x->background_pixel = pix_temp;
734
735 XSetWindowBackground (x_current_display, FRAME_X_WINDOW (f),
736 f->display.x->background_pixel);
737 if (f->display.x->background_pixel == f->display.x->cursor_pixel)
738 {
739 f->display.x->cursor_pixel = f->display.x->foreground_pixel;
740 XSetBackground (x_current_display, f->display.x->cursor_gc,
741 f->display.x->cursor_pixel);
742 XSetForeground (x_current_display, f->display.x->cursor_gc,
743 f->display.x->background_pixel);
744 }
745 redraw_frame (f);
746 #endif /* ! defined (HAVE_X11) */
747 }
748 781
749 /* Make audible bell. */ 782 /* Make audible bell. */
750 783
751 #ifdef HAVE_X11 784 #ifdef HAVE_X11
752 #define XRINGBELL XBell(x_current_display, 0) 785 #define XRINGBELL XBell(x_current_display, 0)
754 #define XRINGBELL XFeep(0); 787 #define XRINGBELL XFeep(0);
755 #endif /* ! defined (HAVE_X11) */ 788 #endif /* ! defined (HAVE_X11) */
756 789
757 XTring_bell () 790 XTring_bell ()
758 { 791 {
792 #if defined (HAVE_TIMEVAL) && defined (HAVE_SELECT)
759 if (visible_bell) 793 if (visible_bell)
760 #if 0
761 XTflash (selected_frame); 794 XTflash (selected_frame);
762 #endif /* ! 0 */
763 {
764 x_invert_frame (selected_frame);
765 x_invert_frame (selected_frame);
766 }
767 else 795 else
796 #endif
768 { 797 {
769 BLOCK_INPUT; 798 BLOCK_INPUT;
770 XRINGBELL; 799 XRINGBELL;
771 XFlushQueue (); 800 XFlushQueue ();
772 UNBLOCK_INPUT; 801 UNBLOCK_INPUT;
1756 a.background_pixel = frame->display.x->background_pixel; 1785 a.background_pixel = frame->display.x->background_pixel;
1757 a.event_mask = (ButtonPressMask | ButtonReleaseMask 1786 a.event_mask = (ButtonPressMask | ButtonReleaseMask
1758 | ButtonMotionMask | PointerMotionHintMask 1787 | ButtonMotionMask | PointerMotionHintMask
1759 | ExposureMask); 1788 | ExposureMask);
1760 a.cursor = x_vertical_scrollbar_cursor; 1789 a.cursor = x_vertical_scrollbar_cursor;
1761 a.win_gravity = EastGravity; 1790
1762 1791 mask = (CWBackPixel | CWEventMask | CWCursor);
1763 mask = (CWBackPixel | CWEventMask | CWCursor | CWWinGravity);
1764 1792
1765 SET_SCROLLBAR_X_WINDOW 1793 SET_SCROLLBAR_X_WINDOW
1766 (bar, 1794 (bar,
1767 XCreateWindow (x_current_display, FRAME_X_WINDOW (frame), 1795 XCreateWindow (x_current_display, FRAME_X_WINDOW (frame),
1768 1796
2316 mouse_moved = 0; 2344 mouse_moved = 0;
2317 last_mouse_scrollbar = Qnil; 2345 last_mouse_scrollbar = Qnil;
2318 2346
2319 done: 2347 done:
2320 UNBLOCK_INPUT; 2348 UNBLOCK_INPUT;
2349 }
2350
2351
2352 /* The screen has been cleared so we may have changed foreground or
2353 background colors, and the scrollbars may need to be redrawn.
2354 Clear out the scrollbars, and ask for expose events, so we can
2355 redraw them. */
2356
2357 x_scrollbar_clear (f)
2358 FRAME_PTR f;
2359 {
2360 Lisp_Object bar;
2361
2362 for (bar = FRAME_SCROLLBARS (f);
2363 XTYPE (bar) == Lisp_Vector;
2364 bar = XSCROLLBAR (bar)->next)
2365 XClearArea (x_current_display, SCROLLBAR_X_WINDOW (XSCROLLBAR (bar)),
2366 0, 0, 0, 0, True);
2321 } 2367 }
2322 2368
2323 2369
2324 2370
2325 /* The main X event-reading loop - XTread_socket. */ 2371 /* The main X event-reading loop - XTread_socket. */
2863 } 2909 }
2864 } 2910 }
2865 break; 2911 break;
2866 2912
2867 case ConfigureNotify: 2913 case ConfigureNotify:
2868 { 2914 f = x_window_to_frame (event.xconfigure.window);
2869 int rows, columns; 2915 if (f)
2870 f = x_window_to_frame (event.xconfigure.window); 2916 {
2871 if (!f) 2917 int rows = PIXEL_TO_CHAR_HEIGHT (f, event.xconfigure.height);
2872 break; 2918 int columns = PIXEL_TO_CHAR_WIDTH (f, event.xconfigure.width);
2873 2919
2874 columns = PIXEL_TO_CHAR_WIDTH (f, event.xconfigure.width); 2920 /* Even if the number of character rows and columns has
2875 rows = PIXEL_TO_CHAR_HEIGHT (f, event.xconfigure.height); 2921 not changed, the font size may have changed, so we need
2876 2922 to check the pixel dimensions as well. */
2877 /* Even if the number of character rows and columns has 2923 if (columns != f->width
2878 not changed, the font size may have changed, so we need 2924 || rows != f->height
2879 to check the pixel dimensions as well. */ 2925 || event.xconfigure.width != f->display.x->pixel_width
2880 if (columns != f->width 2926 || event.xconfigure.height != f->display.x->pixel_height)
2881 || rows != f->height 2927 {
2882 || event.xconfigure.width != f->display.x->pixel_width 2928 change_frame_size (f, rows, columns, 0, 1);
2883 || event.xconfigure.height != f->display.x->pixel_height) 2929 SET_FRAME_GARBAGED (f);
2884 { 2930 }
2885 change_frame_size (f, rows, columns, 0, 1); 2931
2886 SET_FRAME_GARBAGED (f); 2932 f->display.x->pixel_width = event.xconfigure.width;
2887 } 2933 f->display.x->pixel_height = event.xconfigure.height;
2888 2934 f->display.x->left_pos = event.xconfigure.x;
2889 f->display.x->pixel_width = event.xconfigure.width; 2935 f->display.x->top_pos = event.xconfigure.y;
2890 f->display.x->pixel_height = event.xconfigure.height; 2936 }
2891 f->display.x->left_pos = event.xconfigure.x; 2937 break;
2892 f->display.x->top_pos = event.xconfigure.y;
2893 break;
2894 }
2895 2938
2896 case ButtonPress: 2939 case ButtonPress:
2897 case ButtonRelease: 2940 case ButtonRelease:
2898 { 2941 {
2899 /* If we decide we want to generate an event to be seen 2942 /* If we decide we want to generate an event to be seen
3151 f->display.x->background_pixel); 3194 f->display.x->background_pixel);
3152 #endif /* ! defined (HAVE_X11) */ 3195 #endif /* ! defined (HAVE_X11) */
3153 f->phys_cursor_x = -1; 3196 f->phys_cursor_x = -1;
3154 } 3197 }
3155 3198
3156 static void
3157 x_display_bar_cursor (f, on)
3158 struct frame *f;
3159 int on;
3160 {
3161 register int phys_x = f->phys_cursor_x;
3162 register int phys_y = f->phys_cursor_y;
3163 register int x1;
3164 register int y1;
3165 register int y2;
3166
3167 if (! FRAME_VISIBLE_P (f) || (! on && f->phys_cursor_x < 0))
3168 return;
3169
3170 #ifdef HAVE_X11
3171 if (phys_x >= 0 &&
3172 (!on || phys_x != f->cursor_x || phys_y != f->cursor_y))
3173 {
3174 x1 = CHAR_TO_PIXEL_COL (f, phys_x);
3175 y1 = CHAR_TO_PIXEL_ROW (f, phys_y) - 1;
3176 y2 = y1 + FONT_HEIGHT (f->display.x->font) + 1;
3177
3178 XDrawLine (x_current_display, FRAME_X_WINDOW (f),
3179 f->display.x->reverse_gc, x1, y1, x1, y2);
3180
3181 f->phys_cursor_x = phys_x = -1;
3182 }
3183
3184 if (on && f == x_highlight_frame)
3185 {
3186 x1 = CHAR_TO_PIXEL_COL (f, f->cursor_x);
3187 y1 = CHAR_TO_PIXEL_ROW (f, f->cursor_y) - 1;
3188 y2 = y1 + FONT_HEIGHT (f->display.x->font) + 1;
3189
3190 XDrawLine (x_current_display, FRAME_X_WINDOW (f),
3191 f->display.x->cursor_gc, x1, y1, x1, y2);
3192
3193 f->phys_cursor_x = f->cursor_x;
3194 f->phys_cursor_y = f->cursor_y;
3195 }
3196 #else /* ! defined (HAVE_X11) */
3197 Give it up, dude.
3198 #endif /* ! defined (HAVE_X11) */
3199 }
3200
3201
3202 /* Redraw the glyph at ROW, COLUMN on frame F, in the style 3199 /* Redraw the glyph at ROW, COLUMN on frame F, in the style
3203 HIGHLIGHT. HIGHLIGHT is as defined for dumpglyphs. Return the 3200 HIGHLIGHT. HIGHLIGHT is as defined for dumpglyphs. Return the
3204 glyph drawn. */ 3201 glyph drawn. */
3205 3202
3206 static void 3203 static void
3214 CHAR_TO_PIXEL_COL (f, column), 3211 CHAR_TO_PIXEL_COL (f, column),
3215 CHAR_TO_PIXEL_ROW (f, row), 3212 CHAR_TO_PIXEL_ROW (f, row),
3216 &glyph, 1, highlight, f->display.x->font); 3213 &glyph, 1, highlight, f->display.x->font);
3217 } 3214 }
3218 3215
3216 static void
3217 x_display_bar_cursor (f, on)
3218 struct frame *f;
3219 int on;
3220 {
3221 struct frame_glyphs *current_glyphs = FRAME_CURRENT_GLYPHS (f);
3222
3223 if (! FRAME_VISIBLE_P (f))
3224 return;
3225
3226 if (! on && f->phys_cursor_x < 0)
3227 return;
3228
3229 /* If we're not updating, then we want to use the current frame's
3230 cursor position, not our local idea of where the cursor ought to be. */
3231 if (f != updating_frame)
3232 {
3233 curs_x = FRAME_CURSOR_X (f);
3234 curs_y = FRAME_CURSOR_Y (f);
3235 }
3236
3237 /* If there is anything wrong with the current cursor state, remove it. */
3238 if (f->phys_cursor_x >= 0
3239 && (!on
3240 || f->phys_cursor_x != curs_x
3241 || f->phys_cursor_y != curs_y
3242 || f->display.x->current_cursor != bar_cursor))
3243 {
3244 /* Erase the cursor by redrawing the character underneath it. */
3245 x_draw_single_glyph (f, f->phys_cursor_y, f->phys_cursor_x,
3246 f->phys_cursor_glyph,
3247 current_glyphs->highlight[f->phys_cursor_y]);
3248 f->phys_cursor_x = -1;
3249 }
3250
3251 /* If we now need a cursor in the new place or in the new form, do it so. */
3252 if (on
3253 && (f->phys_cursor_x < 0
3254 || (f->display.x->current_cursor != bar_cursor)))
3255 {
3256 f->phys_cursor_glyph
3257 = ((current_glyphs->enable[curs_y]
3258 && curs_x < current_glyphs->used[curs_y])
3259 ? current_glyphs->glyphs[curs_y][curs_x]
3260 : SPACEGLYPH);
3261 XFillRectangle (x_current_display, FRAME_X_WINDOW (f),
3262 f->display.x->cursor_gc,
3263 CHAR_TO_PIXEL_COL (f, curs_x),
3264 CHAR_TO_PIXEL_ROW (f, curs_y),
3265 1, FONT_HEIGHT (f->display.x->font));
3266
3267 f->phys_cursor_x = curs_x;
3268 f->phys_cursor_y = curs_y;
3269
3270 f->display.x->current_cursor = bar_cursor;
3271 }
3272
3273 if (updating_frame != f)
3274 XFlushQueue ();
3275 }
3276
3277
3219 /* Turn the displayed cursor of frame F on or off according to ON. 3278 /* Turn the displayed cursor of frame F on or off according to ON.
3220 If ON is nonzero, where to put the cursor is specified 3279 If ON is nonzero, where to put the cursor is specified
3221 by F->cursor_x and F->cursor_y. */ 3280 by F->cursor_x and F->cursor_y. */
3222 3281
3223 static void 3282 static void
3225 struct frame *f; 3284 struct frame *f;
3226 int on; 3285 int on;
3227 { 3286 {
3228 struct frame_glyphs *current_glyphs = FRAME_CURRENT_GLYPHS (f); 3287 struct frame_glyphs *current_glyphs = FRAME_CURRENT_GLYPHS (f);
3229 3288
3289 if (! FRAME_VISIBLE_P (f))
3290 return;
3291
3292 /* If cursor is off and we want it off, return quickly. */
3293 if (!on && f->phys_cursor_x < 0)
3294 return;
3295
3230 /* If we're not updating, then we want to use the current frame's 3296 /* If we're not updating, then we want to use the current frame's
3231 cursor position, not our local idea of where the cursor ought to be. */ 3297 cursor position, not our local idea of where the cursor ought to be. */
3232 if (f != updating_frame) 3298 if (f != updating_frame)
3233 { 3299 {
3234 curs_x = FRAME_CURSOR_X (f); 3300 curs_x = FRAME_CURSOR_X (f);
3235 curs_y = FRAME_CURSOR_Y (f); 3301 curs_y = FRAME_CURSOR_Y (f);
3236 } 3302 }
3237
3238 if (! FRAME_VISIBLE_P (f))
3239 return;
3240
3241 /* If cursor is off and we want it off, return quickly. */
3242 if (!on && f->phys_cursor_x < 0)
3243 return;
3244 3303
3245 /* If cursor is currently being shown and we don't want it to be 3304 /* If cursor is currently being shown and we don't want it to be
3246 or it is in the wrong place, 3305 or it is in the wrong place,
3247 or we want a hollow box and it's not so, (pout!) 3306 or we want a hollow box and it's not so, (pout!)
3248 erase it. */ 3307 erase it. */
3249 if (f->phys_cursor_x >= 0 3308 if (f->phys_cursor_x >= 0
3250 && (!on 3309 && (!on
3251 || f->phys_cursor_x != curs_x 3310 || f->phys_cursor_x != curs_x
3252 || f->phys_cursor_y != curs_y 3311 || f->phys_cursor_y != curs_y
3253 || (f->display.x->text_cursor_kind != hollow_box_cursor 3312 || (f->display.x->current_cursor != hollow_box_cursor
3254 && (f != x_highlight_frame)))) 3313 && (f != x_highlight_frame))))
3255 { 3314 {
3256 /* Erase the cursor by redrawing the character underneath it. */ 3315 /* Erase the cursor by redrawing the character underneath it. */
3257 x_draw_single_glyph (f, f->phys_cursor_y, f->phys_cursor_x, 3316 x_draw_single_glyph (f, f->phys_cursor_y, f->phys_cursor_x,
3258 f->phys_cursor_glyph, 3317 f->phys_cursor_glyph,
3263 /* If we want to show a cursor, 3322 /* If we want to show a cursor,
3264 or we want a box cursor and it's not so, 3323 or we want a box cursor and it's not so,
3265 write it in the right place. */ 3324 write it in the right place. */
3266 if (on 3325 if (on
3267 && (f->phys_cursor_x < 0 3326 && (f->phys_cursor_x < 0
3268 || (f->display.x->text_cursor_kind != filled_box_cursor 3327 || (f->display.x->current_cursor != filled_box_cursor
3269 && f == x_highlight_frame))) 3328 && f == x_highlight_frame)))
3270 { 3329 {
3271 f->phys_cursor_glyph 3330 f->phys_cursor_glyph
3272 = ((current_glyphs->enable[curs_y] 3331 = ((current_glyphs->enable[curs_y]
3273 && curs_x < current_glyphs->used[curs_y]) 3332 && curs_x < current_glyphs->used[curs_y])
3274 ? current_glyphs->glyphs[curs_y][curs_x] 3333 ? current_glyphs->glyphs[curs_y][curs_x]
3275 : SPACEGLYPH); 3334 : SPACEGLYPH);
3276 if (f != x_highlight_frame) 3335 if (f != x_highlight_frame)
3277 { 3336 {
3278 x_draw_box (f); 3337 x_draw_box (f);
3279 f->display.x->text_cursor_kind = hollow_box_cursor; 3338 f->display.x->current_cursor = hollow_box_cursor;
3280 } 3339 }
3281 else 3340 else
3282 { 3341 {
3283 x_draw_single_glyph (f, curs_y, curs_x, 3342 x_draw_single_glyph (f, curs_y, curs_x,
3284 f->phys_cursor_glyph, 2); 3343 f->phys_cursor_glyph, 2);
3285 f->display.x->text_cursor_kind = filled_box_cursor; 3344 f->display.x->current_cursor = filled_box_cursor;
3286 } 3345 }
3287 3346
3288 f->phys_cursor_x = curs_x; 3347 f->phys_cursor_x = curs_x;
3289 f->phys_cursor_y = curs_y; 3348 f->phys_cursor_y = curs_y;
3290 } 3349 }
3291 3350
3292 if (updating_frame != f) 3351 if (updating_frame != f)
3293 XFlushQueue (); 3352 XFlushQueue ();
3294 } 3353 }
3295
3296 extern Lisp_Object Vbar_cursor;
3297 3354
3298 x_display_cursor (f, on) 3355 x_display_cursor (f, on)
3299 struct frame *f; 3356 struct frame *f;
3300 int on; 3357 int on;
3301 { 3358 {
3302 if (EQ (Vbar_cursor, Qnil)) 3359 if (FRAME_DESIRED_CURSOR (f) == filled_box_cursor)
3303 x_display_box_cursor (f, on); 3360 x_display_box_cursor (f, on);
3361 else if (FRAME_DESIRED_CURSOR (f) == bar_cursor)
3362 x_display_bar_cursor (f, on);
3304 else 3363 else
3305 x_display_bar_cursor (f, on); 3364 /* Those are the only two we have implemented! */
3365 abort ();
3306 } 3366 }
3307 3367
3308 /* Icons. */ 3368 /* Icons. */
3309 3369
3310 /* Refresh bitmap kitchen sink icon for frame F 3370 /* Refresh bitmap kitchen sink icon for frame F
3345 } 3405 }
3346 XFlushQueue (); 3406 XFlushQueue ();
3347 #endif /* ! defined (HAVE_X11) */ 3407 #endif /* ! defined (HAVE_X11) */
3348 } 3408 }
3349 3409
3350 /* Make the x-window of frame F use the kitchen-sink icon 3410 /* Make the x-window of frame F use the gnu icon bitmap. */
3351 that's a window generated by Emacs. */
3352 3411
3353 int 3412 int
3354 x_bitmap_icon (f) 3413 x_bitmap_icon (f)
3355 struct frame *f; 3414 struct frame *f;
3356 { 3415 {
3421 #endif /* BlackPixel */ 3480 #endif /* BlackPixel */
3422 #endif /* HAVE_X11 */ 3481 #endif /* HAVE_X11 */
3423 3482
3424 if (FRAME_X_WINDOW (f) == 0) 3483 if (FRAME_X_WINDOW (f) == 0)
3425 return 1; 3484 return 1;
3426
3427 if (icon_font_info == 0)
3428 icon_font_info
3429 = XGetFont (XGetDefault (XDISPLAY
3430 (char *) XSTRING (invocation_name)->data,
3431 "BodyFont"));
3432 3485
3433 #ifdef HAVE_X11 3486 #ifdef HAVE_X11
3434 if (icon_name) 3487 if (icon_name)
3435 f->display.x->icon_label = icon_name; 3488 f->display.x->icon_label = icon_name;
3436 else 3489 else
3441 (char *) f->display.x->icon_label); 3494 (char *) f->display.x->icon_label);
3442 3495
3443 f->display.x->icon_bitmap_flag = 0; 3496 f->display.x->icon_bitmap_flag = 0;
3444 x_wm_set_icon_pixmap (f, 0); 3497 x_wm_set_icon_pixmap (f, 0);
3445 #else /* ! defined (HAVE_X11) */ 3498 #else /* ! defined (HAVE_X11) */
3499 if (icon_font_info == 0)
3500 icon_font_info
3501 = XGetFont (XGetDefault (XDISPLAY
3502 (char *) XSTRING (invocation_name)->data,
3503 "BodyFont"));
3504
3446 if (f->display.x->icon_desc) 3505 if (f->display.x->icon_desc)
3447 { 3506 {
3448 XClearIconWindow (XDISPLAY FRAME_X_WINDOW (f)); 3507 XClearIconWindow (XDISPLAY FRAME_X_WINDOW (f));
3449 XDestroyWindow (XDISPLAY f->display.x->icon_desc); 3508 XDestroyWindow (XDISPLAY f->display.x->icon_desc);
3450 } 3509 }
3799 XChangeWindowSize (FRAME_X_WINDOW (f), pixelwidth, pixelheight); 3858 XChangeWindowSize (FRAME_X_WINDOW (f), pixelwidth, pixelheight);
3800 3859
3801 /* Now, strictly speaking, we can't be sure that this is accurate, 3860 /* Now, strictly speaking, we can't be sure that this is accurate,
3802 but the window manager will get around to dealing with the size 3861 but the window manager will get around to dealing with the size
3803 change request eventually, and we'll hear how it went when the 3862 change request eventually, and we'll hear how it went when the
3804 ConfigureNotify event gets here. */ 3863 ConfigureNotify event gets here.
3864
3865 We could just not bother storing any of this information here,
3866 and let the ConfigureNotify event set everything up, but that
3867 might be kind of confusing to the lisp code, since size changes
3868 wouldn't be reported in the frame parameters until some random
3869 point in the future when the ConfigureNotify event arrives. */
3805 FRAME_WIDTH (f) = cols; 3870 FRAME_WIDTH (f) = cols;
3806 FRAME_HEIGHT (f) = rows; 3871 FRAME_HEIGHT (f) = rows;
3807 PIXEL_WIDTH (f) = pixelwidth; 3872 PIXEL_WIDTH (f) = pixelwidth;
3808 PIXEL_HEIGHT (f) = pixelheight; 3873 PIXEL_HEIGHT (f) = pixelheight;
3874
3875 /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
3876 receive in the ConfigureNotify event; if we get what we asked
3877 for, then the event won't cause the screen to become garbaged, so
3878 we have to make sure to do it here. */
3879 SET_FRAME_GARBAGED (f);
3809 3880
3810 XFlushQueue (); 3881 XFlushQueue ();
3811 UNBLOCK_INPUT; 3882 UNBLOCK_INPUT;
3812 } 3883 }
3813 3884
3900 XLowerWindow (XDISPLAY FRAME_X_WINDOW (f)); 3971 XLowerWindow (XDISPLAY FRAME_X_WINDOW (f));
3901 XFlushQueue (); 3972 XFlushQueue ();
3902 UNBLOCK_INPUT; 3973 UNBLOCK_INPUT;
3903 } 3974 }
3904 } 3975 }
3976
3977 static void
3978 XTframe_raise_lower (f, raise)
3979 FRAME_PTR f;
3980 int raise;
3981 {
3982 if (raise)
3983 x_raise_frame (f);
3984 else
3985 x_lower_frame (f);
3986 }
3987
3905 3988
3906 /* Change from withdrawn state to mapped state. */ 3989 /* Change from withdrawn state to mapped state. */
3907 3990
3908 x_make_frame_visible (f) 3991 x_make_frame_visible (f)
3909 struct frame *f; 3992 struct frame *f;
4257 struct frame *f; 4340 struct frame *f;
4258 Pixmap icon_pixmap; 4341 Pixmap icon_pixmap;
4259 { 4342 {
4260 Window window = FRAME_X_WINDOW (f); 4343 Window window = FRAME_X_WINDOW (f);
4261 4344
4262 f->display.x->wm_hints.flags |= IconPixmapHint; 4345 if (icon_pixmap)
4263 f->display.x->wm_hints.icon_pixmap = icon_pixmap ? icon_pixmap : None; 4346 {
4347 f->display.x->wm_hints.icon_pixmap = icon_pixmap;
4348 f->display.x->wm_hints.flags |= IconPixmapHint;
4349 }
4350 else
4351 f->display.x->wm_hints.flags &= ~IconPixmapHint;
4264 4352
4265 XSetWMHints (x_current_display, window, &f->display.x->wm_hints); 4353 XSetWMHints (x_current_display, window, &f->display.x->wm_hints);
4266 } 4354 }
4267 4355
4268 x_wm_set_icon_position (f, icon_x, icon_y) 4356 x_wm_set_icon_position (f, icon_x, icon_y)
4393 read_socket_hook = XTread_socket; 4481 read_socket_hook = XTread_socket;
4394 cursor_to_hook = XTcursor_to; 4482 cursor_to_hook = XTcursor_to;
4395 reassert_line_highlight_hook = XTreassert_line_highlight; 4483 reassert_line_highlight_hook = XTreassert_line_highlight;
4396 mouse_position_hook = XTmouse_position; 4484 mouse_position_hook = XTmouse_position;
4397 frame_rehighlight_hook = XTframe_rehighlight; 4485 frame_rehighlight_hook = XTframe_rehighlight;
4486 frame_raise_lower_hook = XTframe_raise_lower;
4398 set_vertical_scrollbar_hook = XTset_vertical_scrollbar; 4487 set_vertical_scrollbar_hook = XTset_vertical_scrollbar;
4399 condemn_scrollbars_hook = XTcondemn_scrollbars; 4488 condemn_scrollbars_hook = XTcondemn_scrollbars;
4400 redeem_scrollbar_hook = XTredeem_scrollbar; 4489 redeem_scrollbar_hook = XTredeem_scrollbar;
4401 judge_scrollbars_hook = XTjudge_scrollbars; 4490 judge_scrollbars_hook = XTjudge_scrollbars;
4402 4491