Commits

Jeff Sparkes committed 3b11491

Implement visible-bell in Gtk using cairo.

* redisplay.c (vars_of_redisplay): Document that Gtk supports
special values for visible-bell as well.

* redisplay-gtk.c (XLIKE_flash): Copy from redisplay-xlike-inc.c,
convert to cairo.

* redisplay-x.c (XLIKE_flash): Copy from redisplay-xlike-inc.c

Comments (0)

Files changed (5)

src/ChangeLog.GTK

+2012-05-08  Jeff Sparkes  <jsparkes@gmail.com>
+
+	* redisplay.c (vars_of_redisplay): Document that Gtk supports
+	special values for visible-bell as well.
+
+	* redisplay-gtk.c (XLIKE_flash): Copy from redisplay-xlike-inc.c,
+	convert to cairo.
+
+	* redisplay-x.c (XLIKE_flash): Copy from redisplay-xlike-inc.c
+
 2012-04-24  Jeff Sparkes  <jsparkes@gmail.com>
 
 	* redisplay-gtk.c (XLIKE_output_horizontal_line): Use a Gtk style

src/redisplay-gtk.c

 {
   struct frame *f = XFRAME (w->frame);
   GtkWidget *widget = FRAME_GTK_TEXT_WIDGET (f);
+  GtkStyle *gstyle = FRAME_GTK_TEXT_WIDGET (f)->style;
+  XLIKE_WINDOW x_win = GET_XLIKE_WINDOW (f);
   cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
   enum edge_style style;
   int x, ytop, ybottom, width, shadow_thickness, spacing;
   gtk_bevel_area (w, div_face, x + spacing, ytop,
 		  width - 2 * spacing, ybottom - ytop,
 		  shadow_thickness, EDGE_ALL, style);
+  gtk_paint_vline (gstyle, x_win, GTK_STATE_NORMAL, NULL,
+		   FRAME_GTK_TEXT_WIDGET (f), "vline", ytop + spacing,
+		   ybottom + spacing, x + width / 2);
   cairo_destroy (cr);
 }
 
 		       ypos3 + rb->object.hline.thickness / 2);
       /* gtk_fill_rectangle (cr, x, ypos3, width, rb->object.hline.thickness); */
     }
+  cairo_destroy (cr);
 }
 
 /* Make audible bell.  */
     }
 }
 
+static int
+XLIKE_flash (struct device *d)
+{
+  struct frame *f = device_selected_frame (d);
+  GtkWidget *widget = FRAME_GTK_TEXT_WIDGET (f);
+  cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+  struct window *w = XWINDOW (FRAME_ROOT_WINDOW (f));
+  Lisp_Object frame = wrap_frame (f);
+  int flash_height;
+
+  cr_set_foreground (cr, FACE_FOREGROUND (Vdefault_face, frame));
+  cairo_set_operator (cr, CAIRO_OPERATOR_XOR);
+  default_face_width_and_height (frame, 0, &flash_height);
+
+  /* If window is tall, flash top and bottom line.  */
+  if (EQ (Vvisible_bell, Qtop_bottom) && w->pixel_height > 3 * flash_height)
+    {
+      gtk_fill_rectangle (cr, w->pixel_left, w->pixel_top,
+			  w->pixel_width, flash_height);
+      gtk_fill_rectangle (cr, w->pixel_left,
+			  w->pixel_top + w->pixel_height - flash_height,
+			  w->pixel_width, flash_height);
+    }
+  else
+    /* If it is short, flash it all.  */
+    gtk_fill_rectangle (cr, w->pixel_left, w->pixel_top,
+			w->pixel_width, w->pixel_height);
+
+  gdk_flush ();
+  g_poll (NULL, 0, 100);
+
+  /* If window is tall, flash top and bottom line.  */
+  if (EQ (Vvisible_bell, Qtop_bottom) && w->pixel_height > 3 * flash_height)
+    {
+      gtk_fill_rectangle (cr, w->pixel_left, w->pixel_top,
+			  w->pixel_width, flash_height);
+      gtk_fill_rectangle (cr, w->pixel_left,
+			  w->pixel_top + w->pixel_height - flash_height,
+			  w->pixel_width, flash_height);
+    }
+  else
+    /* If it is short, flash it all.  */
+    gtk_fill_rectangle (cr, w->pixel_left, w->pixel_top,
+			w->pixel_width, w->pixel_height);
+
+  cairo_destroy (cr);
+  return 1;
+}
+
 static void
 XLIKE_output_eol_cursor (struct window *w, struct display_line *dl, int xpos,
 		       face_index findex)
   cairo_destroy (cr);
 }
 
-
 
 #include "sysgdkx.h"
 

src/redisplay-x.c

     }
 }
 
+/* briefly swap the foreground and background colors.
+ */
+static int
+XLIKE_flash (struct device *d)
+{
+  struct frame *f = device_selected_frame (d);
+  XLIKE_DISPLAY dpy = GET_XLIKE_X_DISPLAY (d);
+  XLIKE_WINDOW win = GET_XLIKE_WINDOW (f);
+  XLIKE_GC gc = NULL;
+  XLIKE_GCVALUES gcv;
+  XLIKE_PIXEL tmp_fcolor, tmp_bcolor;
+  Lisp_Object tmp_pixel, frame;
+  struct window *w = XWINDOW (FRAME_ROOT_WINDOW (f));
+  int flash_height;
+
+  frame = wrap_frame (f);
+
+  tmp_pixel = FACE_FOREGROUND (Vdefault_face, frame);
+  tmp_fcolor = XLIKE_COLOR_TO_PIXEL (XCOLOR_INSTANCE_XLIKE_COLOR (tmp_pixel));
+  tmp_pixel = FACE_BACKGROUND (Vdefault_face, frame);
+  tmp_bcolor = XLIKE_COLOR_TO_PIXEL (XCOLOR_INSTANCE_XLIKE_COLOR (tmp_pixel));
+  memset (&gcv, ~0, sizeof (gcv)); /* initialize all slots to ~0 */
+  XLIKE_SET_GC_PIXEL (gcv.foreground, tmp_fcolor ^ tmp_bcolor);
+  gcv.function = XLIKE_GX_XOR;
+  gcv.graphics_exposures = XLIKE_FALSE;
+  gc = gc_cache_lookup (DEVICE_XLIKE_GC_CACHE (XDEVICE (f->device)), &gcv,
+			XLIKE_GC_FOREGROUND | XLIKE_GC_FUNCTION | XLIKE_GC_EXPOSURES);
+  default_face_width_and_height (frame, 0, &flash_height);
+
+  /* If window is tall, flash top and bottom line.  */
+  if (EQ (Vvisible_bell, Qtop_bottom) && w->pixel_height > 3 * flash_height)
+    {
+      XLIKE_FILL_RECTANGLE (dpy, win, gc, w->pixel_left, w->pixel_top,
+			    w->pixel_width, flash_height);
+      XLIKE_FILL_RECTANGLE (dpy, win, gc, w->pixel_left,
+			    w->pixel_top + w->pixel_height - flash_height,
+			    w->pixel_width, flash_height);
+    }
+  else
+    /* If it is short, flash it all.  */
+    XLIKE_FILL_RECTANGLE (dpy, win, gc, w->pixel_left, w->pixel_top,
+			  w->pixel_width, w->pixel_height);
+
+  XLIKE_FLUSH (dpy);
+
+#ifdef HAVE_SELECT
+  {
+    int usecs = 100000;
+    struct timeval tv;
+    tv.tv_sec  = usecs / 1000000L;
+    tv.tv_usec = usecs % 1000000L;
+    /* I'm sure someone is going to complain about this... */
+    select (0, 0, 0, 0, &tv);
+  }
+#else
+#ifdef HAVE_POLL
+  poll (0, 0, 100);
+#else /* !HAVE_POLL */
+#error bite me
+#endif /* HAVE_POLL */
+#endif /* HAVE_SELECT */
+
+  /* If window is tall, flash top and bottom line.  */
+  if (EQ (Vvisible_bell, Qtop_bottom) && w->pixel_height > 3 * flash_height)
+    {
+      XLIKE_FILL_RECTANGLE (dpy, win, gc, w->pixel_left, w->pixel_top,
+			    w->pixel_width, flash_height);
+      XLIKE_FILL_RECTANGLE (dpy, win, gc, w->pixel_left,
+			    w->pixel_top + w->pixel_height - flash_height,
+			    w->pixel_width, flash_height);
+    }
+  else
+    /* If it is short, flash it all.  */
+    XLIKE_FILL_RECTANGLE (dpy, win, gc, w->pixel_left, w->pixel_top,
+			  w->pixel_width, w->pixel_height);
+
+  XLIKE_FLUSH (dpy);
+
+  return 1;
+}
+
 /* The end-of-line cursor is narrower than the normal cursor. */
 static void
 XLIKE_output_eol_cursor (struct window *w, struct display_line *dl, int xpos,

src/redisplay-xlike-inc.c

 				int width, int height, Lisp_Object fg,
 				Lisp_Object bg, Lisp_Object bg_pixmap,
 				Lisp_Object bg_placement);
+static int XLIKE_flash (struct device *d);
+
 #ifdef THIS_IS_X
 static void XLIKE_window_output_begin (struct window *UNUSED (w));
 static void XLIKE_window_output_end (struct window *w);
 #endif /* THIS_IS_X */
 }
 
-/* briefly swap the foreground and background colors.
- */
-
-static int
-XLIKE_flash (struct device *d)
-{
-  struct frame *f = device_selected_frame (d);
-  XLIKE_DISPLAY dpy = GET_XLIKE_X_DISPLAY (d);
-  XLIKE_WINDOW win = GET_XLIKE_WINDOW (f);
-  XLIKE_GC gc = NULL;
-  XLIKE_GCVALUES gcv;
-  XLIKE_PIXEL tmp_fcolor, tmp_bcolor;
-  Lisp_Object tmp_pixel, frame;
-  struct window *w = XWINDOW (FRAME_ROOT_WINDOW (f));
-  int flash_height;
-
-  frame = wrap_frame (f);
-
-  tmp_pixel = FACE_FOREGROUND (Vdefault_face, frame);
-  tmp_fcolor = XLIKE_COLOR_TO_PIXEL (XCOLOR_INSTANCE_XLIKE_COLOR (tmp_pixel));
-  tmp_pixel = FACE_BACKGROUND (Vdefault_face, frame);
-  tmp_bcolor = XLIKE_COLOR_TO_PIXEL (XCOLOR_INSTANCE_XLIKE_COLOR (tmp_pixel));
-  memset (&gcv, ~0, sizeof (gcv)); /* initialize all slots to ~0 */
-  XLIKE_SET_GC_PIXEL (gcv.foreground, tmp_fcolor ^ tmp_bcolor);
-  gcv.function = XLIKE_GX_XOR;
-  gcv.graphics_exposures = XLIKE_FALSE;
-  gc = gc_cache_lookup (DEVICE_XLIKE_GC_CACHE (XDEVICE (f->device)), &gcv,
-			XLIKE_GC_FOREGROUND | XLIKE_GC_FUNCTION | XLIKE_GC_EXPOSURES);
-  default_face_width_and_height (frame, 0, &flash_height);
-
-  /* If window is tall, flash top and bottom line.  */
-  if (EQ (Vvisible_bell, Qtop_bottom) && w->pixel_height > 3 * flash_height)
-    {
-      XLIKE_FILL_RECTANGLE (dpy, win, gc, w->pixel_left, w->pixel_top,
-			    w->pixel_width, flash_height);
-      XLIKE_FILL_RECTANGLE (dpy, win, gc, w->pixel_left,
-			    w->pixel_top + w->pixel_height - flash_height,
-			    w->pixel_width, flash_height);
-    }
-  else
-    /* If it is short, flash it all.  */
-    XLIKE_FILL_RECTANGLE (dpy, win, gc, w->pixel_left, w->pixel_top,
-			  w->pixel_width, w->pixel_height);
-
-  XLIKE_FLUSH (dpy);
-
-#ifdef HAVE_SELECT
-  {
-    int usecs = 100000;
-    struct timeval tv;
-    tv.tv_sec  = usecs / 1000000L;
-    tv.tv_usec = usecs % 1000000L;
-    /* I'm sure someone is going to complain about this... */
-    select (0, 0, 0, 0, &tv);
-  }
-#else
-#ifdef HAVE_POLL
-  poll (0, 0, 100);
-#else /* !HAVE_POLL */
-#error bite me
-#endif /* HAVE_POLL */
-#endif /* HAVE_SELECT */
-
-  /* If window is tall, flash top and bottom line.  */
-  if (EQ (Vvisible_bell, Qtop_bottom) && w->pixel_height > 3 * flash_height)
-    {
-      XLIKE_FILL_RECTANGLE (dpy, win, gc, w->pixel_left, w->pixel_top,
-			    w->pixel_width, flash_height);
-      XLIKE_FILL_RECTANGLE (dpy, win, gc, w->pixel_left,
-			    w->pixel_top + w->pixel_height - flash_height,
-			    w->pixel_width, flash_height);
-    }
-  else
-    /* If it is short, flash it all.  */
-    XLIKE_FILL_RECTANGLE (dpy, win, gc, w->pixel_left, w->pixel_top,
-			  w->pixel_width, w->pixel_height);
-
-  XLIKE_FLUSH (dpy);
-
-  return 1;
-}
-
 
 /************************************************************************/
 /*                            initialization                            */
 `top-bottom'    Flash only the top and bottom lines of the selected frame.
 
 When effects are unavailable on a platform, the visual bell is the
-default, whole screen.  (Currently only X supports any special effects.)
+default, whole screen.  (Currently only X and Gtk support any special effects.)
 */ );
   Vvisible_bell = Qnil;
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.