]> Git Repo - qemu.git/blame - include/ui/console.h
vnc: remove unused DisplayState parameter, add id instead.
[qemu.git] / include / ui / console.h
CommitLineData
87ecb68b
PB
1#ifndef CONSOLE_H
2#define CONSOLE_H
3
28ecbaee 4#include "ui/qemu-pixman.h"
95be0669 5#include "qom/object.h"
7b1b5d19 6#include "qapi/qmp/qdict.h"
1de7afc9 7#include "qemu/notify.h"
83c9089e 8#include "monitor/monitor.h"
1048c88f 9#include "qapi-types.h"
7b1b5d19 10#include "qapi/error.h"
87ecb68b
PB
11
12/* keyboard/mouse support */
13
14#define MOUSE_EVENT_LBUTTON 0x01
15#define MOUSE_EVENT_RBUTTON 0x02
16#define MOUSE_EVENT_MBUTTON 0x04
21bae11a
GH
17#define MOUSE_EVENT_WHEELUP 0x08
18#define MOUSE_EVENT_WHEELDN 0x10
87ecb68b 19
03a23a85
GH
20/* identical to the ps/2 keyboard bits */
21#define QEMU_SCROLL_LOCK_LED (1 << 0)
22#define QEMU_NUM_LOCK_LED (1 << 1)
23#define QEMU_CAPS_LOCK_LED (1 << 2)
24
7ed9eba3 25/* in ms */
0f7b2864
GH
26#define GUI_REFRESH_INTERVAL_DEFAULT 30
27#define GUI_REFRESH_INTERVAL_IDLE 3000
7ed9eba3 28
87ecb68b 29typedef void QEMUPutKBDEvent(void *opaque, int keycode);
03a23a85 30typedef void QEMUPutLEDEvent(void *opaque, int ledstate);
87ecb68b
PB
31typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
32
72711efb 33typedef struct QEMUPutMouseEntry QEMUPutMouseEntry;
5a37532d 34typedef struct QEMUPutKbdEntry QEMUPutKbdEntry;
72711efb 35typedef struct QEMUPutLEDEntry QEMUPutLEDEntry;
03a23a85 36
5a37532d
GH
37QEMUPutKbdEntry *qemu_add_kbd_event_handler(QEMUPutKBDEvent *func,
38 void *opaque);
39void qemu_remove_kbd_event_handler(QEMUPutKbdEntry *entry);
87ecb68b
PB
40QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
41 void *opaque, int absolute,
42 const char *name);
43void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry);
6fef28ee
AL
44void qemu_activate_mouse_event_handler(QEMUPutMouseEntry *entry);
45
03a23a85
GH
46QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func, void *opaque);
47void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry);
87ecb68b 48
03a23a85 49void kbd_put_ledstate(int ledstate);
eb2e259d 50
bc24a225 51struct MouseTransformInfo {
a5d7eb65
AZ
52 /* Touchscreen resolution */
53 int x;
54 int y;
55 /* Calibration values as used/generated by tslib */
56 int a[7];
57};
58
d54908a5 59void do_mouse_set(Monitor *mon, const QDict *qdict);
87ecb68b
PB
60
61/* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
62 constants) */
63#define QEMU_KEY_ESC1(c) ((c) | 0xe100)
64#define QEMU_KEY_BACKSPACE 0x007f
65#define QEMU_KEY_UP QEMU_KEY_ESC1('A')
66#define QEMU_KEY_DOWN QEMU_KEY_ESC1('B')
67#define QEMU_KEY_RIGHT QEMU_KEY_ESC1('C')
68#define QEMU_KEY_LEFT QEMU_KEY_ESC1('D')
69#define QEMU_KEY_HOME QEMU_KEY_ESC1(1)
70#define QEMU_KEY_END QEMU_KEY_ESC1(4)
71#define QEMU_KEY_PAGEUP QEMU_KEY_ESC1(5)
72#define QEMU_KEY_PAGEDOWN QEMU_KEY_ESC1(6)
73#define QEMU_KEY_DELETE QEMU_KEY_ESC1(3)
74
75#define QEMU_KEY_CTRL_UP 0xe400
76#define QEMU_KEY_CTRL_DOWN 0xe401
77#define QEMU_KEY_CTRL_LEFT 0xe402
78#define QEMU_KEY_CTRL_RIGHT 0xe403
79#define QEMU_KEY_CTRL_HOME 0xe404
80#define QEMU_KEY_CTRL_END 0xe405
81#define QEMU_KEY_CTRL_PAGEUP 0xe406
82#define QEMU_KEY_CTRL_PAGEDOWN 0xe407
83
3f9a6e85 84void kbd_put_keysym_console(QemuConsole *s, int keysym);
50ef4679 85bool kbd_put_qcode_console(QemuConsole *s, int qcode);
bdef9724 86void kbd_put_string_console(QemuConsole *s, const char *str, int len);
87ecb68b
PB
87void kbd_put_keysym(int keysym);
88
89/* consoles */
90
95be0669
GH
91#define TYPE_QEMU_CONSOLE "qemu-console"
92#define QEMU_CONSOLE(obj) \
93 OBJECT_CHECK(QemuConsole, (obj), TYPE_QEMU_CONSOLE)
94#define QEMU_CONSOLE_GET_CLASS(obj) \
95 OBJECT_GET_CLASS(QemuConsoleClass, (obj), TYPE_QEMU_CONSOLE)
96#define QEMU_CONSOLE_CLASS(klass) \
97 OBJECT_CLASS_CHECK(QemuConsoleClass, (klass), TYPE_QEMU_CONSOLE)
98
99typedef struct QemuConsoleClass QemuConsoleClass;
100
101struct QemuConsoleClass {
102 ObjectClass parent_class;
103};
104
77bfcf28 105#define QEMU_ALLOCATED_FLAG 0x01
7d957bd8
AL
106
107struct PixelFormat {
108 uint8_t bits_per_pixel;
109 uint8_t bytes_per_pixel;
110 uint8_t depth; /* color depth in bits */
111 uint32_t rmask, gmask, bmask, amask;
112 uint8_t rshift, gshift, bshift, ashift;
113 uint8_t rmax, gmax, bmax, amax;
90a1e3c0 114 uint8_t rbits, gbits, bbits, abits;
7d957bd8
AL
115};
116
117struct DisplaySurface {
69c77777
GH
118 pixman_format_code_t format;
119 pixman_image_t *image;
7d957bd8 120 uint8_t flags;
7d957bd8
AL
121};
122
6f90f3d7
GH
123typedef struct QemuUIInfo {
124 /* geometry */
125 int xoff;
126 int yoff;
127 uint32_t width;
128 uint32_t height;
129} QemuUIInfo;
130
254e5950
GH
131/* cursor data format is 32bit RGBA */
132typedef struct QEMUCursor {
133 int width, height;
134 int hot_x, hot_y;
135 int refcount;
136 uint32_t data[];
137} QEMUCursor;
138
139QEMUCursor *cursor_alloc(int width, int height);
140void cursor_get(QEMUCursor *c);
141void cursor_put(QEMUCursor *c);
142QEMUCursor *cursor_builtin_hidden(void);
143QEMUCursor *cursor_builtin_left_ptr(void);
144void cursor_print_ascii_art(QEMUCursor *c, const char *prefix);
145int cursor_get_mono_bpl(QEMUCursor *c);
146void cursor_set_mono(QEMUCursor *c,
147 uint32_t foreground, uint32_t background, uint8_t *image,
148 int transparent, uint8_t *mask);
149void cursor_get_mono_image(QEMUCursor *c, int foreground, uint8_t *mask);
150void cursor_get_mono_mask(QEMUCursor *c, int transparent, uint8_t *mask);
151
7c20b4a3
GH
152typedef struct DisplayChangeListenerOps {
153 const char *dpy_name;
154
bc2ed970 155 void (*dpy_refresh)(DisplayChangeListener *dcl);
7c20b4a3
GH
156
157 void (*dpy_gfx_update)(DisplayChangeListener *dcl,
7c20b4a3 158 int x, int y, int w, int h);
c12aeb86 159 void (*dpy_gfx_switch)(DisplayChangeListener *dcl,
c12aeb86 160 struct DisplaySurface *new_surface);
7c20b4a3 161 void (*dpy_gfx_copy)(DisplayChangeListener *dcl,
bc2ed970 162 int src_x, int src_y,
a93a4a22 163 int dst_x, int dst_y, int w, int h);
49743df3
BH
164 bool (*dpy_gfx_check_format)(DisplayChangeListener *dcl,
165 pixman_format_code_t format);
a93a4a22 166
7c20b4a3 167 void (*dpy_text_cursor)(DisplayChangeListener *dcl,
7c20b4a3
GH
168 int x, int y);
169 void (*dpy_text_resize)(DisplayChangeListener *dcl,
7c20b4a3
GH
170 int w, int h);
171 void (*dpy_text_update)(DisplayChangeListener *dcl,
7c20b4a3
GH
172 int x, int y, int w, int h);
173
174 void (*dpy_mouse_set)(DisplayChangeListener *dcl,
7c20b4a3
GH
175 int x, int y, int on);
176 void (*dpy_cursor_define)(DisplayChangeListener *dcl,
7c20b4a3
GH
177 QEMUCursor *cursor);
178} DisplayChangeListenerOps;
7d957bd8 179
7c20b4a3 180struct DisplayChangeListener {
0f7b2864 181 uint64_t update_interval;
7c20b4a3
GH
182 const DisplayChangeListenerOps *ops;
183 DisplayState *ds;
284d1c6b 184 QemuConsole *con;
bf2fde70 185
87e487a1 186 QLIST_ENTRY(DisplayChangeListener) next;
7d957bd8
AL
187};
188
64840c66 189DisplayState *init_displaystate(void);
30f1e661
GH
190DisplaySurface *qemu_create_displaysurface_from(int width, int height,
191 pixman_format_code_t format,
192 int linesize, uint8_t *data);
a77549b3
GH
193DisplaySurface *qemu_create_displaysurface_guestmem(int width, int height,
194 pixman_format_code_t format,
195 int linesize,
196 uint64_t addr);
0da2ea1b 197PixelFormat qemu_different_endianness_pixelformat(int bpp);
198PixelFormat qemu_default_pixelformat(int bpp);
7d957bd8 199
da229ef3
GH
200DisplaySurface *qemu_create_displaysurface(int width, int height);
201void qemu_free_displaysurface(DisplaySurface *surface);
7b5d76da
AL
202
203static inline int is_surface_bgr(DisplaySurface *surface)
204{
30f1e661
GH
205 if (PIXMAN_FORMAT_BPP(surface->format) == 32 &&
206 PIXMAN_FORMAT_TYPE(surface->format) == PIXMAN_TYPE_ABGR) {
7b5d76da 207 return 1;
30f1e661 208 } else {
7b5d76da 209 return 0;
30f1e661 210 }
7b5d76da
AL
211}
212
7d957bd8
AL
213static inline int is_buffer_shared(DisplaySurface *surface)
214{
187cd1d9 215 return !(surface->flags & QEMU_ALLOCATED_FLAG);
7d957bd8
AL
216}
217
5209089f 218void register_displaychangelistener(DisplayChangeListener *dcl);
0f7b2864
GH
219void update_displaychangelistener(DisplayChangeListener *dcl,
220 uint64_t interval);
7c20b4a3
GH
221void unregister_displaychangelistener(DisplayChangeListener *dcl);
222
6f90f3d7
GH
223int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info);
224
c78f7137
GH
225void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h);
226void dpy_gfx_replace_surface(QemuConsole *con,
da229ef3 227 DisplaySurface *surface);
c78f7137 228void dpy_gfx_copy(QemuConsole *con, int src_x, int src_y,
7c20b4a3 229 int dst_x, int dst_y, int w, int h);
c78f7137
GH
230void dpy_text_cursor(QemuConsole *con, int x, int y);
231void dpy_text_update(QemuConsole *con, int x, int y, int w, int h);
232void dpy_text_resize(QemuConsole *con, int w, int h);
233void dpy_mouse_set(QemuConsole *con, int x, int y, int on);
234void dpy_cursor_define(QemuConsole *con, QEMUCursor *cursor);
235bool dpy_cursor_define_supported(QemuConsole *con);
4c38762f
GH
236void dpy_gfx_update_dirty(QemuConsole *con,
237 MemoryRegion *address_space,
238 uint64_t base,
239 bool invalidate);
49743df3
BH
240bool dpy_gfx_check_format(QemuConsole *con,
241 pixman_format_code_t format);
bf2fde70 242
626e3b34
GH
243static inline int surface_stride(DisplaySurface *s)
244{
245 return pixman_image_get_stride(s->image);
246}
247
248static inline void *surface_data(DisplaySurface *s)
249{
250 return pixman_image_get_data(s->image);
251}
252
253static inline int surface_width(DisplaySurface *s)
254{
255 return pixman_image_get_width(s->image);
256}
257
258static inline int surface_height(DisplaySurface *s)
259{
260 return pixman_image_get_height(s->image);
261}
262
263static inline int surface_bits_per_pixel(DisplaySurface *s)
264{
265 int bits = PIXMAN_FORMAT_BPP(s->format);
266 return bits;
267}
268
269static inline int surface_bytes_per_pixel(DisplaySurface *s)
270{
271 int bits = PIXMAN_FORMAT_BPP(s->format);
272 return (bits + 7) / 8;
273}
274
df00bed0
DP
275#ifdef CONFIG_CURSES
276#include <curses.h>
277typedef chtype console_ch_t;
278#else
c227f099 279typedef unsigned long console_ch_t;
df00bed0 280#endif
c227f099 281static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
4d3b6f6e 282{
f6d20d0f
BK
283 if (!(ch & 0xff))
284 ch |= ' ';
9ae19b65 285 *dest = ch;
4d3b6f6e
AZ
286}
287
380cd056
GH
288typedef struct GraphicHwOps {
289 void (*invalidate)(void *opaque);
290 void (*gfx_update)(void *opaque);
291 void (*text_update)(void *opaque, console_ch_t *text);
dea1b0bd 292 void (*update_interval)(void *opaque, uint64_t interval);
6f90f3d7 293 int (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info);
380cd056 294} GraphicHwOps;
87ecb68b 295
5643706a 296QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head,
aa2beaa1 297 const GraphicHwOps *ops,
c78f7137 298 void *opaque);
1c1f9498
GH
299void graphic_console_set_hwops(QemuConsole *con,
300 const GraphicHwOps *hw_ops,
301 void *opaque);
3023f332 302
1dbfa005
GH
303void graphic_hw_update(QemuConsole *con);
304void graphic_hw_invalidate(QemuConsole *con);
305void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata);
87ecb68b 306
284d1c6b 307QemuConsole *qemu_console_lookup_by_index(unsigned int index);
5643706a 308QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head);
81c0d5a6
GH
309bool qemu_console_is_visible(QemuConsole *con);
310bool qemu_console_is_graphic(QemuConsole *con);
311bool qemu_console_is_fixedsize(QemuConsole *con);
d4c85337 312int qemu_console_get_index(QemuConsole *con);
5643706a 313uint32_t qemu_console_get_head(QemuConsole *con);
6f90f3d7 314QemuUIInfo *qemu_console_get_ui_info(QemuConsole *con);
d4c85337
GH
315int qemu_console_get_width(QemuConsole *con, int fallback);
316int qemu_console_get_height(QemuConsole *con, int fallback);
81c0d5a6 317
2796dae0 318void text_consoles_set_display(DisplayState *ds);
87ecb68b
PB
319void console_select(unsigned int index);
320void console_color_init(DisplayState *ds);
c78f7137
GH
321void qemu_console_resize(QemuConsole *con, int width, int height);
322void qemu_console_copy(QemuConsole *con, int src_x, int src_y,
3023f332 323 int dst_x, int dst_y, int w, int h);
c78f7137
GH
324DisplaySurface *qemu_console_surface(QemuConsole *con);
325DisplayState *qemu_console_displaystate(QemuConsole *console);
87ecb68b
PB
326
327/* sdl.c */
328void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
329
330/* cocoa.m */
331void cocoa_display_init(DisplayState *ds, int full_screen);
332
333/* vnc.c */
14f7143e
GH
334void vnc_display_init(const char *id);
335void vnc_display_open(const char *id, const char *display, Error **errp);
336void vnc_display_add_client(const char *id, int csock, bool skipauth);
337char *vnc_display_local_addr(const char *id);
821601ea 338#ifdef CONFIG_VNC
14f7143e
GH
339int vnc_display_password(const char *id, const char *password);
340int vnc_display_pw_expire(const char *id, time_t expires);
821601ea 341#else
14f7143e 342static inline int vnc_display_password(const char *id, const char *password)
821601ea 343{
821601ea
JS
344 return -ENODEV;
345}
14f7143e 346static inline int vnc_display_pw_expire(const char *id, time_t expires)
821601ea 347{
821601ea
JS
348 return -ENODEV;
349};
821601ea 350#endif
87ecb68b 351
4d3b6f6e
AZ
352/* curses.c */
353void curses_display_init(DisplayState *ds, int full_screen);
354
1048c88f 355/* input.c */
1048c88f 356int index_from_key(const char *key);
1048c88f 357
a4ccabcf
AL
358/* gtk.c */
359void early_gtk_display_init(void);
881249c7 360void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover);
a4ccabcf 361
87ecb68b 362#endif
This page took 0.554339 seconds and 4 git commands to generate.