[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master f5adb2584a: Clean up some uses of XInternAtom
From: |
Po Lu |
Subject: |
master f5adb2584a: Clean up some uses of XInternAtom |
Date: |
Sun, 27 Mar 2022 21:00:58 -0400 (EDT) |
branch: master
commit f5adb2584a9e25e3bbf01d1ca1c7fc6e511a4012
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
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.
---
src/xfns.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
src/xterm.c | 2 ++
src/xterm.h | 5 ++++-
3 files changed, 67 insertions(+), 8 deletions(-)
diff --git a/src/xfns.c b/src/xfns.c
index 3f3054422a..534fb7c544 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
#else
Display *dpy = FRAME_X_DISPLAY (f);
PropMotifWmHints hints;
- Atom prop = XInternAtom (dpy, "_MOTIF_WM_HINTS", False);
+ Atom prop = FRAME_DISPLAY_INFO (f)->Xatom_MOTIF_WM_HINTS;
memset (&hints, 0, sizeof(hints));
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
xg_set_no_focus_on_map (f, new_value);
#else /* not USE_GTK */
Display *dpy = FRAME_X_DISPLAY (f);
- Atom prop = XInternAtom (dpy, "_NET_WM_USER_TIME", False);
+ Atom prop = FRAME_DISPLAY_INFO (f)->Xatom_net_wm_user_time;
Time timestamp = NILP (new_value) ? CurrentTime : 0;
XChangeProperty (dpy, FRAME_OUTER_WINDOW (f), prop,
@@ -3918,7 +3918,7 @@ x_window (struct frame *f, long window_prompting)
{
Display *dpy = FRAME_X_DISPLAY (f);
PropMotifWmHints hints;
- Atom prop = XInternAtom (dpy, "_MOTIF_WM_HINTS", False);
+ Atom prop = FRAME_DISPLAY_INFO (f)->Xatom_MOTIF_WM_HINTS;
memset (&hints, 0, sizeof(hints));
hints.flags = MWM_HINTS_DECORATIONS;
@@ -4097,7 +4097,7 @@ x_window (struct frame *f)
{
Display *dpy = FRAME_X_DISPLAY (f);
PropMotifWmHints hints;
- Atom prop = XInternAtom (dpy, "_MOTIF_WM_HINTS", False);
+ Atom prop = FRAME_DISPLAY_INFO (f)->Xatom_MOTIF_WM_HINTS;
memset (&hints, 0, sizeof(hints));
hints.flags = MWM_HINTS_DECORATIONS;
@@ -4435,9 +4435,7 @@ set_machine_and_pid_properties (struct frame *f)
unsigned long xpid = pid;
XChangeProperty (FRAME_X_DISPLAY (f),
FRAME_OUTER_WINDOW (f),
- XInternAtom (FRAME_X_DISPLAY (f),
- "_NET_WM_PID",
- False),
+ FRAME_DISPLAY_INFO (f)->Xatom_net_wm_pid,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &xpid, 1);
}
@@ -7073,6 +7071,13 @@ If WINDOW-ID is non-nil, change the property of that
window instead
unsigned char *data;
int nelements;
Window target_window;
+#ifdef USE_XCB
+ xcb_intern_atom_cookie_t prop_atom_cookie;
+ xcb_intern_atom_cookie_t target_type_cookie;
+ xcb_intern_atom_reply_t *reply;
+ xcb_generic_error_t *generic_error;
+ bool rc;
+#endif
CHECK_STRING (prop);
@@ -7136,12 +7141,61 @@ If WINDOW-ID is non-nil, change the property of that
window instead
}
block_input ();
+#ifndef USE_XCB
prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False);
if (! NILP (type))
{
CHECK_STRING (type);
target_type = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (type), False);
}
+#else
+ rc = true;
+ prop_atom_cookie
+ = xcb_intern_atom (FRAME_DISPLAY_INFO (f)->xcb_connection,
+ 0, SBYTES (prop), SSDATA (prop));
+
+ if (!NILP (type))
+ {
+ CHECK_STRING (type);
+ target_type_cookie
+ = xcb_intern_atom (FRAME_DISPLAY_INFO (f)->xcb_connection,
+ 0, SBYTES (type), SSDATA (type));
+ }
+
+ reply = xcb_intern_atom_reply (FRAME_DISPLAY_INFO (f)->xcb_connection,
+ prop_atom_cookie, &generic_error);
+
+ if (reply)
+ {
+ prop_atom = (Atom) reply->atom;
+ free (reply);
+ }
+ else
+ {
+ free (generic_error);
+ rc = false;
+ }
+
+ if (!NILP (type))
+ {
+ reply = xcb_intern_atom_reply (FRAME_DISPLAY_INFO (f)->xcb_connection,
+ target_type_cookie, &generic_error);
+
+ if (reply)
+ {
+ target_type = (Atom) reply->atom;
+ free (reply);
+ }
+ else
+ {
+ free (generic_error);
+ rc = false;
+ }
+ }
+
+ if (!rc)
+ error ("Failed to intern type or property atom");
+#endif
XChangeProperty (FRAME_X_DISPLAY (f), target_window,
prop_atom, target_type, element_format, PropModeReplace,
diff --git a/src/xterm.c b/src/xterm.c
index fbd6fadf1d..97dfbc5add 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)
ATOM_REFS_INIT ("CLIPBOARD_MANAGER", Xatom_CLIPBOARD_MANAGER)
ATOM_REFS_INIT ("XATOM_COUNTER", Xatom_XEMBED_INFO)
ATOM_REFS_INIT ("_XEMBED_INFO", Xatom_XEMBED_INFO)
+ ATOM_REFS_INIT ("_MOTIF_WM_HINTS", Xatom_MOTIF_WM_HINTS)
/* For properties of font. */
ATOM_REFS_INIT ("PIXEL_SIZE", Xatom_PIXEL_SIZE)
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)
ATOM_REFS_INIT ("_NET_WM_STATE_BELOW", Xatom_net_wm_state_below)
ATOM_REFS_INIT ("_NET_WM_OPAQUE_REGION", Xatom_net_wm_opaque_region)
ATOM_REFS_INIT ("_NET_WM_PING", Xatom_net_wm_ping)
+ ATOM_REFS_INIT ("_NET_WM_PID", Xatom_net_wm_pid)
#ifdef HAVE_XKB
ATOM_REFS_INIT ("Meta", Xatom_Meta)
ATOM_REFS_INIT ("Super", Xatom_Super)
diff --git a/src/xterm.h b/src/xterm.h
index a155245f81..57b55ecf0d 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -433,6 +433,8 @@ struct x_display_info
/* Atom used to determine whether or not the screen is composited. */
Atom Xatom_NET_WM_CM_Sn;
+ Atom Xatom_MOTIF_WM_HINTS;
+
/* The frame (if any) which has the X window that has keyboard focus.
Zero if none. This is examined by Ffocus_frame in xfns.c. Note
that a mere EnterNotify event can set this; if you need to know the
@@ -551,7 +553,8 @@ struct x_display_info
Xatom_net_workarea, Xatom_net_wm_opaque_region, Xatom_net_wm_ping,
Xatom_net_wm_sync_request, Xatom_net_wm_sync_request_counter,
Xatom_net_wm_frame_drawn, Xatom_net_wm_user_time,
- Xatom_net_wm_user_time_window, Xatom_net_client_list_stacking;
+ Xatom_net_wm_user_time_window, Xatom_net_client_list_stacking,
+ Xatom_net_wm_pid;
/* XSettings atoms and windows. */
Atom Xatom_xsettings_sel, Xatom_xsettings_prop, Xatom_xsettings_mgr;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master f5adb2584a: Clean up some uses of XInternAtom,
Po Lu <=