-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcommon.c
More file actions
66 lines (55 loc) · 1.51 KB
/
common.c
File metadata and controls
66 lines (55 loc) · 1.51 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// fullscreenhack.c
// Alistair Buxton <a.j.buxton@gmail.com>
// Common functions for npapi and ppapi.
// "running_under_flash" detection code from libvdpau "smurf bug" workaround.
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xinerama.h>
int _running_under_flash = 0;
void fshack_init_running_under_flash(void)
{
FILE *fp;
char buffer[1024];
int ret, i;
fp = fopen("/proc/self/cmdline", "r");
if (!fp) {
return;
}
ret = fread(buffer, 1, sizeof(buffer) - 1, fp);
fclose(fp);
if (ret < 0) {
return;
}
/*
* Sometimes the file contains null between arguments. Wipe these out so
* strstr doesn't stop early.
*/
for (i = 0; i < ret; i++) {
if (buffer[i] == '\0') {
buffer[i] = ' ';
}
}
buffer[ret] = '\0';
fprintf(stderr, "--- %s ---\n", buffer);
if (strstr(buffer, "libflashplayer") != NULL) {
_running_under_flash = 1;
}
}
// event mask filter prevents flash exiting fullscreen on focus switch.
// by Steve Purchase <steve@t220.com>
typedef int (*xselectinput_func)(Display*, Window, long);
int XSelectInput(Display* display, Window window, long event_mask)
{
void *xlib_handle;
xlib_handle = dlopen("libX11.so", RTLD_LAZY);
xselectinput_func fn = dlsym(xlib_handle, "XSelectInput");
// Mask out PropertyChange events so Flash doesn't realise
// the pointer/focus has left the window.
if(_running_under_flash) {
event_mask &= ~PropertyChangeMask;
}
return fn(display, window, event_mask);
}