]> git.sesse.net Git - vlc/blobdiff - modules/video_output/xcb/window.c
XCB/window: pass requested position to the X server
[vlc] / modules / video_output / xcb / window.c
index 69914959e99420e4a494cb18f1536a372b7dfb6a..fc193b462447ec5df774ebf744b65b1e8bc5794d 100644 (file)
@@ -184,7 +184,7 @@ static void CacheAtoms (vout_window_sys_t *p_sys)
 
     wm_state_ck = intern_string (conn, "_NET_WM_STATE");
     wm_state_above_ck = intern_string (conn, "_NET_WM_STATE_ABOVE");
-    wm_state_below_ck = intern_string (conn, "_NET_WM_STATE_ABOVE");
+    wm_state_below_ck = intern_string (conn, "_NET_WM_STATE_BELOW");
     wm_state_fs_ck = intern_string (conn, "_NET_WM_STATE_FULLSCREEN");
 #ifdef MATCHBOX_HACK
     xcb_intern_atom_cookie_t mb_current_app_window;
@@ -253,7 +253,8 @@ static int Open (vlc_object_t *obj)
 
     xcb_window_t window = xcb_generate_id (conn);
     ck = xcb_create_window_checked (conn, scr->root_depth, window, scr->root,
-                                    0, 0, wnd->cfg->width, wnd->cfg->height, 0,
+                                    wnd->cfg->x, wnd->cfg->y,
+                                    wnd->cfg->width, wnd->cfg->height, 0,
                                     XCB_WINDOW_CLASS_INPUT_OUTPUT,
                                     scr->root_visual, mask, values);
     err = xcb_request_check (conn, ck);
@@ -264,8 +265,8 @@ static int Open (vlc_object_t *obj)
         goto error;
     }
 
-    wnd->xid = window;
-    wnd->x11_display = display;
+    wnd->handle.xid = window;
+    wnd->display.x11 = display;
     wnd->control = Control;
     wnd->sys = p_sys;
 
@@ -278,9 +279,16 @@ static int Open (vlc_object_t *obj)
 
     /* ICCCM
      * No cut&paste nor drag&drop, only Window Manager communication. */
-    /* Plain ASCII localization of VLC for ICCCM window name */
+    /* xgettext:
+       Plain ASCII of "VLC media player" for the ICCCM window name.
+       This must be ASCII. The limitation is partially with ICCCM
+       and partially with VLC.
+       For Latin script languages, you may need to strip accents.
+       For other scripts, you will need to transliterate into Latin. */
     set_ascii_prop (conn, window, XA_WM_NAME,
                   vlc_pgettext ("ASCII", "VLC media player"));
+    /* xgettext:
+       Plain ASCII of "VLC" for the ICCCM window name. */
     set_ascii_prop (conn, window, XA_WM_ICON_NAME,
                     vlc_pgettext ("ASCII", "VLC"));
     set_wm_hints (conn, window);
@@ -330,6 +338,12 @@ static int Open (vlc_object_t *obj)
     /* Make the window visible */
     xcb_map_window (conn, window);
 
+    if (var_CreateGetBool (obj, "video-wallpaper"))
+    {
+        vout_window_SetState (wnd, VOUT_WINDOW_STATE_BELOW);
+        vout_window_SetFullScreen (wnd, true);
+    }
+
     /* Create the event thread. It will dequeue all events, so any checked
      * request from this thread must be completed at this point. */
     if ((p_sys->keys != NULL)
@@ -339,7 +353,7 @@ static int Open (vlc_object_t *obj)
 #ifdef MATCHBOX_HACK
     if (p_sys->mb_current_app_window)
         xcb_set_input_focus (p_sys->conn, XCB_INPUT_FOCUS_POINTER_ROOT,
-                             wnd->xid, XCB_CURRENT_TIME);
+                             wnd->handle.xid, XCB_CURRENT_TIME);
 #endif
     xcb_flush (conn); /* Make sure map_window is sent (should be useless) */
     return VLC_SUCCESS;
@@ -368,7 +382,7 @@ static void Close (vlc_object_t *obj)
         DestroyKeyHandler (p_sys->keys);
     }
     xcb_disconnect (conn);
-    free (wnd->x11_display);
+    free (wnd->display.x11);
     free (p_sys);
 }
 
@@ -410,13 +424,13 @@ static void *Thread (void *data)
                             xcb_get_property (conn, 0, pne->window, pne->atom,
                                               XA_WINDOW, 0, 4), NULL);
                     if (r != NULL
-                     && !memcmp (xcb_get_property_value (r), &wnd->xid,
+                     && !memcmp (xcb_get_property_value (r), &wnd->handle.xid,
                                  4))
                     {
                         msg_Dbg (wnd, "asking Matchbox for input focus");
                         xcb_set_input_focus (conn,
                                              XCB_INPUT_FOCUS_POINTER_ROOT,
-                                             wnd->xid, pne->time);
+                                             wnd->handle.xid, pne->time);
                         xcb_flush (conn);
                     }
                     free (r);
@@ -446,7 +460,7 @@ static void set_wm_state (vout_window_t *wnd, bool on, xcb_atom_t state)
     xcb_client_message_event_t ev = {
          .response_type = XCB_CLIENT_MESSAGE,
          .format = 32,
-         .window = wnd->xid,
+         .window = wnd->handle.xid,
          .type = sys->wm_state,
     };
 
@@ -476,7 +490,7 @@ static int Control (vout_window_t *wnd, int cmd, va_list ap)
             unsigned height = va_arg (ap, unsigned);
             const uint32_t values[] = { width, height, };
 
-            xcb_configure_window (conn, wnd->xid,
+            xcb_configure_window (conn, wnd->handle.xid,
                                   XCB_CONFIG_WINDOW_WIDTH |
                                   XCB_CONFIG_WINDOW_HEIGHT, values);
             break;
@@ -494,8 +508,13 @@ static int Control (vout_window_t *wnd, int cmd, va_list ap)
         }
 
         case VOUT_WINDOW_SET_FULLSCREEN:
-            set_wm_state (wnd, va_arg (ap, int), p_sys->wm_state_fullscreen);
+        {
+            bool fs = va_arg (ap, int);
+            if (!fs && var_GetBool (wnd, "video-wallpaper"))
+                return VLC_EGENERIC;
+            set_wm_state (wnd, fs, p_sys->wm_state_fullscreen);
             break;
+        }
 
         default:
             msg_Err (wnd, "request %d not implemented", cmd);
@@ -598,7 +617,7 @@ static int EmOpen (vlc_object_t *obj)
     if (p_sys == NULL || xcb_connection_has_error (conn))
         goto error;
 
-    wnd->xid = window;
+    wnd->handle.xid = window;
     wnd->control = Control;
     wnd->sys = p_sys;
 
@@ -646,7 +665,7 @@ error:
 static void EmClose (vlc_object_t *obj)
 {
     vout_window_t *wnd = (vout_window_t *)obj;
-    xcb_window_t window = wnd->xid;
+    xcb_window_t window = wnd->handle.xid;
 
     Close (obj);
     ReleaseDrawable (obj, window);