FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
io_xfocus.c
Go to the documentation of this file.
1
/* XTerm focus query helpers */
2
3
#include "../fb.h"
4
5
#ifndef DISABLE_X11
6
#include "../fb_private_hdynload.h"
7
#include <X11/Xlib.h>
8
9
typedef
Display *(*XOPENDISPLAY)(
char
*);
10
typedef
int (*
XCLOSEDISPLAY
)(Display *);
11
typedef
int (*
XGETINPUTFOCUS
)(Display *, Window *,
int
*);
12
13
typedef
struct
{
14
XOPENDISPLAY
OpenDisplay;
15
XCLOSEDISPLAY
CloseDisplay;
16
XGETINPUTFOCUS
GetInputFocus
;
17
}
X_FUNCS
;
18
19
static
int
ref_count
= 0;
20
static
FB_DYLIB
xlib
;
21
static
X_FUNCS
X
= {
NULL
};
22
static
Display *
display
;
23
static
Window
xterm_window
;
24
#endif
25
26
int
fb_hXTermInitFocus
(
void
)
27
{
28
#ifndef DISABLE_X11
29
const
char
*funcs[] = {
"XOpenDisplay"
,
"XCloseDisplay"
,
"XGetInputFocus"
,
NULL
};
30
int
dummy;
31
32
ref_count
++;
33
if
(
ref_count
> 1)
34
return
0;
35
36
xlib
=
fb_hDynLoad
(
"libX11.so"
, funcs, (
void
**)&X);
37
if
(!
xlib
)
38
return
-1;
39
40
display
= X.
OpenDisplay
(
NULL
);
41
if
(!
display
)
42
return
-1;
43
44
X.
GetInputFocus
(
display
, &
xterm_window
, &dummy);
45
#endif
46
return
0;
47
}
48
49
void
fb_hXTermExitFocus
(
void
)
50
{
51
#ifndef DISABLE_X11
52
ref_count
--;
53
if
(
ref_count
> 0)
54
return
;
55
X.
CloseDisplay
(
display
);
56
fb_hDynUnload
(&
xlib
);
57
#endif
58
}
59
60
int
fb_hXTermHasFocus
(
void
)
61
{
62
#ifndef DISABLE_X11
63
Window focus_window;
64
int
dummy;
65
66
X.
GetInputFocus
(
display
, &focus_window, &dummy);
67
68
return
(focus_window ==
xterm_window
);
69
#else
70
return
0;
71
#endif
72
}
rtlib
unix
io_xfocus.c
Generated on Thu Jan 23 2014 19:40:14 for FreeBASIC by
1.8.4