diff src/redisplay-xlike-inc.c @ 5080:5502045ec510

The background-placement face property. -------------------- ChangeLog entries follow: -------------------- lisp/ChangeLog addition: 2010-02-25 Didier Verna <didier@xemacs.org> The background-placement face property. * cl-macs.el (face-background-placement): New defsetf. * cus-face.el (custom-face-attributes): * faces.el (face-interactive): * faces.el (set-face-property): * faces.el (face-equal): * faces.el (init-other-random-faces): Update. * faces.el (face-background-placement): * faces.el (set-face-background-placement): * faces.el (face-background-placement-instance): * faces.el (face-background-placement-instance-p): * frame.el (set-frame-background-placement): * frame.el (frame-background-placement): * frame.el (frame-background-placement-instance): * objects.el (make-face-background-placement-specifier): New. man/ChangeLog addition: 2010-02-25 Didier Verna <didier@xemacs.org> The background-placement face property. * xemacs/custom.texi (Faces): Document it. src/ChangeLog addition: 2010-02-25 Didier Verna <didier@xemacs.org> The background-placement face property. * console-x-impl.h (struct x_frame): Add new slots x and y. * console-x-impl.h (FRAME_X_X, FRAME_X_Y): New slot accessors. * console-gtk-impl.h: Fake something similar for potential port. * frame-x.c (x_get_frame_text_position): New function. * frame-x.c (x_init_frame_3): Use it. * event-Xt.c (emacs_Xt_handle_magic_event): Eat spurious ConfigureNotify events, get the frame position and mark frame faces changed. * objects-impl.h: The face_background_placement_specifier structure and its accessors. * objects.c: New symbols Qabsolute and Qrelative. * objects.c (face_background_placement_create): * objects.c (face_background_placement_mark): * objects.c (face_background_placement_instantiate): * objects.c (face_background_placement_validate): * objects.c (face_background_placement_after_change): * objects.c (set_face_background_placement_attached_to): New. * objects.h (set_face_background_palcement_attached_to): Declare the one above. * objects.c (syms_of_objects): * objects.c (specifier_type_create_objects): * objects.c (reinit_specifier_type_create_objects): * objects.c (reinit_vars_of_objects): Update for the modifications above. * console-xlike-inc.h (XLIKE_GC_TS_X_ORIGIN, XLIKE_GC_TS_X_ORIGIN): New X11/Gtk compatibility macros. * redisplay-xlike-inc.c (XLIKE_get_gc): Add a background placement argument and handle it. * gtk-glue.c (face_to_gc): * redisplay-xlike-inc.c (XLIKE_output_string): * redisplay-xlike-inc.c (XLIKE_output_pixmap): * redisplay-xlike-inc.c (XLIKE_output_blank): * redisplay-xlike-inc.c (XLIKE_output_horizontal_line): * redisplay-xlike-inc.c (XLIKE_output_eol_cursor): Update accordingly. * console-impl.h (struct console_methods): Add a background placement (Lisp_Object) argument to the clear_region method. * console-stream.c (stream_clear_region): * redisplay-tty.c (tty_clear_region): * redisplay-msw.c (mswindows_clear_region): * redisplay-xlike-inc.c (XLIKE_clear_region): Update accordingly. * redisplay-output.c (redisplay_clear_region): Handle the background placement property and update the call to the clear_region method. * faces.h (struct Lisp_Face): * faces.h (struct face_cachel): Add a background placement slot. * faces.h (WINDOW_FACE_CACHEL_BACKGROUND_PLACEMENT): New accessor. * faces.c (mark_face): * faces.c (face_equal): * faces.c (face_getprop): * faces.c (face_putprop): * faces.c (face_remprop): * faces.c (face_plist): * faces.c (reset_face): * faces.c (mark_face_cachels): * faces.c (update_face_cachel_data): * faces.c (merge_face_cachel_data): * faces.c (reset_face_cachel): * faces.c (Fmake_face): * faces.c (Fcopy_face): Handle the background placement property. * faces.c (syms_of_faces): * faces.c (vars_of_faces): * faces.c (complex_vars_of_faces): Update accordingly.
author Didier Verna <didier@lrde.epita.fr>
date Thu, 25 Feb 2010 16:19:01 +0100
parents 8af6a32b170d
children 0ca81354c4c7
line wrap: on
line diff
--- a/src/redisplay-xlike-inc.c	Thu Feb 25 06:14:50 2010 -0600
+++ b/src/redisplay-xlike-inc.c	Thu Feb 25 16:19:01 2010 +0100
@@ -3,6 +3,7 @@
    Copyright (C) 1994 Lucid, Inc.
    Copyright (C) 1995 Sun Microsystems, Inc.
    Copyright (C) 2002, 2003, 2005, 2009, 2010 Ben Wing.
+   Copyright (C) 2010 Didier Verna
 
 This file is part of XEmacs.
 
@@ -812,8 +813,9 @@
 
 /* Called as gtk_get_gc from gtk-glue.c */
 
-XLIKE_GC XLIKE_get_gc (struct frame *f, Lisp_Object font, Lisp_Object fg, 
-		       Lisp_Object bg, Lisp_Object bg_pmap,
+XLIKE_GC XLIKE_get_gc (struct frame *f, Lisp_Object font,
+		       Lisp_Object fg, Lisp_Object bg,
+		       Lisp_Object bg_pixmap, Lisp_Object bg_placement,
 		       Lisp_Object lwidth);
 
 /*****************************************************************************
@@ -822,8 +824,10 @@
  Given a number of parameters return a GC with those properties.
  ****************************************************************************/
 XLIKE_GC
-XLIKE_get_gc (struct frame *f, Lisp_Object font, Lisp_Object fg, 
-	      Lisp_Object bg, Lisp_Object bg_pmap, Lisp_Object lwidth)
+XLIKE_get_gc (struct frame *f, Lisp_Object font, 
+	      Lisp_Object fg, Lisp_Object bg,
+	      Lisp_Object bg_pixmap, Lisp_Object bg_placement, 
+	      Lisp_Object lwidth)
 {
   struct device *d = XDEVICE (f->device);
   XLIKE_GCVALUES gcv;
@@ -837,7 +841,8 @@
   gcv.clip_x_origin = 0;
   gcv.clip_y_origin = 0;
   XLIKE_SET_GC_FILL (gcv, XLIKE_FILL_SOLID);
-  mask = XLIKE_GC_EXPOSURES | XLIKE_GC_CLIP_MASK | XLIKE_GC_CLIP_X_ORIGIN | XLIKE_GC_CLIP_Y_ORIGIN;
+  mask = XLIKE_GC_EXPOSURES
+    | XLIKE_GC_CLIP_MASK | XLIKE_GC_CLIP_X_ORIGIN | XLIKE_GC_CLIP_Y_ORIGIN;
   mask |= XLIKE_GC_FILL;
 
   if (!NILP (font)
@@ -883,7 +888,7 @@
 
   /* This special case comes from a request to draw text with a face which has
      the dim property. We'll use a stippled foreground GC. */
-  if (EQ (bg_pmap, Qdim))
+  if (EQ (bg_pixmap, Qdim))
     {
       assert (DEVICE_XLIKE_GRAY_PIXMAP (d) != XLIKE_NONE);
 
@@ -891,21 +896,35 @@
       gcv.stipple = DEVICE_XLIKE_GRAY_PIXMAP (d);
       mask |= (XLIKE_GC_FILL | XLIKE_GC_STIPPLE);
     }
-  else if (IMAGE_INSTANCEP (bg_pmap)
-	   && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
+  else if (IMAGE_INSTANCEP (bg_pixmap)
+	   && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pixmap)))
     {
-      if (XIMAGE_INSTANCE_PIXMAP_DEPTH (bg_pmap) == 0)
+      if (XIMAGE_INSTANCE_PIXMAP_DEPTH (bg_pixmap) == 0)
 	{
 	  XLIKE_SET_GC_FILL (gcv, XLIKE_FILL_OPAQUE_STIPPLED);
-	  gcv.stipple = XIMAGE_INSTANCE_XLIKE_PIXMAP (bg_pmap);
+	  gcv.stipple = XIMAGE_INSTANCE_XLIKE_PIXMAP (bg_pixmap);
 	  mask |= (XLIKE_GC_STIPPLE | XLIKE_GC_FILL);
 	}
       else
 	{
 	  XLIKE_SET_GC_FILL (gcv, XLIKE_FILL_TILED);
-	  gcv.tile = XIMAGE_INSTANCE_XLIKE_PIXMAP (bg_pmap);
+	  gcv.tile = XIMAGE_INSTANCE_XLIKE_PIXMAP (bg_pixmap);
 	  mask |= (XLIKE_GC_TILE | XLIKE_GC_FILL);
 	}
+      if (EQ (bg_placement, Qabsolute))
+	{
+#ifdef THIS_IS_GTK
+	  /* #### WARNING: this does not currently work. -- dvl
+	     gcv.ts_x_origin = - FRAME_GTK_X (f);
+	     gcv.ts_y_origin = - FRAME_GTK_Y (f);
+	     mask |= (XLIKE_GC_TS_X_ORIGIN | XLIKE_GC_TS_Y_ORIGIN);
+	  */
+#else
+	  gcv.ts_x_origin = - FRAME_X_X (f);
+	  gcv.ts_y_origin = - FRAME_X_Y (f);
+	  mask |= (XLIKE_GC_TS_X_ORIGIN | XLIKE_GC_TS_Y_ORIGIN);
+#endif
+	}
     }
 
   if (!NILP (lwidth))
@@ -1078,7 +1097,7 @@
     bgc = 0;
   else
     bgc = XLIKE_get_gc (f, Qnil, cachel->foreground, cachel->background,
-			bg_pmap, Qnil);
+			bg_pmap, cachel->background_placement, Qnil);
 
   if (bgc)
     {
@@ -1159,7 +1178,7 @@
 	  bg = XFT_FROB_LISP_COLOR (cursor_cachel->background, 0);
 #endif
 	  gc = XLIKE_get_gc (f, font, cursor_cachel->foreground,
-			     cursor_cachel->background, Qnil, Qnil);
+			     cursor_cachel->background, Qnil, Qnil, Qnil);
 	}
       else if (cachel->dim)
 	{
@@ -1181,7 +1200,7 @@
 	  bg = XFT_FROB_LISP_COLOR (cachel->background, 0);
 #endif
 	  gc = XLIKE_get_gc (f, font, cachel->foreground, cachel->background,
-			     Qdim, Qnil);
+			     Qdim, Qnil, Qnil);
 	}
       else
 	{
@@ -1190,7 +1209,7 @@
 	  bg = XFT_FROB_LISP_COLOR (cachel->background, 0);
 #endif
 	  gc = XLIKE_get_gc (f, font, cachel->foreground, cachel->background,
-			     Qnil, Qnil);
+			     Qnil, Qnil, Qnil);
 	}
 #ifdef USE_XFT
       {
@@ -1464,7 +1483,7 @@
 	      XLIKE_RECTANGLE clip_box;
 	      XLIKE_GC cgc;
 	      cgc = XLIKE_get_gc (f, font, cursor_cachel->foreground,
-				  cursor_cachel->background, Qnil, Qnil);
+				  cursor_cachel->background, Qnil, Qnil, Qnil);
 
 	      clip_box.x = 0;
 	      clip_box.y = 0;
@@ -1535,13 +1554,14 @@
 
       if (!NILP (bar_cursor_value))
 	{
-	  gc = XLIKE_get_gc (f, Qnil, cursor_cachel->background, Qnil, Qnil,
+	  gc = XLIKE_get_gc (f, Qnil, cursor_cachel->background, Qnil,
+			     Qnil, Qnil,
 			     make_int (bar_width));
 	}
       else
 	{
 	  gc = XLIKE_get_gc (f, Qnil, cursor_cachel->background,
-			     Qnil, Qnil, Qnil);
+			     Qnil, Qnil, Qnil, Qnil);
 	}
 
       tmp_y = dl->ypos - bogusly_obtained_ascent_value;
@@ -1729,7 +1749,8 @@
 			    get_builtin_face_cache_index
 			    (w, Vtext_cursor_face));
 
-      gc = XLIKE_get_gc (f, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
+      gc = XLIKE_get_gc (f, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil,
+			 Qnil);
 
       if (cursor_width > db->xpos + dga->width - cursor_start)
 	cursor_width = db->xpos + dga->width - cursor_start;
@@ -1874,10 +1895,12 @@
 
   if (NILP (bg_pmap))
     gc = XLIKE_get_gc (f, Qnil, WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex),
-		       Qnil, Qnil, Qnil);
+		       Qnil, Qnil, Qnil, Qnil);
   else
     gc = XLIKE_get_gc (f, Qnil, WINDOW_FACE_CACHEL_FOREGROUND (w, rb->findex),
-		       WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex), bg_pmap,
+		       WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex),
+		       bg_pmap,
+		       WINDOW_FACE_CACHEL_BACKGROUND_PLACEMENT (w, rb->findex),
 		       Qnil);
 
   XLIKE_FILL_RECTANGLE (dpy, x_win, gc, x, y, width, height);
@@ -1898,7 +1921,8 @@
 			   (WINDOW_FACE_CACHEL (w, rb->findex),
 			    Vcharset_ascii));
 
-      gc = XLIKE_get_gc (f, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
+      gc = XLIKE_get_gc (f, Qnil, cursor_cachel->background, Qnil,
+			 Qnil, Qnil, Qnil);
 
       cursor_y = dl->ypos - fi->ascent;
       cursor_height = fi->height;
@@ -1917,7 +1941,8 @@
 	      int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
 
 	      gc = XLIKE_get_gc (f, Qnil, cursor_cachel->background,
-				 Qnil, Qnil, make_int (bar_width));
+				 Qnil, Qnil, Qnil,
+				 make_int (bar_width));
 	      XLIKE_DRAW_LINE (dpy, x_win, gc, cursor_start + bar_width - 1,
 			       cursor_y, cursor_start + bar_width - 1,
 			       cursor_y + cursor_height - 1);
@@ -1962,7 +1987,7 @@
     {
       gc = XLIKE_get_gc (f, Qnil,
 			 WINDOW_FACE_CACHEL_FOREGROUND (w, rb->findex),
-			 Qnil, Qnil, Qnil);
+			 Qnil, Qnil, Qnil, Qnil);
 
       if (ypos2 - ypos1 > 0)
 	XLIKE_FILL_RECTANGLE (dpy, x_win, gc, x, ypos1, width, ypos2 - ypos1);
@@ -1979,7 +2004,7 @@
 #else /* THIS_IS_X */
   /* Now draw the line. */
   gc = XLIKE_get_gc (f, Qnil, WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex),
-		     Qnil, Qnil, Qnil);
+		     Qnil, Qnil, Qnil, Qnil);
 
   if (ypos2 < ypos1)
     ypos2 = ypos1;
@@ -2000,8 +2025,10 @@
 static void
 XLIKE_clear_region (Lisp_Object UNUSED (locale), struct device* d,
 		    struct frame* f, face_index UNUSED (findex), int x, int y,
-		    int width, int height, Lisp_Object fcolor,
-		    Lisp_Object bcolor, Lisp_Object background_pixmap)
+		    int width, int height,
+		    Lisp_Object fcolor, Lisp_Object bcolor,
+		    Lisp_Object background_pixmap,
+		    Lisp_Object background_placement)
 {
   XLIKE_DISPLAY dpy = GET_XLIKE_DISPLAY (d);
   XLIKE_WINDOW x_win = GET_XLIKE_WINDOW (f);
@@ -2009,7 +2036,8 @@
 
   if (!UNBOUNDP (background_pixmap))
     {
-      gc = XLIKE_get_gc (f, Qnil, fcolor, bcolor, background_pixmap, Qnil);
+      gc = XLIKE_get_gc (f, Qnil, fcolor, bcolor,
+			 background_pixmap, background_placement, Qnil);
     }
 
   if (gc)
@@ -2055,7 +2083,8 @@
   if (NILP (w->text_cursor_visible_p))
     return;
 
-  gc = XLIKE_get_gc (f, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
+  gc = XLIKE_get_gc (f, Qnil, cursor_cachel->background, Qnil,
+		     Qnil, Qnil, Qnil);
 
   default_face_font_info (window, &defascent, 0, 0, &defheight, 0);
 
@@ -2079,7 +2108,8 @@
 	{
 	  int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
 
-	  gc = XLIKE_get_gc (f, Qnil, cursor_cachel->background, Qnil, Qnil,
+	  gc = XLIKE_get_gc (f, Qnil, cursor_cachel->background, Qnil,
+			     Qnil, Qnil,
 			     make_int (bar_width));
 	  XLIKE_DRAW_LINE (dpy, x_win, gc, x + bar_width - 1, cursor_y,
 			   x + bar_width - 1, cursor_y + cursor_height - 1);