]> git.sesse.net Git - ffmpeg/blobdiff - libavdevice/xcbgrab.c
Merge commit '64f7575fbd64e5b65d5c644347408588c776f1fe'
[ffmpeg] / libavdevice / xcbgrab.c
index f2b913508a24d30b11d4a976b27396496709d690..e26448ccfb8735d75697a5704758190dbe8fc158 100644 (file)
@@ -106,12 +106,16 @@ static int xcbgrab_reposition(AVFormatContext *s,
                               xcb_get_geometry_reply_t *geo)
 {
     XCBGrabContext *c = s->priv_data;
-    int x = c->x, y = c->y, p_x = p->win_x, p_y = p->win_y;
+    int x = c->x, y = c->y;
     int w = c->width, h = c->height, f = c->follow_mouse;
+    int p_x, p_y;
 
     if (!p || !geo)
         return AVERROR(EIO);
 
+    p_x = p->win_x;
+    p_y = p->win_y;
+
     if (f == FOLLOW_CENTER) {
         x = p_x - w / 2;
         y = p_y - h / 2;
@@ -608,11 +612,11 @@ static av_cold int xcbgrab_read_header(AVFormatContext *s)
         sscanf(s->filename, "+%d,%d", &c->x, &c->y);
     }
 
-    c->conn = xcb_connect(display_name, &screen_num);
+    c->conn = xcb_connect(display_name[0] ? display_name : NULL, &screen_num);
     av_freep(&display_name);
     if ((ret = xcb_connection_has_error(c->conn))) {
         av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d.\n",
-               (*s->filename) ? s->filename : "default", ret);
+               s->filename[0] ? s->filename : "default", ret);
         return AVERROR(EIO);
     }
     setup = xcb_get_setup(c->conn);