diff options
| author | Po Lu | 2022-03-28 08:59:50 +0800 |
|---|---|---|
| committer | Po Lu | 2022-03-28 08:59:50 +0800 |
| commit | f5adb2584a9e25e3bbf01d1ca1c7fc6e511a4012 (patch) | |
| tree | b2fff5c7ecf62e8374b97d3a67e1154d410ae5bd /src | |
| parent | 45a1bb0efbdd827e91cf80d0c93f60c311e85255 (diff) | |
| download | emacs-f5adb2584a9e25e3bbf01d1ca1c7fc6e511a4012.tar.gz emacs-f5adb2584a9e25e3bbf01d1ca1c7fc6e511a4012.zip | |
Clean up some uses of XInternAtom
* src/xfns.c (x_set_undecorated, x_set_no_focus_on_map, x_window)
(set_machine_and_pid_properties): Move calls to XInternAtom for
static string to use previously interned atoms.
(Fx_change_window_property): Use XCB if available to avoid extra
call to XSync.
* src/xterm.c (x_term_init):
* src/xterm.h (struct x_display_info): New atoms _MOTIF_WM_HINTS
and _NET_WM_PID.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 68 | ||||
| -rw-r--r-- | src/xterm.c | 2 | ||||
| -rw-r--r-- | src/xterm.h | 5 |
3 files changed, 67 insertions, 8 deletions
diff --git a/src/xfns.c b/src/xfns.c index 3f3054422a8..534fb7c544e 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -867,7 +867,7 @@ x_set_undecorated (struct frame *f, Lisp_Object new_value, Lisp_Object old_value | |||
| 867 | #else | 867 | #else |
| 868 | Display *dpy = FRAME_X_DISPLAY (f); | 868 | Display *dpy = FRAME_X_DISPLAY (f); |
| 869 | PropMotifWmHints hints; | 869 | PropMotifWmHints hints; |
| 870 | Atom prop = XInternAtom (dpy, "_MOTIF_WM_HINTS", False); | 870 | Atom prop = FRAME_DISPLAY_INFO (f)->Xatom_MOTIF_WM_HINTS; |
| 871 | 871 | ||
| 872 | memset (&hints, 0, sizeof(hints)); | 872 | memset (&hints, 0, sizeof(hints)); |
| 873 | hints.flags = MWM_HINTS_DECORATIONS; | 873 | hints.flags = MWM_HINTS_DECORATIONS; |
| @@ -979,7 +979,7 @@ x_set_no_focus_on_map (struct frame *f, Lisp_Object new_value, Lisp_Object old_v | |||
| 979 | xg_set_no_focus_on_map (f, new_value); | 979 | xg_set_no_focus_on_map (f, new_value); |
| 980 | #else /* not USE_GTK */ | 980 | #else /* not USE_GTK */ |
| 981 | Display *dpy = FRAME_X_DISPLAY (f); | 981 | Display *dpy = FRAME_X_DISPLAY (f); |
| 982 | Atom prop = XInternAtom (dpy, "_NET_WM_USER_TIME", False); | 982 | Atom prop = FRAME_DISPLAY_INFO (f)->Xatom_net_wm_user_time; |
| 983 | Time timestamp = NILP (new_value) ? CurrentTime : 0; | 983 | Time timestamp = NILP (new_value) ? CurrentTime : 0; |
| 984 | 984 | ||
| 985 | XChangeProperty (dpy, FRAME_OUTER_WINDOW (f), prop, | 985 | XChangeProperty (dpy, FRAME_OUTER_WINDOW (f), prop, |
| @@ -3918,7 +3918,7 @@ x_window (struct frame *f, long window_prompting) | |||
| 3918 | { | 3918 | { |
| 3919 | Display *dpy = FRAME_X_DISPLAY (f); | 3919 | Display *dpy = FRAME_X_DISPLAY (f); |
| 3920 | PropMotifWmHints hints; | 3920 | PropMotifWmHints hints; |
| 3921 | Atom prop = XInternAtom (dpy, "_MOTIF_WM_HINTS", False); | 3921 | Atom prop = FRAME_DISPLAY_INFO (f)->Xatom_MOTIF_WM_HINTS; |
| 3922 | 3922 | ||
| 3923 | memset (&hints, 0, sizeof(hints)); | 3923 | memset (&hints, 0, sizeof(hints)); |
| 3924 | hints.flags = MWM_HINTS_DECORATIONS; | 3924 | hints.flags = MWM_HINTS_DECORATIONS; |
| @@ -4097,7 +4097,7 @@ x_window (struct frame *f) | |||
| 4097 | { | 4097 | { |
| 4098 | Display *dpy = FRAME_X_DISPLAY (f); | 4098 | Display *dpy = FRAME_X_DISPLAY (f); |
| 4099 | PropMotifWmHints hints; | 4099 | PropMotifWmHints hints; |
| 4100 | Atom prop = XInternAtom (dpy, "_MOTIF_WM_HINTS", False); | 4100 | Atom prop = FRAME_DISPLAY_INFO (f)->Xatom_MOTIF_WM_HINTS; |
| 4101 | 4101 | ||
| 4102 | memset (&hints, 0, sizeof(hints)); | 4102 | memset (&hints, 0, sizeof(hints)); |
| 4103 | hints.flags = MWM_HINTS_DECORATIONS; | 4103 | hints.flags = MWM_HINTS_DECORATIONS; |
| @@ -4435,9 +4435,7 @@ set_machine_and_pid_properties (struct frame *f) | |||
| 4435 | unsigned long xpid = pid; | 4435 | unsigned long xpid = pid; |
| 4436 | XChangeProperty (FRAME_X_DISPLAY (f), | 4436 | XChangeProperty (FRAME_X_DISPLAY (f), |
| 4437 | FRAME_OUTER_WINDOW (f), | 4437 | FRAME_OUTER_WINDOW (f), |
| 4438 | XInternAtom (FRAME_X_DISPLAY (f), | 4438 | FRAME_DISPLAY_INFO (f)->Xatom_net_wm_pid, |
| 4439 | "_NET_WM_PID", | ||
| 4440 | False), | ||
| 4441 | XA_CARDINAL, 32, PropModeReplace, | 4439 | XA_CARDINAL, 32, PropModeReplace, |
| 4442 | (unsigned char *) &xpid, 1); | 4440 | (unsigned char *) &xpid, 1); |
| 4443 | } | 4441 | } |
| @@ -7073,6 +7071,13 @@ If WINDOW-ID is non-nil, change the property of that window instead | |||
| 7073 | unsigned char *data; | 7071 | unsigned char *data; |
| 7074 | int nelements; | 7072 | int nelements; |
| 7075 | Window target_window; | 7073 | Window target_window; |
| 7074 | #ifdef USE_XCB | ||
| 7075 | xcb_intern_atom_cookie_t prop_atom_cookie; | ||
| 7076 | xcb_intern_atom_cookie_t target_type_cookie; | ||
| 7077 | xcb_intern_atom_reply_t *reply; | ||
| 7078 | xcb_generic_error_t *generic_error; | ||
| 7079 | bool rc; | ||
| 7080 | #endif | ||
| 7076 | 7081 | ||
| 7077 | CHECK_STRING (prop); | 7082 | CHECK_STRING (prop); |
| 7078 | 7083 | ||
| @@ -7136,12 +7141,61 @@ If WINDOW-ID is non-nil, change the property of that window instead | |||
| 7136 | } | 7141 | } |
| 7137 | 7142 | ||
| 7138 | block_input (); | 7143 | block_input (); |
| 7144 | #ifndef USE_XCB | ||
| 7139 | prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False); | 7145 | prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False); |
| 7140 | if (! NILP (type)) | 7146 | if (! NILP (type)) |
| 7141 | { | 7147 | { |
| 7142 | CHECK_STRING (type); | 7148 | CHECK_STRING (type); |
| 7143 | target_type = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (type), False); | 7149 | target_type = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (type), False); |
| 7144 | } | 7150 | } |
| 7151 | #else | ||
| 7152 | rc = true; | ||
| 7153 | prop_atom_cookie | ||
| 7154 | = xcb_intern_atom (FRAME_DISPLAY_INFO (f)->xcb_connection, | ||
| 7155 | 0, SBYTES (prop), SSDATA (prop)); | ||
| 7156 | |||
| 7157 | if (!NILP (type)) | ||
| 7158 | { | ||
| 7159 | CHECK_STRING (type); | ||
| 7160 | target_type_cookie | ||
| 7161 | = xcb_intern_atom (FRAME_DISPLAY_INFO (f)->xcb_connection, | ||
| 7162 | 0, SBYTES (type), SSDATA (type)); | ||
| 7163 | } | ||
| 7164 | |||
| 7165 | reply = xcb_intern_atom_reply (FRAME_DISPLAY_INFO (f)->xcb_connection, | ||
| 7166 | prop_atom_cookie, &generic_error); | ||
| 7167 | |||
| 7168 | if (reply) | ||
| 7169 | { | ||
| 7170 | prop_atom = (Atom) reply->atom; | ||
| 7171 | free (reply); | ||
| 7172 | } | ||
| 7173 | else | ||
| 7174 | { | ||
| 7175 | free (generic_error); | ||
| 7176 | rc = false; | ||
| 7177 | } | ||
| 7178 | |||
| 7179 | if (!NILP (type)) | ||
| 7180 | { | ||
| 7181 | reply = xcb_intern_atom_reply (FRAME_DISPLAY_INFO (f)->xcb_connection, | ||
| 7182 | target_type_cookie, &generic_error); | ||
| 7183 | |||
| 7184 | if (reply) | ||
| 7185 | { | ||
| 7186 | target_type = (Atom) reply->atom; | ||
| 7187 | free (reply); | ||
| 7188 | } | ||
| 7189 | else | ||
| 7190 | { | ||
| 7191 | free (generic_error); | ||
| 7192 | rc = false; | ||
| 7193 | } | ||
| 7194 | } | ||
| 7195 | |||
| 7196 | if (!rc) | ||
| 7197 | error ("Failed to intern type or property atom"); | ||
| 7198 | #endif | ||
| 7145 | 7199 | ||
| 7146 | XChangeProperty (FRAME_X_DISPLAY (f), target_window, | 7200 | XChangeProperty (FRAME_X_DISPLAY (f), target_window, |
| 7147 | prop_atom, target_type, element_format, PropModeReplace, | 7201 | prop_atom, target_type, element_format, PropModeReplace, |
diff --git a/src/xterm.c b/src/xterm.c index fbd6fadf1d5..97dfbc5add1 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -20233,6 +20233,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 20233 | ATOM_REFS_INIT ("CLIPBOARD_MANAGER", Xatom_CLIPBOARD_MANAGER) | 20233 | ATOM_REFS_INIT ("CLIPBOARD_MANAGER", Xatom_CLIPBOARD_MANAGER) |
| 20234 | ATOM_REFS_INIT ("XATOM_COUNTER", Xatom_XEMBED_INFO) | 20234 | ATOM_REFS_INIT ("XATOM_COUNTER", Xatom_XEMBED_INFO) |
| 20235 | ATOM_REFS_INIT ("_XEMBED_INFO", Xatom_XEMBED_INFO) | 20235 | ATOM_REFS_INIT ("_XEMBED_INFO", Xatom_XEMBED_INFO) |
| 20236 | ATOM_REFS_INIT ("_MOTIF_WM_HINTS", Xatom_MOTIF_WM_HINTS) | ||
| 20236 | /* For properties of font. */ | 20237 | /* For properties of font. */ |
| 20237 | ATOM_REFS_INIT ("PIXEL_SIZE", Xatom_PIXEL_SIZE) | 20238 | ATOM_REFS_INIT ("PIXEL_SIZE", Xatom_PIXEL_SIZE) |
| 20238 | ATOM_REFS_INIT ("AVERAGE_WIDTH", Xatom_AVERAGE_WIDTH) | 20239 | ATOM_REFS_INIT ("AVERAGE_WIDTH", Xatom_AVERAGE_WIDTH) |
| @@ -20282,6 +20283,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 20282 | ATOM_REFS_INIT ("_NET_WM_STATE_BELOW", Xatom_net_wm_state_below) | 20283 | ATOM_REFS_INIT ("_NET_WM_STATE_BELOW", Xatom_net_wm_state_below) |
| 20283 | ATOM_REFS_INIT ("_NET_WM_OPAQUE_REGION", Xatom_net_wm_opaque_region) | 20284 | ATOM_REFS_INIT ("_NET_WM_OPAQUE_REGION", Xatom_net_wm_opaque_region) |
| 20284 | ATOM_REFS_INIT ("_NET_WM_PING", Xatom_net_wm_ping) | 20285 | ATOM_REFS_INIT ("_NET_WM_PING", Xatom_net_wm_ping) |
| 20286 | ATOM_REFS_INIT ("_NET_WM_PID", Xatom_net_wm_pid) | ||
| 20285 | #ifdef HAVE_XKB | 20287 | #ifdef HAVE_XKB |
| 20286 | ATOM_REFS_INIT ("Meta", Xatom_Meta) | 20288 | ATOM_REFS_INIT ("Meta", Xatom_Meta) |
| 20287 | ATOM_REFS_INIT ("Super", Xatom_Super) | 20289 | ATOM_REFS_INIT ("Super", Xatom_Super) |
diff --git a/src/xterm.h b/src/xterm.h index a155245f810..57b55ecf0db 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -433,6 +433,8 @@ struct x_display_info | |||
| 433 | /* Atom used to determine whether or not the screen is composited. */ | 433 | /* Atom used to determine whether or not the screen is composited. */ |
| 434 | Atom Xatom_NET_WM_CM_Sn; | 434 | Atom Xatom_NET_WM_CM_Sn; |
| 435 | 435 | ||
| 436 | Atom Xatom_MOTIF_WM_HINTS; | ||
| 437 | |||
| 436 | /* The frame (if any) which has the X window that has keyboard focus. | 438 | /* The frame (if any) which has the X window that has keyboard focus. |
| 437 | Zero if none. This is examined by Ffocus_frame in xfns.c. Note | 439 | Zero if none. This is examined by Ffocus_frame in xfns.c. Note |
| 438 | that a mere EnterNotify event can set this; if you need to know the | 440 | that a mere EnterNotify event can set this; if you need to know the |
| @@ -551,7 +553,8 @@ struct x_display_info | |||
| 551 | Xatom_net_workarea, Xatom_net_wm_opaque_region, Xatom_net_wm_ping, | 553 | Xatom_net_workarea, Xatom_net_wm_opaque_region, Xatom_net_wm_ping, |
| 552 | Xatom_net_wm_sync_request, Xatom_net_wm_sync_request_counter, | 554 | Xatom_net_wm_sync_request, Xatom_net_wm_sync_request_counter, |
| 553 | Xatom_net_wm_frame_drawn, Xatom_net_wm_user_time, | 555 | Xatom_net_wm_frame_drawn, Xatom_net_wm_user_time, |
| 554 | Xatom_net_wm_user_time_window, Xatom_net_client_list_stacking; | 556 | Xatom_net_wm_user_time_window, Xatom_net_client_list_stacking, |
| 557 | Xatom_net_wm_pid; | ||
| 555 | 558 | ||
| 556 | /* XSettings atoms and windows. */ | 559 | /* XSettings atoms and windows. */ |
| 557 | Atom Xatom_xsettings_sel, Xatom_xsettings_prop, Xatom_xsettings_mgr; | 560 | Atom Xatom_xsettings_sel, Xatom_xsettings_prop, Xatom_xsettings_mgr; |