Ben noticed that printer would not print because redisplay gets
preempted by a pending input event. Printers should not obey the
regular preemption rules. Here's a fix. Also, I moved "implementation
flags", so they are no more returned by a device method, rather
stored in console method table. Since they are inherently static,
they should not be returned by implicitly dynamic device method
mechanism.
I think this change is lucid enough, pardon the pun, to to into 20.4?
I found one thingy in redisplay.c which I did not include in this
patch, as it is definitely controversial - separate patch follows.
Bill, could you please verify device-gtk.c?
-kkm
2001-05-02 Kirill 'Big K' Katsnelson <kkm(a)dtmx.com>
* console.h (struct console_methods): Added flags member.
(CONSOLE_IMPLEMENTATION_FLAGS): Defined.
(CONMETH_IMPL_FLAG):
(CONSOLE_IMPL_FLAG): Macro to check implememntation flags.
Defined XDEVIMPF_DONT_PREEMPT_REDISPLAY.
* device.c (window_system_pixelated_geometry): Use the above macros.
* device.h (DEVICE_IMPL_FLAG): Macro to check a device
implememntation flag.
* device.h (DEVICE_DISPLAY_P): Use it.
* frame.c (delete_frame_internal): Use the above macro.
* redisplay.c (redisplay_device): Use it.
(redisplay_device): Obey XDEVIMPF_DONT_PREEMPT_REDISPLAY.
(redisplay_frame): Ditto.
* device-msw.c (mswindows_device_implementation_flags): Removed.
(msprinter_device_implementation_flags): Removed.
(console_type_create_device_mswindows): Removed references to
implementation_flags methods, set implementation flags here.
(console_type_create_device_mswindows): Added XDEVIMPF_DONT_PREEMPT.
* device-gtk.c (gtk_device_implementation_flags): Removed method.
(console_type_create_device_gtk): Removed method declaration.
Added commented out statement which semantically matches the
commented out statement in the above removed method.
Index: console.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/console.h,v
retrieving revision 1.24
diff -u -r1.24 console.h
--- console.h 2001/04/12 18:23:30 1.24
+++ console.h 2001/05/03 06:26:51
@@ -63,11 +63,34 @@
extern const struct struct_description cted_description;
extern const struct struct_description console_methods_description;
+
+/*
+ * Constants returned by device_implementation_flags_method
+ */
+
+/* Set when device uses pixel-based geometry */
+#define XDEVIMPF_PIXEL_GEOMETRY 0x00000001L
+
+/* Indicates that the device is a printer */
+#define XDEVIMPF_IS_A_PRINTER 0x00000002L
+
+/* Do not automatically redisplay this device */
+#define XDEVIMPF_NO_AUTO_REDISPLAY 0x00000004L
+
+/* Do not delete the device when last frame's gone */
+#define XDEVIMPF_FRAMELESS_OK 0x00000008L
+
+/* Do not preempt resiaply of frame or device once it starts */
+#define XDEVIMPF_DONT_PREEMPT_REDISPLAY 0x00000010L
+
struct console_methods
{
const char *name; /* Used by print_console, print_device, print_frame */
Lisp_Object symbol;
Lisp_Object predicate_symbol;
+ unsigned int flags; /* Read-only implementation flags, set once upon
+ console type creation. INITIALIZE_CONSOLE_TYPE sets
+ this member to 0. */
/* console methods */
void (*init_console_method) (struct console *, Lisp_Object props);
@@ -93,7 +116,6 @@
void (*asynch_device_change_method) (void);
Lisp_Object (*device_system_metrics_method) (struct device *,
enum device_metrics);
- unsigned int (*device_implementation_flags_method) (void);
Lisp_Object (*own_selection_method)(Lisp_Object selection_name,
Lisp_Object selection_value,
Lisp_Object how_to_add,
@@ -303,26 +325,12 @@
#endif
};
-/*
- * Constants returned by device_implementation_flags_method
- */
-
-/* Set when device uses pixel-based geometry */
-#define XDEVIMPF_PIXEL_GEOMETRY 0x00000001L
-
-/* Indicates that the device is a printer */
-#define XDEVIMPF_IS_A_PRINTER 0x00000002L
-
-/* Do not automatically redisplay this device */
-#define XDEVIMPF_NO_AUTO_REDISPLAY 0x00000004L
-
-/* Do not delete the device when last frame's gone */
-#define XDEVIMPF_FRAMELESS_OK 0x00000008L
-
+#define CONMETH_TYPE(meths) ((meths)->symbol)
+#define CONMETH_IMPL_FLAG(meths, f) ((meths)->flags & (f))
#define CONSOLE_TYPE_NAME(c) ((c)->conmeths->name)
#define CONSOLE_TYPE(c) ((c)->conmeths->symbol)
-#define CONMETH_TYPE(meths) ((meths)->symbol)
+#define CONSOLE_IMPL_FLAG(c, f) CONMETH_IMPL_FLAG ((c)->conmeths, (f))
/******** Accessing / calling a console method *********/
@@ -406,6 +414,10 @@
implementation from console-type FROMTYPE */
#define CONSOLE_INHERITS_METHOD(type, fromtype, m) \
(type##_console_methods->m##_method = fromtype##_##m)
+
+/* Define console type implementation flags */
+#define CONSOLE_IMPLEMENTATION_FLAGS(type, flg) \
+ (type##_console_methods->flags = flg)
struct console
{
Index: device-gtk.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/device-gtk.c,v
retrieving revision 1.2
diff -u -r1.2 device-gtk.c
--- device-gtk.c 2001/04/12 18:23:32 1.2
+++ device-gtk.c 2001/05/03 06:26:51
@@ -680,12 +680,6 @@
return (result);
}
-static unsigned int
-gtk_device_implementation_flags (void)
-{
- return 0; /* XDEVIMPF_PIXEL_GEOMETRY; */
-}
-
/************************************************************************/
/* initialization */
@@ -717,7 +711,10 @@
CONSOLE_HAS_METHOD (gtk, mark_device);
CONSOLE_HAS_METHOD (gtk, delete_device);
CONSOLE_HAS_METHOD (gtk, device_system_metrics);
- CONSOLE_HAS_METHOD (gtk, device_implementation_flags);
+ /* CONSOLE_IMPLEMENTATION_FLAGS (gtk, XDEVIMPF_PIXEL_GEOMETRY); */
+ /* I inserted the above commented out statement, as the original
+ implementation of gtk_device_implementation_flags(), which I
+ deleted, contained commented out XDEVIMPF_PIXEL_GEOMETRY - kkm*/
}
void
Index: device-msw.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/device-msw.c,v
retrieving revision 1.24
diff -u -r1.24 device-msw.c
--- device-msw.c 2001/04/12 18:23:32 1.24
+++ device-msw.c 2001/05/03 06:26:51
@@ -334,12 +334,6 @@
return Qunbound;
}
-static unsigned int
-mswindows_device_implementation_flags (void)
-{
- return XDEVIMPF_PIXEL_GEOMETRY;
-}
-
/************************************************************************/
/* printer helpers */
@@ -527,14 +521,6 @@
mark_object (DEVICE_MSPRINTER_DEVMODE (d));
}
-static unsigned int
-msprinter_device_implementation_flags (void)
-{
- return ( XDEVIMPF_PIXEL_GEOMETRY
- | XDEVIMPF_IS_A_PRINTER
- | XDEVIMPF_NO_AUTO_REDISPLAY
- | XDEVIMPF_FRAMELESS_OK );
-}
/************************************************************************/
/* printer Lisp subroutines */
@@ -1291,13 +1277,17 @@
CONSOLE_HAS_METHOD (mswindows, mark_device);
CONSOLE_HAS_METHOD (mswindows, delete_device);
CONSOLE_HAS_METHOD (mswindows, device_system_metrics);
- CONSOLE_HAS_METHOD (mswindows, device_implementation_flags);
+ CONSOLE_IMPLEMENTATION_FLAGS (mswindows, XDEVIMPF_PIXEL_GEOMETRY);
CONSOLE_HAS_METHOD (msprinter, init_device);
CONSOLE_HAS_METHOD (msprinter, mark_device);
CONSOLE_HAS_METHOD (msprinter, delete_device);
CONSOLE_HAS_METHOD (msprinter, device_system_metrics);
- CONSOLE_HAS_METHOD (msprinter, device_implementation_flags);
+ CONSOLE_IMPLEMENTATION_FLAGS (msprinter, (XDEVIMPF_PIXEL_GEOMETRY
+ | XDEVIMPF_IS_A_PRINTER
+ | XDEVIMPF_NO_AUTO_REDISPLAY
+ | XDEVIMPF_DONT_PREEMPT_REDISPLAY
+ | XDEVIMPF_FRAMELESS_OK));
}
Index: device.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/device.c,v
retrieving revision 1.16
diff -u -r1.16 device.c
--- device.c 2001/04/12 18:23:33 1.16
+++ device.c 2001/05/03 06:26:52
@@ -1175,8 +1175,7 @@
Lisp_Object winsy = domain_device_type (domain);
struct console_methods *meth = decode_console_type (winsy, ERROR_ME_NOT);
assert (meth);
- return (MAYBE_INT_CONTYPE_METH (meth, device_implementation_flags, ())
- & XDEVIMPF_PIXEL_GEOMETRY);
+ return CONMETH_IMPL_FLAG (meth, XDEVIMPF_PIXEL_GEOMETRY);
}
DEFUN ("domain-device-type", Fdomain_device_type, 0, 1, 0, /*
Index: device.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/device.h,v
retrieving revision 1.9
diff -u -r1.9 device.h
--- device.h 2001/04/12 18:23:33 1.9
+++ device.h 2001/05/03 06:26:52
@@ -48,6 +48,7 @@
#define DEVICE_TYPE_NAME(d) ((d)->devmeths->name)
#define DEVICE_TYPE(d) ((d)->devmeths->symbol)
+#define DEVICE_IMPL_FLAG(d, f) CONMETH_IMPL_FLAG ((d)->devmeths, (f))
#define DEVICE_SPECIFIC_FRAME_PROPS(d) \
((d)->devmeths->device_specific_frame_props)
@@ -273,9 +274,7 @@
#define DEVICE_DISPLAY_P(dev) \
(DEVICE_LIVE_P (dev) && \
- (MAYBE_INT_DEVMETH (dev, \
- device_implementation_flags, ()) \
- & XDEVIMPF_IS_A_PRINTER) ? 0 : 1)
+ !DEVICE_IMPL_FLAG (dev, XDEVIMPF_IS_A_PRINTER))
#define CHECK_DISPLAY_DEVICE(dev) \
do { \
Index: frame.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/frame.c,v
retrieving revision 1.40
diff -u -r1.40 frame.c
--- frame.c 2001/04/12 18:23:47 1.40
+++ frame.c 2001/05/03 06:26:53
@@ -1304,9 +1304,8 @@
console = DEVICE_CONSOLE (d);
con = XCONSOLE (console);
- if (!called_from_delete_device &&
- !(MAYBE_INT_DEVMETH (d, device_implementation_flags, ())
- & XDEVIMPF_FRAMELESS_OK))
+ if (!called_from_delete_device
+ && !DEVICE_IMPL_FLAG (d, XDEVIMPF_FRAMELESS_OK))
{
/* If we're deleting the only non-minibuffer frame on the
device, delete the device. */
Index: redisplay.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/redisplay.c,v
retrieving revision 1.62
diff -u -r1.62 redisplay.c
--- redisplay.c 2001/04/12 18:24:14 1.62
+++ redisplay.c 2001/05/03 06:26:57
@@ -6276,7 +6276,8 @@
{
struct device *d = XDEVICE (f->device);
- if (preemption_check)
+ if (preemption_check
+ && !DEVICE_IMPL_FLAG (d, XDEVIMPF_DONT_PREEMPT_REDISPLAY))
{
/* The preemption check itself takes a lot of time,
so normally don't do it here. We do it if called
@@ -6436,27 +6437,29 @@
redisplay_device (struct device *d, int automatic)
{
Lisp_Object frame, frmcons;
- int preempted = 0;
int size_change_failed = 0;
struct frame *f;
- if (automatic
- && (MAYBE_INT_DEVMETH (d, device_implementation_flags, ())
- & XDEVIMPF_NO_AUTO_REDISPLAY))
+ if (automatic && DEVICE_IMPL_FLAG (d, XDEVIMPF_NO_AUTO_REDISPLAY))
return 0;
if (DEVICE_STREAM_P (d)) /* nothing to do */
return 0;
/* It is possible that redisplay has been called before the
- device is fully initialized. If so then continue with the
- next device. */
+ device is fully initialized, or that the console implementation
+ allows frameless devices. If so then continue with the next
+ device. */
if (NILP (DEVICE_SELECTED_FRAME (d)))
return 0;
- REDISPLAY_PREEMPTION_CHECK;
- if (preempted)
- return 1;
+ if (!DEVICE_IMPL_FLAG (d, XDEVIMPF_DONT_PREEMPT_REDISPLAY))
+ {
+ int preempted;
+ REDISPLAY_PREEMPTION_CHECK;
+ if (preempted)
+ return 1;
+ }
/* Always do the selected frame first. */
frame = DEVICE_SELECTED_FRAME (d);
@@ -6470,12 +6473,11 @@
{
if (CLASS_REDISPLAY_FLAGS_CHANGEDP(f))
{
- preempted = redisplay_frame (f, 0);
+ int preempted = redisplay_frame (f, 0);
+ if (preempted)
+ return 1;
}
- if (preempted)
- return 1;
-
/* If the frame redisplay did not get preempted, then this flag
should have gotten set to 0. It might be possible for that
not to happen if a size change event were to occur at an odd
@@ -6500,11 +6502,10 @@
{
if (CLASS_REDISPLAY_FLAGS_CHANGEDP (f))
{
- preempted = redisplay_frame (f, 0);
+ int preempted = redisplay_frame (f, 0);
+ if (preempted)
+ return 1;
}
-
- if (preempted)
- return 1;
if (f->size_change_pending)
size_change_failed = 1;