1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-03-22 03:13:31 +01:00

WINGs: fix TARGETS request return type

According to the ICCCM, a reply to a TARGETS request must be a list of atoms.
Took the chance to also fix variable naming consistency between wtext and
wtextfield which are using the same kind of code.
This commit is contained in:
David Maciejak
2026-01-20 17:26:19 -05:00
committed by Carlos R. Mafra
parent 9ddacfc29b
commit d37a3162e0
2 changed files with 26 additions and 26 deletions

View File

@@ -219,9 +219,9 @@ static char *default_bullet[] = {
}; };
/* These id are used when sharing the selected text between applications */ /* These id are used when sharing the selected text between applications */
static Atom XA_Targets = None; static Atom XA_TARGETS = None;
static Atom XA_Format_Text = None; static Atom XA_TEXT = None;
static Atom XA_Format_Compound_Text = None; static Atom XA_COMPOUND_TEXT = None;
static void handleEvents(XEvent * event, void *data); static void handleEvents(XEvent * event, void *data);
static void layOutDocument(Text * tPtr); static void layOutDocument(Text * tPtr);
@@ -2050,7 +2050,7 @@ static WMData *requestHandler(WMView * view, Atom selection, Atom target, void *
(void) selection; (void) selection;
(void) cdata; (void) cdata;
if (target == XA_STRING || target == XA_Format_Text || target == XA_Format_Compound_Text) { if (target == XA_STRING || target == XA_TEXT || target == XA_COMPOUND_TEXT) {
char *text = WMGetTextSelectedStream(tPtr); char *text = WMGetTextSelectedStream(tPtr);
if (text) { if (text) {
@@ -2063,18 +2063,18 @@ static WMData *requestHandler(WMView * view, Atom selection, Atom target, void *
} else } else
printf("didn't get it\n"); printf("didn't get it\n");
if (target == XA_Targets) { if (target == XA_TARGETS) {
Atom array[4]; Atom supported_type[4];
array[0] = XA_Targets; supported_type[0] = XA_TARGETS;
array[1] = XA_STRING; supported_type[1] = XA_STRING;
array[2] = XA_Format_Text; supported_type[2] = XA_TEXT;
array[3] = XA_Format_Compound_Text; supported_type[3] = XA_COMPOUND_TEXT;
data = WMCreateDataWithBytes(&array, sizeof(array)); data = WMCreateDataWithBytes(supported_type, sizeof(supported_type));
WMSetDataFormat(data, 32); WMSetDataFormat(data, 32);
*type = target; *type = XA_ATOM;
return data; return data;
} }
@@ -2977,15 +2977,15 @@ WMText *WMCreateTextForDocumentType(WMWidget * parent, WMAction * parser, WMActi
dpy = tPtr->view->screen->display; dpy = tPtr->view->screen->display;
scr = tPtr->view->screen; scr = tPtr->view->screen;
if (XA_Targets == None) { if (XA_TARGETS == None) {
/* /*
* Because the X protocol guaranties that the value will never change in * Because the X protocol guaranties that the value will never change in
* the lifespan of the server, we query the values only the first time a * the lifespan of the server, we query the values only the first time a
* widget is created * widget is created
*/ */
XA_Targets = XInternAtom(dpy, "TARGETS", False); XA_TARGETS = XInternAtom(dpy, "TARGETS", False);
XA_Format_Text = XInternAtom(dpy, "TEXT", False); XA_TEXT = XInternAtom(dpy, "TEXT", False);
XA_Format_Compound_Text = XInternAtom(dpy, "COMPOUND_TEXT", False); XA_COMPOUND_TEXT = XInternAtom(dpy, "COMPOUND_TEXT", False);
} }
tPtr->view->self = tPtr; tPtr->view->self = tPtr;

View File

@@ -239,9 +239,9 @@ static WMData *requestHandler(WMView * view, Atom selection, Atom target, void *
TextField *tPtr = view->self; TextField *tPtr = view->self;
int count; int count;
Display *dpy = tPtr->view->screen->display; Display *dpy = tPtr->view->screen->display;
Atom _TARGETS; Atom XA_TARGETS;
Atom TEXT = XInternAtom(dpy, "TEXT", False); Atom XA_TEXT = XInternAtom(dpy, "TEXT", False);
Atom COMPOUND_TEXT = XInternAtom(dpy, "COMPOUND_TEXT", False); Atom XA_COMPOUND_TEXT = XInternAtom(dpy, "COMPOUND_TEXT", False);
WMData *data; WMData *data;
/* Parameter not used, but tell the compiler that it is ok */ /* Parameter not used, but tell the compiler that it is ok */
@@ -251,7 +251,7 @@ static WMData *requestHandler(WMView * view, Atom selection, Atom target, void *
count = tPtr->selection.count < 0 count = tPtr->selection.count < 0
? tPtr->selection.position + tPtr->selection.count : tPtr->selection.position; ? tPtr->selection.position + tPtr->selection.count : tPtr->selection.position;
if (target == XA_STRING || target == TEXT || target == COMPOUND_TEXT) { if (target == XA_STRING || target == XA_TEXT || target == XA_COMPOUND_TEXT) {
data = WMCreateDataWithBytes(&(tPtr->text[count]), abs(tPtr->selection.count)); data = WMCreateDataWithBytes(&(tPtr->text[count]), abs(tPtr->selection.count));
WMSetDataFormat(data, 8); WMSetDataFormat(data, 8);
@@ -260,19 +260,19 @@ static WMData *requestHandler(WMView * view, Atom selection, Atom target, void *
return data; return data;
} }
_TARGETS = XInternAtom(dpy, "TARGETS", False); XA_TARGETS = XInternAtom(dpy, "TARGETS", False);
if (target == _TARGETS) { if (target == XA_TARGETS) {
Atom supported_type[4]; Atom supported_type[4];
supported_type[0] = _TARGETS; supported_type[0] = XA_TARGETS;
supported_type[1] = XA_STRING; supported_type[1] = XA_STRING;
supported_type[2] = TEXT; supported_type[2] = XA_TEXT;
supported_type[3] = COMPOUND_TEXT; supported_type[3] = XA_COMPOUND_TEXT;
data = WMCreateDataWithBytes(supported_type, sizeof(supported_type)); data = WMCreateDataWithBytes(supported_type, sizeof(supported_type));
WMSetDataFormat(data, 32); WMSetDataFormat(data, 32);
*type = target; *type = XA_ATOM;
return data; return data;
} }