summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2013-02-06 19:28:33 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2013-02-06 21:17:47 +0100
commit3725c23fddd8e936a91296f74e3fd6342270d6bb (patch)
tree4aec8e8d58ad232918aea32863a75d36f976587e /src
parent5c0abe47a800dca3faf97b7ec608d86fddab25b6 (diff)
downloadratpoison-3725c23fddd8e936a91296f74e3fd6342270d6bb.zip
make TEXT atoms global variables
* (events.c) extract xa_compound_text from selection_request(), make it a global * introduce xa_string (same as XA_STRING) and rename utf8_string to xa_utf8_string, for consistency
Diffstat (limited to 'src')
-rw-r--r--src/communications.c6
-rw-r--r--src/events.c21
-rw-r--r--src/globals.c10
-rw-r--r--src/globals.h6
-rw-r--r--src/main.c6
-rw-r--r--src/screen.c2
6 files changed, 30 insertions, 21 deletions
diff --git a/src/communications.c b/src/communications.c
index 5f0cdc7..0b50c9e 100644
--- a/src/communications.c
+++ b/src/communications.c
@@ -43,7 +43,7 @@ receive_command_result (Window w)
/* First, find out how big the property is. */
status = XGetWindowProperty (dpy, w, rp_command_result,
- 0, 0, False, XA_STRING,
+ 0, 0, False, xa_string,
&type_ret, &format_ret, &nitems, &bytes_after,
&result);
@@ -62,7 +62,7 @@ receive_command_result (Window w)
whole message. */
status = XGetWindowProperty (dpy, w, rp_command_result,
0, (bytes_after / 4) + (bytes_after % 4 ? 1 : 0),
- True, XA_STRING, &type_ret, &format_ret, &nitems,
+ True, xa_string, &type_ret, &format_ret, &nitems,
&bytes_after, &result);
/* Failed to retrieve property. */
@@ -108,7 +108,7 @@ send_command (unsigned char interactive, unsigned char *cmd, int screen_num)
/* Select first to avoid race condition */
XSelectInput (dpy, w, PropertyChangeMask);
- XChangeProperty (dpy, w, rp_command, XA_STRING,
+ XChangeProperty (dpy, w, rp_command, xa_string,
8, PropModeReplace, (unsigned char*)sbuf_get(s), strlen ((char *)cmd) + 2);
XChangeProperty (dpy, root,
diff --git a/src/events.c b/src/events.c
index 0a5d759..816d7b7 100644
--- a/src/events.c
+++ b/src/events.c
@@ -475,7 +475,7 @@ execute_remote_command (Window w)
unsigned char *req;
status = XGetWindowProperty (dpy, w, rp_command,
- 0, 0, False, XA_STRING,
+ 0, 0, False, xa_string,
&type_ret, &format_ret, &nitems, &bytes_after,
&req);
@@ -490,7 +490,7 @@ execute_remote_command (Window w)
status = XGetWindowProperty (dpy, w, rp_command,
0, (bytes_after / 4) + (bytes_after % 4 ? 1 : 0),
- True, XA_STRING, &type_ret, &format_ret, &nitems,
+ True, xa_string, &type_ret, &format_ret, &nitems,
&bytes_after, &req);
if (status != Success || req == NULL)
@@ -573,10 +573,10 @@ receive_command (Window root)
else
result = NULL;
if (result)
- XChangeProperty (dpy, w, rp_command_result, XA_STRING,
+ XChangeProperty (dpy, w, rp_command_result, xa_string,
8, PropModeReplace, (unsigned char *)result, strlen (result));
else
- XChangeProperty (dpy, w, rp_command_result, XA_STRING,
+ XChangeProperty (dpy, w, rp_command_result, xa_string,
8, PropModeReplace, NULL, 0);
free (result);
cmdret_free (cmd_ret);
@@ -733,16 +733,13 @@ selection_request (XSelectionRequestEvent *rq)
CARD32 target_list[4];
Atom target;
static Atom xa_targets = None;
- static Atom xa_compound_text = None;
- static Atom xa_text = None;
+ static Atom xa_text = None; /* XXX */
XTextProperty ct;
XICCEncodingStyle style;
char *cl[4];
if (xa_text == None)
xa_text = XInternAtom(dpy, "TEXT", False);
- if (xa_compound_text == None)
- xa_compound_text = XInternAtom(dpy, "COMPOUND_TEXT", False);
if (xa_targets == None)
xa_targets = XInternAtom(dpy, "TARGETS", False);
@@ -756,7 +753,7 @@ selection_request (XSelectionRequestEvent *rq)
if (rq->target == xa_targets) {
target_list[0] = (CARD32) xa_targets;
- target_list[1] = (CARD32) XA_STRING;
+ target_list[1] = (CARD32) xa_string;
target_list[2] = (CARD32) xa_text;
target_list[3] = (CARD32) xa_compound_text;
XChangeProperty(dpy, rq->requestor, rq->property, rq->target,
@@ -764,12 +761,12 @@ selection_request (XSelectionRequestEvent *rq)
(unsigned char *)target_list,
(sizeof(target_list) / sizeof(target_list[0])));
ev.xselection.property = rq->property;
- } else if (rq->target == XA_STRING
+ } else if (rq->target == xa_string
|| rq->target == xa_compound_text
|| rq->target == xa_text) {
- if (rq->target == XA_STRING) {
+ if (rq->target == xa_string) {
style = XStringStyle;
- target = XA_STRING;
+ target = xa_string;
} else {
target = xa_compound_text;
style = (rq->target == xa_compound_text) ? XCompoundTextStyle
diff --git a/src/globals.c b/src/globals.c
index 3029aef..8824484 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -47,13 +47,17 @@ Atom rp_command_request;
Atom rp_command_result;
Atom rp_selection;
+/* TEXT atoms */
+Atom xa_string;
+Atom xa_compound_text;
+Atom xa_utf8_string;
+
/* netwm atoms */
Atom _net_wm_pid;
Atom _net_supported;
Atom _net_wm_window_type;
Atom _net_wm_window_type_dialog;
Atom _net_wm_name;
-Atom utf8_string;
int rp_current_screen;
rp_screen *screens;
@@ -94,7 +98,7 @@ x_export_selection (void)
XSetSelectionOwner(dpy, XA_PRIMARY, screens[0].key_window, CurrentTime);
if (XGetSelectionOwner(dpy, XA_PRIMARY) != screens[0].key_window)
PRINT_ERROR(("can't get primary selection"));
- XChangeProperty(dpy, screens[0].root, XA_CUT_BUFFER0, XA_STRING, 8,
+ XChangeProperty(dpy, screens[0].root, XA_CUT_BUFFER0, xa_string, 8,
PropModeReplace, (unsigned char*)selection.text, selection.len);
}
@@ -196,7 +200,7 @@ get_selection (void)
/* be a good icccm citizen */
XDeleteProperty (dpy, s->input_window, rp_selection);
/* TODO: we shouldn't use CurrentTime here, use the time of the XKeyEvent, should we fake it? */
- XConvertSelection (dpy, XA_PRIMARY, XA_STRING, rp_selection, s->input_window, CurrentTime);
+ XConvertSelection (dpy, XA_PRIMARY, xa_string, rp_selection, s->input_window, CurrentTime);
/* This seems like a hack. */
while (!XCheckTypedWindowEvent (dpy, s->input_window, SelectionNotify, &ev))
diff --git a/src/globals.h b/src/globals.h
index e5ba32a..61081f4 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -124,13 +124,17 @@ extern Atom wm_delete;
extern Atom wm_take_focus;
extern Atom wm_colormaps;
+/* TEXT atoms */
+extern Atom xa_string;
+extern Atom xa_compound_text;
+extern Atom xa_utf8_string;
+
/* netwm atoms. */
extern Atom _net_wm_pid;
extern Atom _net_supported;
extern Atom _net_wm_window_type;
extern Atom _net_wm_window_type_dialog;
extern Atom _net_wm_name;
-extern Atom utf8_string;
/* mouse properties */
extern int rat_x;
diff --git a/src/main.c b/src/main.c
index bbd0e12..61aad69 100644
--- a/src/main.c
+++ b/src/main.c
@@ -701,6 +701,11 @@ main (int argc, char *argv[])
wm_take_focus = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
wm_colormaps = XInternAtom(dpy, "WM_COLORMAP_WINDOWS", False);
+ /* TEXT atoms */
+ xa_string = XA_STRING;
+ xa_compound_text = XInternAtom(dpy, "COMPOUND_TEXT", False);
+ xa_utf8_string = XInternAtom(dpy, "UTF8_STRING", False);
+
/* netwm atoms */
_net_wm_pid = XInternAtom(dpy, "_NET_WM_PID", False);
PRINT_DEBUG (("_NET_WM_PID = %ld\n", _net_wm_pid));
@@ -709,7 +714,6 @@ main (int argc, char *argv[])
_net_wm_window_type = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
_net_wm_window_type_dialog = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
_net_wm_name = XInternAtom(dpy, "_NET_WM_NAME", False);
- utf8_string = XInternAtom(dpy, "UTF8_STRING", False);
/* Setup signal handlers. */
XSetErrorHandler(handler);
diff --git a/src/screen.c b/src/screen.c
index ab8bf95..d843c04 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -395,7 +395,7 @@ activate_screen (rp_screen *s)
/* set window manager name */
XChangeProperty (dpy, RootWindow (dpy, s->screen_num),
- _net_wm_name, utf8_string, 8, PropModeReplace,
+ _net_wm_name, xa_utf8_string, 8, PropModeReplace,
(unsigned char*)"ratpoison", 9);
XMapWindow (dpy, s->key_window);
}