Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow using extra buttons on disabled devices #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions grabber.cc
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,18 @@ void Grabber::grab_xi(bool grab) {
if (!xi_grabbed == !grab)
return;
xi_grabbed = grab;
for (DeviceMap::iterator i = xi_devs.begin(); i != xi_devs.end(); ++i)
if (i->second->active)
for (std::vector<ButtonInfo>::iterator j = buttons.begin(); j != buttons.end(); j++)
i->second->grab_button(*j, grab);
if (! experimental) { //standard behaviour; only grab enabled devices
for (DeviceMap::iterator i = xi_devs.begin(); i != xi_devs.end(); ++i)
if (i->second->active)
for (std::vector<ButtonInfo>::iterator j = buttons.begin(); j != buttons.end(); j++)
i->second->grab_button(*j, grab );
}
else { //modified behaviour; also grab additional buttons of disabled devices
for (DeviceMap::iterator i = xi_devs.begin(); i != xi_devs.end(); ++i)
for (std::vector<ButtonInfo>::iterator j = buttons.begin(); j != buttons.end(); j++)
if (i->second->active || j!=buttons.begin() )
i->second->grab_button(*j, grab );
}
}

void Grabber::XiDevice::grab_device(GrabState grab) {
Expand Down
18 changes: 18 additions & 0 deletions handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,17 @@ void XState::handle_xi2_event(XIDeviceEvent *event) {
break;
xinput_pressed.erase(event->detail);
in_proximity = get_axis(event->valuators, current_dev->proximity_axis);

if (experimental) //if device is disabled, but extra buttons followed, treat last extra button as the default button
for (std::set<std::string>::iterator i = prefs.excluded_devices.ref().begin(); i != prefs.excluded_devices.ref().end(); i++)
if (! i->compare(grabber->get_xi_dev(event->deviceid)->name) ) //check if the grabbed device name is in disabled device list
{

if ( prefs.extra_buttons.ref().size() && (guint) event->detail == prefs.extra_buttons.ref().rbegin()->button) //check if the button is same as last extra button
event->detail = 100+event->detail; //fake the default button
//event->detail = prefs.button.ref().button; //fake the default button
}

H->release(event->detail, create_triple(event->root_x, event->root_y, event->time));
break;
case XI_Motion:
Expand Down Expand Up @@ -968,6 +979,13 @@ class StrokeHandler : public Handler, public sigc::trackable {
virtual void release(guint b, RTriple e) {
RStroke s = finish(0);

if (experimental) //button 1 should be treated as trigger 0, other trigger buttons copied from the event button b itself
if (b>100)
{
b=b-100;
s->trigger = prefs.button.ref().button-1;
}

if (prefs.move_back.get() && !xstate->current_dev->absolute)
XTestFakeMotionEvent(dpy, DefaultScreen(dpy), orig->x, orig->y, 0);
else
Expand Down