* Patch to trunk: merge common code in hourglass impl
@ 2008-06-04 0:05 Adrian Robert
2008-06-04 5:53 ` Stefan Monnier
0 siblings, 1 reply; 10+ messages in thread
From: Adrian Robert @ 2008-06-04 0:05 UTC (permalink / raw)
To: emacs- devel
[-- Attachment #1: Type: text/plain, Size: 794 bytes --]
Hello,
When I updated the hourglass implementation in the NS (Cocoa) port for
the hourglass changes of 2008-03-19 I put some code that was
duplicated in {x,mac,w32}fns.c into xdisp.c, leaving only
{show,hide}_hourglass functions for the port to implement. Other GUIs
could use this common code as well, and here is a patch against trunk
to do so.
There are three issues:
- I have tested only the X version.
- Under W32, atimers are not currently used, so the common code cannot
be either. If atimers will work under W32, then the patch can be
improved to benefit W32 as well.
- Under Mac, the hourglass impl is under #ifdef MAC_OSX. I replicate
this constraint in xdisp.c as "#if !defined (MAC_OS) || defined
(MAC_OSX)". Hopefully this is correct.
(Patch attached)
[-- Attachment #2: hourglass_common.patch --]
[-- Type: application/octet-stream, Size: 13948 bytes --]
=== modified file 'src/dispextern.h'
--- src/dispextern.h 2008-06-01 11:04:21 +0000
+++ src/dispextern.h 2008-06-03 23:27:30 +0000
@@ -2908,6 +2908,15 @@
extern void cancel_hourglass P_ ((void));
extern int hourglass_started P_ ((void));
extern int display_hourglass_p;
+extern int hourglass_shown_p;
+struct atimer; /* Defined in atimer.h. */
+/* If non-null, an asynchronous timer that, when it expires, displays
+ an hourglass cursor on all frames. */
+extern struct atimer *hourglass_atimer;
+
+/* Each GUI implements these. PENDING: move into RIF. */
+extern void show_hourglass P_ ((struct atimer *));
+extern void hide_hourglass P_ ((void));
/* Returns the background color of IMG, calculating one heuristically if
necessary. If non-zero, XIMG is an existing XImage object to use for
=== modified file 'src/macfns.c'
--- src/macfns.c 2008-05-22 20:51:54 +0000
+++ src/macfns.c 2008-06-03 23:57:56 +0000
@@ -57,10 +57,6 @@
#endif /* TARGET_API_MAC_CARBON */
-/* Non-zero means we're allowed to display an hourglass cursor. */
-
-int display_hourglass_p;
-
/* The background and shape of the mouse pointer, and shape when not
over text or in the modeline. */
@@ -3420,89 +3416,6 @@
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;
-
-/* Number of seconds to wait before displaying an hourglass cursor. */
-
-static Lisp_Object Vhourglass_delay;
-
-/* Default number of seconds to wait before displaying an hourglass
- cursor. */
-
-#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_atimer != NULL;
-}
-
-
-/* Cancel a currently active hourglass timer, and start a new one. */
-
-void
-start_hourglass ()
-{
-#ifdef MAC_OSX
- EMACS_TIME delay;
- int secs, usecs = 0;
-
- cancel_hourglass ();
-
- if (INTEGERP (Vhourglass_delay)
- && XINT (Vhourglass_delay) > 0)
- secs = XFASTINT (Vhourglass_delay);
- else if (FLOATP (Vhourglass_delay)
- && XFLOAT_DATA (Vhourglass_delay) > 0)
- {
- Lisp_Object tem;
- tem = Ftruncate (Vhourglass_delay, Qnil);
- secs = XFASTINT (tem);
- usecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000000;
- }
- else
- secs = DEFAULT_HOURGLASS_DELAY;
-
- EMACS_SET_SECS_USECS (delay, secs, usecs);
- hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
- show_hourglass, NULL);
-#endif /* MAC_OSX */
-}
-
-
-/* Cancel the hourglass cursor timer if active, hide a busy cursor if
- shown. */
-
-void
-cancel_hourglass ()
-{
-#ifdef MAC_OSX
- if (hourglass_atimer)
- {
- cancel_atimer (hourglass_atimer);
- hourglass_atimer = NULL;
- }
-
- if (hourglass_shown_p)
- hide_hourglass ();
-#endif /* MAC_OSX */
-}
-
-
/* Timer function of hourglass_atimer. TIMER is equal to
hourglass_atimer.
@@ -3510,7 +3423,7 @@
arrows) at the upper-right corner of each frame instead of the
hourglass pointer. */
-static void
+void
show_hourglass (timer)
struct atimer *timer;
{
@@ -3545,7 +3458,7 @@
/* Hide the progress indicators on all frames, if it is currently
shown. */
-static void
+void
hide_hourglass ()
{
#if TARGET_API_MAC_CARBON
@@ -4379,15 +4292,6 @@
or when you set the mouse color. */);
Vx_hourglass_pointer_shape = Qnil;
- DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
- doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */);
- display_hourglass_p = 1;
-
- DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
- doc: /* *Seconds to wait before displaying an hourglass pointer.
-Value must be an integer or float. */);
- Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
-
#if 0 /* This doesn't really do anything. */
DEFVAR_LISP ("x-mode-pointer-shape", &Vx_mode_pointer_shape,
doc: /* The shape of the pointer when over the mode line.
=== modified file 'src/w32fns.c'
--- src/w32fns.c 2008-06-02 12:09:12 +0000
+++ src/w32fns.c 2008-06-03 23:58:37 +0000
@@ -149,10 +149,6 @@
/* Non nil if no window manager is in use. */
Lisp_Object Vx_no_window_manager;
-/* Non-zero means we're allowed to display a hourglass pointer. */
-
-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;
@@ -344,10 +340,6 @@
extern void syms_of_w32uniscribe ();
extern int uniscribe_available;
-/* 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. */
@@ -7224,20 +7216,9 @@
Busy cursor
***********************************************************************/
-/* Non-zero means an hourglass cursor is currently shown. */
-
-static int hourglass_shown_p;
-
-/* Number of seconds to wait before displaying an hourglass cursor. */
-
-static Lisp_Object Vhourglass_delay;
-
-/* Default number of seconds to wait before displaying an hourglass
- cursor. */
-
-#define DEFAULT_HOURGLASS_DELAY 1
-
/* Return non-zero if houglass timer has been started or hourglass is shown. */
+/* PENDING: if W32 can use atimers (atimer.[hc]) then the common impl in
+ xdisp.c could be used. */
int
hourglass_started ()
@@ -9142,15 +9123,6 @@
or when you set the mouse color. */);
Vx_hourglass_pointer_shape = Qnil;
- DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
- doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */);
- display_hourglass_p = 1;
-
- DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
- doc: /* *Seconds to wait before displaying an hourglass pointer.
-Value must be an integer or float. */);
- Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
-
DEFVAR_LISP ("x-sensitive-text-pointer-shape",
&Vx_sensitive_text_pointer_shape,
doc: /* The shape of the pointer when over mouse-sensitive text.
@@ -9348,7 +9320,7 @@
hourglass_timer = 0;
hourglass_hwnd = NULL;
- hourglass_shown_p = 0;
+
defsubr (&Sx_show_tip);
defsubr (&Sx_hide_tip);
tip_timer = Qnil;
=== modified file 'src/xdisp.c'
--- src/xdisp.c 2008-06-01 11:04:21 +0000
+++ src/xdisp.c 2008-06-03 23:30:44 +0000
@@ -836,6 +836,25 @@
static struct glyph_slice null_glyph_slice = { 0, 0, 0, 0 };
+/* Platform-independent portion of hourglass implementation. */
+
+/* Non-zero means we're allowed to display a hourglass pointer. */
+int display_hourglass_p;
+
+/* Non-zero means an hourglass cursor is currently shown. */
+int hourglass_shown_p;
+
+/* If non-null, an asynchronous timer that, when it expires, displays
+ an hourglass cursor on all frames. */
+struct atimer *hourglass_atimer;
+
+/* Number of seconds to wait before displaying an hourglass cursor. */
+static Lisp_Object Vhourglass_delay;
+
+/* Default number of seconds to wait before displaying an hourglass
+ cursor. */
+#define DEFAULT_HOURGLASS_DELAY 1
+
\f
/* Function prototypes. */
@@ -24791,6 +24810,17 @@
The default value is 2: the height of the overline (1 pixel) plus 1 pixel
margin to the caracter height. */);
overline_margin = 2;
+ DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
+ doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */);
+ display_hourglass_p = 1;
+
+ DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
+ doc: /* *Seconds to wait before displaying an hourglass pointer.
+Value must be an integer or float. */);
+ Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
+
+ hourglass_atimer = NULL;
+ hourglass_shown_p = 0;
}
@@ -24846,6 +24876,64 @@
help_echo_showing_p = 0;
}
+/* Platform-independent portion of hourglass implementation. */
+
+/* Return non-zero if houglass timer has been started or hourglass is shown. */
+int
+hourglass_started ()
+{
+ return hourglass_shown_p || hourglass_atimer != NULL;
+}
+
+
+/* Cancel a currently active hourglass timer, and start a new one. */
+void
+start_hourglass ()
+{
+#if !defined (MAC_OS) || defined (MAC_OSX)
+ EMACS_TIME delay;
+ int secs, usecs = 0;
+
+ cancel_hourglass ();
+
+ if (INTEGERP (Vhourglass_delay)
+ && XINT (Vhourglass_delay) > 0)
+ secs = XFASTINT (Vhourglass_delay);
+ else if (FLOATP (Vhourglass_delay)
+ && XFLOAT_DATA (Vhourglass_delay) > 0)
+ {
+ Lisp_Object tem;
+ tem = Ftruncate (Vhourglass_delay, Qnil);
+ secs = XFASTINT (tem);
+ usecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000000;
+ }
+ else
+ secs = DEFAULT_HOURGLASS_DELAY;
+
+ EMACS_SET_SECS_USECS (delay, secs, usecs);
+ hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
+ show_hourglass, NULL);
+#endif
+}
+
+
+/* Cancel the hourglass cursor timer if active, hide a busy cursor if
+ shown. */
+void
+cancel_hourglass ()
+{
+#if !defined (MAC_OS) || defined (MAC_OSX)
+ if (hourglass_atimer)
+ {
+ cancel_atimer (hourglass_atimer);
+ hourglass_atimer = NULL;
+ }
+
+ if (hourglass_shown_p)
+ hide_hourglass ();
+#endif
+}
+
/* arch-tag: eacc864d-bb6a-4b74-894a-1a4399a1358b
(do not change this comment) */
=== modified file 'src/xfns.c'
--- src/xfns.c 2008-05-22 20:51:54 +0000
+++ src/xfns.c 2008-06-03 23:27:37 +0000
@@ -149,10 +149,6 @@
int gray_bitmap_height = gray_height;
char *gray_bitmap_bits = gray_bits;
-/* Non-zero means we're allowed to display an hourglass cursor. */
-
-int display_hourglass_p;
-
/* Non-zero means prompt with the old GTK file selection dialog. */
int x_gtk_use_old_file_dialog;
@@ -4450,85 +4446,6 @@
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;
-
-/* Number of seconds to wait before displaying an hourglass cursor. */
-
-static Lisp_Object Vhourglass_delay;
-
-/* Default number of seconds to wait before displaying an hourglass
- cursor. */
-
-#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_atimer != NULL;
-}
-
-
-/* Cancel a currently active hourglass timer, and start a new one. */
-
-void
-start_hourglass ()
-{
- EMACS_TIME delay;
- int secs, usecs = 0;
-
- cancel_hourglass ();
-
- if (INTEGERP (Vhourglass_delay)
- && XINT (Vhourglass_delay) > 0)
- secs = XFASTINT (Vhourglass_delay);
- else if (FLOATP (Vhourglass_delay)
- && XFLOAT_DATA (Vhourglass_delay) > 0)
- {
- Lisp_Object tem;
- tem = Ftruncate (Vhourglass_delay, Qnil);
- secs = XFASTINT (tem);
- usecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000000;
- }
- else
- secs = DEFAULT_HOURGLASS_DELAY;
-
- EMACS_SET_SECS_USECS (delay, secs, usecs);
- hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
- show_hourglass, NULL);
-}
-
-
-/* Cancel the hourglass cursor timer if active, hide a busy cursor if
- shown. */
-
-void
-cancel_hourglass ()
-{
- if (hourglass_atimer)
- {
- cancel_atimer (hourglass_atimer);
- hourglass_atimer = NULL;
- }
-
- if (hourglass_shown_p)
- hide_hourglass ();
-}
-
-
/* Timer function of hourglass_atimer. TIMER is equal to
hourglass_atimer.
@@ -4537,7 +4454,7 @@
output_data.x structure to indicate that an hourglass cursor is
shown on the frames. */
-static void
+void
show_hourglass (timer)
struct atimer *timer;
{
@@ -4602,7 +4519,7 @@
/* Hide the hourglass pointer on all frames, if it is currently
shown. */
-static void
+void
hide_hourglass ()
{
if (hourglass_shown_p)
@@ -5828,15 +5745,6 @@
or when you set the mouse color. */);
Vx_hourglass_pointer_shape = Qnil;
- DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
- doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */);
- display_hourglass_p = 1;
-
- DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
- doc: /* *Seconds to wait before displaying an hourglass pointer.
-Value must be an integer or float. */);
- Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
-
#if 0 /* This doesn't really do anything. */
DEFVAR_LISP ("x-mode-pointer-shape", &Vx_mode_pointer_shape,
doc: /* The shape of the pointer when over the mode line.
@@ -5976,9 +5884,6 @@
/* Setting callback functions for fontset handler. */
check_window_system_func = check_x;
- hourglass_atimer = NULL;
- hourglass_shown_p = 0;
-
defsubr (&Sx_show_tip);
defsubr (&Sx_hide_tip);
tip_timer = Qnil;
[-- Attachment #3: Type: text/plain, Size: 3 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Patch to trunk: merge common code in hourglass impl
2008-06-04 0:05 Patch to trunk: merge common code in hourglass impl Adrian Robert
@ 2008-06-04 5:53 ` Stefan Monnier
2008-06-04 9:31 ` Jason Rumney
0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2008-06-04 5:53 UTC (permalink / raw)
To: Adrian Robert; +Cc: emacs- devel
> When I updated the hourglass implementation in the NS (Cocoa) port for the
> hourglass changes of 2008-03-19 I put some code that was duplicated in
> {x,mac,w32}fns.c into xdisp.c, leaving only {show,hide}_hourglass functions
> for the port to implement. Other GUIs could use this common code as well,
> and here is a patch against trunk to do so.
> There are three issues:
> - I have tested only the X version.
> - Under W32, atimers are not currently used, so the common code cannot be
> either. If atimers will work under W32, then the patch can be improved to
> benefit W32 as well.
It would be good to know if the avoidance of atimers was done
on purpose. Eli? Jason?
> - Under Mac, the hourglass impl is under #ifdef MAC_OSX. I replicate this
> constraint in xdisp.c as "#if !defined (MAC_OS) || defined (MAC_OSX)".
> Hopefully this is correct.
A similar problem exists for the tty-only version. I think the code
needs to check HAVE_WINDOW_SYSTEM.
Not sure what's up with the MAC_OS-non-MAC_OSX code. Now that we do not
support MAC_OS8 any more, MAC_OS-non-MAC_OSX should be impossible (and
since the Carbon code is broken anyway, there's no good reason to worry
about it, really).
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Patch to trunk: merge common code in hourglass impl
2008-06-04 5:53 ` Stefan Monnier
@ 2008-06-04 9:31 ` Jason Rumney
2008-06-04 16:17 ` Stefan Monnier
2008-06-04 17:31 ` Eli Zaretskii
0 siblings, 2 replies; 10+ messages in thread
From: Jason Rumney @ 2008-06-04 9:31 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Adrian Robert, emacs- devel
Stefan Monnier wrote:
>> - Under W32, atimers are not currently used, so the common code cannot be
>> either. If atimers will work under W32, then the patch can be improved to
>> benefit W32 as well.
>>
>
> It would be good to know if the avoidance of atimers was done
> on purpose. Eli? Jason?
>
I don't think atimers are supported on Windows. My understanding is that
they require signals.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Patch to trunk: merge common code in hourglass impl
2008-06-04 9:31 ` Jason Rumney
@ 2008-06-04 16:17 ` Stefan Monnier
2008-06-04 17:31 ` Eli Zaretskii
1 sibling, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2008-06-04 16:17 UTC (permalink / raw)
To: Jason Rumney; +Cc: Adrian Robert, emacs- devel
>>> - Under W32, atimers are not currently used, so the common code cannot be
>>> either. If atimers will work under W32, then the patch can be improved to
>>> benefit W32 as well.
>> It would be good to know if the avoidance of atimers was done
>> on purpose. Eli? Jason?
> I don't think atimers are supported on Windows. My understanding is that
> they require signals.
That'd explain it, thanks,
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Patch to trunk: merge common code in hourglass impl
2008-06-04 9:31 ` Jason Rumney
2008-06-04 16:17 ` Stefan Monnier
@ 2008-06-04 17:31 ` Eli Zaretskii
2008-06-04 21:31 ` Jason Rumney
1 sibling, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2008-06-04 17:31 UTC (permalink / raw)
To: Jason Rumney; +Cc: adrian.b.robert, monnier, emacs-devel
> Date: Wed, 04 Jun 2008 10:31:29 +0100
> From: Jason Rumney <jasonr@gnu.org>
> Cc: Adrian Robert <adrian.b.robert@gmail.com>,
> emacs- devel <emacs-devel@gnu.org>
>
> Stefan Monnier wrote:
> >> - Under W32, atimers are not currently used, so the common code cannot be
> >> either. If atimers will work under W32, then the patch can be improved to
> >> benefit W32 as well.
> >>
> >
> > It would be good to know if the avoidance of atimers was done
> > on purpose. Eli? Jason?
> >
>
> I don't think atimers are supported on Windows. My understanding is that
> they require signals.
Yes, atimers work by sending SIGALRM, which isn't supported on
Windows. While Windows has equivalent functionality, no one stepped
forward to emulate atimers, probably because their use in Emacs is
quite limited, and in areas where Windows offers alternate ways of
doing the same.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Patch to trunk: merge common code in hourglass impl
2008-06-04 17:31 ` Eli Zaretskii
@ 2008-06-04 21:31 ` Jason Rumney
2008-06-04 21:38 ` Lennart Borgman (gmail)
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Jason Rumney @ 2008-06-04 21:31 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: adrian.b.robert, monnier, emacs-devel
Eli Zaretskii wrote:
> Yes, atimers work by sending SIGALRM, which isn't supported on
> Windows. While Windows has equivalent functionality, no one stepped
> forward to emulate atimers, probably because their use in Emacs is
> quite limited, and in areas where Windows offers alternate ways of
> doing the same.
>
What is the equivalent functionality? Threads are not the same as
signals, as they do not block other threads from executing. This is a
problem when any Lisp code is run, as a GC can occur in the main Lisp
thread while the signal emulation thread is running Lisp code, leading
to memory corruption and crashes. So any system timers need to be
handled in the Lisp thread, which effectively means they are
synchronous. Since the hourglass code doesn't actually need to run Lisp,
I used a Windows system timer running in the UI thread, which is not
generally busy enough to have delays like the Lisp thread, but I don't
think a general atimer implementation can be done that way.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Patch to trunk: merge common code in hourglass impl
2008-06-04 21:31 ` Jason Rumney
@ 2008-06-04 21:38 ` Lennart Borgman (gmail)
2008-06-06 20:00 ` Eli Zaretskii
2008-07-15 0:46 ` Adrian Robert
2 siblings, 0 replies; 10+ messages in thread
From: Lennart Borgman (gmail) @ 2008-06-04 21:38 UTC (permalink / raw)
To: Jason Rumney; +Cc: Eli Zaretskii, adrian.b.robert, monnier, emacs-devel
Jason Rumney wrote:
> Eli Zaretskii wrote:
>> Yes, atimers work by sending SIGALRM, which isn't supported on
>> Windows. While Windows has equivalent functionality, no one stepped
>> forward to emulate atimers, probably because their use in Emacs is
>> quite limited, and in areas where Windows offers alternate ways of
>> doing the same.
>>
>
> What is the equivalent functionality? Threads are not the same as
> signals, as they do not block other threads from executing. This is a
> problem when any Lisp code is run, as a GC can occur in the main Lisp
> thread while the signal emulation thread is running Lisp code, leading
> to memory corruption and crashes. So any system timers need to be
> handled in the Lisp thread, which effectively means they are
> synchronous. Since the hourglass code doesn't actually need to run Lisp,
> I used a Windows system timer running in the UI thread, which is not
> generally busy enough to have delays like the Lisp thread, but I don't
> think a general atimer implementation can be done that way.
Is it not possible to use critical sections (which is like a low cost in
process semaphore)?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Patch to trunk: merge common code in hourglass impl
2008-06-04 21:31 ` Jason Rumney
2008-06-04 21:38 ` Lennart Borgman (gmail)
@ 2008-06-06 20:00 ` Eli Zaretskii
2008-07-15 0:46 ` Adrian Robert
2 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2008-06-06 20:00 UTC (permalink / raw)
To: Jason Rumney; +Cc: adrian.b.robert, monnier, emacs-devel
> Date: Wed, 04 Jun 2008 22:31:28 +0100
> From: Jason Rumney <jasonr@gnu.org>
> CC: monnier@iro.umontreal.ca, adrian.b.robert@gmail.com,
> emacs-devel@gnu.org
>
> Eli Zaretskii wrote:
> > Yes, atimers work by sending SIGALRM, which isn't supported on
> > Windows. While Windows has equivalent functionality, no one stepped
> > forward to emulate atimers, probably because their use in Emacs is
> > quite limited, and in areas where Windows offers alternate ways of
> > doing the same.
> >
>
> What is the equivalent functionality? Threads are not the same as
> signals, as they do not block other threads from executing.
I didn't mean threads, I meant SetWaitableTimer or one of its sibling
synchronization APIs.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Patch to trunk: merge common code in hourglass impl
2008-06-04 21:31 ` Jason Rumney
2008-06-04 21:38 ` Lennart Borgman (gmail)
2008-06-06 20:00 ` Eli Zaretskii
@ 2008-07-15 0:46 ` Adrian Robert
2008-07-15 1:41 ` Stefan Monnier
2 siblings, 1 reply; 10+ messages in thread
From: Adrian Robert @ 2008-07-15 0:46 UTC (permalink / raw)
To: emacs- devel
[-- Attachment #1: Type: text/plain, Size: 547 bytes --]
Hi,
Re: http://thread.gmane.org/gmane.emacs.devel/98341
I posted this patch last month, and although it does not help matters
under w32 and it was established it would not be easy to do this
anytime soon, it does allow the X, Carbon, and upcoming Cocoa ports to
share non-GUI hourglass logic code. Since there were no objections to
the patch, and it was tested under X (and will be soon under Cocoa),
would it be OK to commit it?
I am attaching a re-synced version of the patch, with a
HAVE_WINDOW_SYSTEM check added.
-Adrian
[-- Attachment #2: hourglass_common_v2.patch --]
[-- Type: application/octet-stream, Size: 13632 bytes --]
=== modified file 'src/dispextern.h'
--- src/dispextern.h 2008-07-01 15:39:26 +0000
+++ src/dispextern.h 2008-07-14 23:22:54 +0000
@@ -2925,6 +2925,15 @@
extern void cancel_hourglass P_ ((void));
extern int hourglass_started P_ ((void));
extern int display_hourglass_p;
+extern int hourglass_shown_p;
+struct atimer; /* Defined in atimer.h. */
+/* If non-null, an asynchronous timer that, when it expires, displays
+ an hourglass cursor on all frames. */
+extern struct atimer *hourglass_atimer;
+
+/* Each GUI implements these. PENDING: move into RIF. */
+extern void show_hourglass P_ ((struct atimer *));
+extern void hide_hourglass P_ ((void));
/* Returns the background color of IMG, calculating one heuristically if
necessary. If non-zero, XIMG is an existing XImage object to use for
=== modified file 'src/macfns.c'
--- src/macfns.c 2008-07-08 23:30:41 +0000
+++ src/macfns.c 2008-07-14 23:22:54 +0000
@@ -57,10 +57,6 @@
#endif /* TARGET_API_MAC_CARBON */
-/* Non-zero means we're allowed to display an hourglass cursor. */
-
-int display_hourglass_p;
-
/* The background and shape of the mouse pointer, and shape when not
over text or in the modeline. */
@@ -3420,89 +3416,6 @@
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;
-
-/* Number of seconds to wait before displaying an hourglass cursor. */
-
-static Lisp_Object Vhourglass_delay;
-
-/* Default number of seconds to wait before displaying an hourglass
- cursor. */
-
-#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_atimer != NULL;
-}
-
-
-/* Cancel a currently active hourglass timer, and start a new one. */
-
-void
-start_hourglass ()
-{
-#ifdef MAC_OSX
- EMACS_TIME delay;
- int secs, usecs = 0;
-
- cancel_hourglass ();
-
- if (INTEGERP (Vhourglass_delay)
- && XINT (Vhourglass_delay) > 0)
- secs = XFASTINT (Vhourglass_delay);
- else if (FLOATP (Vhourglass_delay)
- && XFLOAT_DATA (Vhourglass_delay) > 0)
- {
- Lisp_Object tem;
- tem = Ftruncate (Vhourglass_delay, Qnil);
- secs = XFASTINT (tem);
- usecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000000;
- }
- else
- secs = DEFAULT_HOURGLASS_DELAY;
-
- EMACS_SET_SECS_USECS (delay, secs, usecs);
- hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
- show_hourglass, NULL);
-#endif /* MAC_OSX */
-}
-
-
-/* Cancel the hourglass cursor timer if active, hide a busy cursor if
- shown. */
-
-void
-cancel_hourglass ()
-{
-#ifdef MAC_OSX
- if (hourglass_atimer)
- {
- cancel_atimer (hourglass_atimer);
- hourglass_atimer = NULL;
- }
-
- if (hourglass_shown_p)
- hide_hourglass ();
-#endif /* MAC_OSX */
-}
-
-
/* Timer function of hourglass_atimer. TIMER is equal to
hourglass_atimer.
@@ -3510,7 +3423,7 @@
arrows) at the upper-right corner of each frame instead of the
hourglass pointer. */
-static void
+void
show_hourglass (timer)
struct atimer *timer;
{
@@ -3545,7 +3458,7 @@
/* Hide the progress indicators on all frames, if it is currently
shown. */
-static void
+void
hide_hourglass ()
{
#if TARGET_API_MAC_CARBON
@@ -4379,15 +4292,6 @@
or when you set the mouse color. */);
Vx_hourglass_pointer_shape = Qnil;
- DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
- doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */);
- display_hourglass_p = 1;
-
- DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
- doc: /* *Seconds to wait before displaying an hourglass pointer.
-Value must be an integer or float. */);
- Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
-
#if 0 /* This doesn't really do anything. */
DEFVAR_LISP ("x-mode-pointer-shape", &Vx_mode_pointer_shape,
doc: /* The shape of the pointer when over the mode line.
=== modified file 'src/w32fns.c'
--- src/w32fns.c 2008-07-14 16:38:49 +0000
+++ src/w32fns.c 2008-07-14 23:26:17 +0000
@@ -151,10 +151,6 @@
/* Non nil if no window manager is in use. */
Lisp_Object Vx_no_window_manager;
-/* Non-zero means we're allowed to display a hourglass pointer. */
-
-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;
@@ -5233,20 +5229,9 @@
Busy cursor
***********************************************************************/
-/* Non-zero means an hourglass cursor is currently shown. */
-
-static int hourglass_shown_p;
-
-/* Number of seconds to wait before displaying an hourglass cursor. */
-
-static Lisp_Object Vhourglass_delay;
-
-/* Default number of seconds to wait before displaying an hourglass
- cursor. */
-
-#define DEFAULT_HOURGLASS_DELAY 1
-
/* Return non-zero if houglass timer has been started or hourglass is shown. */
+/* PENDING: if W32 can use atimers (atimer.[hc]) then the common impl in
+ xdisp.c could be used. */
int
hourglass_started ()
@@ -7150,15 +7135,6 @@
or when you set the mouse color. */);
Vx_hourglass_pointer_shape = Qnil;
- DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
- doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */);
- display_hourglass_p = 1;
-
- DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
- doc: /* *Seconds to wait before displaying an hourglass pointer.
-Value must be an integer or float. */);
- Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
-
DEFVAR_LISP ("x-sensitive-text-pointer-shape",
&Vx_sensitive_text_pointer_shape,
doc: /* The shape of the pointer when over mouse-sensitive text.
@@ -7274,7 +7250,7 @@
hourglass_timer = 0;
hourglass_hwnd = NULL;
- hourglass_shown_p = 0;
+
defsubr (&Sx_show_tip);
defsubr (&Sx_hide_tip);
tip_timer = Qnil;
=== modified file 'src/xdisp.c'
--- src/xdisp.c 2008-07-11 05:47:00 +0000
+++ src/xdisp.c 2008-07-15 00:07:52 +0000
@@ -852,6 +852,25 @@
static struct glyph_slice null_glyph_slice = { 0, 0, 0, 0 };
+/* Platform-independent portion of hourglass implementation. */
+
+/* Non-zero means we're allowed to display a hourglass pointer. */
+int display_hourglass_p;
+
+/* Non-zero means an hourglass cursor is currently shown. */
+int hourglass_shown_p;
+
+/* If non-null, an asynchronous timer that, when it expires, displays
+ an hourglass cursor on all frames. */
+struct atimer *hourglass_atimer;
+
+/* Number of seconds to wait before displaying an hourglass cursor. */
+static Lisp_Object Vhourglass_delay;
+
+/* Default number of seconds to wait before displaying an hourglass
+ cursor. */
+#define DEFAULT_HOURGLASS_DELAY 1
+
\f
/* Function prototypes. */
@@ -25143,6 +25162,18 @@
with fonts that specify an UNDERLINE_POSITION relatively close to the
baseline. The default value is 1. */);
underline_minimum_offset = 1;
+
+ DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
+ doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */);
+ display_hourglass_p = 1;
+
+ DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
+ doc: /* *Seconds to wait before displaying an hourglass pointer.
+Value must be an integer or float. */);
+ Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
+
+ hourglass_atimer = NULL;
+ hourglass_shown_p = 0;
}
@@ -25198,6 +25229,64 @@
help_echo_showing_p = 0;
}
+/* Platform-independent portion of hourglass implementation. */
+
+/* Return non-zero if houglass timer has been started or hourglass is shown. */
+int
+hourglass_started ()
+{
+ return hourglass_shown_p || hourglass_atimer != NULL;
+}
+
+
+/* Cancel a currently active hourglass timer, and start a new one. */
+void
+start_hourglass ()
+{
+#if defined (HAVE_WINDOW_SYSTEM)
+ EMACS_TIME delay;
+ int secs, usecs = 0;
+
+ cancel_hourglass ();
+
+ if (INTEGERP (Vhourglass_delay)
+ && XINT (Vhourglass_delay) > 0)
+ secs = XFASTINT (Vhourglass_delay);
+ else if (FLOATP (Vhourglass_delay)
+ && XFLOAT_DATA (Vhourglass_delay) > 0)
+ {
+ Lisp_Object tem;
+ tem = Ftruncate (Vhourglass_delay, Qnil);
+ secs = XFASTINT (tem);
+ usecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000000;
+ }
+ else
+ secs = DEFAULT_HOURGLASS_DELAY;
+
+ EMACS_SET_SECS_USECS (delay, secs, usecs);
+ hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
+ show_hourglass, NULL);
+#endif
+}
+
+
+/* Cancel the hourglass cursor timer if active, hide a busy cursor if
+ shown. */
+void
+cancel_hourglass ()
+{
+#if defined (HAVE_WINDOW_SYSTEM)
+ if (hourglass_atimer)
+ {
+ cancel_atimer (hourglass_atimer);
+ hourglass_atimer = NULL;
+ }
+
+ if (hourglass_shown_p)
+ hide_hourglass ();
+#endif
+}
+
/* arch-tag: eacc864d-bb6a-4b74-894a-1a4399a1358b
(do not change this comment) */
=== modified file 'src/xfns.c'
--- src/xfns.c 2008-07-09 21:35:29 +0000
+++ src/xfns.c 2008-07-14 23:22:54 +0000
@@ -149,10 +149,6 @@
int gray_bitmap_height = gray_height;
char *gray_bitmap_bits = gray_bits;
-/* Non-zero means we're allowed to display an hourglass cursor. */
-
-int display_hourglass_p;
-
/* Non-zero means prompt with the old GTK file selection dialog. */
int x_gtk_use_old_file_dialog;
@@ -4472,85 +4468,6 @@
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;
-
-/* Number of seconds to wait before displaying an hourglass cursor. */
-
-static Lisp_Object Vhourglass_delay;
-
-/* Default number of seconds to wait before displaying an hourglass
- cursor. */
-
-#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_atimer != NULL;
-}
-
-
-/* Cancel a currently active hourglass timer, and start a new one. */
-
-void
-start_hourglass ()
-{
- EMACS_TIME delay;
- int secs, usecs = 0;
-
- cancel_hourglass ();
-
- if (INTEGERP (Vhourglass_delay)
- && XINT (Vhourglass_delay) > 0)
- secs = XFASTINT (Vhourglass_delay);
- else if (FLOATP (Vhourglass_delay)
- && XFLOAT_DATA (Vhourglass_delay) > 0)
- {
- Lisp_Object tem;
- tem = Ftruncate (Vhourglass_delay, Qnil);
- secs = XFASTINT (tem);
- usecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000000;
- }
- else
- secs = DEFAULT_HOURGLASS_DELAY;
-
- EMACS_SET_SECS_USECS (delay, secs, usecs);
- hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
- show_hourglass, NULL);
-}
-
-
-/* Cancel the hourglass cursor timer if active, hide a busy cursor if
- shown. */
-
-void
-cancel_hourglass ()
-{
- if (hourglass_atimer)
- {
- cancel_atimer (hourglass_atimer);
- hourglass_atimer = NULL;
- }
-
- if (hourglass_shown_p)
- hide_hourglass ();
-}
-
-
/* Timer function of hourglass_atimer. TIMER is equal to
hourglass_atimer.
@@ -4559,7 +4476,7 @@
output_data.x structure to indicate that an hourglass cursor is
shown on the frames. */
-static void
+void
show_hourglass (timer)
struct atimer *timer;
{
@@ -4624,7 +4541,7 @@
/* Hide the hourglass pointer on all frames, if it is currently
shown. */
-static void
+void
hide_hourglass ()
{
if (hourglass_shown_p)
@@ -5905,15 +5822,6 @@
or when you set the mouse color. */);
Vx_hourglass_pointer_shape = Qnil;
- DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
- doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */);
- display_hourglass_p = 1;
-
- DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
- doc: /* *Seconds to wait before displaying an hourglass pointer.
-Value must be an integer or float. */);
- Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
-
#if 0 /* This doesn't really do anything. */
DEFVAR_LISP ("x-mode-pointer-shape", &Vx_mode_pointer_shape,
doc: /* The shape of the pointer when over the mode line.
@@ -6053,9 +5961,6 @@
/* Setting callback functions for fontset handler. */
check_window_system_func = check_x;
- hourglass_atimer = NULL;
- hourglass_shown_p = 0;
-
defsubr (&Sx_show_tip);
defsubr (&Sx_hide_tip);
tip_timer = Qnil;
[-- Attachment #3: Type: text/plain, Size: 3 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Patch to trunk: merge common code in hourglass impl
2008-07-15 0:46 ` Adrian Robert
@ 2008-07-15 1:41 ` Stefan Monnier
0 siblings, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2008-07-15 1:41 UTC (permalink / raw)
To: Adrian Robert; +Cc: emacs- devel
> Re: http://thread.gmane.org/gmane.emacs.devel/98341
> I posted this patch last month, and although it does not help matters under
> w32 and it was established it would not be easy to do this anytime soon, it
> does allow the X, Carbon, and upcoming Cocoa ports to share non-GUI
> hourglass logic code. Since there were no objections to the patch, and it
> was tested under X (and will be soon under Cocoa), would it be OK to
> commit it?
> I am attaching a re-synced version of the patch, with a HAVE_WINDOW_SYSTEM
> check added.
Sounds good to me,
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-07-15 1:41 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-04 0:05 Patch to trunk: merge common code in hourglass impl Adrian Robert
2008-06-04 5:53 ` Stefan Monnier
2008-06-04 9:31 ` Jason Rumney
2008-06-04 16:17 ` Stefan Monnier
2008-06-04 17:31 ` Eli Zaretskii
2008-06-04 21:31 ` Jason Rumney
2008-06-04 21:38 ` Lennart Borgman (gmail)
2008-06-06 20:00 ` Eli Zaretskii
2008-07-15 0:46 ` Adrian Robert
2008-07-15 1:41 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.