summaryrefslogtreecommitdiffstats
path: root/tkmacosx/xxlib.M
blob: 412c56ce3e659763e6fdabdaafc89612f0787ff1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (C) 1999-2016
// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
// For conditions of distribution and use, see copyright notice in "copyright"

#include <iostream>
#include <sstream>
#include <iomanip>
using namespace std;

#include <tkMacOSXPrivate.h>

void XXWarpPointer(Display* display, Window src_w, Window dest_w,
		     int src_x, int src_y,
		     unsigned int src_width, unsigned int src_height,
		     int dest_x, int dest_y)
{
    int xx, yy;
    if (dest_w)
      Tk_GetRootCoords(Tk_IdToWindow(display,dest_w), &xx, &yy);
    else
      XQueryPointer(display, dest_w, NULL, NULL, &xx, &yy, NULL, NULL, NULL);

    CGPoint pt;
    pt.x = xx+dest_x;
    pt.y = yy+dest_y;

    CGEventSourceRef src = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState);
    CGEventRef ev = CGEventCreateMouseEvent(src,kCGEventMouseMoved,pt,kCGMouseButtonLeft);
    CGEventPost(kCGSessionEventTap,ev);
    CFRelease(ev);
    CFRelease(src);
}