Unified · Split
| @@ -1866,9 +1866,8 @@ static void destroy_offer(struct vo_wayland_data_offer *o) · 1865 unmodified lines | ||
| 1866 | 1866 | *o = (struct vo_wayland_data_offer){.fd = -1, .action = -1}; |
| 1867 | 1867 | } |
| 1868 | 1868 | |
| 1869 | −static void check_dnd_fd(struct vo_wayland_state *wl) | |
| 1869 | +static void check_fd(struct vo_wayland_state *wl, struct vo_wayland_data_offer *o, bool is_dnd) | |
| 1870 | 1870 | { |
| 1871 | − struct vo_wayland_data_offer *o = wl->dnd_offer; | |
| 1872 | 1871 | if (o->fd == -1) |
| 1873 | 1872 | return; |
| 1874 | 1873 | |
| @@ -1879,41 +1878,43 @@ static void check_dnd_fd(struct vo_wayland_state *wl) · 4 unmodified lines | ||
| 1879 | 1878 | if (fdp.revents & POLLIN) { |
| 1880 | 1879 | ssize_t data_read = 0; |
| 1881 | 1880 | const size_t chunk_size = 256; |
| 1882 | − bstr file_list = { | |
| 1883 | − .start = talloc_zero_size(NULL, chunk_size), | |
| 1881 | + bstr content = { | |
| 1882 | + .start = talloc_zero_size(wl, chunk_size), | |
| 1884 | 1883 | }; |
| 1885 | 1884 | |
| 1886 | 1885 | while (1) { |
| 1887 | − data_read = read(o->fd, file_list.start + file_list.len, chunk_size); | |
| 1886 | + data_read = read(o->fd, content.start + content.len, chunk_size); | |
| 1888 | 1887 | if (data_read == -1 && errno == EINTR) |
| 1889 | 1888 | continue; |
| 1890 | 1889 | else if (data_read <= 0) |
| 1891 | 1890 | break; |
| 1892 | − file_list.len += data_read; | |
| 1893 | − file_list.start = talloc_realloc_size(NULL, file_list.start, file_list.len + chunk_size); | |
| 1894 | − memset(file_list.start + file_list.len, 0, chunk_size); | |
| 1891 | + content.len += data_read; | |
| 1892 | + content.start = talloc_realloc_size(wl, content.start, content.len + chunk_size); | |
| 1893 | + memset(content.start + content.len, 0, chunk_size); | |
| 1895 | 1894 | } |
| 1896 | 1895 | |
| 1897 | 1896 | if (data_read == -1) { |
| 1898 | − MP_VERBOSE(wl, "DND aborted (read error)\n"); | |
| 1897 | + MP_VERBOSE(wl, "data offer aborted (read error)\n"); | |
| 1899 | 1898 | } else { |
| 1900 | − MP_VERBOSE(wl, "Read %zu bytes from the DND fd\n", file_list.len); | |
| 1899 | + MP_VERBOSE(wl, "Read %zu bytes from the data offer fd\n", content.len); | |
| 1901 | 1900 | |
| 1902 | − if (o->offer) | |
| 1903 | − wl_data_offer_finish(o->offer); | |
| 1901 | + if (is_dnd) { | |
| 1902 | + if (o->offer) | |
| 1903 | + wl_data_offer_finish(o->offer); | |
| 1904 | 1904 | |
| 1905 | − assert(o->action >= 0); | |
| 1906 | − mp_event_drop_mime_data(wl->vo->input_ctx, o->mime_type, | |
| 1907 | − file_list, o->action); | |
| 1905 | + assert(o->action >= 0); | |
| 1906 | + mp_event_drop_mime_data(wl->vo->input_ctx, o->mime_type, | |
| 1907 | + content, o->action); | |
| 1908 | + } | |
| 1908 | 1909 | } |
| 1909 | 1910 | |
| 1910 | − talloc_free(file_list.start); | |
| 1911 | + talloc_free(content.start); | |
| 1911 | 1912 | destroy_offer(o); |
| 1912 | 1913 | } |
| 1913 | 1914 | |
| 1914 | 1915 | if (fdp.revents & (POLLIN | POLLERR | POLLHUP)) { |
| 1915 | 1916 | if (o->action >= 0) |
| 1916 | − MP_VERBOSE(wl, "DND aborted (hang up or error)\n"); | |
| 1917 | + MP_VERBOSE(wl, "data offer aborted (hang up or error)\n"); | |
| 1917 | 1918 | destroy_offer(o); |
| 1918 | 1919 | } |
| 1919 | 1920 | } |
| @@ -2858,7 +2859,7 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg) · 938 unmodified lines | ||
| 2858 | 2859 | |
| 2859 | 2860 | switch (request) { |
| 2860 | 2861 | case VOCTRL_CHECK_EVENTS: { |
| 2861 | − check_dnd_fd(wl); | |
| 2862 | + check_fd(wl, wl->dnd_offer, true); | |
| 2862 | 2863 | *events |= wl->pending_vo_events; |
| 2863 | 2864 | if (*events & VO_EVENT_RESIZE) { |
| 2864 | 2865 | *events |= VO_EVENT_EXPOSE; |