X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/c03c730481bd2dc7bc857d9b4f1c41eea9bd495e..4d9e34e02c11b05b075ada241ef93f458f486fe5:/src/xterm.h diff --git a/src/xterm.h b/src/xterm.h index 3081c1653e..8e1fc788bc 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -1,13 +1,13 @@ /* Definitions and headers for communication with X protocol. - Copyright (C) 1989, 1993-1994, 1998-2015 Free Software Foundation, + Copyright (C) 1989, 1993-1994, 1998-2016 Free Software Foundation, Inc. This file is part of GNU Emacs. GNU Emacs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +the Free Software Foundation, either version 3 of the License, or (at +your option) any later version. GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -87,6 +87,10 @@ typedef GtkWidget *xt_or_gtk_widget; #include #endif +#ifdef USE_XCB +#include +#endif + #include "dispextern.h" #include "termhooks.h" @@ -152,6 +156,17 @@ struct x_gc_ext_data }; #endif + +struct color_name_cache_entry +{ + struct color_name_cache_entry *next; + XColor rgb; + char *name; +}; + +Status x_parse_color (struct frame *f, const char *color_name, + XColor *color); + /* For each X display, we have a structure that records information about it. */ @@ -385,6 +400,9 @@ struct x_display_info struct xim_inst_t *xim_callback_data; #endif + /* A cache mapping color names to RGB values. */ + struct color_name_cache_entry *color_names; + /* If non-null, a cache of the colors in the color map. Don't use this directly, call x_color_cells instead. */ XColor *color_cells; @@ -441,9 +459,18 @@ struct x_display_info /* SM */ Atom Xatom_SM_CLIENT_ID; +#ifdef HAVE_XRANDR + int xrandr_major_version; + int xrandr_minor_version; +#endif + #ifdef USE_CAIRO XExtCodes *ext_codes; #endif + +#ifdef USE_XCB + xcb_connection_t *xcb_connection; +#endif }; #ifdef HAVE_X_I18N @@ -960,7 +987,7 @@ struct scroll_bar struct selection_input_event { - int kind; + ENUM_BF (event_kind) kind : EVENT_KIND_WIDTH; struct x_display_info *dpyinfo; /* We spell it with an "o" here because X does. */ Window requestor; @@ -970,23 +997,23 @@ struct selection_input_event /* Unlike macros below, this can't be used as an lvalue. */ INLINE Display * -SELECTION_EVENT_DISPLAY (struct input_event *ev) +SELECTION_EVENT_DISPLAY (struct selection_input_event *ev) { - return ((struct selection_input_event *) ev)->dpyinfo->display; + return ev->dpyinfo->display; } #define SELECTION_EVENT_DPYINFO(eventp) \ - (((struct selection_input_event *) (eventp))->dpyinfo) + ((eventp)->dpyinfo) /* We spell it with an "o" here because X does. */ #define SELECTION_EVENT_REQUESTOR(eventp) \ - (((struct selection_input_event *) (eventp))->requestor) + ((eventp)->requestor) #define SELECTION_EVENT_SELECTION(eventp) \ - (((struct selection_input_event *) (eventp))->selection) + ((eventp)->selection) #define SELECTION_EVENT_TARGET(eventp) \ - (((struct selection_input_event *) (eventp))->target) + ((eventp)->target) #define SELECTION_EVENT_PROPERTY(eventp) \ - (((struct selection_input_event *) (eventp))->property) + ((eventp)->property) #define SELECTION_EVENT_TIME(eventp) \ - (((struct selection_input_event *) (eventp))->time) + ((eventp)->time) /* From xfns.c. */ @@ -1010,12 +1037,18 @@ XrmDatabase x_load_resources (Display *, const char *, const char *, /* Defined in xterm.c */ +typedef void (*x_special_error_handler)(Display *, XErrorEvent *, char *, + void *); + extern bool x_text_icon (struct frame *, const char *); extern void x_catch_errors (Display *); +extern void x_catch_errors_with_handler (Display *, x_special_error_handler, + void *); extern void x_check_errors (Display *, const char *) ATTRIBUTE_FORMAT_PRINTF (2, 0); extern bool x_had_errors_p (Display *); extern void x_uncatch_errors (void); +extern void x_uncatch_errors_after_check (void); extern void x_clear_errors (Display *); extern void xembed_request_focus (struct frame *); extern void x_ewmh_activate_frame (struct frame *); @@ -1071,7 +1104,35 @@ x_display_set_last_user_time (struct x_display_info *dpyinfo, Time t) dpyinfo->last_user_time = t; } +INLINE unsigned long +x_make_truecolor_pixel (struct x_display_info *dpyinfo, int r, int g, int b) +{ + unsigned long pr, pg, pb; + + /* Scale down RGB values to the visual's bits per RGB, and shift + them to the right position in the pixel color. Note that the + original RGB values are 16-bit values, as usual in X. */ + pr = (r >> (16 - dpyinfo->red_bits)) << dpyinfo->red_offset; + pg = (g >> (16 - dpyinfo->green_bits)) << dpyinfo->green_offset; + pb = (b >> (16 - dpyinfo->blue_bits)) << dpyinfo->blue_offset; + + /* Assemble the pixel color. */ + return pr | pg | pb; +} + +/* If display has an immutable color map, freeing colors is not + necessary and some servers don't allow it, so we won't do it. That + also allows us to make other optimizations relating to server-side + reference counts. */ +INLINE bool +x_mutable_colormap (Visual *visual) +{ + int class = visual->class; + return (class != StaticColor && class != StaticGray && class != TrueColor); +} + extern void x_set_sticky (struct frame *, Lisp_Object, Lisp_Object); +extern bool x_wm_supports (struct frame *, Atom); extern void x_wait_for_event (struct frame *, int); extern void x_clear_under_internal_border (struct frame *f); @@ -1079,7 +1140,7 @@ extern void x_clear_under_internal_border (struct frame *f); extern void x_handle_property_notify (const XPropertyEvent *); extern void x_handle_selection_notify (const XSelectionEvent *); -extern void x_handle_selection_event (struct input_event *); +extern void x_handle_selection_event (struct selection_input_event *); extern void x_clear_frame_selections (struct frame *); extern void x_send_client_event (Lisp_Object display,