Results 1 to 11 of 11

Thread: hooks in linux

  1. #1
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default hooks in linux

    hi!
    is there something like windows hooks in linux?
    can i use grabMouse for this, or do other apps dont get mouse events than anymore?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

  3. The following user says thank you to jpn for this useful post:

    kernel_panic (20th October 2007)

  4. #3
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: hooks in linux

    hm this doen't work very fine....
    im doing this:

    Qt Code:
    1. Display *display = QX11Info::display();
    2. Window grab_window = oWidget->winId();
    3. Bool owner_events = true;
    4. unsigned int event_mask = ButtonPressMask | PointerMotionMask;
    5. int pointer_mode = GrabModeAsync, keyboard_mode = GrabModeAsync;
    6. Window confine_to = QX11Info::appRootWindow();
    7. Cursor cursor = 0;
    8. Time time = CurrentTime;
    9. XGrabPointer(display, grab_window, owner_events, event_mask, pointer_mode,
    10. keyboard_mode, confine_to, cursor, time);
    To copy to clipboard, switch view to plain text mode 
    is it wrong?
    i call it in a thread.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: hooks in linux

    But what are you trying to achieve? I don't think you have to use the native API here, because Qt handles that. I think the only question is if you really want to grab the pointer.

  6. #5
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: hooks in linux

    YEs i really want to grab, but how i do it under windows!
    My widget shall get all mouse events, before all other applications get the events.
    When the mouse somewhere at the screen was moved, i want to know.
    But without freezing the pointer for other widgets. isn't this possible on linux?

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: hooks in linux

    If you grab the mouse, no other window (regardless of the application) than the grabbing one will get the event. It's a way to steal events, not to monitor them. Thus my question - what is your goal? Maybe it's enough to reimplement x11Event() and handle some specific event there...

  8. #7
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: hooks in linux

    if x11Event is global (for the whole desktop, not only for my app) this is what i need.

    i show you what i want to do. This app doesn't act as i want it. i need to know all global mouse events to make it work right.
    Attached Files Attached Files

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: hooks in linux

    There surely has to be a way to intercept pending mouse events on X. You might check out KDE sources (specificaly applications like Karm) to see how to do it. You are entering desktop manager specific things here...

  10. #9
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: hooks in linux

    There are ways to listen to global events on both Windows and X11. I've done it, but it has been years and I don't remember now what the details are.

  11. #10
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: hooks in linux

    this is what i need! please find out or give me a hint. which librarys did you use under linux? xlib?

  12. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: hooks in linux


Similar Threads

  1. Opacity in Linux OS
    By shyam prasad in forum Qt Programming
    Replies: 2
    Last Post: 22nd May 2007, 05:59
  2. Compiling Linux project on Mac
    By December in forum Newbie
    Replies: 2
    Last Post: 25th March 2007, 04:25
  3. Replies: 2
    Last Post: 12th January 2007, 11:19
  4. QT 3 (linux) to 4(windows XP)
    By deekayt in forum Qt Programming
    Replies: 1
    Last Post: 17th October 2006, 18:30
  5. Qt 4.1.2 Fails to build on Linux
    By rohandhruva in forum Installation and Deployment
    Replies: 6
    Last Post: 16th April 2006, 21:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.