15b944e2aSmrg/* 20309d3b3Smrg * Copyright © 2007 Peter Hutterer 30309d3b3Smrg * Copyright © 2009 Red Hat, Inc. 45b944e2aSmrg * 50309d3b3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 60309d3b3Smrg * copy of this software and associated documentation files (the "Software"), 70309d3b3Smrg * to deal in the Software without restriction, including without limitation 80309d3b3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 90309d3b3Smrg * and/or sell copies of the Software, and to permit persons to whom the 100309d3b3Smrg * Software is furnished to do so, subject to the following conditions: 115b944e2aSmrg * 120309d3b3Smrg * The above copyright notice and this permission notice (including the next 130309d3b3Smrg * paragraph) shall be included in all copies or substantial portions of the 140309d3b3Smrg * Software. 155b944e2aSmrg * 160309d3b3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 170309d3b3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 180309d3b3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 190309d3b3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 200309d3b3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 210309d3b3Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 220309d3b3Smrg * DEALINGS IN THE SOFTWARE. 235b944e2aSmrg */ 245b944e2aSmrg 255b944e2aSmrg 265b944e2aSmrg#include "xinput.h" 275b944e2aSmrg#include <string.h> 285b944e2aSmrg 295b944e2aSmrgint 305b944e2aSmrgset_clientpointer(Display* dpy, int argc, char** argv, char* name, char *desc) 315b944e2aSmrg{ 3253719b08Smrg XIDeviceInfo *info; 335b944e2aSmrg XID window; 345b944e2aSmrg char* id; 355b944e2aSmrg char* dummy; 365b944e2aSmrg 375b944e2aSmrg if (argc <= 1) 385b944e2aSmrg { 395b944e2aSmrg fprintf(stderr, "Usage: xinput %s %s\n", name, desc); 405b944e2aSmrg return EXIT_FAILURE; 415b944e2aSmrg } 425b944e2aSmrg 435b944e2aSmrg id = argv[0]; 445b944e2aSmrg 455b944e2aSmrg while(*id == '0') id++; 465b944e2aSmrg 475b944e2aSmrg window = strtol(argv[0], &dummy, (*id == 'x') ? 16 : 10); 485b944e2aSmrg 4953719b08Smrg info = xi2_find_device_info(dpy, argv[1]); 505b944e2aSmrg 515b944e2aSmrg if (!info) { 520309d3b3Smrg fprintf(stderr, "unable to find device '%s'\n", argv[1]); 535b944e2aSmrg return EXIT_FAILURE; 545b944e2aSmrg } 555b944e2aSmrg 5653719b08Smrg XISetClientPointer(dpy, window, info->deviceid); 575b944e2aSmrg return 0; 585b944e2aSmrg} 59