#include "xterm.h"
#include <X11/cursorfont.h>
+/* If we have Xfixes extension, use it for pointer blanking. */
+#ifdef HAVE_XFIXES
+#include <X11/extensions/Xfixes.h>
+#endif
+
/* Load sys/types.h if not already loaded.
In some systems loading it twice is suicidal. */
#ifndef makedev
void
record_event (char *locus, int type)
{
- if (event_record_index == sizeof (event_record) / sizeof (struct record))
+ if (event_record_index == ARRAYELTS (event_record))
event_record_index = 0;
event_record[event_record_index].locus = locus;
s->stippled_p = s->face->stipple != 0;
}
else
- {
- s->gc = s->face->gc;
- s->stippled_p = s->face->stipple != 0;
- }
+ emacs_abort ();
/* GC must have been set. */
eassert (s->gc != 0);
XTtoggle_invisible_pointer (struct frame *f, int invisible)
{
block_input ();
- if (invisible)
- {
- if (FRAME_DISPLAY_INFO (f)->invisible_cursor != 0)
- XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
- FRAME_DISPLAY_INFO (f)->invisible_cursor);
- }
- else
- XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
- f->output_data.x->current_cursor);
- f->pointer_invisible = invisible;
+ FRAME_DISPLAY_INFO (f)->toggle_visible_pointer (f, invisible);
unblock_input ();
}
static short temp_buffer[100];
#define STORE_KEYSYM_FOR_DEBUG(keysym) \
- if (temp_index == sizeof temp_buffer / sizeof (short)) \
+ if (temp_index == ARRAYELTS (temp_buffer)) \
temp_index = 0; \
temp_buffer[temp_index++] = (keysym)
#ifdef USE_GTK
- if (xg_set_icon (f, xg_default_icon_file)
- || xg_set_icon_from_xpm_data (f, gnu_xpm_bits))
- return 0;
+ if (FRAME_DISPLAY_INFO (f)->icon_bitmap_id == -2
+ || xg_set_icon (f, xg_default_icon_file)
+ || xg_set_icon_from_xpm_data (f, gnu_xpm_bits))
+ {
+ FRAME_DISPLAY_INFO (f)->icon_bitmap_id = -2;
+ return 0;
+ }
#elif defined (HAVE_XPM) && defined (HAVE_X_WINDOWS)
}
#endif
+/* Create invisible cursor on X display referred by DPYINFO. */
+
+static Cursor
+make_invisible_cursor (struct x_display_info *dpyinfo)
+{
+ Display *dpy = dpyinfo->display;
+ static char const no_data[] = { 0 };
+ Pixmap pix;
+ XColor col;
+ Cursor c = 0;
+
+ x_catch_errors (dpy);
+ pix = XCreateBitmapFromData (dpy, dpyinfo->root_window, no_data, 1, 1);
+ if (! x_had_errors_p (dpy) && pix != None)
+ {
+ Cursor pixc;
+ col.pixel = 0;
+ col.red = col.green = col.blue = 0;
+ col.flags = DoRed | DoGreen | DoBlue;
+ pixc = XCreatePixmapCursor (dpy, pix, pix, &col, &col, 0, 0);
+ if (! x_had_errors_p (dpy) && pixc != None)
+ c = pixc;
+ XFreePixmap (dpy, pix);
+ }
+
+ x_uncatch_errors ();
+
+ return c;
+}
+
+/* True if DPY supports Xfixes extension >= 4. */
+
+static bool
+x_probe_xfixes_extension (Display *dpy)
+{
+#ifdef HAVE_XFIXES
+ int major, minor;
+ return XFixesQueryVersion (dpy, &major, &minor) && major >= 4;
+#else
+ return false;
+#endif /* HAVE_XFIXES */
+}
+
+/* Toggle mouse pointer visibility on frame F by using Xfixes functions. */
+
+static void
+xfixes_toggle_visible_pointer (struct frame *f, bool invisible)
+{
+#ifdef HAVE_XFIXES
+ if (invisible)
+ XFixesHideCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
+ else
+ XFixesShowCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
+ f->pointer_invisible = invisible;
+#else
+ emacs_abort ();
+#endif /* HAVE_XFIXES */
+}
+
+/* Toggle mouse pointer visibility on frame F by using invisible cursor. */
+
+static void
+x_toggle_visible_pointer (struct frame *f, bool invisible)
+{
+ eassert (FRAME_DISPLAY_INFO (f)->invisible_cursor != 0);
+ if (invisible)
+ XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+ FRAME_DISPLAY_INFO (f)->invisible_cursor);
+ else
+ XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+ f->output_data.x->current_cursor);
+ f->pointer_invisible = invisible;
+}
+
+/* Setup pointer blanking, prefer Xfixes if available. */
+
+static void
+x_setup_pointer_blanking (struct x_display_info *dpyinfo)
+{
+ if (x_probe_xfixes_extension (dpyinfo->display))
+ dpyinfo->toggle_visible_pointer = xfixes_toggle_visible_pointer;
+ else
+ {
+ dpyinfo->toggle_visible_pointer = x_toggle_visible_pointer;
+ dpyinfo->invisible_cursor = make_invisible_cursor (dpyinfo);
+ }
+}
+
/* Current X display connection identifier. Incremented for each next
connection established. */
static unsigned x_display_id;
};
int i;
- const int atom_count = sizeof (atom_refs) / sizeof (atom_refs[0]);
+ const int atom_count = ARRAYELTS (atom_refs);
/* 1 for _XSETTINGS_SN */
const int total_atom_count = 1 + atom_count;
Atom *atoms_return = xmalloc (total_atom_count * sizeof *atoms_return);
gray_bits, gray_width, gray_height,
1, 0, 1);
+ x_setup_pointer_blanking (dpyinfo);
+
#ifdef HAVE_X_I18N
xim_initialize (dpyinfo, resource_name);
#endif
#ifdef USE_LUCID
{
+ XFontStruct *xfont = NULL;
XrmValue d, fr, to;
Font font;
x_catch_errors (dpy);
if (!XtCallConverter (dpy, XtCvtStringToFont, &d, 1, &fr, &to, NULL))
emacs_abort ();
- if (x_had_errors_p (dpy) || !XQueryFont (dpy, font))
+ if (x_had_errors_p (dpy) || !((xfont = XQueryFont (dpy, font))))
XrmPutLineResource (&xrdb, "Emacs.dialog.*.font: 9x15");
+ if (xfont)
+ XFreeFont (dpy, xfont);
x_uncatch_errors ();
}
#endif