diff options
author | Ulrich Sibiller <uli42@gmx.de> | 2020-09-23 23:21:37 +0200 |
---|---|---|
committer | Ulrich Sibiller <uli42@gmx.de> | 2021-06-20 20:12:50 +0200 |
commit | a3adf6641e9d93fdeb7d345b28f59f6415bb9aa6 (patch) | |
tree | 2a36a2c76a73bc26dc5e7363953b9c949449b608 /nx-X11/programs/Xserver/hw | |
parent | d79db429dd1db5a507dcecb2bd8f79d4e3545be4 (diff) | |
download | nx-libs-a3adf6641e9d93fdeb7d345b28f59f6415bb9aa6.tar.gz nx-libs-a3adf6641e9d93fdeb7d345b28f59f6415bb9aa6.tar.bz2 nx-libs-a3adf6641e9d93fdeb7d345b28f59f6415bb9aa6.zip |
Clipboard.c: remove superflous index determination
we already have it at that stage
Diffstat (limited to 'nx-X11/programs/Xserver/hw')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 172 |
1 files changed, 84 insertions, 88 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 40a812b9b..da07cad40 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -1554,32 +1554,46 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X) } else { - int index = nxagentFindLastSelectionOwnerIndex(X->xselection.selection); - if (index < nxagentMaxSelections) + /* if the last owner was an internal one, read the + * clientCutProperty and push the contents to the + * lastServers[index].requestor on the real X server. + */ + if (IS_INTERNAL_OWNER(index) && + lastSelectionOwner[index].windowPtr != NULL && + X->xselection.property == serverTransFromAgentProperty) { - /* if the last owner was an internal one, read the - * clientCutProperty and push the contents to the - * lastServers[index].requestor on the real X server. - */ - if (IS_INTERNAL_OWNER(index) && - lastSelectionOwner[index].windowPtr != NULL && - X->xselection.property == serverTransFromAgentProperty) - { - Atom atomReturnType; - int resultFormat; - unsigned long ulReturnItems; - unsigned long ulReturnBytesLeft; - unsigned char *pszReturnData = NULL; + Atom atomReturnType; + int resultFormat; + unsigned long ulReturnItems; + unsigned long ulReturnBytesLeft; + unsigned char *pszReturnData = NULL; - /* first get size values ... */ - int result = GetWindowProperty(lastSelectionOwner[index].windowPtr, clientCutProperty, 0, 0, False, - AnyPropertyType, &atomReturnType, &resultFormat, - &ulReturnItems, &ulReturnBytesLeft, &pszReturnData); + /* first get size values ... */ + int result = GetWindowProperty(lastSelectionOwner[index].windowPtr, clientCutProperty, 0, 0, False, + AnyPropertyType, &atomReturnType, &resultFormat, + &ulReturnItems, &ulReturnBytesLeft, &pszReturnData); + #ifdef DEBUG + fprintf(stderr, "%s: GetWindowProperty() window [0x%x] property [%d] returned [%s]\n", __func__, + lastSelectionOwner[index].window, clientCutProperty, getXErrorString(result)); + #endif + if (result == BadAlloc || result == BadAtom || + result == BadWindow || result == BadValue) + { + lastServers[index].property = None; + } + else + { + /* ... then use the size values for the actual request */ + result = GetWindowProperty(lastSelectionOwner[index].windowPtr, clientCutProperty, 0, + ulReturnBytesLeft, False, AnyPropertyType, &atomReturnType, + &resultFormat, &ulReturnItems, &ulReturnBytesLeft, + &pszReturnData); #ifdef DEBUG fprintf(stderr, "%s: GetWindowProperty() window [0x%x] property [%d] returned [%s]\n", __func__, lastSelectionOwner[index].window, clientCutProperty, getXErrorString(result)); #endif + if (result == BadAlloc || result == BadAtom || result == BadWindow || result == BadValue) { @@ -1587,84 +1601,66 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X) } else { - /* ... then use the size values for the actual request */ - result = GetWindowProperty(lastSelectionOwner[index].windowPtr, clientCutProperty, 0, - ulReturnBytesLeft, False, AnyPropertyType, &atomReturnType, - &resultFormat, &ulReturnItems, &ulReturnBytesLeft, - &pszReturnData); - #ifdef DEBUG - fprintf(stderr, "%s: GetWindowProperty() window [0x%x] property [%d] returned [%s]\n", __func__, - lastSelectionOwner[index].window, clientCutProperty, getXErrorString(result)); - #endif + /* Fill the property on the initial requestor with the requested data */ + /* The XChangeProperty source code reveals it will always + return 1, no matter what, so no need to check the result */ + /* FIXME: better use the format returned by above request */ + XChangeProperty(nxagentDisplay, + lastServers[index].requestor, + lastServers[index].property, + lastServers[index].target, + 8, + PropModeReplace, + pszReturnData, + ulReturnItems); - if (result == BadAlloc || result == BadAtom || - result == BadWindow || result == BadValue) - { - lastServers[index].property = None; - } - else + #ifdef DEBUG { - /* Fill the property on the initial requestor with the requested data */ - /* The XChangeProperty source code reveals it will always - return 1, no matter what, so no need to check the result */ - /* FIXME: better use the format returned by above request */ - XChangeProperty(nxagentDisplay, - lastServers[index].requestor, - lastServers[index].property, - lastServers[index].target, - 8, - PropModeReplace, - pszReturnData, - ulReturnItems); - - #ifdef DEBUG - { - char *s = XGetAtomName(nxagentDisplay, lastServers[index].property); - fprintf(stderr, "%s: XChangeProperty sent to window [0x%x] for property [%ld][%s] value [\"%*.*s\"...]\n", - __func__, - lastServers[index].requestor, - lastServers[index].property, - s, - (int)(min(20, ulReturnItems * 8 / 8)), - (int)(min(20, ulReturnItems * 8 / 8)), - pszReturnData); - SAFE_XFree(s); - } - #endif + char *s = XGetAtomName(nxagentDisplay, lastServers[index].property); + fprintf(stderr, "%s: XChangeProperty sent to window [0x%x] for property [%ld][%s] value [\"%*.*s\"...]\n", + __func__, + lastServers[index].requestor, + lastServers[index].property, + s, + (int)(min(20, ulReturnItems * 8 / 8)), + (int)(min(20, ulReturnItems * 8 / 8)), + pszReturnData); + SAFE_XFree(s); } - - /* FIXME: free it or not? */ - /* - * SAFE_XFree(pszReturnData); - */ + #endif } + /* FIXME: free it or not? */ /* - * inform the initial requestor that the requested data has - * arrived in the desired property. If we have been unable to - * get the data from the owner XChangeProperty will not have - * been called and lastServers[index].property will be None which - * effectively will send a "Request denied" to the initial - * requestor. + * SAFE_XFree(pszReturnData); */ - XSelectionEvent eventSelection = { - .requestor = lastServers[index].requestor, - .selection = X->xselection.selection, - /* .target = X->xselection.target, */ - .target = lastServers[index].target, - .property = lastServers[index].property, - .time = lastServers[index].time, - /* .time = CurrentTime */ - }; - #ifdef DEBUG - fprintf(stderr, "%s: Sending SelectionNotify event to requestor [%p].\n", __func__, - (void *)eventSelection.requestor); - #endif + } - sendSelectionNotifyEventToXServer(&eventSelection); + /* + * inform the initial requestor that the requested data has + * arrived in the desired property. If we have been unable to + * get the data from the owner XChangeProperty will not have + * been called and lastServers[index].property will be None which + * effectively will send a "Request denied" to the initial + * requestor. + */ + XSelectionEvent eventSelection = { + .requestor = lastServers[index].requestor, + .selection = X->xselection.selection, + /* .target = X->xselection.target, */ + .target = lastServers[index].target, + .property = lastServers[index].property, + .time = lastServers[index].time, + /* .time = CurrentTime */ + }; + #ifdef DEBUG + fprintf(stderr, "%s: Sending SelectionNotify event to requestor [%p].\n", __func__, + (void *)eventSelection.requestor); + #endif - lastServers[index].requestor = None; /* allow further request */ - } + sendSelectionNotifyEventToXServer(&eventSelection); + + lastServers[index].requestor = None; /* allow further request */ } } } |