Giter VIP home page Giter VIP logo

Comments (10)

kwhat avatar kwhat commented on May 13, 2024 4

Hi, It is possible for Windows and OS X systems, however, it is not currently possible on Linux or Unix. To use this functionality, you need to set the reserved flag of the uiohook_event structure to 0x1 when you recieve the event on callback. This flag must be set synchronously on the same thread as the callback is received on. So far, only the mask 1 >> 0 is supported for the reserved field.

from libuiohook.

WilixLead avatar WilixLead commented on May 13, 2024 2

Please look at this file https://github.com/WilixLead/iohook/blob/master/src/iohook.cc
For tests I just make this:

case EVENT_KEY_PRESSED:
    case EVENT_KEY_RELEASED:
    case EVENT_KEY_TYPED:
    case EVENT_MOUSE_PRESSED:
    case EVENT_MOUSE_RELEASED:
    case EVENT_MOUSE_CLICKED:
    case EVENT_MOUSE_MOVED:
    case EVENT_MOUSE_DRAGGED:
    case EVENT_MOUSE_WHEEL:
      event->reserved = 0x1; // <----- THIS
      uiohook_event event_copy;
      memcpy(&event_copy, event, sizeof(uiohook_event));

As I think, It should prevent all propagation. But really no :(
Where Im wrong?

from libuiohook.

WilixLead avatar WilixLead commented on May 13, 2024

Thank you!
But. I use parts of code from examples and my code looks like this:

void dispatch_proc(uiohook_event * const event) {
  switch (event->type) {
    ....
    case EVENT_KEY_PRESSED:
    case EVENT_KEY_RELEASED:
    case EVENT_KEY_TYPED:
    case EVENT_MOUSE_PRESSED:
    case EVENT_MOUSE_RELEASED:
    case EVENT_MOUSE_CLICKED:
    case EVENT_MOUSE_MOVED:
    case EVENT_MOUSE_DRAGGED:
    case EVENT_MOUSE_WHEEL:
      event->reserved = 0x1;
      ......
    break;
  }
}

But events still emits to the system. What I'm doing wrong?

from libuiohook.

kwhat avatar kwhat commented on May 13, 2024

That looks correct, which branch are you compiling? The master branch is probably broken and 1.1 is the current stable.

from libuiohook.

WilixLead avatar WilixLead commented on May 13, 2024

I use 1.1 branch. Some later I try remove current version of libuiohook and clone clean 1.1. But I think it is not help.
What should happen if I prevent key? When I type something and always set reserverd = 0x1, nothing will be typed (in notepad or terminal for example) ?

from libuiohook.

kwhat avatar kwhat commented on May 13, 2024

Yes, if you set the reserved flag, it will prevent the event it was set for from propagating. So if it was a mouse move event, the mouse will not move. If it was a key down and key up, you will not be able to type.

from libuiohook.

kwhat avatar kwhat commented on May 13, 2024

Please post the code you are using for the callback so I may better help you.

from libuiohook.

kwhat avatar kwhat commented on May 13, 2024

I am not sure if it matters in your implementation, but the reserved flag must be set on the same thread context that it was called from. So you cannot copy the memory to a different thread.

from libuiohook.

pigfrown avatar pigfrown commented on May 13, 2024

Is it still the case that preventing event propagation is not possible on *nix?

If so are there any plans to add this functionality?

Thanks

from libuiohook.

kwhat avatar kwhat commented on May 13, 2024

It's not possible on X11 due to some technical limitations and I doubt that will ever change. It maybe possible on Wayland, but that hasn't really seen widespread adoption thus far. Migrating this library to wayland is going to take substantial effort and I haven't really looked into it much at this point. If anyone really wants this functionality, start looking into wayland to see this maybe possible. I only have so many hours in a day and right now 2.2 getting finalized and a 3.0 refactor to fix several other long standing issues are a priority.

from libuiohook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.