int *, struct input_event *);
/* Don't declare this NO_RETURN because we want no
interference with debugging failing X calls. */
-static SIGTYPE x_connection_closed (Display *, const char *);
+static void x_connection_closed (Display *, const char *);
/* Flush display of frame F, or of all frames if F is null. */
/* We don't set the output cursor here because there will always
follow an explicit cursor_to. */
BLOCK_INPUT;
- XClearWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
- /* We have to clear the scroll bars, too. If we have changed
- colors or something like that, then they should be notified. */
+ /* The following calls have been commented out because they do not
+ seem to accomplish anything, apart from causing flickering during
+ window resize. */
+ /* XClearWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); */
+
+ /* We have to clear the scroll bars. If we have changed colors or
+ something like that, then they should be notified. */
x_scroll_bar_clear (f);
#if defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS)
/* Use Gdk routines to draw. This way, we won't draw over scroll bars
when the scroll bars and the edit widget share the same X window. */
GdkWindow *window = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
+#ifdef HAVE_GTK3
+ cairo_t *cr = gdk_cairo_create (window);
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_set_operator (cr, CAIRO_OPERATOR_DIFFERENCE);
+#define XFillRectangle(d, win, gc, x, y, w, h) \
+ do { \
+ cairo_rectangle (cr, x, y, w, h); \
+ cairo_fill (cr); \
+ } \
+ while (0)
+#else /* ! HAVE_GTK3 */
GdkGCValues vals;
GdkGC *gc;
vals.foreground.pixel = (FRAME_FOREGROUND_PIXEL (f)
&vals, GDK_GC_FUNCTION | GDK_GC_FOREGROUND);
#define XFillRectangle(d, win, gc, x, y, w, h) \
gdk_draw_rectangle (window, gc, TRUE, x, y, w, h)
-#else
+#endif /* ! HAVE_GTK3 */
+#else /* ! USE_GTK */
GC gc;
/* Create a GC that will use the GXxor function to flip foreground
width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
#ifdef USE_GTK
+#ifdef HAVE_GTK3
+ cairo_destroy (cr);
+#else
g_object_unref (G_OBJECT (gc));
+#endif
#undef XFillRectangle
#else
XFreeGC (FRAME_X_DISPLAY (f), gc);
return XSCROLL_BAR (bar);
}
- return 0;
+ return NULL;
}
x_send_scroll_bar_event and x_scroll_bar_to_input_event. */
static struct window **scroll_bar_windows;
-static int scroll_bar_windows_size;
+static size_t scroll_bar_windows_size;
/* Send a client message with message type Xatom_Scrollbar for a
XClientMessageEvent *ev = (XClientMessageEvent *) &event;
struct window *w = XWINDOW (window);
struct frame *f = XFRAME (w->frame);
- int i;
+ size_t i;
BLOCK_INPUT;
if (i == scroll_bar_windows_size)
{
- int new_size = max (10, 2 * scroll_bar_windows_size);
+ size_t new_size = max (10, 2 * scroll_bar_windows_size);
size_t nbytes = new_size * sizeof *scroll_bar_windows;
size_t old_nbytes = scroll_bar_windows_size * sizeof *scroll_bar_windows;
+ if ((size_t) -1 / sizeof *scroll_bar_windows < new_size)
+ memory_full ();
scroll_bar_windows = (struct window **) xrealloc (scroll_bar_windows,
nbytes);
memset (&scroll_bar_windows[i], 0, nbytes - old_nbytes);
{
XClientMessageEvent *ev = (XClientMessageEvent *) event;
Lisp_Object window;
- struct frame *f;
struct window *w;
w = scroll_bar_windows[ev->data.l[0]];
scroll_bar_windows[ev->data.l[0]] = NULL;
XSETWINDOW (window, w);
- f = XFRAME (w->frame);
ievent->kind = SCROLL_BAR_CLICK_EVENT;
ievent->frame_or_window = window;
#ifdef USE_GTK
ievent->timestamp = CurrentTime;
#else
- ievent->timestamp = XtLastTimestampProcessed (FRAME_X_DISPLAY (f));
+ ievent->timestamp =
+ XtLastTimestampProcessed (FRAME_X_DISPLAY (XFRAME (w->frame)));
#endif
ievent->part = ev->data.l[1];
ievent->code = ev->data.l[2];
goto OTHER;
#endif /* USE_X_TOOLKIT */
{
- XSelectionClearEvent *eventp = (XSelectionClearEvent *) &event;
+ XSelectionClearEvent *eventp = &(event.xselectionclear);
inev.ie.kind = SELECTION_CLEAR_EVENT;
SELECTION_EVENT_DISPLAY (&inev.sie) = eventp->display;
goto OTHER;
#endif /* USE_X_TOOLKIT */
{
- XSelectionRequestEvent *eventp
- = (XSelectionRequestEvent *) &event;
+ XSelectionRequestEvent *eventp = &(event.xselectionrequest);
inev.ie.kind = SELECTION_REQUEST_EVENT;
SELECTION_EVENT_DISPLAY (&inev.sie) = eventp->display;
Calling x_uncatch_errors resumes the normal error handling. */
-void x_check_errors (Display *dpy, const char *format);
-
void
x_catch_errors (Display *dpy)
{
SIGPIPE will fail, causing Xlib to invoke the X IO error handler,
which will do the appropriate cleanup for us. */
-static SIGTYPE
+static void
x_connection_signal (int signalnum) /* If we don't have an argument, */
/* some compilers complain in signal calls. */
{
/* Handle the loss of connection to display DPY. ERROR_MESSAGE is
the text of an error message that lead to the connection loss. */
-static SIGTYPE
+static void
x_connection_closed (Display *dpy, const char *error_message)
{
struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
unknown reason, the call to XtMapWidget is completely ignored.
Mapping the widget a second time works. */
- if (!FRAME_VISIBLE_P (f) && --retry_count > 0)
+ if (!FRAME_VISIBLE_P (f) && --retry_count != 0)
goto retry;
}
}
for (; *name1 != '\0' && *name1 == *name2; name1++, name2++)
{
if (*name1 == ':')
- seen_colon++;
+ seen_colon = 1;
if (seen_colon && *name1 == '.')
return 1;
}
XSetLocaleModifiers ("");
+ /* Emacs can only handle core input events, so make sure
+ Gtk doesn't use Xinput or Xinput2 extensions. */
+ {
+ static char fix_events[] = "GDK_CORE_DEVICE_EVENTS=1";
+ putenv (fix_events);
+ }
+
/* Work around GLib bug that outputs a faulty warning. See
https://bugzilla.gnome.org/show_bug.cgi?id=563627. */
id = g_log_set_handler ("GLib", G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
fixup_locale ();
xg_initialize ();
- dpy = GDK_DISPLAY ();
+ dpy = DEFAULT_GDK_DISPLAY ();
/* NULL window -> events for all windows go to our function */
gdk_window_add_filter (NULL, event_handler_gdk, NULL);
+#if GTK_MAJOR_VERSION <= 2 && GTK_MINOR_VERSION <= 90
/* Load our own gtkrc if it exists. */
{
const char *file = "~/.emacs.d/gtkrc";
if (! NILP (abs_file) && !NILP (Ffile_readable_p (abs_file)))
gtk_rc_parse (SSDATA (abs_file));
}
+#endif
XSetErrorHandler (x_error_handler);
XSetIOErrorHandler (x_io_error_quitter);