188cd5fc2Smrg/*
288cd5fc2Smrg * Copyright © 2013 Keith Packard
388cd5fc2Smrg *
488cd5fc2Smrg * Permission to use, copy, modify, distribute, and sell this software and its
588cd5fc2Smrg * documentation for any purpose is hereby granted without fee, provided that
688cd5fc2Smrg * the above copyright notice appear in all copies and that both that copyright
788cd5fc2Smrg * notice and this permission notice appear in supporting documentation, and
888cd5fc2Smrg * that the name of the copyright holders not be used in advertising or
988cd5fc2Smrg * publicity pertaining to distribution of the software without specific,
1088cd5fc2Smrg * written prior permission.  The copyright holders make no representations
1188cd5fc2Smrg * about the suitability of this software for any purpose.  It is provided "as
1288cd5fc2Smrg * is" without express or implied warranty.
1388cd5fc2Smrg *
1488cd5fc2Smrg * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1588cd5fc2Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
1688cd5fc2Smrg * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1788cd5fc2Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
1888cd5fc2Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
1988cd5fc2Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
2088cd5fc2Smrg * OF THIS SOFTWARE.
2188cd5fc2Smrg */
2288cd5fc2Smrg
2388cd5fc2Smrg#ifndef _XPRESENT_H_
2488cd5fc2Smrg#define _XPRESENT_H_
2588cd5fc2Smrg
2688cd5fc2Smrg#include <stdint.h>
2788cd5fc2Smrg#include <X11/extensions/presenttokens.h>
2888cd5fc2Smrg
2988cd5fc2Smrg#include <X11/Xfuncproto.h>
3088cd5fc2Smrg#include <X11/Xlib.h>
3188cd5fc2Smrg#include <X11/extensions/Xfixes.h>
3288cd5fc2Smrg#include <X11/extensions/Xrandr.h>
3388cd5fc2Smrg#include <X11/extensions/sync.h>
3488cd5fc2Smrg
3588cd5fc2Smrg/*
3688cd5fc2Smrg * This revision number also appears in configure.ac, they have
3788cd5fc2Smrg * to be manually synchronized
3888cd5fc2Smrg */
3988cd5fc2Smrg#define PRESENT_REVISION	0
4088cd5fc2Smrg#define PRESENT_VERSION	((PRESENT_MAJOR * 10000) + (PRESENT_MINOR * 100) + (PRESENT_REVISION))
4188cd5fc2Smrg
4288cd5fc2Smrg/**
4388cd5fc2Smrg * Generic Present event. All Present events have the same header.
4488cd5fc2Smrg */
4588cd5fc2Smrg
4688cd5fc2Smrgtypedef struct {
4788cd5fc2Smrg    Window      window;
4888cd5fc2Smrg    uint32_t    serial;
4988cd5fc2Smrg} XPresentNotify;
5088cd5fc2Smrg
5188cd5fc2Smrgtypedef struct {
5288cd5fc2Smrg    int type;			/* event base */
5388cd5fc2Smrg    unsigned long serial;
5488cd5fc2Smrg    Bool send_event;
5588cd5fc2Smrg    Display *display;
5688cd5fc2Smrg    int extension;
5788cd5fc2Smrg    int evtype;
5888cd5fc2Smrg} XPresentEvent;
5988cd5fc2Smrg
6088cd5fc2Smrgtypedef struct {
6188cd5fc2Smrg    int type;			/* event base */
6288cd5fc2Smrg    unsigned long serial;
6388cd5fc2Smrg    Bool send_event;
6488cd5fc2Smrg    Display *display;
6588cd5fc2Smrg    int extension;
6688cd5fc2Smrg    int evtype;
6788cd5fc2Smrg
6888cd5fc2Smrg    uint32_t eid;
6988cd5fc2Smrg    Window window;
7088cd5fc2Smrg    int x,y;
7188cd5fc2Smrg    unsigned width, height;
7288cd5fc2Smrg    int off_x, off_y;
7388cd5fc2Smrg    int pixmap_width, pixmap_height;
7488cd5fc2Smrg    long pixmap_flags;
7588cd5fc2Smrg} XPresentConfigureNotifyEvent;
7688cd5fc2Smrg
7788cd5fc2Smrgtypedef struct {
7888cd5fc2Smrg    int type;			/* event base */
7988cd5fc2Smrg    unsigned long serial;
8088cd5fc2Smrg    Bool send_event;
8188cd5fc2Smrg    Display *display;
8288cd5fc2Smrg    int extension;
8388cd5fc2Smrg    int evtype;
8488cd5fc2Smrg
8588cd5fc2Smrg    uint32_t eid;
8688cd5fc2Smrg    Window window;
8788cd5fc2Smrg    uint32_t serial_number;
8888cd5fc2Smrg    uint64_t ust;
8988cd5fc2Smrg    uint64_t msc;
9088cd5fc2Smrg    uint8_t kind;
9188cd5fc2Smrg    uint8_t mode;
9288cd5fc2Smrg} XPresentCompleteNotifyEvent;
9388cd5fc2Smrg
9488cd5fc2Smrgtypedef struct {
9588cd5fc2Smrg    int type;			/* event base */
9688cd5fc2Smrg    unsigned long serial;
9788cd5fc2Smrg    Bool send_event;
9888cd5fc2Smrg    Display *display;
9988cd5fc2Smrg    int extension;
10088cd5fc2Smrg    int evtype;
10188cd5fc2Smrg
10288cd5fc2Smrg    uint32_t eid;
10388cd5fc2Smrg    Window window;
10488cd5fc2Smrg    uint32_t serial_number;
10588cd5fc2Smrg    Pixmap pixmap;
10688cd5fc2Smrg    XSyncFence idle_fence;
10788cd5fc2Smrg} XPresentIdleNotifyEvent;
10888cd5fc2Smrg
10988cd5fc2Smrg#if PRESENT_FUTURE_VERSION
11088cd5fc2Smrg
11188cd5fc2Smrgtypedef struct {
11288cd5fc2Smrg    int type;			/* event base */
11388cd5fc2Smrg    unsigned long serial;
11488cd5fc2Smrg    Bool send_event;
11588cd5fc2Smrg    Display *display;
11688cd5fc2Smrg    int extension;
11788cd5fc2Smrg    int evtype;
11888cd5fc2Smrg
11988cd5fc2Smrg    uint32_t eid;
12088cd5fc2Smrg    Window event_window;
12188cd5fc2Smrg
12288cd5fc2Smrg    Window window;
12388cd5fc2Smrg    Pixmap pixmap;
12488cd5fc2Smrg    uint32_t serial_number;
12588cd5fc2Smrg
12688cd5fc2Smrg    XserverRegion valid_region;
12788cd5fc2Smrg    XserverRegion update_region;
12888cd5fc2Smrg
12988cd5fc2Smrg    XRectangle valid_rect;
13088cd5fc2Smrg    XRectangle update_rect;
13188cd5fc2Smrg
13288cd5fc2Smrg    int x_off, y_off;
13388cd5fc2Smrg
13488cd5fc2Smrg    RRCrtc target_crtc;
13588cd5fc2Smrg
13688cd5fc2Smrg    XSyncFence wait_fence;
13788cd5fc2Smrg    XSyncFence idle_fence;
13888cd5fc2Smrg
13988cd5fc2Smrg    uint32_t options;
14088cd5fc2Smrg
14188cd5fc2Smrg    uint64_t target_msc;
14288cd5fc2Smrg    uint64_t divisor;
14388cd5fc2Smrg    uint64_t remainder;
14488cd5fc2Smrg    XPresentNotify *notifies;
14588cd5fc2Smrg    int nnotifies;
14688cd5fc2Smrg} XPresentRedirectNotifyEvent;
14788cd5fc2Smrg
14888cd5fc2Smrg#endif
14988cd5fc2Smrg
15088cd5fc2Smrg_XFUNCPROTOBEGIN
15188cd5fc2Smrg
15288cd5fc2SmrgBool XPresentQueryExtension (Display *dpy,
15388cd5fc2Smrg                             int *major_opcode_return,
15488cd5fc2Smrg                             int *event_base_return,
15588cd5fc2Smrg                             int *error_base_return);
15688cd5fc2Smrg
15788cd5fc2SmrgStatus XPresentQueryVersion (Display *dpy,
15888cd5fc2Smrg			    int     *major_version_return,
15988cd5fc2Smrg			    int     *minor_version_return);
16088cd5fc2Smrg
16188cd5fc2Smrgint XPresentVersion (void);
16288cd5fc2Smrg
16388cd5fc2Smrgvoid
16488cd5fc2SmrgXPresentPixmap(Display *dpy,
16588cd5fc2Smrg               Window window,
16688cd5fc2Smrg               Pixmap pixmap,
16788cd5fc2Smrg               uint32_t serial,
16888cd5fc2Smrg               XserverRegion valid,
16988cd5fc2Smrg               XserverRegion update,
17088cd5fc2Smrg               int x_off,
17188cd5fc2Smrg               int y_off,
17288cd5fc2Smrg               RRCrtc target_crtc,
17388cd5fc2Smrg               XSyncFence wait_fence,
17488cd5fc2Smrg               XSyncFence idle_fence,
17588cd5fc2Smrg               uint32_t options,
17688cd5fc2Smrg               uint64_t target_msc,
17788cd5fc2Smrg               uint64_t divisor,
17888cd5fc2Smrg               uint64_t remainder,
17988cd5fc2Smrg               XPresentNotify *notifies,
18088cd5fc2Smrg               int nnotifies);
18188cd5fc2Smrg
18288cd5fc2Smrgvoid
18388cd5fc2SmrgXPresentNotifyMSC(Display *dpy,
18488cd5fc2Smrg                  Window window,
18588cd5fc2Smrg                  uint32_t serial,
18688cd5fc2Smrg                  uint64_t target_msc,
18788cd5fc2Smrg                  uint64_t divisor,
18888cd5fc2Smrg                  uint64_t remainder);
18988cd5fc2Smrg
19088cd5fc2SmrgXID
19188cd5fc2SmrgXPresentSelectInput(Display *dpy,
19288cd5fc2Smrg                    Window window,
19388cd5fc2Smrg                    unsigned event_mask);
19488cd5fc2Smrg
19588cd5fc2Smrgvoid
19688cd5fc2SmrgXPresentFreeInput(Display *dpy,
19788cd5fc2Smrg                  Window window,
19888cd5fc2Smrg                  XID event_id);
19988cd5fc2Smrg
20088cd5fc2Smrguint32_t
20188cd5fc2SmrgXPresentQueryCapabilities(Display *dpy,
20288cd5fc2Smrg                          XID target);
20388cd5fc2Smrg
20488cd5fc2Smrg_XFUNCPROTOEND
20588cd5fc2Smrg
20688cd5fc2Smrg#endif /* _XPRESENT_H_ */
207