Find the answer to your Linux question:
Results 1 to 4 of 4
i wrote a program,it is an xlib program.. i want to catch the event regarding to a window like firefox that is running on the server and i got this ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2010
    Posts
    14

    problem in xlib programming


    i wrote a program,it is an xlib program..
    i want to catch the event regarding to a window like firefox that is running on the server and i got this error:

    X Error of failed request: BadAccess (attempt to access private resource denied)
    Major opcode of failed request: 2 (X_ChangeWindowAttributes)
    Serial number of failed request: 11
    Current serial number in output stream: 13



    when i add this line to the code ,error occured:
    XSelectInput (display, w, ExposureMask | KeyPressMask | ButtonPressMask);
    this is a part of code:

    Window rt,pr;
    Window *children_return;
    unsigned int nofch;
    int f=XQueryTree(display, DefaultRootWindow(display), &rt, &pr, &children_return, &nofch);
    uint *array=(uint*)children_return;
    uint k;
    for (k = 0; k < nofch; k++)
    {
    //GET THE STATUS OF WINDOW
    XWindowAttributes a;
    XGetWindowAttributes(display, children_return[k], &a);
    //printf("status:%d",a.map_state);

    //GET THE WINDOW ID:
    Window w = (Window) array[k];
    char * name='\0';
    int status =XFetchName(display,w,&name);
    if (status>=Success&&a.map_state==2)
    {
    printf("Found %u: %u %s -- statuse=%d\n",k, w, name,a.map_state);
    XSelectInput (display, w, ExposureMask | KeyPressMask | ButtonPressMask);
    }
    }

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,755
    Are you running the xlib program in the same user account as Firefox? On the same machine where Firefox is being run (client machine), or (if they are different) on the X display server machine? You may need to make sure that your X display is the same as Firefox, and it is possible that you may need to run the xlib application as root in order to overcome the privacy/permissions issue that you have run into.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Sep 2010
    Posts
    14
    Quote Originally Posted by Rubberman View Post
    Are you running the xlib program in the same user account as Firefox? On the same machine where Firefox is being run (client machine), or (if they are different) on the X display server machine? You may need to make sure that your X display is the same as Firefox, and it is possible that you may need to run the xlib application as root in order to overcome the privacy/permissions issue that you have run into.
    yes,it is running on single computer..
    also i run it as root...

    but i dont know how i can check weather X display is the same as Firefox or not??
    i create' display' in my program by this command "display = XOpenDisplay (0); ".

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,755
    The display is either set via the DISPLAY environment variable, or a command-line option to the program which in turn sets the DISPLAY environment inside the application. Normall this would be :0.0
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •