-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathx11.go
More file actions
107 lines (91 loc) · 2.28 KB
/
Copy pathx11.go
File metadata and controls
107 lines (91 loc) · 2.28 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* Bamboo - A Vietnamese Input method editor
* Copyright (C) 2018 Luong Thanh Lam <ltlam93@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
/*
#cgo CFLAGS: -std=gnu99
#cgo LDFLAGS: -lX11 -lXtst -pthread
#include <stdlib.h>
extern void x11Copy(char*);
extern void x11Paste(int);
extern void clipboard_init();
extern void clipboard_exit();
extern void x11ClipboardReset();
extern void x11SendBackspace(int n, int timeout);
extern void x11SendShiftR();
extern void x11SendShiftLeft(int n, int r, int timeout);
extern void setXIgnoreErrorHandler();
extern char* x11GetFocusWindowClass();
extern void x11StartWindowInspector();
extern void x11StopWindowInspector();
*/
import "C"
import (
"sync"
"unsafe"
)
var (
mcapRunning bool
mcapMutex sync.RWMutex
)
func init() {
C.setXIgnoreErrorHandler()
}
func x11StartWindowInspector() {
C.x11StartWindowInspector()
}
func x11StopWindowInspector() {
C.x11StopWindowInspector()
}
func x11Copy(str string) {
cs := C.CString(str)
defer C.free(unsafe.Pointer(cs))
C.x11Copy(cs)
}
func x11ClipboardInit() {
C.clipboard_init()
}
func x11ClipboardExit() {
C.clipboard_exit()
}
func x11ClipboardReset() {
C.x11ClipboardReset()
}
func x11Paste(n int) {
C.x11Paste(C.int(n))
}
func x11SendShiftR() {
C.x11SendShiftR()
}
func x11SendShiftLeft(n int, shiftRightIsPressing bool, timeout int) {
var r = 0
if shiftRightIsPressing {
r = 1
}
C.x11SendShiftLeft(C.int(n), C.int(r), C.int(timeout))
}
func x11SendBackspace(n int, timeout int) {
C.x11SendBackspace(C.int(n), C.int(timeout))
}
func x11GetFocusWindowClass() string {
var wmClass = C.x11GetFocusWindowClass()
if wmClass != nil {
return C.GoString(wmClass)
}
return ""
}