# HG changeset patch # User Jason Rumney # Date 951944752 0 # Node ID 4c1ad68f8688deb4676e4b851ac0d0d0ca9593b0 # Parent 4c76cea514bb8a4ecef154951fce75adfd1388a7 Bring up to date with xfns.c changes from 2000-02-25 and 2000-02-21. diff -r 4c76cea514bb -r 4c1ad68f8688 src/w32fns.c --- a/src/w32fns.c Wed Mar 01 21:02:37 2000 +0000 +++ b/src/w32fns.c Wed Mar 01 21:05:52 2000 +0000 @@ -378,6 +378,10 @@ f = XFRAME (frame); if (!FRAME_W32_P (f) || FRAME_W32_DISPLAY_INFO (f) != dpyinfo) continue; + if (f->output_data.w32->busy_window == wdesc) + return f; + + /* NTEMACS_TODO: Check tooltips when supported. */ if (FRAME_W32_WINDOW (f) == wdesc) return f; } @@ -11597,109 +11601,156 @@ Busy cursor ***********************************************************************/ -/* The implementation partly follows a patch from - F.Pierresteguy@frcl.bull.fr dated 1994. */ - -/* Setting inhibit_busy_cursor to 2 inhibits busy-cursor display until - the next X event is read and we enter XTread_socket again. Setting - it to 1 inhibits busy-cursor display for direct commands. */ - -int inhibit_busy_cursor; - -/* Incremented with each call to x-display-busy-cursor. - Decremented in x-undisplay-busy-cursor. */ - -static int busy_count; - - -DEFUN ("x-show-busy-cursor", Fx_show_busy_cursor, - Sx_show_busy_cursor, 0, 0, 0, - "Show a busy cursor, if not already shown.\n\ -Each call to this function must be matched by a call to\n\ -x-undisplay-busy-cursor to make the busy pointer disappear again.") - () -{ - ++busy_count; - if (busy_count == 1) +/* If non-null, an asynchronous timer that, when it expires, displays + a busy cursor on all frames. */ + +static struct atimer *busy_cursor_atimer; + +/* Non-zero means a busy cursor is currently shown. */ + +static int busy_cursor_shown_p; + +/* Number of seconds to wait before displaying a busy cursor. */ + +static Lisp_Object Vbusy_cursor_delay; + +/* Default number of seconds to wait before displaying a busy + cursor. */ + +#define DEFAULT_BUSY_CURSOR_DELAY 1 + +/* Function prototypes. */ + +static void show_busy_cursor P_ ((struct atimer *)); +static void hide_busy_cursor P_ ((void)); + + +/* Cancel a currently active busy-cursor timer, and start a new one. */ + +void +start_busy_cursor () +{ +#if 0 /* NTEMACS_TODO: cursor shape changes. */ + EMACS_TIME delay; + int secs; + + cancel_busy_cursor (); + + if (INTEGERP (Vbusy_cursor_delay) + && XINT (Vbusy_cursor_delay) > 0) + secs = XFASTINT (Vbusy_cursor_delay); + else + secs = DEFAULT_BUSY_CURSOR_DELAY; + + EMACS_SET_SECS_USECS (delay, secs, 0); + busy_cursor_atimer = start_atimer (ATIMER_RELATIVE, delay, + show_busy_cursor, NULL); +#endif +} + + +/* Cancel the busy cursor timer if active, hide a busy cursor if + shown. */ + +void +cancel_busy_cursor () +{ + if (busy_cursor_atimer) + cancel_atimer (busy_cursor_atimer); + if (busy_cursor_shown_p) + hide_busy_cursor (); +} + + +/* Timer function of busy_cursor_atimer. TIMER is equal to + busy_cursor_atimer. + + Display a busy cursor on all frames by mapping the frames' + busy_window. Set the busy_p flag in the frames' output_data.x + structure to indicate that a busy cursor is shown on the + frames. */ + +static void +show_busy_cursor (timer) + struct atimer *timer; +{ +#if 0 /* NTEMACS_TODO: cursor shape changes. */ + /* The timer implementation will cancel this timer automatically + after this function has run. Set busy_cursor_atimer to null + so that we know the timer doesn't have to be canceled. */ + busy_cursor_atimer = NULL; + + if (!busy_cursor_shown_p) { Lisp_Object rest, frame; - + + BLOCK_INPUT; + FOR_EACH_FRAME (rest, frame) if (FRAME_X_P (XFRAME (frame))) { struct frame *f = XFRAME (frame); -#if 0 /* NTEMACS_TODO : busy cursor */ - - BLOCK_INPUT; + f->output_data.w32->busy_p = 1; - + if (!f->output_data.w32->busy_window) { unsigned long mask = CWCursor; XSetWindowAttributes attrs; - + attrs.cursor = f->output_data.w32->busy_cursor; + f->output_data.w32->busy_window - = XCreateWindow (FRAME_W32_DISPLAY (f), + = XCreateWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), 0, 0, 32000, 32000, 0, 0, - InputOnly, CopyFromParent, + InputOnly, + CopyFromParent, mask, &attrs); } - - XMapRaised (FRAME_W32_DISPLAY (f), f->output_data.w32->busy_window); - UNBLOCK_INPUT; -#endif + + XMapRaised (FRAME_X_DISPLAY (f), f->output_data.w32->busy_window); + XFlush (FRAME_X_DISPLAY (f)); } - } - - return Qnil; -} - - -DEFUN ("x-hide-busy-cursor", Fx_hide_busy_cursor, - Sx_hide_busy_cursor, 0, 1, 0, - "Hide a busy-cursor.\n\ -A busy-cursor will actually be undisplayed when a matching\n\ -`x-undisplay-busy-cursor' is called for each `x-display-busy-cursor'\n\ -issued. FORCE non-nil means undisplay the busy-cursor forcibly,\n\ -not counting calls.") - (force) - Lisp_Object force; -{ - Lisp_Object rest, frame; - - if (busy_count == 0) - return Qnil; - - if (!NILP (force) && busy_count != 0) - busy_count = 1; - - --busy_count; - if (busy_count != 0) - return Qnil; - - FOR_EACH_FRAME (rest, frame) - { - struct frame *f = XFRAME (frame); + + busy_cursor_shown_p = 1; + UNBLOCK_INPUT; + } +#endif +} + + +/* Hide the busy cursor on all frames, if it is currently shown. */ + +static void +hide_busy_cursor () +{ +#if 0 /* NTEMACS_TODO: cursor shape changes. */ + if (busy_cursor_shown_p) + { + Lisp_Object rest, frame; + + BLOCK_INPUT; + FOR_EACH_FRAME (rest, frame) + { + struct frame *f = XFRAME (frame); - if (FRAME_X_P (f) - /* Watch out for newly created frames. */ - && f->output_data.w32->busy_window) - { -#if 0 /* NTEMACS_TODO : busy cursor */ - BLOCK_INPUT; - XUnmapWindow (FRAME_W32_DISPLAY (f), f->output_data.w32->busy_window); - /* Sync here because XTread_socket looks at the busy_p flag - that is reset to zero below. */ - XSync (FRAME_W32_DISPLAY (f), False); - UNBLOCK_INPUT; - f->output_data.w32->busy_p = 0; + if (FRAME_X_P (f) + /* Watch out for newly created frames. */ + && f->output_data.x->busy_window) + { + XUnmapWindow (FRAME_X_DISPLAY (f), f->output_data.x->busy_window); + /* Sync here because XTread_socket looks at the busy_p flag + that is reset to zero below. */ + XSync (FRAME_X_DISPLAY (f), False); + f->output_data.x->busy_p = 0; + } + } + + busy_cursor_shown_p = 0; + UNBLOCK_INPUT; + } #endif - } - } - - return Qnil; } @@ -12864,6 +12915,11 @@ "Non-zero means Emacs displays a busy cursor on window systems."); display_busy_cursor_p = 1; + DEFVAR_LISP ("busy-cursor-delay", &Vbusy_cursor_delay, + "*Seconds to wait before displaying a busy-cursor.\n\ +Value must be an integer."); + Vbusy_cursor_delay = make_number (DEFAULT_BUSY_CURSOR_DELAY); + DEFVAR_LISP ("x-sensitive-text-pointer-shape", &Vx_sensitive_text_pointer_shape, "The shape of the pointer when over mouse-sensitive text.\n\ @@ -13060,12 +13116,6 @@ #endif #endif /* NTEMACS_TODO */ - /* Busy-cursor. */ - defsubr (&Sx_show_busy_cursor); - defsubr (&Sx_hide_busy_cursor); - busy_count = 0; - inhibit_busy_cursor = 0; - defsubr (&Sx_show_tip); defsubr (&Sx_hide_tip); staticpro (&tip_timer);