-2008-03-19 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * window.c (run_funs): New fun.
- (run_window_configuration_change_hook): Use it to run the buffer-local
- and the global part of the hook.
-
- * xdisp.c (format_mode_line_unwind_data): Add window argument.
- (unwind_format_mode_line): Restore selected window.
- (x_consider_frame_title, Fformat_mode_line): Set selected window.
+2008-03-19 Jason Rumney <jasonr@gnu.org>
+
+ * w32fns.c (hourglass_timer, hourglass_hwnd): New variables.
+ (syms_of_w32fns): Initialize them.
+ (HOURGLASS_ID): New constant.
+ (x_window_to_frame): Don't check hourglass_window.
+ (w32_wnd_proc) <WM_TIMER>: Handle hourglass_timer.
+ (w32_wnd_proc) <WM_EXITMENULOOP>: Set pending hourglass cursor.
+ (w32_wnd_proc) <WM_SETCURSOR>: Set the hourglass or current cursor.
+ (w32_wnd_proc) <WM_EMACS_SETCURSOR>: Set frame's current_cursor.
+ Only change the cursor if hourglass is not active.
+ (Fx_create_frame): Initialize frame's current_cursor.
+ (hourglass_atimer): Remove.
+ (hourglass_started): New function.
+ (start_hourglass, cancel_hourglass, hide_hourglass): Adapt to w32.
+ (show_hourglass): Adapt to w32, changing argument to frame.
+
+ * w32term.h (struct w32_output): Remove hourglass_window.
+ Add current_cursor.
+
+ * eval.c (call_debugger, Fsignal):
+ * keyboard.c (recursive_edit_1, cmd_error, Ftop_level)
+ (command_loop_1, Fread_key_sequence, Fread_key_sequence_vector)
+ (Fexecute_extended_command, cancel_hourglass_unwind):
+ * minibuf.c (read_minibuf):
+ * fns.c (Fy_or_n_p): Enable hourglass when HAVE_WINDOW_SYSTEM.
2008-03-17 Stefan Monnier <monnier@iro.umontreal.ca>
specbind (Qstandard_input, Qt);
}
-#ifdef HAVE_X_WINDOWS
+#ifdef HAVE_WINDOW_SYSTEM
/* The command loop has started an hourglass timer, so we have to
cancel it here, otherwise it will fire because the recursive edit
can take some time. Do not check for display_hourglass_p here,
Lisp_Object old_level, old_length;
char macroerror[50];
-#ifdef HAVE_X_WINDOWS
+#ifdef HAVE_WINDOW_SYSTEM
if (display_hourglass_p)
cancel_hourglass ();
#endif
doc: /* Exit all recursive editing levels. */)
()
{
-#ifdef HAVE_X_WINDOWS
+#ifdef HAVE_WINDOW_SYSTEM
if (display_hourglass_p)
cancel_hourglass ();
#endif
/* Cancel hourglass from protect_unwind.
ARG is not used. */
-#ifdef HAVE_X_WINDOWS
+#ifdef HAVE_WINDOW_SYSTEM
static Lisp_Object
cancel_hourglass_unwind (arg)
Lisp_Object arg;
/* Here for a command that isn't executed directly */
{
-#ifdef HAVE_X_WINDOWS
+#ifdef HAVE_WINDOW_SYSTEM
int scount = SPECPDL_INDEX ();
if (display_hourglass_p
Fundo_boundary ();
Fcommand_execute (Vthis_command, Qnil, Qnil, Qnil);
-#ifdef HAVE_X_WINDOWS
+#ifdef HAVE_WINDOW_SYSTEM
/* Do not check display_hourglass_p here, because
Fcommand_execute could change it, but we should cancel
hourglass cursor anyway.
this_single_command_key_start = 0;
}
-#ifdef HAVE_X_WINDOWS
+#ifdef HAVE_WINDOW_SYSTEM
if (display_hourglass_p)
cancel_hourglass ();
#endif
#if 0 /* The following is fine for code reading a key sequence and
then proceeding with a lenghty computation, but it's not good
for code reading keys in a loop, like an input method. */
-#ifdef HAVE_X_WINDOWS
+#ifdef HAVE_WINDOW_SYSTEM
if (display_hourglass_p)
start_hourglass ();
#endif
this_single_command_key_start = 0;
}
-#ifdef HAVE_X_WINDOWS
+#ifdef HAVE_WINDOW_SYSTEM
if (display_hourglass_p)
cancel_hourglass ();
#endif
prompt, ! NILP (dont_downcase_last),
! NILP (can_return_switch_frame), 0);
-#ifdef HAVE_X_WINDOWS
+#ifdef HAVE_WINDOW_SYSTEM
if (display_hourglass_p)
start_hourglass ();
#endif
Lisp_Object saved_keys, saved_last_point_position_buffer;
Lisp_Object bindings, value;
struct gcpro gcpro1, gcpro2, gcpro3;
-#ifdef HAVE_X_WINDOWS
+#ifdef HAVE_WINDOW_SYSTEM
/* The call to Fcompleting_read wil start and cancel the hourglass,
but if the hourglass was already scheduled, this means that no
hourglass will be shown for the actual M-x command itself.
Qt, Qnil, Qextended_command_history, Qnil,
Qnil);
-#ifdef HAVE_X_WINDOWS
+#ifdef HAVE_WINDOW_SYSTEM
if (hstarted) start_hourglass ();
#endif
int display_hourglass_p;
+/* If non-zero, a w32 timer that, when it expires, displays an
+ hourglass cursor on all frames. */
+static unsigned hourglass_timer = 0;
+static HWND hourglass_hwnd = NULL;
+
/* The background and shape of the mouse pointer, and shape when not
over text or in the modeline. */
#define MOUSE_BUTTON_ID 1
#define MOUSE_MOVE_ID 2
#define MENU_FREE_ID 3
+#define HOURGLASS_ID 4
/* The delay (milliseconds) before a menu is freed after WM_EXITMENULOOP
is received. */
#define MENU_FREE_DELAY 1000
extern HMENU current_popup_menu;
static int menubar_in_use = 0;
+/* Function prototypes for hourglass support. */
+static void show_hourglass P_ ((struct frame *));
+static void hide_hourglass P_ ((void));
+
+
\f
/* Error if we are not connected to MS-Windows. */
void
f = XFRAME (frame);
if (!FRAME_W32_P (f) || FRAME_W32_DISPLAY_INFO (f) != dpyinfo)
continue;
- if (f->output_data.w32->hourglass_window == wdesc)
- return f;
if (FRAME_W32_WINDOW (f) == wdesc)
return f;
menubar_in_use = 0;
}
}
+ else if (wParam == hourglass_timer)
+ {
+ KillTimer (hwnd, hourglass_timer);
+ hourglass_timer = 0;
+ show_hourglass (x_window_to_frame (dpyinfo, hwnd));
+ }
return 0;
case WM_NCACTIVATE:
*/
if (f && menubar_in_use && current_popup_menu == NULL)
menu_free_timer = SetTimer (hwnd, MENU_FREE_ID, MENU_FREE_DELAY, NULL);
+
+ /* If hourglass cursor should be displayed, display it now. */
+ if (f && f->output_data.w32->hourglass_p)
+ SetCursor (f->output_data.w32->hourglass_cursor);
+
goto dflt;
case WM_MENUSELECT:
case WM_SETCURSOR:
if (LOWORD (lParam) == HTCLIENT)
- return 0;
-
+ {
+ f = x_window_to_frame (dpyinfo, hwnd);
+ if (f->output_data.w32->hourglass_p && !menubar_in_use
+ && !current_popup_menu)
+ SetCursor (f->output_data.w32->hourglass_cursor);
+ else
+ SetCursor (f->output_data.w32->current_cursor);
+ return 0;
+ }
goto dflt;
case WM_EMACS_SETCURSOR:
{
Cursor cursor = (Cursor) wParam;
- if (cursor)
- SetCursor (cursor);
+ f = x_window_to_frame (dpyinfo, hwnd);
+ if (f && cursor)
+ {
+ f->output_data.w32->current_cursor = cursor;
+ if (!f->output_data.w32->hourglass_p)
+ SetCursor (cursor);
+ }
return 0;
}
f->output_data.w32->hourglass_cursor = w32_load_cursor (IDC_WAIT);
f->output_data.w32->horizontal_drag_cursor = w32_load_cursor (IDC_SIZEWE);
+ f->output_data.w32->current_cursor = f->output_data.w32->nontext_cursor;
+
window_prompting = x_figure_window_size (f, parameters, 1);
tem = w32_get_arg (parameters, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
Busy cursor
***********************************************************************/
-/* If non-null, an asynchronous timer that, when it expires, displays
- an hourglass cursor on all frames. */
-
-static struct atimer *hourglass_atimer;
-
/* Non-zero means an hourglass cursor is currently shown. */
static int hourglass_shown_p;
#define DEFAULT_HOURGLASS_DELAY 1
-/* Function prototypes. */
-
-static void show_hourglass P_ ((struct atimer *));
-static void hide_hourglass P_ ((void));
+/* Return non-zero if houglass timer has been started or hourglass is shown. */
+int
+hourglass_started ()
+{
+ return hourglass_shown_p || hourglass_timer;
+}
/* Cancel a currently active hourglass timer, and start a new one. */
void
start_hourglass ()
{
-#if 0 /* TODO: cursor shape changes. */
- EMACS_TIME delay;
- int secs, usecs = 0;
+ DWORD delay;
+ int secs, msecs = 0;
+ struct frame * f = SELECTED_FRAME ();
cancel_hourglass ();
Lisp_Object tem;
tem = Ftruncate (Vhourglass_delay, Qnil);
secs = XFASTINT (tem);
- usecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000000;
+ msecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000;
}
else
secs = DEFAULT_HOURGLASS_DELAY;
- EMACS_SET_SECS_USECS (delay, secs, usecs);
- hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
- show_hourglass, NULL);
-#endif
+ delay = secs * 1000 + msecs;
+ hourglass_hwnd = FRAME_W32_WINDOW (f);
+ hourglass_timer = SetTimer (hourglass_hwnd, HOURGLASS_ID, delay, NULL);
}
void
cancel_hourglass ()
{
- if (hourglass_atimer)
+ if (hourglass_timer)
{
- cancel_atimer (hourglass_atimer);
- hourglass_atimer = NULL;
+ KillTimer (hourglass_hwnd, hourglass_timer);
+ hourglass_timer = 0;
}
if (hourglass_shown_p)
}
-/* Timer function of hourglass_atimer. TIMER is equal to
- hourglass_atimer.
+/* Timer function of hourglass_timer.
- Display an hourglass cursor on all frames by mapping the frames'
- hourglass_window. Set the hourglass_p flag in the frames'
- output_data.x structure to indicate that an hourglass cursor is
- shown on the frames. */
+ Display an hourglass cursor. Set the hourglass_p flag in display info
+ to indicate that an hourglass cursor is shown. */
static void
-show_hourglass (timer)
- struct atimer *timer;
+show_hourglass (f)
+ struct frame *f;
{
-#if 0 /* TODO: cursor shape changes. */
- /* The timer implementation will cancel this timer automatically
- after this function has run. Set hourglass_atimer to null
- so that we know the timer doesn't have to be canceled. */
- hourglass_atimer = NULL;
-
if (!hourglass_shown_p)
{
- Lisp_Object rest, frame;
-
- BLOCK_INPUT;
-
- FOR_EACH_FRAME (rest, frame)
- if (FRAME_W32_P (XFRAME (frame)))
- {
- struct frame *f = XFRAME (frame);
-
- f->output_data.w32->hourglass_p = 1;
-
- if (!f->output_data.w32->hourglass_window)
- {
- unsigned long mask = CWCursor;
- XSetWindowAttributes attrs;
-
- attrs.cursor = f->output_data.w32->hourglass_cursor;
-
- f->output_data.w32->hourglass_window
- = XCreateWindow (FRAME_X_DISPLAY (f),
- FRAME_OUTER_WINDOW (f),
- 0, 0, 32000, 32000, 0, 0,
- InputOnly,
- CopyFromParent,
- mask, &attrs);
- }
-
- XMapRaised (FRAME_X_DISPLAY (f),
- f->output_data.w32->hourglass_window);
- XFlush (FRAME_X_DISPLAY (f));
- }
-
+ f->output_data.w32->hourglass_p = 1;
+ if (!menubar_in_use && !current_popup_menu)
+ SetCursor (f->output_data.w32->hourglass_cursor);
hourglass_shown_p = 1;
- UNBLOCK_INPUT;
}
-#endif
}
static void
hide_hourglass ()
{
-#if 0 /* TODO: cursor shape changes. */
if (hourglass_shown_p)
{
- Lisp_Object rest, frame;
-
- BLOCK_INPUT;
- FOR_EACH_FRAME (rest, frame)
- {
- struct frame *f = XFRAME (frame);
-
- if (FRAME_W32_P (f)
- /* Watch out for newly created frames. */
- && f->output_data.x->hourglass_window)
- {
- XUnmapWindow (FRAME_X_DISPLAY (f),
- f->output_data.x->hourglass_window);
- /* Sync here because XTread_socket looks at the
- hourglass_p flag that is reset to zero below. */
- XSync (FRAME_X_DISPLAY (f), False);
- f->output_data.x->hourglass_p = 0;
- }
- }
+ struct frame *f = x_window_to_frame (&one_w32_display_info,
+ hourglass_hwnd);
+ f->output_data.w32->hourglass_p = 0;
+ SetCursor (f->output_data.w32->current_cursor);
hourglass_shown_p = 0;
- UNBLOCK_INPUT;
}
-#endif
}
check_window_system_func = check_w32;
- hourglass_atimer = NULL;
+ hourglass_timer = 0;
+ hourglass_hwnd = NULL;
hourglass_shown_p = 0;
defsubr (&Sx_show_tip);
defsubr (&Sx_hide_tip);