-
Notifications
You must be signed in to change notification settings - Fork 5
/
xcb-xembed.el
184 lines (142 loc) · 6.76 KB
/
xcb-xembed.el
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
;;; xcb-xembed.el --- XEmbed protocol -*- lexical-binding: t -*-
;; Copyright (C) 2016-2024 Free Software Foundation, Inc.
;; Author: Chris Feng <[email protected]>
;; This file is part of GNU Emacs.
;; GNU Emacs 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.
;; GNU Emacs 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This library implements the XEmbed protocol.
;; Usage tips:
;; + Do not forget to call `xcb:xembed:init' for _every_ connection using this
;; library.
;; + Use `xcb:xembed:SendEvent' instead of `xcb:SendEvent' to send XEmbed
;; messages defined in this library.
;; References:
;; + Xembed protocol (https://specifications.freedesktop.org/
;; xembed-spec/xembed-spec-0.5.html)
;;; Code:
(require 'xcb-icccm)
;; XEmbed atoms
(eval-and-compile
(defconst xcb:xembed:-atoms
'(_XEMBED_INFO _XEMBED)
"XEmbed atoms.")
(dolist (atom xcb:xembed:-atoms)
(eval `(defvar ,(intern (concat "xcb:Atom:" (symbol-name atom))) nil))))
;; XEMBED message opcodes.
(defconst xcb:xembed:opcode:EMBEDDED-NOTIFY 0)
(defconst xcb:xembed:opcode:WINDOW-ACTIVATE 1)
(defconst xcb:xembed:opcode:WINDOW-DEACTIVATE 2)
(defconst xcb:xembed:opcode:REQUEST-FOCUS 3)
(defconst xcb:xembed:opcode:FOCUS-IN 4)
(defconst xcb:xembed:opcode:FOCUS-OUT 5)
(defconst xcb:xembed:opcode:FOCUS-NEXT 6)
(defconst xcb:xembed:opcode:FOCUS-PREV 7)
(defconst xcb:xembed:opcode:MODALITY-ON 10)
(defconst xcb:xembed:opcode:MODALITY-OFF 11)
(defconst xcb:xembed:opcode:REGISTER-ACCELERATOR 12)
(defconst xcb:xembed:opcode:UNREGISTER-ACCELERATOR 13)
(defconst xcb:xembed:opcode:ACTIVATE-ACCELERATOR 14)
(cl-defmethod xcb:xembed:init ((obj xcb:connection) &optional force)
"Initialize the XEmbed module.
This method must be called before using any other method in this module."
(when (or force (not xcb:Atom:_XEMBED_INFO))
(xcb:icccm:intern-atoms obj xcb:xembed:-atoms force)))
;; Flags for _XEMBED_INFO.
(defconst xcb:xembed:MAPPED 1)
(defclass xcb:xembed:get-_XEMBED_INFO (xcb:icccm:-GetProperty-explicit)
((property :initform 'xcb:Atom:_XEMBED_INFO)
(type :initform 'xcb:Atom:_XEMBED_INFO)))
(defclass xcb:xembed:get-_XEMBED_INFO~reply
(xcb:icccm:-GetProperty-explicit~reply)
((version :type xcb:-ignore)
(flags :type xcb:-ignore)))
(defclass xcb:xembed:set-_XEMBED_INFO (xcb:icccm:-ChangeProperty-explicit)
((property :initform 'xcb:Atom:_XEMBED_INFO)
(type :initform 'xcb:Atom:_XEMBED_INFO)
(format :initform 32)
(version :initarg :version :type xcb:-ignore)
(flags :initarg :flags :type xcb:-ignore)))
(defclass xcb:xembed:SendEvent (xcb:SendEvent)
((propagate :initform 0)
(event-mask :initform 'xcb:EventMask:NoEvent))
:documentation "Send XEmbed message.")
(defclass xcb:xembed:-ClientMessage
(xcb:icccm:--ClientMessage xcb:ClientMessage)
((format :initform 32)
(type :initform 'xcb:Atom:_XEMBED)
(time :initarg :time :type xcb:TIMESTAMP) ;new slot
(opcode :initarg :opcode :type xcb:CARD32) ;new slot
(detail :initarg :detail :initform 0 :type xcb:CARD32)) ;new slot
:documentation "An XEmbed client message.")
(defclass xcb:xembed:EMBEDDED-NOTIFY (xcb:xembed:-ClientMessage)
((opcode :initform 'xcb:xembed:opcode:EMBEDDED-NOTIFY)
(embedder :initarg :embedder :type xcb:WINDOW)
(version :initarg :version :type xcb:CARD32)))
(defclass xcb:xembed:WINDOW-ACTIVATE (xcb:xembed:-ClientMessage)
((opcode :initform 'xcb:xembed:opcode:WINDOW-ACTIVATE)
(pad~0 :initform 8 :type xcb:-pad)))
(defclass xcb:xembed:WINDOW-DEACTIVATE (xcb:xembed:-ClientMessage)
((opcode :initform 'xcb:xembed:opcode:WINDOW-DEACTIVATE)
(pad~0 :initform 8 :type xcb:-pad)))
(defclass xcb:xembed:REQUEST-FOCUS (xcb:xembed:-ClientMessage)
((opcode :initform 'xcb:xembed:opcode:REQUEST-FOCUS)
(pad~0 :initform 8 :type xcb:-pad)))
;; Details for xcb:xembed:FOCUS-IN.
(defconst xcb:xembed:FOCUS:CURRENT 0)
(defconst xcb:xembed:FOCUS:FIRST 1)
(defconst xcb:xembed:FOCUS:LAST 2)
;; Directions for focusing.
(defconst xcb:xembed:DIRECTION:DEFAULT 0)
(defconst xcb:xembed:DIRECTION:UP-DOWN 1)
(defconst xcb:xembed:DIRECTION:LEFT-RIGHT 2)
(defclass xcb:xembed:FOCUS-IN (xcb:xembed:-ClientMessage)
((opcode :initform 'xcb:xembed:opcode:FOCUS-IN)
(direction :initarg :direction :initform 0 :type xcb:CARD32)
(pad~0 :initform 4 :type xcb:-pad)))
(defclass xcb:xembed:FOCUS-OUT (xcb:xembed:-ClientMessage)
((opcode :initform 'xcb:xembed:opcode:FOCUS-OUT)
(pad~0 :initform 8 :type xcb:-pad)))
(defclass xcb:xembed:FOCUS-NEXT (xcb:xembed:-ClientMessage)
((opcode :initform 'xcb:xembed:opcode:FOCUS-NEXT)
(direction :initarg :direction :initform 0 :type xcb:CARD32)
(pad~0 :initform 4 :type xcb:-pad)))
(defclass xcb:xembed:FOCUS-PREV (xcb:xembed:-ClientMessage)
((opcode :initform 'xcb:xembed:opcode:FOCUS-PREV)
(direction :initarg :direction :initform 0 :type xcb:CARD32)
(pad~0 :initform 4 :type xcb:-pad)))
;; Modifiers field for xcb:xembed:REGISTER-ACCELERATOR.
(defconst xcb:xembed:MODIFIER:SHIFT 1)
(defconst xcb:xembed:MODIFIER:CONTROL 2)
(defconst xcb:xembed:MODIFIER:ALT 4)
(defconst xcb:xembed:MODIFIER:SUPER 8)
(defconst xcb:xembed:MODIFIER:HYPER 16)
(defclass xcb:xembed:REGISTER-ACCELERATOR (xcb:xembed:-ClientMessage)
((opcode :initform 'xcb:xembed:opcode:REGISTER-ACCELERATOR)
(keysym :initarg :keysym :type xcb:KEYSYM)
(modifier :initarg :modifier :type xcb:CARD32)))
(defclass xcb:xembed:UNREGISTER-ACCELERATOR (xcb:xembed:-ClientMessage)
((opcode :initform 'xcb:xembed:opcode:UNREGISTER-ACCELERATOR)
(pad~0 :initform 8 :type xcb:-pad)))
;; Flags for XEMBED-ACTIVATE-ACCELERATOR.
(defconst xcb:xembed:ACCELERATOR:OVERLOADED 1)
(defclass xcb:xembed:ACTIVATE-ACCELERATOR (xcb:xembed:-ClientMessage)
((opcode :initform 'xcb:xembed:opcode:ACTIVATE-ACCELERATOR)
(flags :initarg :flags :type xcb:CARD32)
(pad~0 :initform 4 :type xcb:-pad)))
(defclass xcb:xembed:MODALITY-ON (xcb:xembed:-ClientMessage)
((opcode :initform 'xcb:xembed:opcode:MODALITY-ON)
(pad~0 :initform 8 :type xcb:-pad)))
(defclass xcb:xembed:MODALITY-OFF (xcb:xembed:-ClientMessage)
((opcode :initform 'xcb:xembed:opcode:MODALITY-OFF)
(pad~0 :initform 8 :type xcb:-pad)))
(provide 'xcb-xembed)
;;; xcb-xembed.el ends here