[vlc-commits] vout: xcb: window: implement VOUT_WINDOW_HIDE_MOUSE

Thomas Guillem git at videolan.org
Wed Nov 30 17:23:32 CET 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Nov 30 11:56:46 2016 +0100| [a695036a527ca8256ae824d65440d8a58c0970e8] | committer: Thomas Guillem

vout: xcb: window: implement VOUT_WINDOW_HIDE_MOUSE

Ref #9787

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a695036a527ca8256ae824d65440d8a58c0970e8
---

 modules/video_output/xcb/window.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/modules/video_output/xcb/window.c b/modules/video_output/xcb/window.c
index c4c6275..4aac15f 100644
--- a/modules/video_output/xcb/window.c
+++ b/modules/video_output/xcb/window.c
@@ -46,6 +46,8 @@ struct vout_window_sys_t
     key_handler_t *keys;
     vlc_thread_t thread;
 
+    xcb_cursor_t cursor; /* blank cursor */
+
     xcb_window_t root;
     xcb_atom_t wm_state;
     xcb_atom_t wm_state_above;
@@ -219,6 +221,14 @@ static int Control (vout_window_t *wnd, int cmd, va_list ap)
             change_wm_state (wnd, fs, p_sys->wm_state_fullscreen);
             break;
         }
+        case VOUT_WINDOW_HIDE_MOUSE:
+        {
+            xcb_cursor_t cursor = (va_arg (ap, int) ? p_sys->cursor
+                                                    : XCB_CURSOR_NONE);
+            xcb_change_window_attributes (p_sys->conn, wnd->handle.xid,
+                                          XCB_CW_CURSOR, &(uint32_t){ cursor });
+            break;
+        }
 
         default:
             msg_Err (wnd, "request %d not implemented", cmd);
@@ -299,6 +309,18 @@ xcb_atom_t get_atom (xcb_connection_t *conn, xcb_intern_atom_cookie_t ck)
     return atom;
 }
 
+static
+xcb_cursor_t CursorCreate(xcb_connection_t *conn,
+                                   const xcb_screen_t *scr)
+{
+    xcb_cursor_t cur = xcb_generate_id (conn);
+    xcb_pixmap_t pix = xcb_generate_id (conn);
+
+    xcb_create_pixmap (conn, 1, pix, scr->root, 1, 1);
+    xcb_create_cursor (conn, cur, pix, pix, 0, 0, 0, 0, 0, 0, 1, 1);
+    return cur;
+}
+
 static void CacheAtoms (vout_window_sys_t *p_sys)
 {
     xcb_connection_t *conn = p_sys->conn;
@@ -474,6 +496,9 @@ static int Open (vout_window_t *wnd, const vout_window_cfg_t *cfg)
         goto error;
     }
 
+    /* Create cursor */
+    p_sys->cursor = CursorCreate(conn, scr);
+
     xcb_flush (conn); /* Make sure map_window is sent (should be useless) */
     return VLC_SUCCESS;
 
@@ -497,6 +522,11 @@ static void Close (vout_window_t *wnd)
     vlc_join (p_sys->thread, NULL);
     if (p_sys->keys != NULL)
         XCB_keyHandler_Destroy (p_sys->keys);
+
+    /* show the default cursor */
+    xcb_change_window_attributes (p_sys->conn, wnd->handle.xid, XCB_CW_CURSOR,
+                                  &(uint32_t) { XCB_CURSOR_NONE });
+
     xcb_disconnect (conn);
     free (wnd->display.x11);
     free (p_sys);



More information about the vlc-commits mailing list