--- glyphs.c~ Mon Mar 20 20:43:49 2000 +++ glyphs.c Wed Mar 22 09:16:50 2000 @@ -2789,18 +2789,11 @@ Lisp_Object pointer_fg = Qnil; Lisp_Object pointer_bg = Qnil; - if (dest_mask & (IMAGE_SUBWINDOW_MASK - | IMAGE_WIDGET_MASK - | IMAGE_TEXT_MASK)) - { - if (!WINDOWP (domain)) - signal_simple_error ("Can't instantiate text or subwindow outside a window", - instantiator); - else if ((dest_mask & (IMAGE_SUBWINDOW_MASK - | IMAGE_WIDGET_MASK)) - && MINI_WINDOW_P (XWINDOW (domain))) - domain = Fnext_window (domain, Qnil, Qnil, Qnil); - } + /* We have to put subwindow, widget and text image instances in + a per-window cache so that we can see the same glyph in + different windows. Unfortunately we do not know the type of + image_instance until after it has been created. We thus need + to be really careful how we place things. */ if (pointerp) { @@ -2855,11 +2848,25 @@ && dest_mask & (IMAGE_SUBWINDOW_MASK | IMAGE_WIDGET_MASK - | IMAGE_TEXT_MASK)) + | IMAGE_LAYOUT_MASK + | IMAGE_TEXT_MASK) + && WINDOWP (domain)) { instance = Fgethash (instantiator, XWINDOW (domain)->subwindow_instance_cache, Qunbound); + /* If we failed to get an instance try modifying the + domain slightly. */ + if (UNBOUNDP (instance) + && (dest_mask & (IMAGE_SUBWINDOW_MASK + | IMAGE_WIDGET_MASK + | IMAGE_LAYOUT_MASK)) + && MINI_WINDOW_P (XWINDOW (domain))) + instance = Fgethash + (instantiator, + XWINDOW (Fnext_window (domain, + Qnil, Qnil, Qnil))-> subwindow_instance_cache, + Qunbound); } } @@ -2894,8 +2901,18 @@ & (IMAGE_SUBWINDOW_MASK | IMAGE_WIDGET_MASK + | IMAGE_LAYOUT_MASK | IMAGE_TEXT_MASK )) { + if (!WINDOWP (domain)) + signal_simple_error ("Can't instantiate text or subwindow outside a window", + instantiator); + else if ((dest_mask & (IMAGE_SUBWINDOW_MASK + | IMAGE_WIDGET_MASK + | IMAGE_LAYOUT_MASK)) + && MINI_WINDOW_P (XWINDOW (domain))) + domain = Fnext_window (domain, Qnil, Qnil, Qnil); + Fsetcdr (XCDR (locative), XWINDOW (domain)->subwindow_instance_cache); } unbind_to (speccount, Qnil); @@ -2906,6 +2923,12 @@ if (NILP (instance)) signal_simple_error ("Can't instantiate image (probably cached)", instantiator); +#ifdef ERROR_CHECK_GLYPHS + if (image_instance_type_to_mask (XIMAGE_INSTANCE_TYPE (instance)) + & (IMAGE_SUBWINDOW_MASK | IMAGE_WIDGET_MASK)) + assert (EQ (XIMAGE_INSTANCE_SUBWINDOW_FRAME (instance), + FW_FRAME (domain))); +#endif return instance; }