xlw_monitor_dimensions_at_pos (Display *dpy, Screen *screen, int src_x,
int src_y, int *x, int *y, int *width, int *height)
{
- struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
-
- if (!dpyinfo)
- emacs_abort ();
+ struct x_display_info *dpyinfo = x_dpyinfo (dpy);
block_input ();
xlw_monitor_dimensions_at_pos_1 (dpyinfo, screen, src_x, src_y,
int
XDisplayCells (Display *dpy, int screen_number)
{
- struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
-
- if (!dpyinfo)
- emacs_abort ();
+ struct x_display_info *dpyinfo = x_dpyinfo (dpy);
/* Not strictly correct, since the display could be using a
non-default visual, but it satisfies the callers we need to care
unsigned long *prev_masks UNINIT;
specpdl_ref count;
Display *dpy UNINIT;
- struct x_display_info *dpyinfo;
if (!x_dnd_toplevels)
/* Probably called inside an IO error handler. */
record_unwind_protect_ptr (xfree, destroy_windows);
record_unwind_protect_ptr (xfree, prev_masks);
- if (display_alive)
+ if (display_alive && n_windows)
{
- dpyinfo = x_display_info_for_display (dpy);
+ struct x_display_info *dpyinfo = x_dpyinfo (dpy);
- if (n_windows)
- {
- eassume (dpyinfo);
- x_ignore_errors_for_next_request (dpyinfo, 0);
+ x_ignore_errors_for_next_request (dpyinfo, 0);
- for (i = 0; i < n_windows; ++i)
- {
- XSelectInput (dpy, destroy_windows[i], prev_masks[i]);
+ for (i = 0; i < n_windows; ++i)
+ {
+ XSelectInput (dpy, destroy_windows[i], prev_masks[i]);
#ifdef HAVE_XSHAPE
- XShapeSelectInput (dpy, destroy_windows[i], None);
+ XShapeSelectInput (dpy, destroy_windows[i], None);
#endif
- }
-
- x_stop_ignoring_errors (dpyinfo);
}
+
+ x_stop_ignoring_errors (dpyinfo);
}
unbind_to (count, Qnil);
#endif
\f
-/* Return the struct x_display_info corresponding to DPY. */
+/* Return the struct x_display_info corresponding to DPY,
+ when it is guaranteed that one will correspond. */
+
+struct x_display_info *
+x_dpyinfo (Display *dpy)
+{
+ for (struct x_display_info *dpyinfo = x_display_list; ;
+ dpyinfo = dpyinfo->next)
+ if (dpyinfo->display == dpy)
+ return dpyinfo;
+}
+
+/* Return the struct x_display_info corresponding to DPY,
+ or a null pointer if none corresponds. */
struct x_display_info *
x_display_info_for_display (Display *dpy)
Lisp_Object tail, frame;
struct frame *f;
- dpyinfo = x_display_info_for_display (XtDisplay (widget));
+ dpyinfo = x_dpyinfo (XtDisplay (widget));
/* Find the top-level shell of the widget. Note that this function
can be called when the widget is not yet realized, so XtWindow
static const XColor *
x_color_cells (Display *dpy, int *ncells)
{
- struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
- eassume (dpyinfo);
+ struct x_display_info *dpyinfo = x_dpyinfo (dpy);
if (dpyinfo->color_cells == NULL)
{
static bool
x_alloc_nearest_color_1 (Display *dpy, Colormap cmap, XColor *color)
{
- struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
- bool rc;
-
- eassume (dpyinfo);
- rc = XAllocColor (dpy, cmap, color) != 0;
+ struct x_display_info *dpyinfo = x_dpyinfo (dpy);
+ bool rc = XAllocColor (dpy, cmap, color) != 0;
if (dpyinfo->visual_info.class == DirectColor)
return rc;
- if (rc == 0)
+ if (!rc)
{
/* If we got to this point, the colormap is full, so we're going
to try and get the next closest color. The algorithm used is
/* If allocation succeeded, and the allocated pixel color is not
equal to a cached pixel color recorded earlier, there was a
change in the colormap, so clear the color cache. */
- struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
- eassume (dpyinfo);
+ struct x_display_info *dpyinfo = x_dpyinfo (dpy);
if (dpyinfo->color_cells)
{
int *root_y_return, int *win_x_return,
int *win_y_return, unsigned int *mask_return)
{
- struct x_display_info *dpyinfo;
-
- dpyinfo = x_display_info_for_display (dpy);
-
- if (!dpyinfo)
- emacs_abort ();
+ struct x_display_info *dpyinfo = x_dpyinfo (dpy);
#ifdef HAVE_XINPUT2
return x_query_pointer_1 (dpyinfo, dpyinfo->client_pointer_device,