-
Notifications
You must be signed in to change notification settings - Fork 0
/
xthread.c
executable file
·52 lines (44 loc) · 1.46 KB
/
xthread.c
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <pthread.h>
#include <X11/X.h>
#include <X11/extensions/Xdamage.h>
#include <X11/Xthreads.h>
#include <stdint.h>
#include <stdio.h>
#include "pulsar.h"
//#include "xthread.h"
void xthread(void *data)
{
printf("xthread\n");
pulsar_context_t *context = (pulsar_context_t*)data;
Display *display = XOpenDisplay(NULL);
Window root = RootWindow(display, DefaultScreen(display));
int damage_event_base, damage_error_base;
XDamageQueryExtension(display, &damage_event_base, &damage_error_base);
Damage damage_handle = XDamageCreate(display, root, XDamageReportRawRectangles);
XEvent xevt;
XDamageNotifyEvent *damage_event;
uint8_t *output;
int output_size, i;
while (1) {
XNextEvent(display, &xevt);
switch (xevt.type) {
default:
if (xevt.type == damage_event_base + XDamageNotify) {
damage_event = (XDamageNotifyEvent*)&xevt;
int x = damage_event->area.x;
int y = damage_event->area.y;
int width = damage_event->area.width;
int height = damage_event->area.height;
if (width == 0 || height == 0) {
break;
}
pulsar_context_region_add(context, x, y, width, height);
}
break;
}
}
}
void start_xthread(pthread_t *t, pulsar_context_t *context)
{
pthread_create(t, NULL, (void*)xthread, context);
}