struct selection_data;
static void x_decline_selection_request (struct input_event *);
-static int x_convert_selection (struct input_event *, Lisp_Object, Lisp_Object,
- Atom, int, struct x_display_info *);
-static int waiting_for_other_props_on_window (Display *, Window);
+static bool x_convert_selection (struct input_event *, Lisp_Object,
+ Lisp_Object, Atom, bool,
+ struct x_display_info *);
+static bool waiting_for_other_props_on_window (Display *, Window);
static struct prop_location *expect_property_change (Display *, Window,
Atom, int);
static void unexpect_property_change (struct prop_location *);
static Lisp_Object
x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type,
- int local_request, struct x_display_info *dpyinfo)
+ bool local_request, struct x_display_info *dpyinfo)
{
Lisp_Object local_value;
Lisp_Object handler_fn, value, check;
ptrdiff_t size;
int format;
Atom type;
- int nofree;
+ bool nofree;
Atom property;
/* This can be set to non-NULL during x_reply_selection_request, if
the selection is waiting for an INCR transfer to complete. Don't
for (cs = converted_selections; cs; cs = next)
{
next = cs->next;
- if (cs->nofree == 0 && cs->data)
+ if (! cs->nofree && cs->data)
xfree (cs->data);
xfree (cs);
}
Window window;
Atom property;
int desired_state;
- int arrived;
+ bool arrived;
struct prop_location *next;
};
Lisp_Object target_symbol = x_atom_to_symbol (dpyinfo, target);
Atom property = SELECTION_EVENT_PROPERTY (event);
Lisp_Object local_selection_data;
- int success = 0;
+ bool success = false;
ptrdiff_t count = SPECPDL_INDEX ();
GCPRO2 (local_selection_data, target_symbol);
if (subproperty != None)
x_convert_selection (event, selection_symbol, subtarget,
- subproperty, 1, dpyinfo);
+ subproperty, true, dpyinfo);
}
- success = 1;
+ success = true;
}
else
{
property = SELECTION_EVENT_TARGET (event);
success = x_convert_selection (event, selection_symbol,
target_symbol, property,
- 0, dpyinfo);
+ false, dpyinfo);
}
DONE:
/* Perform the requested selection conversion, and write the data to
the converted_selections linked list, where it can be accessed by
- x_reply_selection_request. If FOR_MULTIPLE is non-zero, write out
+ x_reply_selection_request. If FOR_MULTIPLE, write out
the data even if conversion fails, using conversion_fail_tag.
- Return 0 if the selection failed to convert, 1 otherwise. */
+ Return true iff successful. */
-static int
+static bool
x_convert_selection (struct input_event *event, Lisp_Object selection_symbol,
Lisp_Object target_symbol, Atom property,
- int for_multiple, struct x_display_info *dpyinfo)
+ bool for_multiple, struct x_display_info *dpyinfo)
{
struct gcpro gcpro1;
Lisp_Object lisp_selection;
lisp_selection
= x_get_local_selection (selection_symbol, target_symbol,
- 0, dpyinfo);
+ false, dpyinfo);
/* A nil return value means we can't perform the conversion. */
if (NILP (lisp_selection)
cs->size = 1;
cs->format = 32;
cs->type = XA_ATOM;
- cs->nofree = 1;
+ cs->nofree = true;
cs->property = property;
cs->wait_object = NULL;
cs->next = converted_selections;
}
UNGCPRO;
- return 0;
+ return false;
}
/* Otherwise, record the converted selection to binary. */
cs = xmalloc (sizeof *cs);
cs->data = NULL;
- cs->nofree = 1;
+ cs->nofree = true;
cs->property = property;
cs->wait_object = NULL;
cs->next = converted_selections;
converted_selections = cs;
lisp_data_to_selection_data (dpyinfo, lisp_selection, cs);
UNGCPRO;
- return 1;
+ return true;
}
\f
/* Handle a SelectionClear event EVENT, which indicates that some
}
}
\f
-/* Nonzero if any properties for DISPLAY and WINDOW
+/* True if any properties for DISPLAY and WINDOW
are on the list of what we are waiting for. */
-static int
+static bool
waiting_for_other_props_on_window (Display *display, Window window)
{
- struct prop_location *rest = property_change_wait_list;
- while (rest)
- if (rest->display == display && rest->window == window)
- return 1;
- else
- rest = rest->next;
- return 0;
+ for (struct prop_location *p = property_change_wait_list; p; p = p->next)
+ if (p->display == display && p->window == window)
+ return true;
+ return false;
}
/* Add an entry to the list of property changes we are waiting for.
pl->property = property;
pl->desired_state = state;
pl->next = property_change_wait_list;
- pl->arrived = 0;
+ pl->arrived = false;
property_change_wait_list = pl;
return pl;
}
EMACS_INT secs = timeout / 1000;
int nsecs = (timeout % 1000) * 1000000;
TRACE2 (" Waiting %"pI"d secs, %d nsecs", secs, nsecs);
- wait_reading_process_output (secs, nsecs, 0, 0,
+ wait_reading_process_output (secs, nsecs, 0, false,
property_change_reply, NULL, 0);
if (NILP (XCAR (property_change_reply)))
(event->state == PropertyDelete ? "deletion" : "change"),
XGetAtomName (event->display, event->atom));
- rest->arrived = 1;
+ rest->arrived = true;
/* If this is the one wait_for_property_change is waiting for,
tell it to wake up. */
during this time. In fact, the SAVE_TARGETS mechanism requires
us to handle a clipboard manager's requests before it returns
SelectionNotify. */
-#if 0
+#if false
x_start_queuing_selection_requests ();
record_unwind_protect_void (x_stop_queuing_selection_requests);
#endif
secs = timeout / 1000;
nsecs = (timeout % 1000) * 1000000;
TRACE1 (" Start waiting %"pI"d secs for SelectionNotify", secs);
- wait_reading_process_output (secs, nsecs, 0, 0,
+ wait_reading_process_output (secs, nsecs, 0, false,
reading_selection_reply, NULL, 0);
TRACE1 (" Got event = %d", !NILP (XCAR (reading_selection_reply)));
x_get_window_property (Display *display, Window window, Atom property,
unsigned char **data_ret, ptrdiff_t *bytes_ret,
Atom *actual_type_ret, int *actual_format_ret,
- unsigned long *actual_size_ret, int delete_p)
+ unsigned long *actual_size_ret)
{
ptrdiff_t total_size;
unsigned long bytes_remaining;
XFlush (display);
unblock_input ();
- while (1)
+ while (true)
{
unsigned char *tmp_data;
ptrdiff_t tmp_size_bytes;
TRACE0 (" Get property value");
x_get_window_property (display, window, property,
&tmp_data, &tmp_size_bytes,
- type_ret, format_ret, size_ret, 1);
+ type_ret, format_ret, size_ret);
TRACE1 (" Read increment of %"pD"d bytes", tmp_size_bytes);
TRACE0 ("Reading selection data");
x_get_window_property (display, window, property, &data, &bytes,
- &actual_type, &actual_format, &actual_size, 1);
+ &actual_type, &actual_format, &actual_size);
if (! data)
{
- int there_is_a_selection_owner;
block_input ();
- there_is_a_selection_owner
- = XGetSelectionOwner (display, selection_atom);
+ bool there_is_a_selection_owner
+ = XGetSelectionOwner (display, selection_atom) != 0;
unblock_input ();
if (there_is_a_selection_owner)
signal_error ("Selection owner couldn't convert",
Lisp_Object type = Qnil;
eassert (cs != NULL);
- cs->nofree = 0;
+ cs->nofree = false;
if (CONSP (obj) && SYMBOLP (XCAR (obj)))
{
cs->format = 8;
cs->size = SBYTES (obj);
cs->data = SDATA (obj);
- cs->nofree = 1;
+ cs->nofree = true;
}
else if (SYMBOLP (obj))
{
if (!f)
error ("X selection unavailable for this frame");
- val = x_get_local_selection (selection_symbol, target_type, 1,
+ val = x_get_local_selection (selection_symbol, target_type, true,
FRAME_DISPLAY_INFO (f));
if (NILP (val) && FRAME_LIVE_P (f))
/* Convert an XClientMessageEvent to a Lisp event of type DRAG_N_DROP_EVENT. */
-int
+bool
x_handle_dnd_message (struct frame *f, const XClientMessageEvent *event,
struct x_display_info *dpyinfo, struct input_event *bufp)
{
for (i = 0; i < dpyinfo->x_dnd_atoms_length; ++i)
if (dpyinfo->x_dnd_atoms[i] == event->message_type) break;
- if (i == dpyinfo->x_dnd_atoms_length) return 0;
+ if (i == dpyinfo->x_dnd_atoms_length) return false;
XSETFRAME (frame, f);
bufp->arg = vec;
bufp->modifiers = 0;
- return 1;
+ return true;
}
DEFUN ("x-send-client-message", Fx_send_client_message,
Window wdest;
XEvent event;
struct frame *f = decode_window_system_frame (from);
- int to_root;
+ bool to_root;
CHECK_NUMBER (format);
CHECK_CONS (values);
event then goes to clients selecting for events on the root window. */
x_catch_errors (dpyinfo->display);
{
- int propagate = to_root ? False : True;
+ bool propagate = !to_root;
long mask = to_root ? 0xffffff : 0;
XSendEvent (dpyinfo->display, wdest, propagate, mask, &event);
kbd_buffer_store_event (&event);
}
-/* Return non-zero if DPYINFO is still valid. */
-static int
+/* Return true if DPYINFO is still valid. */
+static bool
dpyinfo_valid (struct x_display_info *dpyinfo)
{
- int found = 0;
+ bool found = false;
if (dpyinfo != NULL)
{
struct x_display_info *d;
CARD32 vlen, ival = 0;
char name[128]; /* The names we are looking for are not this long. */
char sval[128]; /* The values we are looking for are not this long. */
- int want_this;
+ bool want_this;
int to_cpy;
sval[0] = '\0';
/* Read settings from the XSettings property window on display for DPYINFO.
Store settings read in SETTINGS.
- Return non-zero if successful, zero if not. */
+ Return true iff successful. */
-static int
+static bool
read_settings (struct x_display_info *dpyinfo, struct xsettings *settings)
{
Atom act_type;
}
/* Apply Xft settings in SETTINGS to the Xft library.
- If SEND_EVENT_P is non-zero store a Lisp event that Xft settings changed. */
+ Store a Lisp event that Xft settings changed. */
static void
apply_xft_settings (struct x_display_info *dpyinfo,
- int send_event_p,
struct xsettings *settings)
{
#ifdef HAVE_XFT
FcPattern *pat;
struct xsettings oldsettings;
- int changed = 0;
+ bool changed = false;
memset (&oldsettings, 0, sizeof (oldsettings));
pat = FcPatternCreate ();
{
FcPatternDel (pat, FC_ANTIALIAS);
FcPatternAddBool (pat, FC_ANTIALIAS, settings->aa);
- ++changed;
+ changed = true;
oldsettings.aa = settings->aa;
}
{
FcPatternDel (pat, FC_HINTING);
FcPatternAddBool (pat, FC_HINTING, settings->hinting);
- ++changed;
+ changed = true;
oldsettings.hinting = settings->hinting;
}
if ((settings->seen & SEEN_RGBA) != 0 && oldsettings.rgba != settings->rgba)
FcPatternDel (pat, FC_RGBA);
FcPatternAddInteger (pat, FC_RGBA, settings->rgba);
oldsettings.rgba = settings->rgba;
- ++changed;
+ changed = true;
}
/* Older fontconfig versions don't have FC_LCD_FILTER. */
{
FcPatternDel (pat, FC_LCD_FILTER);
FcPatternAddInteger (pat, FC_LCD_FILTER, settings->lcdfilter);
- ++changed;
+ changed = true;
oldsettings.lcdfilter = settings->lcdfilter;
}
{
FcPatternDel (pat, FC_HINT_STYLE);
FcPatternAddInteger (pat, FC_HINT_STYLE, settings->hintstyle);
- ++changed;
+ changed = true;
oldsettings.hintstyle = settings->hintstyle;
}
#endif
{
FcPatternDel (pat, FC_DPI);
FcPatternAddDouble (pat, FC_DPI, settings->dpi);
- ++changed;
+ changed = true;
oldsettings.dpi = settings->dpi;
/* Changing the DPI on this display affects all frames on it.
char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth];
XftDefaultSet (dpyinfo->display, pat);
- if (send_event_p)
- store_config_changed_event (Qfont_render,
- XCAR (dpyinfo->name_list_element));
+ store_config_changed_event (Qfont_render,
+ XCAR (dpyinfo->name_list_element));
Vxft_settings
= make_formatted_string (buf, format,
oldsettings.aa, oldsettings.hinting,
}
/* Read XSettings from the display for DPYINFO.
- If SEND_EVENT_P is non-zero store a Lisp event settings that changed. */
+ If SEND_EVENT_P store a Lisp event settings that changed. */
static void
-read_and_apply_settings (struct x_display_info *dpyinfo, int send_event_p)
+read_and_apply_settings (struct x_display_info *dpyinfo, bool send_event_p)
{
struct xsettings settings;
if (!read_settings (dpyinfo, &settings))
return;
- apply_xft_settings (dpyinfo, True, &settings);
+ apply_xft_settings (dpyinfo, &settings);
if (settings.seen & SEEN_TB_STYLE)
{
if (send_event_p)
void
xft_settings_event (struct x_display_info *dpyinfo, const XEvent *event)
{
- bool check_window_p = 0, apply_settings_p = 0;
+ bool check_window_p = false, apply_settings_p = false;
switch (event->type)
{
case DestroyNotify:
if (dpyinfo->xsettings_window == event->xany.window)
- check_window_p = 1;
+ check_window_p = true;
break;
case ClientMessage:
if (event->xclient.message_type == dpyinfo->Xatom_xsettings_mgr
&& event->xclient.data.l[1] == dpyinfo->Xatom_xsettings_sel
&& event->xclient.window == dpyinfo->root_window)
- check_window_p = 1;
+ check_window_p = true;
break;
case PropertyNotify:
if (event->xproperty.window == dpyinfo->xsettings_window
&& event->xproperty.state == PropertyNewValue
&& event->xproperty.atom == dpyinfo->Xatom_xsettings_prop)
- apply_settings_p = 1;
+ apply_settings_p = true;
break;
}
dpyinfo->xsettings_window = None;
get_prop_window (dpyinfo);
if (dpyinfo->xsettings_window != None)
- apply_settings_p = 1;
+ apply_settings_p = true;
}
if (apply_settings_p)
- read_and_apply_settings (dpyinfo, True);
+ read_and_apply_settings (dpyinfo, true);
}
/* Initialize GSettings and read startup values. */
{
#ifdef HAVE_GSETTINGS
GVariant *val;
- int schema_found = 0;
+ bool schema_found = false;
#if ! GLIB_CHECK_VERSION (2, 36, 0)
g_type_init ();
get_prop_window (dpyinfo);
if (dpyinfo->xsettings_window != None)
- read_and_apply_settings (dpyinfo, False);
+ read_and_apply_settings (dpyinfo, false);
unblock_input ();
}
When this is non-nil and the system defined fixed width font changes, we
update frames dynamically.
If this variable is nil, Emacs ignores system font changes. */);
- use_system_font = 0;
+ use_system_font = false;
DEFVAR_LISP ("xft-settings", Vxft_settings,
doc: /* Font settings applied to Xft. */);