#include "font.h"
#include "fontset.h"
#include "xsettings.h"
+#include "xgselect.h"
#include "sysselect.h"
#ifdef USE_X_TOOLKIT
/* Scroll bar callback for GTK scroll bars. WIDGET is the scroll
bar widget. DATA is a pointer to the scroll_bar structure. */
-static void
-xg_scroll_callback (widget, data)
- GtkRange *widget;
- gpointer data;
+static gboolean
+xg_scroll_callback (GtkRange *range,
+ GtkScrollType scroll,
+ gdouble value,
+ gpointer user_data)
{
- struct scroll_bar *bar = (struct scroll_bar *) data;
- gdouble previous;
+ struct scroll_bar *bar = (struct scroll_bar *) user_data;
gdouble position;
- gdouble *p;
- int diff;
-
int part = -1, whole = 0, portion = 0;
- GtkAdjustment *adj = GTK_ADJUSTMENT (gtk_range_get_adjustment (widget));
+ GtkAdjustment *adj = GTK_ADJUSTMENT (gtk_range_get_adjustment (range));
+ FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (range), XG_FRAME_DATA);
+ if (xg_ignore_gtk_scrollbar) return FALSE;
position = gtk_adjustment_get_value (adj);
- p = g_object_get_data (G_OBJECT (widget), XG_LAST_SB_DATA);
- if (! p)
- {
- p = (gdouble*) xmalloc (sizeof (gdouble));
- *p = XG_SB_MIN;
- g_object_set_data (G_OBJECT (widget), XG_LAST_SB_DATA, p);
- }
-
- previous = *p;
- *p = position;
-
- if (xg_ignore_gtk_scrollbar) return;
- diff = (int) (position - previous);
-
- if (diff == (int) adj->step_increment)
- {
- part = scroll_bar_down_arrow;
- bar->dragging = Qnil;
- }
- else if (-diff == (int) adj->step_increment)
+ switch (scroll)
{
+ case GTK_SCROLL_JUMP:
+ /* Buttons 1 2 or 3 must be grabbed. */
+ if (FRAME_X_DISPLAY_INFO (f)->grabbed != 0
+ && FRAME_X_DISPLAY_INFO (f)->grabbed < (1 << 4))
+ {
+ part = scroll_bar_handle;
+ whole = adj->upper - adj->page_size;
+ portion = min ((int)position, whole);
+ bar->dragging = make_number ((int)portion);
+ }
+ break;
+ case GTK_SCROLL_STEP_BACKWARD:
part = scroll_bar_up_arrow;
bar->dragging = Qnil;
- }
- else if (diff == (int) adj->page_increment)
- {
- part = scroll_bar_below_handle;
+ break;
+ case GTK_SCROLL_STEP_FORWARD:
+ part = scroll_bar_down_arrow;
bar->dragging = Qnil;
- }
- else if (-diff == (int) adj->page_increment)
- {
+ break;
+ case GTK_SCROLL_PAGE_BACKWARD:
part = scroll_bar_above_handle;
bar->dragging = Qnil;
- }
- else
- {
- part = scroll_bar_handle;
- whole = adj->upper - adj->page_size;
- portion = min ((int)position, whole);
- bar->dragging = make_number ((int)portion);
+ break;
+ case GTK_SCROLL_PAGE_FORWARD:
+ part = scroll_bar_below_handle;
+ bar->dragging = Qnil;
+ break;
}
if (part >= 0)
last_scroll_bar_part = part;
x_send_scroll_bar_event (bar->window, part, portion, whole);
}
+
+ return FALSE;
+}
+
+/* Callback for button release. Sets dragging to Qnil when dragging is done. */
+
+static gboolean
+xg_end_scroll_callback (GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
+{
+ struct scroll_bar *bar = (struct scroll_bar *) user_data;
+ bar->dragging = Qnil;
+ if (WINDOWP (window_being_scrolled))
+ {
+ x_send_scroll_bar_event (window_being_scrolled,
+ scroll_bar_end_scroll, 0, 0);
+ window_being_scrolled = Qnil;
+ }
+
+ return FALSE;
}
+
#else /* not USE_GTK and not USE_MOTIF */
/* Xaw scroll bar callback. Invoked when the thumb is dragged.
BLOCK_INPUT;
xg_create_scroll_bar (f, bar, G_CALLBACK (xg_scroll_callback),
+ G_CALLBACK (xg_end_scroll_callback),
scroll_bar_name);
UNBLOCK_INPUT;
}
if (nchars == nbytes)
c = copy_bufptr[i], len = 1;
else
- c = STRING_CHAR_AND_LENGTH (copy_bufptr + i,
- nbytes - i, len);
+ c = STRING_CHAR_AND_LENGTH (copy_bufptr + i, len);
inev.ie.kind = (SINGLE_BYTE_CHAR_P (c)
? ASCII_KEYSTROKE_EVENT
: MULTIBYTE_CHAR_KEYSTROKE_EVENT);
pixelh -= FRAME_MENUBAR_HEIGHT (f);
#endif
rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixelh);
+ /* Update f->scroll_bar_actual_width because it is used in
+ FRAME_PIXEL_WIDTH_TO_TEXT_COLS. */
+ f->scroll_bar_actual_width
+ = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, FRAME_PIXEL_WIDTH (f));
change_frame_size (f, rows, cols, 0, 1, 0);
return dpy_ok;
}
+#ifdef USE_GTK
+static void
+my_log_handler (log_domain, log_level, message, user_data)
+ const gchar *log_domain;
+ GLogLevelFlags log_level;
+ const gchar *message;
+ gpointer user_data;
+{
+ if (!strstr (message, "g_set_prgname"))
+ fprintf (stderr, "%s-WARNING **: %s\n", log_domain, message);
+}
+#endif
+
/* Open a connection to X display DISPLAY_NAME, and return
the structure that describes the open display.
If we cannot contact the display, return null. */
char *argv[NUM_ARGV];
char **argv2 = argv;
GdkAtom atom;
-
+ guint id;
#ifndef HAVE_GTK_MULTIDISPLAY
if (!EQ (Vinitial_window_system, Qx))
error ("Sorry, you cannot connect to X servers with the GTK toolkit");
XSetLocaleModifiers ("");
+ /* 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
+ | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
gtk_init (&argc, &argv2);
+ g_log_remove_handler ("GLib", id);
/* gtk_init does set_locale. We must fix locale after calling it. */
fixup_locale ();
= XInternAtom (dpyinfo->display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
dpyinfo->Xatom_net_wm_state_sticky
= XInternAtom (dpyinfo->display, "_NET_WM_STATE_STICKY", False);
-
+ dpyinfo->Xatom_net_window_type
+ = XInternAtom (dpyinfo->display, "_NET_WM_WINDOW_TYPE", False);
+ dpyinfo->Xatom_net_window_type_tooltip
+ = XInternAtom (dpyinfo->display, "_NET_WM_WINDOW_TYPE_TOOLTIP", False);
+
dpyinfo->cut_buffers_initialized = 0;
dpyinfo->x_dnd_atoms_size = 8;
#endif /* ! USE_GTK */
}
+ /* Mark as dead. */
+ dpyinfo->display = NULL;
x_delete_display (dpyinfo);
UNBLOCK_INPUT;
}
XSetIOErrorHandler (x_io_error_quitter);
signal (SIGPIPE, x_connection_signal);
+
+ xgselect_initialize ();
}