vout_display_SendEventMouseMoved (vd, x, y);
}
+static void HandleVisibilityNotify (vout_display_t *vd, bool *visible,
+ const xcb_visibility_notify_event_t *ev)
+{
+ *visible = ev->state != XCB_VISIBILITY_FULLY_OBSCURED;
+ msg_Dbg (vd, "display is %svisible", *visible ? "" : "not ");
+}
+
static void
HandleParentStructure (vout_display_t *vd,
const xcb_configure_notify_event_t *ev)
/**
* Process an X11 event.
*/
-static int ProcessEvent (vout_display_t *vd,
- xcb_window_t window, xcb_generic_event_t *ev)
+static int ProcessEvent (vout_display_t *vd, bool *visible,
+ xcb_generic_event_t *ev)
{
switch (ev->response_type & 0x7f)
{
HandleMotionNotify (vd, (xcb_motion_notify_event_t *)ev);
break;
- case XCB_CONFIGURE_NOTIFY:
- {
- xcb_configure_notify_event_t *cn =
- (xcb_configure_notify_event_t *)ev;
+ case XCB_VISIBILITY_NOTIFY:
+ HandleVisibilityNotify (vd, visible,
+ (xcb_visibility_notify_event_t *)ev);
+ break;
- assert (cn->window != window);
- HandleParentStructure (vd, cn);
+ case XCB_CONFIGURE_NOTIFY:
+ HandleParentStructure (vd, (xcb_configure_notify_event_t *)ev);
break;
- }
/* FIXME I am not sure it is the right one */
case XCB_DESTROY_NOTIFY:
/**
* Process incoming X events.
*/
-int ManageEvent (vout_display_t *vd, xcb_connection_t *conn, xcb_window_t window)
+int ManageEvent (vout_display_t *vd, xcb_connection_t *conn, bool *visible)
{
xcb_generic_event_t *ev;
while ((ev = xcb_poll_for_event (conn)) != NULL)
- ProcessEvent (vd, window, ev);
+ ProcessEvent (vd, visible, ev);
if (xcb_connection_has_error (conn))
{
xcb_window_t window; /* drawable X window */
xcb_gcontext_t gc; /* context to put images */
bool shm; /* whether to use MIT-SHM */
+ bool visible; /* whether to draw */
uint8_t bpp; /* bits per pixel */
uint8_t pad; /* scanline pad */
uint8_t depth; /* useful bits per pixel */
const uint32_t values[] = {
/* XCB_CW_EVENT_MASK */
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
- XCB_EVENT_MASK_POINTER_MOTION,
+ XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_VISIBILITY_CHANGE,
/* XCB_CW_COLORMAP */
cmap,
};
}
msg_Dbg (vd, "using X11 window %08"PRIx32, p_sys->window);
msg_Dbg (vd, "using X11 graphic context %08"PRIx32, p_sys->gc);
+ p_sys->visible = false;
/* */
vout_display_info_t info = vd->info;
xcb_shm_seg_t segment = pic->p_sys->segment;
xcb_void_cookie_t ck;
+ if (!p_sys->visible)
+ goto out;
if (segment != 0)
ck = xcb_shm_put_image_checked (p_sys->conn, p_sys->window, p_sys->gc,
/* real width */ pic->p->i_pitch / pic->p->i_pixel_pitch,
/* FIXME might be WAY better to wait in some case (be carefull with
* VOUT_DISPLAY_RESET_PICTURES if done) + does not work with
* vout_display wrapper. */
+out:
picture_Release (pic);
}
{
vout_display_sys_t *p_sys = vd->sys;
- ManageEvent (vd, p_sys->conn, p_sys->window);
+ ManageEvent (vd, p_sys->conn, &p_sys->visible);
}
static void ResetPictures (vout_display_t *vd)
#include <vlc_picture.h>
#include <vlc_vout_display.h>
-int ManageEvent (vout_display_t *vd, xcb_connection_t *conn, xcb_window_t window);
+int ManageEvent (vout_display_t *vd, xcb_connection_t *conn, bool *);
/* keys.c */
typedef struct key_handler_t key_handler_t;
uint16_t height; /* display height */
uint32_t data_size; /* picture byte size (for non-SHM) */
bool shm; /* whether to use MIT-SHM */
+ bool visible; /* whether it makes sense to draw at all */
xcb_xv_query_image_attributes_reply_t *att;
picture_pool_t *pool; /* picture pool */
const uint32_t mask =
/* XCB_CW_EVENT_MASK */
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
- XCB_EVENT_MASK_POINTER_MOTION;
+ XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_VISIBILITY_CHANGE;
xcb_void_cookie_t c;
xcb_window_t window = xcb_generate_id (conn);
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
values);
}
+ p_sys->visible = false;
/* Create graphic context */
p_sys->gc = xcb_generate_id (conn);
xcb_shm_seg_t segment = pic->p_sys->segment;
xcb_void_cookie_t ck;
+ if (!p_sys->visible)
+ goto out;
if (segment)
ck = xcb_xv_shm_put_image_checked (p_sys->conn, p_sys->port,
p_sys->window, p_sys->gc, segment, p_sys->id, 0,
msg_Dbg (vd, "%s: X11 error %d", "cannot put image", e->error_code);
free (e);
}
-
+out:
picture_Release (pic);
}
{
vout_display_sys_t *p_sys = vd->sys;
- ManageEvent (vd, p_sys->conn, p_sys->window);
+ ManageEvent (vd, p_sys->conn, &p_sys->visible);
}