Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7919899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:01:21+00:00 2026-06-03T16:01:21+00:00

I have been porting my system to X11 and I have a problem with

  • 0

I have been porting my system to X11 and I have a problem with clipboard copy (paste is already working). I have followed this. After a while I noticed that his example does not work too. Problem is when I try to paste it to somewhere, instead of XA_STRING requested atom id is 434. I couldnt find what this atom is for. When I change XA_STRING to 434 I get a different error. The following is the code.

void SetClipboardText(const std::string &text) {
   XSetSelectionOwner (display, XA_CLIPBOARD, windowhandle, CurrentTime);
   copiedtext=text;
   XFlush(display);
   std::cout<<"COPIED"<<std::endl;
}

...
case SelectionRequest:
    XEvent respond;

    std::cout<<"SELTYPE: "<<event.xselectionrequest.target<<std::endl;

    if(event.xselectionrequest.target==XA_STRING && 
        event.xselectionrequest.selection==XA_CLIPBOARD) {
        std::cout<<"REQUESTED"<<std::endl;

        XChangeProperty (display,
            event.xselectionrequest.requestor,
            event.xselectionrequest.property,
            XA_STRING,
            copiedtext.length(),
            PropModeReplace,
            (unsigned char*) copiedtext.c_str(),
            copiedtext.length()
        );
        respond.xselection.property=event.xselectionrequest.property;
    }
    else {
        respond.xselection.property= None;
    }
    respond.xselection.type= SelectionNotify;
    respond.xselection.display= event.xselectionrequest.display;
    respond.xselection.requestor= event.xselectionrequest.requestor;
    respond.xselection.selection=event.xselectionrequest.selection;
    respond.xselection.target= event.xselectionrequest.target;
    respond.xselection.time = event.xselectionrequest.time;
    XSendEvent (display, event.xselectionrequest.requestor,0,0,&respond);
    XFlush (display);
    break;

Error I got for replacing XA_STRING with 434:

X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  18 (X_ChangeProperty)
  Value in failed request:  0x4
  Serial number of failed request:  33
  Current serial number in output stream:  36

If relevant, I use KDE 4.8 and klipper is currently closed.

EDIT: Example from the website.

#include <X11/Xlib.h> 
#include <X11/Xatom.h>
#include <assert.h>   
#include <unistd.h>   
#include <stdio.h>
#include <stdlib.h>

main()
{
Display *dpy = XOpenDisplay(NULL);
assert(dpy);
Window w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 
                 200, 100, 0, 0, 0);
XSelectInput(dpy, w, StructureNotifyMask);
XMapWindow(dpy, w);
XSelectionRequestEvent *req;
XEvent e, respond;
for(;;) {
    XNextEvent(dpy, &e);
    if (e.type == MapNotify) break;
}
XFlush(dpy);
//
Atom a1, a2, a3, type;
XSelectInput(dpy, w, StructureNotifyMask+ExposureMask);
int format, result;
unsigned long len, bytes_left, dummy;
unsigned char *data;
Window Sown;
for (int ii = 0; ii < 50; ii++) {
    XSetSelectionOwner (dpy, XA_PRIMARY, w, CurrentTime);
    XFlush (dpy);
    XNextEvent (dpy, &e);
    if (e.type == SelectionRequest)
    //
    // Somebody wants our data
    //
    {
        req=&(e.xselectionrequest);
        printf ("Selection Request from Mr %i I am %i\n",
            (int)e.xselection.requestor, (int)w);
        printf ("prop:%i tar:%i sel:%i\n", req->property,
            req->target, req->selection);
        if (req->target == XA_STRING)
        {
            XChangeProperty (dpy,
                req->requestor,
                req->property,
                XA_STRING,
                8,
                PropModeReplace,
                (unsigned char*) "It Works",
                8);
            respond.xselection.property=req->property;
        }
        else // Strings only please
        {
            printf ("No String %i\n",
                (int)req->target);
            respond.xselection.property= None;
        }
        respond.xselection.type= SelectionNotify;
        respond.xselection.display= req->display;
        respond.xselection.requestor= req->requestor;
        respond.xselection.selection=req->selection;
        respond.xselection.target= req->target;
        respond.xselection.time = req->time;
        XSendEvent (dpy, req->requestor,0,0,&respond);
        XFlush (dpy);
    }
}
}

Compile using

gcc copytest.c -o copytest -std=c99 -lX11
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:01:22+00:00Added an answer on June 3, 2026 at 4:01 pm

    Following is requied to work for KDE applications

    else if(event.xselectionrequest.target==XA_TARGETS && 
      event.xselectionrequest.selection==XA_CLIPBOARD) {
        Atom supported[]={XA_STRING};
        XChangeProperty (display,
            event.xselectionrequest.requestor,
            event.xselectionrequest.property,
            XA_TARGETS,
            8,
            PropModeReplace,
            (unsigned char *)(&supported),
            sizeof(supported)
        );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have recently been faced with the problem of porting our C++ framework to
Have been working on this question for a couple hours and have come close
I have been porting oracle selects, and I have been running across a lot
I have been tasked with porting a large Java codebase to the Android platform.
I have been reading up on porting ASP.NET Membership Provider into .NET 3.5 using
I've been tasked with porting/refactoring a Web Application Platform that we have from ASP.NET
In general, I have been having difficulties porting my .NET Windows Forms applications created
So I have been working on a 2 player Tic-Tac-Toe game in java that
Here is my problem. I have a ticket-tracking system that is not very 'user
UPDATE As Mathias notes below, this exact problem has been reported and resolved here:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.