2 * QEMU graphical console
4 * Copyright (c) 2004 Fabrice Bellard
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 #include "qemu/osdep.h"
26 #include "ui/console.h"
27 #include "hw/qdev-core.h"
28 #include "qapi/error.h"
29 #include "qapi/qapi-commands-ui.h"
30 #include "qapi/visitor.h"
31 #include "qemu/coroutine.h"
32 #include "qemu/error-report.h"
33 #include "qemu/main-loop.h"
34 #include "qemu/module.h"
35 #include "qemu/option.h"
36 #include "chardev/char.h"
38 #include "exec/memory.h"
39 #include "qom/object.h"
41 #include "console-priv.h"
43 OBJECT_DEFINE_ABSTRACT_TYPE(QemuConsole
, qemu_console
, QEMU_CONSOLE
, OBJECT
)
45 typedef struct QemuGraphicConsole
{
52 int cursor_x
, cursor_y
, cursor_on
;
55 typedef QemuConsoleClass QemuGraphicConsoleClass
;
57 OBJECT_DEFINE_TYPE(QemuGraphicConsole
, qemu_graphic_console
, QEMU_GRAPHIC_CONSOLE
, QEMU_CONSOLE
)
62 uint64_t update_interval
;
65 QLIST_HEAD(, DisplayChangeListener
) listeners
;
68 static DisplayState
*display_state
;
69 static QTAILQ_HEAD(, QemuConsole
) consoles
=
70 QTAILQ_HEAD_INITIALIZER(consoles
);
72 static void dpy_refresh(DisplayState
*s
);
73 static DisplayState
*get_alloc_displaystate(void);
74 static bool displaychangelistener_has_dmabuf(DisplayChangeListener
*dcl
);
75 static bool console_compatible_with(QemuConsole
*con
,
76 DisplayChangeListener
*dcl
, Error
**errp
);
77 static QemuConsole
*qemu_graphic_console_lookup_unused(void);
78 static void dpy_set_ui_info_timer(void *opaque
);
80 static void gui_update(void *opaque
)
82 uint64_t interval
= GUI_REFRESH_INTERVAL_IDLE
;
83 uint64_t dcl_interval
;
84 DisplayState
*ds
= opaque
;
85 DisplayChangeListener
*dcl
;
87 ds
->refreshing
= true;
89 ds
->refreshing
= false;
91 QLIST_FOREACH(dcl
, &ds
->listeners
, next
) {
92 dcl_interval
= dcl
->update_interval
?
93 dcl
->update_interval
: GUI_REFRESH_INTERVAL_DEFAULT
;
94 if (interval
> dcl_interval
) {
95 interval
= dcl_interval
;
98 if (ds
->update_interval
!= interval
) {
99 ds
->update_interval
= interval
;
100 trace_console_refresh(interval
);
102 ds
->last_update
= qemu_clock_get_ms(QEMU_CLOCK_REALTIME
);
103 timer_mod(ds
->gui_timer
, ds
->last_update
+ interval
);
106 static void gui_setup_refresh(DisplayState
*ds
)
108 DisplayChangeListener
*dcl
;
109 bool need_timer
= false;
111 QLIST_FOREACH(dcl
, &ds
->listeners
, next
) {
112 if (dcl
->ops
->dpy_refresh
!= NULL
) {
117 if (need_timer
&& ds
->gui_timer
== NULL
) {
118 ds
->gui_timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, gui_update
, ds
);
119 timer_mod(ds
->gui_timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
121 if (!need_timer
&& ds
->gui_timer
!= NULL
) {
122 timer_free(ds
->gui_timer
);
123 ds
->gui_timer
= NULL
;
127 void graphic_hw_update_done(QemuConsole
*con
)
130 qemu_co_enter_all(&con
->dump_queue
, NULL
);
134 void graphic_hw_update(QemuConsole
*con
)
140 if (con
->hw_ops
->gfx_update
) {
141 con
->hw_ops
->gfx_update(con
->hw
);
142 async
= con
->hw_ops
->gfx_update_async
;
145 graphic_hw_update_done(con
);
149 static void graphic_hw_update_bh(void *con
)
151 graphic_hw_update(con
);
154 void qemu_console_co_wait_update(QemuConsole
*con
)
156 if (qemu_co_queue_empty(&con
->dump_queue
)) {
157 /* Defer the update, it will restart the pending coroutines */
158 aio_bh_schedule_oneshot(qemu_get_aio_context(),
159 graphic_hw_update_bh
, con
);
161 qemu_co_queue_wait(&con
->dump_queue
, NULL
);
165 static void graphic_hw_gl_unblock_timer(void *opaque
)
167 warn_report("console: no gl-unblock within one second");
170 void graphic_hw_gl_block(QemuConsole
*con
, bool block
)
180 assert(con
->gl_block
>= 0);
181 if (!con
->hw_ops
->gl_block
) {
184 if ((block
&& con
->gl_block
!= 1) || (!block
&& con
->gl_block
!= 0)) {
187 con
->hw_ops
->gl_block(con
->hw
, block
);
190 timeout
= qemu_clock_get_ms(QEMU_CLOCK_REALTIME
);
191 timeout
+= 1000; /* one sec */
192 timer_mod(con
->gl_unblock_timer
, timeout
);
194 timer_del(con
->gl_unblock_timer
);
198 int qemu_console_get_window_id(QemuConsole
*con
)
200 return con
->window_id
;
203 void qemu_console_set_window_id(QemuConsole
*con
, int window_id
)
205 con
->window_id
= window_id
;
208 void graphic_hw_invalidate(QemuConsole
*con
)
210 if (con
&& con
->hw_ops
->invalidate
) {
211 con
->hw_ops
->invalidate(con
->hw
);
215 void graphic_hw_text_update(QemuConsole
*con
, console_ch_t
*chardata
)
217 if (con
&& con
->hw_ops
->text_update
) {
218 con
->hw_ops
->text_update(con
->hw
, chardata
);
222 static void displaychangelistener_gfx_switch(DisplayChangeListener
*dcl
,
223 struct DisplaySurface
*new_surface
,
226 if (dcl
->ops
->dpy_gfx_switch
) {
227 dcl
->ops
->dpy_gfx_switch(dcl
, new_surface
);
230 if (update
&& dcl
->ops
->dpy_gfx_update
) {
231 dcl
->ops
->dpy_gfx_update(dcl
, 0, 0,
232 surface_width(new_surface
),
233 surface_height(new_surface
));
237 static void dpy_gfx_create_texture(QemuConsole
*con
, DisplaySurface
*surface
)
239 if (con
->gl
&& con
->gl
->ops
->dpy_gl_ctx_create_texture
) {
240 con
->gl
->ops
->dpy_gl_ctx_create_texture(con
->gl
, surface
);
244 static void dpy_gfx_destroy_texture(QemuConsole
*con
, DisplaySurface
*surface
)
246 if (con
->gl
&& con
->gl
->ops
->dpy_gl_ctx_destroy_texture
) {
247 con
->gl
->ops
->dpy_gl_ctx_destroy_texture(con
->gl
, surface
);
251 static void dpy_gfx_update_texture(QemuConsole
*con
, DisplaySurface
*surface
,
252 int x
, int y
, int w
, int h
)
254 if (con
->gl
&& con
->gl
->ops
->dpy_gl_ctx_update_texture
) {
255 con
->gl
->ops
->dpy_gl_ctx_update_texture(con
->gl
, surface
, x
, y
, w
, h
);
259 static void displaychangelistener_display_console(DisplayChangeListener
*dcl
,
262 static const char nodev
[] =
263 "This VM has no graphic display device.";
264 static DisplaySurface
*dummy
;
265 QemuConsole
*con
= dcl
->con
;
267 if (!con
|| !console_compatible_with(con
, dcl
, errp
)) {
269 dummy
= qemu_create_placeholder_surface(640, 480, nodev
);
272 dpy_gfx_create_texture(con
, dummy
);
274 displaychangelistener_gfx_switch(dcl
, dummy
, TRUE
);
278 dpy_gfx_create_texture(con
, con
->surface
);
279 displaychangelistener_gfx_switch(dcl
, con
->surface
,
280 con
->scanout
.kind
== SCANOUT_SURFACE
);
282 if (con
->scanout
.kind
== SCANOUT_DMABUF
&&
283 displaychangelistener_has_dmabuf(dcl
)) {
284 dcl
->ops
->dpy_gl_scanout_dmabuf(dcl
, con
->scanout
.dmabuf
);
285 } else if (con
->scanout
.kind
== SCANOUT_TEXTURE
&&
286 dcl
->ops
->dpy_gl_scanout_texture
) {
287 dcl
->ops
->dpy_gl_scanout_texture(dcl
,
288 con
->scanout
.texture
.backing_id
,
289 con
->scanout
.texture
.backing_y_0_top
,
290 con
->scanout
.texture
.backing_width
,
291 con
->scanout
.texture
.backing_height
,
292 con
->scanout
.texture
.x
,
293 con
->scanout
.texture
.y
,
294 con
->scanout
.texture
.width
,
295 con
->scanout
.texture
.height
,
296 con
->scanout
.texture
.d3d_tex2d
);
300 void qemu_text_console_put_keysym(QemuTextConsole
*s
, int keysym
)
302 qemu_text_console_handle_keysym(s
, keysym
);
305 static const int qcode_to_keysym
[Q_KEY_CODE__MAX
] = {
306 [Q_KEY_CODE_UP
] = QEMU_KEY_UP
,
307 [Q_KEY_CODE_DOWN
] = QEMU_KEY_DOWN
,
308 [Q_KEY_CODE_RIGHT
] = QEMU_KEY_RIGHT
,
309 [Q_KEY_CODE_LEFT
] = QEMU_KEY_LEFT
,
310 [Q_KEY_CODE_HOME
] = QEMU_KEY_HOME
,
311 [Q_KEY_CODE_END
] = QEMU_KEY_END
,
312 [Q_KEY_CODE_PGUP
] = QEMU_KEY_PAGEUP
,
313 [Q_KEY_CODE_PGDN
] = QEMU_KEY_PAGEDOWN
,
314 [Q_KEY_CODE_DELETE
] = QEMU_KEY_DELETE
,
315 [Q_KEY_CODE_TAB
] = QEMU_KEY_TAB
,
316 [Q_KEY_CODE_BACKSPACE
] = QEMU_KEY_BACKSPACE
,
319 static const int ctrl_qcode_to_keysym
[Q_KEY_CODE__MAX
] = {
320 [Q_KEY_CODE_UP
] = QEMU_KEY_CTRL_UP
,
321 [Q_KEY_CODE_DOWN
] = QEMU_KEY_CTRL_DOWN
,
322 [Q_KEY_CODE_RIGHT
] = QEMU_KEY_CTRL_RIGHT
,
323 [Q_KEY_CODE_LEFT
] = QEMU_KEY_CTRL_LEFT
,
324 [Q_KEY_CODE_HOME
] = QEMU_KEY_CTRL_HOME
,
325 [Q_KEY_CODE_END
] = QEMU_KEY_CTRL_END
,
326 [Q_KEY_CODE_PGUP
] = QEMU_KEY_CTRL_PAGEUP
,
327 [Q_KEY_CODE_PGDN
] = QEMU_KEY_CTRL_PAGEDOWN
,
330 bool qemu_text_console_put_qcode(QemuTextConsole
*s
, int qcode
, bool ctrl
)
334 keysym
= ctrl
? ctrl_qcode_to_keysym
[qcode
] : qcode_to_keysym
[qcode
];
338 qemu_text_console_put_keysym(s
, keysym
);
342 void qemu_text_console_put_string(QemuTextConsole
*s
, const char *str
, int len
)
346 for (i
= 0; i
< len
&& str
[i
]; i
++) {
347 qemu_text_console_put_keysym(s
, str
[i
]);
352 qemu_console_register(QemuConsole
*c
)
356 if (QTAILQ_EMPTY(&consoles
)) {
358 QTAILQ_INSERT_TAIL(&consoles
, c
, next
);
359 } else if (!QEMU_IS_GRAPHIC_CONSOLE(c
) || phase_check(PHASE_MACHINE_READY
)) {
360 QemuConsole
*last
= QTAILQ_LAST(&consoles
);
361 c
->index
= last
->index
+ 1;
362 QTAILQ_INSERT_TAIL(&consoles
, c
, next
);
365 * HACK: Put graphical consoles before text consoles.
367 * Only do that for coldplugged devices. After initial device
368 * initialization we will not renumber the consoles any more.
370 QemuConsole
*it
= QTAILQ_FIRST(&consoles
);
372 while (QTAILQ_NEXT(it
, next
) != NULL
&& QEMU_IS_GRAPHIC_CONSOLE(it
)) {
373 it
= QTAILQ_NEXT(it
, next
);
375 if (QEMU_IS_GRAPHIC_CONSOLE(it
)) {
376 /* have no text consoles */
377 c
->index
= it
->index
+ 1;
378 QTAILQ_INSERT_AFTER(&consoles
, it
, c
, next
);
380 c
->index
= it
->index
;
381 QTAILQ_INSERT_BEFORE(it
, c
, next
);
382 /* renumber text consoles */
383 for (i
= c
->index
+ 1; it
!= NULL
; it
= QTAILQ_NEXT(it
, next
), i
++) {
391 qemu_console_finalize(Object
*obj
)
393 QemuConsole
*c
= QEMU_CONSOLE(obj
);
395 /* TODO: check this code path, and unregister from consoles */
396 g_clear_pointer(&c
->surface
, qemu_free_displaysurface
);
397 g_clear_pointer(&c
->gl_unblock_timer
, timer_free
);
398 g_clear_pointer(&c
->ui_timer
, timer_free
);
402 qemu_console_class_init(ObjectClass
*oc
, void *data
)
407 qemu_console_init(Object
*obj
)
409 QemuConsole
*c
= QEMU_CONSOLE(obj
);
410 DisplayState
*ds
= get_alloc_displaystate();
412 qemu_co_queue_init(&c
->dump_queue
);
415 c
->ui_timer
= timer_new_ms(QEMU_CLOCK_REALTIME
,
416 dpy_set_ui_info_timer
, c
);
417 qemu_console_register(c
);
421 qemu_graphic_console_finalize(Object
*obj
)
423 QemuGraphicConsole
*c
= QEMU_GRAPHIC_CONSOLE(obj
);
425 g_clear_pointer(&c
->device
, object_unref
);
429 qemu_graphic_console_prop_get_head(Object
*obj
, Visitor
*v
, const char *name
,
430 void *opaque
, Error
**errp
)
432 QemuGraphicConsole
*c
= QEMU_GRAPHIC_CONSOLE(obj
);
434 visit_type_uint32(v
, name
, &c
->head
, errp
);
438 qemu_graphic_console_class_init(ObjectClass
*oc
, void *data
)
440 object_class_property_add_link(oc
, "device", TYPE_DEVICE
,
441 offsetof(QemuGraphicConsole
, device
),
442 object_property_allow_set_link
,
443 OBJ_PROP_LINK_STRONG
);
444 object_class_property_add(oc
, "head", "uint32",
445 qemu_graphic_console_prop_get_head
,
450 qemu_graphic_console_init(Object
*obj
)
455 void qemu_displaysurface_win32_set_handle(DisplaySurface
*surface
,
456 HANDLE h
, uint32_t offset
)
458 assert(!surface
->handle
);
461 surface
->handle_offset
= offset
;
465 win32_pixman_image_destroy(pixman_image_t
*image
, void *data
)
467 DisplaySurface
*surface
= data
;
469 if (!surface
->handle
) {
473 assert(surface
->handle_offset
== 0);
476 pixman_image_get_data(surface
->image
),
483 DisplaySurface
*qemu_create_displaysurface(int width
, int height
)
485 DisplaySurface
*surface
;
488 HANDLE handle
= NULL
;
491 trace_displaysurface_create(width
, height
);
494 bits
= qemu_win32_map_alloc(width
* height
* 4, &handle
, &error_abort
);
497 surface
= qemu_create_displaysurface_from(
502 surface
->flags
= QEMU_ALLOCATED_FLAG
;
505 qemu_displaysurface_win32_set_handle(surface
, handle
, 0);
510 DisplaySurface
*qemu_create_displaysurface_from(int width
, int height
,
511 pixman_format_code_t format
,
512 int linesize
, uint8_t *data
)
514 DisplaySurface
*surface
= g_new0(DisplaySurface
, 1);
516 trace_displaysurface_create_from(surface
, width
, height
, format
);
517 surface
->image
= pixman_image_create_bits(format
,
519 (void *)data
, linesize
);
520 assert(surface
->image
!= NULL
);
522 pixman_image_set_destroy_function(surface
->image
,
523 win32_pixman_image_destroy
, surface
);
529 DisplaySurface
*qemu_create_displaysurface_pixman(pixman_image_t
*image
)
531 DisplaySurface
*surface
= g_new0(DisplaySurface
, 1);
533 trace_displaysurface_create_pixman(surface
);
534 surface
->image
= pixman_image_ref(image
);
539 DisplaySurface
*qemu_create_placeholder_surface(int w
, int h
,
542 DisplaySurface
*surface
= qemu_create_displaysurface(w
, h
);
544 pixman_color_t bg
= QEMU_PIXMAN_COLOR_BLACK
;
545 pixman_color_t fg
= QEMU_PIXMAN_COLOR_GRAY
;
546 pixman_image_t
*glyph
;
550 x
= (w
/ FONT_WIDTH
- len
) / 2;
551 y
= (h
/ FONT_HEIGHT
- 1) / 2;
552 for (i
= 0; i
< len
; i
++) {
553 glyph
= qemu_pixman_glyph_from_vgafont(FONT_HEIGHT
, vgafont16
, msg
[i
]);
554 qemu_pixman_glyph_render(glyph
, surface
->image
, &fg
, &bg
,
555 x
+i
, y
, FONT_WIDTH
, FONT_HEIGHT
);
556 qemu_pixman_image_unref(glyph
);
559 surface
->flags
|= QEMU_PLACEHOLDER_FLAG
;
563 void qemu_free_displaysurface(DisplaySurface
*surface
)
565 if (surface
== NULL
) {
568 trace_displaysurface_free(surface
);
569 qemu_pixman_image_unref(surface
->image
);
573 bool console_has_gl(QemuConsole
*con
)
575 return con
->gl
!= NULL
;
578 static bool displaychangelistener_has_dmabuf(DisplayChangeListener
*dcl
)
580 if (dcl
->ops
->dpy_has_dmabuf
) {
581 return dcl
->ops
->dpy_has_dmabuf(dcl
);
584 if (dcl
->ops
->dpy_gl_scanout_dmabuf
) {
591 static bool console_compatible_with(QemuConsole
*con
,
592 DisplayChangeListener
*dcl
, Error
**errp
)
596 flags
= con
->hw_ops
->get_flags
? con
->hw_ops
->get_flags(con
->hw
) : 0;
598 if (console_has_gl(con
) &&
599 !con
->gl
->ops
->dpy_gl_ctx_is_compatible_dcl(con
->gl
, dcl
)) {
600 error_setg(errp
, "Display %s is incompatible with the GL context",
605 if (flags
& GRAPHIC_FLAGS_GL
&&
606 !console_has_gl(con
)) {
607 error_setg(errp
, "The console requires a GL context.");
612 if (flags
& GRAPHIC_FLAGS_DMABUF
&&
613 !displaychangelistener_has_dmabuf(dcl
)) {
614 error_setg(errp
, "The console requires display DMABUF support.");
621 void console_handle_touch_event(QemuConsole
*con
,
622 struct touch_slot touch_slots
[INPUT_EVENT_SLOTS_MAX
],
624 int width
, int height
,
626 InputMultiTouchType type
,
629 struct touch_slot
*slot
;
630 bool needs_sync
= false;
634 if (num_slot
>= INPUT_EVENT_SLOTS_MAX
) {
636 "Unexpected touch slot number: % " PRId64
" >= %d",
637 num_slot
, INPUT_EVENT_SLOTS_MAX
);
641 slot
= &touch_slots
[num_slot
];
645 if (type
== INPUT_MULTI_TOUCH_TYPE_BEGIN
) {
646 slot
->tracking_id
= num_slot
;
649 for (i
= 0; i
< INPUT_EVENT_SLOTS_MAX
; ++i
) {
653 update
= INPUT_MULTI_TOUCH_TYPE_UPDATE
;
656 slot
= &touch_slots
[i
];
658 if (slot
->tracking_id
== -1) {
662 if (update
== INPUT_MULTI_TOUCH_TYPE_END
) {
663 slot
->tracking_id
= -1;
664 qemu_input_queue_mtt(con
, update
, i
, slot
->tracking_id
);
667 qemu_input_queue_mtt(con
, update
, i
, slot
->tracking_id
);
668 qemu_input_queue_btn(con
, INPUT_BUTTON_TOUCH
, true);
669 qemu_input_queue_mtt_abs(con
,
670 INPUT_AXIS_X
, (int) slot
->x
,
672 i
, slot
->tracking_id
);
673 qemu_input_queue_mtt_abs(con
,
674 INPUT_AXIS_Y
, (int) slot
->y
,
676 i
, slot
->tracking_id
);
682 qemu_input_event_sync();
686 void qemu_console_set_display_gl_ctx(QemuConsole
*con
, DisplayGLCtx
*gl
)
688 /* display has opengl support */
691 error_report("The console already has an OpenGL context.");
698 dcl_set_graphic_cursor(DisplayChangeListener
*dcl
, QemuGraphicConsole
*con
)
700 if (con
&& con
->cursor
&& dcl
->ops
->dpy_cursor_define
) {
701 dcl
->ops
->dpy_cursor_define(dcl
, con
->cursor
);
703 if (con
&& dcl
->ops
->dpy_mouse_set
) {
704 dcl
->ops
->dpy_mouse_set(dcl
, con
->cursor_x
, con
->cursor_y
, con
->cursor_on
);
708 void register_displaychangelistener(DisplayChangeListener
*dcl
)
712 trace_displaychangelistener_register(dcl
, dcl
->ops
->dpy_name
);
713 dcl
->ds
= get_alloc_displaystate();
714 QLIST_INSERT_HEAD(&dcl
->ds
->listeners
, dcl
, next
);
715 gui_setup_refresh(dcl
->ds
);
719 displaychangelistener_display_console(dcl
, &error_fatal
);
720 if (QEMU_IS_GRAPHIC_CONSOLE(dcl
->con
)) {
721 dcl_set_graphic_cursor(dcl
, QEMU_GRAPHIC_CONSOLE(dcl
->con
));
722 } else if (QEMU_IS_TEXT_CONSOLE(dcl
->con
)) {
723 qemu_text_console_update_size(QEMU_TEXT_CONSOLE(dcl
->con
));
725 qemu_text_console_update_cursor();
728 void update_displaychangelistener(DisplayChangeListener
*dcl
,
731 DisplayState
*ds
= dcl
->ds
;
733 dcl
->update_interval
= interval
;
734 if (!ds
->refreshing
&& ds
->update_interval
> interval
) {
735 timer_mod(ds
->gui_timer
, ds
->last_update
+ interval
);
739 void unregister_displaychangelistener(DisplayChangeListener
*dcl
)
741 DisplayState
*ds
= dcl
->ds
;
742 trace_displaychangelistener_unregister(dcl
, dcl
->ops
->dpy_name
);
746 QLIST_REMOVE(dcl
, next
);
748 gui_setup_refresh(ds
);
751 static void dpy_set_ui_info_timer(void *opaque
)
753 QemuConsole
*con
= opaque
;
754 uint32_t head
= qemu_console_get_head(con
);
756 con
->hw_ops
->ui_info(con
->hw
, head
, &con
->ui_info
);
759 bool dpy_ui_info_supported(const QemuConsole
*con
)
765 return con
->hw_ops
->ui_info
!= NULL
;
768 const QemuUIInfo
*dpy_get_ui_info(const QemuConsole
*con
)
770 assert(dpy_ui_info_supported(con
));
772 return &con
->ui_info
;
775 int dpy_set_ui_info(QemuConsole
*con
, QemuUIInfo
*info
, bool delay
)
777 if (!dpy_ui_info_supported(con
)) {
780 if (memcmp(&con
->ui_info
, info
, sizeof(con
->ui_info
)) == 0) {
781 /* nothing changed -- ignore */
786 * Typically we get a flood of these as the user resizes the window.
787 * Wait until the dust has settled (one second without updates), then
788 * go notify the guest.
790 con
->ui_info
= *info
;
791 timer_mod(con
->ui_timer
,
792 qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + (delay
? 1000 : 0));
796 void dpy_gfx_update(QemuConsole
*con
, int x
, int y
, int w
, int h
)
798 DisplayState
*s
= con
->ds
;
799 DisplayChangeListener
*dcl
;
800 int width
= qemu_console_get_width(con
, x
+ w
);
801 int height
= qemu_console_get_height(con
, y
+ h
);
807 w
= MIN(w
, width
- x
);
808 h
= MIN(h
, height
- y
);
810 if (!qemu_console_is_visible(con
)) {
813 dpy_gfx_update_texture(con
, con
->surface
, x
, y
, w
, h
);
814 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
815 if (con
!= dcl
->con
) {
818 if (dcl
->ops
->dpy_gfx_update
) {
819 dcl
->ops
->dpy_gfx_update(dcl
, x
, y
, w
, h
);
824 void dpy_gfx_update_full(QemuConsole
*con
)
826 int w
= qemu_console_get_width(con
, 0);
827 int h
= qemu_console_get_height(con
, 0);
829 dpy_gfx_update(con
, 0, 0, w
, h
);
832 void dpy_gfx_replace_surface(QemuConsole
*con
,
833 DisplaySurface
*surface
)
835 static const char placeholder_msg
[] = "Display output is not active.";
836 DisplayState
*s
= con
->ds
;
837 DisplaySurface
*old_surface
= con
->surface
;
838 DisplaySurface
*new_surface
= surface
;
839 DisplayChangeListener
*dcl
;
845 width
= surface_width(old_surface
);
846 height
= surface_height(old_surface
);
852 new_surface
= qemu_create_placeholder_surface(width
, height
, placeholder_msg
);
855 assert(old_surface
!= new_surface
);
857 con
->scanout
.kind
= SCANOUT_SURFACE
;
858 con
->surface
= new_surface
;
859 dpy_gfx_create_texture(con
, new_surface
);
860 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
861 if (con
!= dcl
->con
) {
864 displaychangelistener_gfx_switch(dcl
, new_surface
, surface
? FALSE
: TRUE
);
866 dpy_gfx_destroy_texture(con
, old_surface
);
867 qemu_free_displaysurface(old_surface
);
870 bool dpy_gfx_check_format(QemuConsole
*con
,
871 pixman_format_code_t format
)
873 DisplayChangeListener
*dcl
;
874 DisplayState
*s
= con
->ds
;
876 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
877 if (dcl
->con
&& dcl
->con
!= con
) {
878 /* dcl bound to another console -> skip */
881 if (dcl
->ops
->dpy_gfx_check_format
) {
882 if (!dcl
->ops
->dpy_gfx_check_format(dcl
, format
)) {
886 /* default is to allow native 32 bpp only */
887 if (format
!= qemu_default_pixman_format(32, true)) {
895 static void dpy_refresh(DisplayState
*s
)
897 DisplayChangeListener
*dcl
;
899 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
900 if (dcl
->ops
->dpy_refresh
) {
901 dcl
->ops
->dpy_refresh(dcl
);
906 void dpy_text_cursor(QemuConsole
*con
, int x
, int y
)
908 DisplayState
*s
= con
->ds
;
909 DisplayChangeListener
*dcl
;
911 if (!qemu_console_is_visible(con
)) {
914 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
915 if (con
!= dcl
->con
) {
918 if (dcl
->ops
->dpy_text_cursor
) {
919 dcl
->ops
->dpy_text_cursor(dcl
, x
, y
);
924 void dpy_text_update(QemuConsole
*con
, int x
, int y
, int w
, int h
)
926 DisplayState
*s
= con
->ds
;
927 DisplayChangeListener
*dcl
;
929 if (!qemu_console_is_visible(con
)) {
932 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
933 if (con
!= dcl
->con
) {
936 if (dcl
->ops
->dpy_text_update
) {
937 dcl
->ops
->dpy_text_update(dcl
, x
, y
, w
, h
);
942 void dpy_text_resize(QemuConsole
*con
, int w
, int h
)
944 DisplayState
*s
= con
->ds
;
945 DisplayChangeListener
*dcl
;
947 if (!qemu_console_is_visible(con
)) {
950 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
951 if (con
!= dcl
->con
) {
954 if (dcl
->ops
->dpy_text_resize
) {
955 dcl
->ops
->dpy_text_resize(dcl
, w
, h
);
960 void dpy_mouse_set(QemuConsole
*c
, int x
, int y
, int on
)
962 QemuGraphicConsole
*con
= QEMU_GRAPHIC_CONSOLE(c
);
963 DisplayState
*s
= c
->ds
;
964 DisplayChangeListener
*dcl
;
969 if (!qemu_console_is_visible(c
)) {
972 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
976 if (dcl
->ops
->dpy_mouse_set
) {
977 dcl
->ops
->dpy_mouse_set(dcl
, x
, y
, on
);
982 void dpy_cursor_define(QemuConsole
*c
, QEMUCursor
*cursor
)
984 QemuGraphicConsole
*con
= QEMU_GRAPHIC_CONSOLE(c
);
985 DisplayState
*s
= c
->ds
;
986 DisplayChangeListener
*dcl
;
988 cursor_unref(con
->cursor
);
989 con
->cursor
= cursor_ref(cursor
);
990 if (!qemu_console_is_visible(c
)) {
993 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
997 if (dcl
->ops
->dpy_cursor_define
) {
998 dcl
->ops
->dpy_cursor_define(dcl
, cursor
);
1003 bool dpy_cursor_define_supported(QemuConsole
*con
)
1005 DisplayState
*s
= con
->ds
;
1006 DisplayChangeListener
*dcl
;
1008 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1009 if (dcl
->ops
->dpy_cursor_define
) {
1016 QEMUGLContext
dpy_gl_ctx_create(QemuConsole
*con
,
1017 struct QEMUGLParams
*qparams
)
1020 return con
->gl
->ops
->dpy_gl_ctx_create(con
->gl
, qparams
);
1023 void dpy_gl_ctx_destroy(QemuConsole
*con
, QEMUGLContext ctx
)
1026 con
->gl
->ops
->dpy_gl_ctx_destroy(con
->gl
, ctx
);
1029 int dpy_gl_ctx_make_current(QemuConsole
*con
, QEMUGLContext ctx
)
1032 return con
->gl
->ops
->dpy_gl_ctx_make_current(con
->gl
, ctx
);
1035 void dpy_gl_scanout_disable(QemuConsole
*con
)
1037 DisplayState
*s
= con
->ds
;
1038 DisplayChangeListener
*dcl
;
1040 if (con
->scanout
.kind
!= SCANOUT_SURFACE
) {
1041 con
->scanout
.kind
= SCANOUT_NONE
;
1043 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1044 if (con
!= dcl
->con
) {
1047 if (dcl
->ops
->dpy_gl_scanout_disable
) {
1048 dcl
->ops
->dpy_gl_scanout_disable(dcl
);
1053 void dpy_gl_scanout_texture(QemuConsole
*con
,
1054 uint32_t backing_id
,
1055 bool backing_y_0_top
,
1056 uint32_t backing_width
,
1057 uint32_t backing_height
,
1058 uint32_t x
, uint32_t y
,
1059 uint32_t width
, uint32_t height
,
1062 DisplayState
*s
= con
->ds
;
1063 DisplayChangeListener
*dcl
;
1065 con
->scanout
.kind
= SCANOUT_TEXTURE
;
1066 con
->scanout
.texture
= (ScanoutTexture
) {
1067 backing_id
, backing_y_0_top
, backing_width
, backing_height
,
1068 x
, y
, width
, height
, d3d_tex2d
,
1070 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1071 if (con
!= dcl
->con
) {
1074 if (dcl
->ops
->dpy_gl_scanout_texture
) {
1075 dcl
->ops
->dpy_gl_scanout_texture(dcl
, backing_id
,
1077 backing_width
, backing_height
,
1078 x
, y
, width
, height
,
1084 void dpy_gl_scanout_dmabuf(QemuConsole
*con
,
1087 DisplayState
*s
= con
->ds
;
1088 DisplayChangeListener
*dcl
;
1090 con
->scanout
.kind
= SCANOUT_DMABUF
;
1091 con
->scanout
.dmabuf
= dmabuf
;
1092 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1093 if (con
!= dcl
->con
) {
1096 if (dcl
->ops
->dpy_gl_scanout_dmabuf
) {
1097 dcl
->ops
->dpy_gl_scanout_dmabuf(dcl
, dmabuf
);
1102 void dpy_gl_cursor_dmabuf(QemuConsole
*con
, QemuDmaBuf
*dmabuf
,
1103 bool have_hot
, uint32_t hot_x
, uint32_t hot_y
)
1105 DisplayState
*s
= con
->ds
;
1106 DisplayChangeListener
*dcl
;
1108 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1109 if (con
!= dcl
->con
) {
1112 if (dcl
->ops
->dpy_gl_cursor_dmabuf
) {
1113 dcl
->ops
->dpy_gl_cursor_dmabuf(dcl
, dmabuf
,
1114 have_hot
, hot_x
, hot_y
);
1119 void dpy_gl_cursor_position(QemuConsole
*con
,
1120 uint32_t pos_x
, uint32_t pos_y
)
1122 DisplayState
*s
= con
->ds
;
1123 DisplayChangeListener
*dcl
;
1125 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1126 if (con
!= dcl
->con
) {
1129 if (dcl
->ops
->dpy_gl_cursor_position
) {
1130 dcl
->ops
->dpy_gl_cursor_position(dcl
, pos_x
, pos_y
);
1135 void dpy_gl_release_dmabuf(QemuConsole
*con
,
1138 DisplayState
*s
= con
->ds
;
1139 DisplayChangeListener
*dcl
;
1141 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1142 if (con
!= dcl
->con
) {
1145 if (dcl
->ops
->dpy_gl_release_dmabuf
) {
1146 dcl
->ops
->dpy_gl_release_dmabuf(dcl
, dmabuf
);
1151 void dpy_gl_update(QemuConsole
*con
,
1152 uint32_t x
, uint32_t y
, uint32_t w
, uint32_t h
)
1154 DisplayState
*s
= con
->ds
;
1155 DisplayChangeListener
*dcl
;
1159 graphic_hw_gl_block(con
, true);
1160 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1161 if (con
!= dcl
->con
) {
1164 if (dcl
->ops
->dpy_gl_update
) {
1165 dcl
->ops
->dpy_gl_update(dcl
, x
, y
, w
, h
);
1168 graphic_hw_gl_block(con
, false);
1171 /***********************************************************/
1172 /* register display */
1174 /* console.c internal use only */
1175 static DisplayState
*get_alloc_displaystate(void)
1177 if (!display_state
) {
1178 display_state
= g_new0(DisplayState
, 1);
1180 return display_state
;
1184 * Called by main(), after creating QemuConsoles
1185 * and before initializing ui (sdl/vnc/...).
1187 DisplayState
*init_displaystate(void)
1192 QTAILQ_FOREACH(con
, &consoles
, next
) {
1193 /* Hook up into the qom tree here (not in object_new()), once
1194 * all QemuConsoles are created and the order / numbering
1195 * doesn't change any more */
1196 name
= g_strdup_printf("console[%d]", con
->index
);
1197 object_property_add_child(container_get(object_get_root(), "/backend"),
1202 return display_state
;
1205 void graphic_console_set_hwops(QemuConsole
*con
,
1206 const GraphicHwOps
*hw_ops
,
1209 con
->hw_ops
= hw_ops
;
1213 QemuConsole
*graphic_console_init(DeviceState
*dev
, uint32_t head
,
1214 const GraphicHwOps
*hw_ops
,
1217 static const char noinit
[] =
1218 "Guest has not initialized the display (yet).";
1222 DisplaySurface
*surface
;
1224 s
= qemu_graphic_console_lookup_unused();
1226 trace_console_gfx_reuse(s
->index
);
1227 width
= qemu_console_get_width(s
, 0);
1228 height
= qemu_console_get_height(s
, 0);
1230 trace_console_gfx_new();
1231 s
= (QemuConsole
*)object_new(TYPE_QEMU_GRAPHIC_CONSOLE
);
1233 QEMU_GRAPHIC_CONSOLE(s
)->head
= head
;
1234 graphic_console_set_hwops(s
, hw_ops
, opaque
);
1236 object_property_set_link(OBJECT(s
), "device", OBJECT(dev
),
1240 surface
= qemu_create_placeholder_surface(width
, height
, noinit
);
1241 dpy_gfx_replace_surface(s
, surface
);
1242 s
->gl_unblock_timer
= timer_new_ms(QEMU_CLOCK_REALTIME
,
1243 graphic_hw_gl_unblock_timer
, s
);
1247 static const GraphicHwOps unused_ops
= {
1251 void graphic_console_close(QemuConsole
*con
)
1253 static const char unplugged
[] =
1254 "Guest display has been unplugged";
1255 DisplaySurface
*surface
;
1256 int width
= qemu_console_get_width(con
, 640);
1257 int height
= qemu_console_get_height(con
, 480);
1259 trace_console_gfx_close(con
->index
);
1260 object_property_set_link(OBJECT(con
), "device", NULL
, &error_abort
);
1261 graphic_console_set_hwops(con
, &unused_ops
, NULL
);
1264 dpy_gl_scanout_disable(con
);
1266 surface
= qemu_create_placeholder_surface(width
, height
, unplugged
);
1267 dpy_gfx_replace_surface(con
, surface
);
1270 QemuConsole
*qemu_console_lookup_default(void)
1274 QTAILQ_FOREACH(con
, &consoles
, next
) {
1275 if (QEMU_IS_GRAPHIC_CONSOLE(con
)) {
1279 return QTAILQ_FIRST(&consoles
);
1282 QemuConsole
*qemu_console_lookup_by_index(unsigned int index
)
1286 QTAILQ_FOREACH(con
, &consoles
, next
) {
1287 if (con
->index
== index
) {
1294 QemuConsole
*qemu_console_lookup_by_device(DeviceState
*dev
, uint32_t head
)
1300 QTAILQ_FOREACH(con
, &consoles
, next
) {
1301 obj
= object_property_get_link(OBJECT(con
),
1302 "device", &error_abort
);
1303 if (DEVICE(obj
) != dev
) {
1306 h
= object_property_get_uint(OBJECT(con
),
1307 "head", &error_abort
);
1316 QemuConsole
*qemu_console_lookup_by_device_name(const char *device_id
,
1317 uint32_t head
, Error
**errp
)
1322 dev
= qdev_find_recursive(sysbus_get_default(), device_id
);
1324 error_set(errp
, ERROR_CLASS_DEVICE_NOT_FOUND
,
1325 "Device '%s' not found", device_id
);
1329 con
= qemu_console_lookup_by_device(dev
, head
);
1331 error_setg(errp
, "Device %s (head %d) is not bound to a QemuConsole",
1339 static QemuConsole
*qemu_graphic_console_lookup_unused(void)
1344 QTAILQ_FOREACH(con
, &consoles
, next
) {
1345 if (!QEMU_IS_GRAPHIC_CONSOLE(con
) || con
->hw_ops
!= &unused_ops
) {
1348 obj
= object_property_get_link(OBJECT(con
),
1349 "device", &error_abort
);
1358 QEMUCursor
*qemu_console_get_cursor(QemuConsole
*con
)
1360 return QEMU_IS_GRAPHIC_CONSOLE(con
) ? QEMU_GRAPHIC_CONSOLE(con
)->cursor
: NULL
;
1363 bool qemu_console_is_visible(QemuConsole
*con
)
1365 return con
->dcls
> 0;
1368 bool qemu_console_is_graphic(QemuConsole
*con
)
1370 return con
&& QEMU_IS_GRAPHIC_CONSOLE(con
);
1373 bool qemu_console_is_fixedsize(QemuConsole
*con
)
1375 return con
&& (QEMU_IS_GRAPHIC_CONSOLE(con
) || QEMU_IS_FIXED_TEXT_CONSOLE(con
));
1378 bool qemu_console_is_gl_blocked(QemuConsole
*con
)
1380 assert(con
!= NULL
);
1381 return con
->gl_block
;
1384 static bool qemu_graphic_console_is_multihead(QemuGraphicConsole
*c
)
1388 QTAILQ_FOREACH(con
, &consoles
, next
) {
1389 QemuGraphicConsole
*candidate
;
1391 if (!QEMU_IS_GRAPHIC_CONSOLE(con
)) {
1395 candidate
= QEMU_GRAPHIC_CONSOLE(con
);
1396 if (candidate
->device
!= c
->device
) {
1400 if (candidate
->head
!= c
->head
) {
1407 char *qemu_console_get_label(QemuConsole
*con
)
1409 if (QEMU_IS_GRAPHIC_CONSOLE(con
)) {
1410 QemuGraphicConsole
*c
= QEMU_GRAPHIC_CONSOLE(con
);
1415 dev
= DEVICE(c
->device
);
1416 multihead
= qemu_graphic_console_is_multihead(c
);
1418 return g_strdup_printf("%s.%d", dev
->id
?
1420 object_get_typename(c
->device
),
1423 return g_strdup_printf("%s", dev
->id
?
1425 object_get_typename(c
->device
));
1428 return g_strdup("VGA");
1429 } else if (QEMU_IS_TEXT_CONSOLE(con
)) {
1430 const char *label
= qemu_text_console_get_label(QEMU_TEXT_CONSOLE(con
));
1432 return g_strdup(label
);
1436 return g_strdup_printf("vc%d", con
->index
);
1439 int qemu_console_get_index(QemuConsole
*con
)
1441 return con
? con
->index
: -1;
1444 uint32_t qemu_console_get_head(QemuConsole
*con
)
1449 if (QEMU_IS_GRAPHIC_CONSOLE(con
)) {
1450 return QEMU_GRAPHIC_CONSOLE(con
)->head
;
1455 int qemu_console_get_width(QemuConsole
*con
, int fallback
)
1460 switch (con
->scanout
.kind
) {
1461 case SCANOUT_DMABUF
:
1462 return con
->scanout
.dmabuf
->width
;
1463 case SCANOUT_TEXTURE
:
1464 return con
->scanout
.texture
.width
;
1465 case SCANOUT_SURFACE
:
1466 return surface_width(con
->surface
);
1472 int qemu_console_get_height(QemuConsole
*con
, int fallback
)
1477 switch (con
->scanout
.kind
) {
1478 case SCANOUT_DMABUF
:
1479 return con
->scanout
.dmabuf
->height
;
1480 case SCANOUT_TEXTURE
:
1481 return con
->scanout
.texture
.height
;
1482 case SCANOUT_SURFACE
:
1483 return surface_height(con
->surface
);
1489 int qemu_invalidate_text_consoles(void)
1494 QTAILQ_FOREACH(s
, &consoles
, next
) {
1495 if (qemu_console_is_graphic(s
) ||
1496 !qemu_console_is_visible(s
)) {
1500 graphic_hw_invalidate(s
);
1506 void qemu_console_resize(QemuConsole
*s
, int width
, int height
)
1508 DisplaySurface
*surface
= qemu_console_surface(s
);
1510 assert(QEMU_IS_GRAPHIC_CONSOLE(s
));
1512 if ((s
->scanout
.kind
!= SCANOUT_SURFACE
||
1513 (surface
&& !is_buffer_shared(surface
) && !is_placeholder(surface
))) &&
1514 qemu_console_get_width(s
, -1) == width
&&
1515 qemu_console_get_height(s
, -1) == height
) {
1519 surface
= qemu_create_displaysurface(width
, height
);
1520 dpy_gfx_replace_surface(s
, surface
);
1523 DisplaySurface
*qemu_console_surface(QemuConsole
*console
)
1525 switch (console
->scanout
.kind
) {
1526 case SCANOUT_SURFACE
:
1527 return console
->surface
;
1533 PixelFormat
qemu_default_pixelformat(int bpp
)
1535 pixman_format_code_t fmt
= qemu_default_pixman_format(bpp
, true);
1536 PixelFormat pf
= qemu_pixelformat_from_pixman(fmt
);
1540 static QemuDisplay
*dpys
[DISPLAY_TYPE__MAX
];
1542 void qemu_display_register(QemuDisplay
*ui
)
1544 assert(ui
->type
< DISPLAY_TYPE__MAX
);
1545 dpys
[ui
->type
] = ui
;
1548 bool qemu_display_find_default(DisplayOptions
*opts
)
1550 static DisplayType prio
[] = {
1551 #if defined(CONFIG_GTK)
1554 #if defined(CONFIG_SDL)
1557 #if defined(CONFIG_COCOA)
1563 for (i
= 0; i
< (int)ARRAY_SIZE(prio
); i
++) {
1564 if (dpys
[prio
[i
]] == NULL
) {
1565 Error
*local_err
= NULL
;
1566 int rv
= ui_module_load(DisplayType_str(prio
[i
]), &local_err
);
1568 error_report_err(local_err
);
1571 if (dpys
[prio
[i
]] == NULL
) {
1574 opts
->type
= prio
[i
];
1580 void qemu_display_early_init(DisplayOptions
*opts
)
1582 assert(opts
->type
< DISPLAY_TYPE__MAX
);
1583 if (opts
->type
== DISPLAY_TYPE_NONE
) {
1586 if (dpys
[opts
->type
] == NULL
) {
1587 Error
*local_err
= NULL
;
1588 int rv
= ui_module_load(DisplayType_str(opts
->type
), &local_err
);
1590 error_report_err(local_err
);
1593 if (dpys
[opts
->type
] == NULL
) {
1594 error_report("Display '%s' is not available.",
1595 DisplayType_str(opts
->type
));
1598 if (dpys
[opts
->type
]->early_init
) {
1599 dpys
[opts
->type
]->early_init(opts
);
1603 void qemu_display_init(DisplayState
*ds
, DisplayOptions
*opts
)
1605 assert(opts
->type
< DISPLAY_TYPE__MAX
);
1606 if (opts
->type
== DISPLAY_TYPE_NONE
) {
1609 assert(dpys
[opts
->type
] != NULL
);
1610 dpys
[opts
->type
]->init(ds
, opts
);
1613 const char *qemu_display_get_vc(DisplayOptions
*opts
)
1615 #ifdef CONFIG_PIXMAN
1616 const char *vc
= "vc:80Cx24C";
1618 const char *vc
= NULL
;
1621 assert(opts
->type
< DISPLAY_TYPE__MAX
);
1622 if (dpys
[opts
->type
] && dpys
[opts
->type
]->vc
) {
1623 vc
= dpys
[opts
->type
]->vc
;
1628 void qemu_display_help(void)
1632 printf("Available display backend types:\n");
1634 for (idx
= DISPLAY_TYPE_NONE
; idx
< DISPLAY_TYPE__MAX
; idx
++) {
1636 Error
*local_err
= NULL
;
1637 int rv
= ui_module_load(DisplayType_str(idx
), &local_err
);
1639 error_report_err(local_err
);
1643 printf("%s\n", DisplayType_str(dpys
[idx
]->type
));