@@ -100,10 +100,6 @@ typedef struct {
100100
101101 clip_wl_selection_T regular ;
102102 clip_wl_selection_T primary ;
103-
104- // Array of file descriptors of clients we are sending data to. These should
105- // be polled for POLLOUT and have the respective callback called for each.
106- garray_T write_fds ;
107103} clip_wl_T ;
108104
109105// Mime types we support sending and receiving
@@ -172,22 +168,6 @@ clip_init(int can_use)
172168 }
173169}
174170
175- static void
176- clip_init_single (Clipboard_T * cb , int can_use )
177- {
178- // No need to init again if cbd is already available
179- if (can_use && cb -> available )
180- return ;
181-
182- cb -> available = can_use ;
183- cb -> owned = FALSE;
184- cb -> start .lnum = 0 ;
185- cb -> start .col = 0 ;
186- cb -> end .lnum = 0 ;
187- cb -> end .col = 0 ;
188- cb -> state = SELECT_CLEARED ;
189- }
190-
191171/*
192172 * Check whether the VIsual area has changed, and if so try to become the owner
193173 * of the selection, and free any old converted selection we may still have
@@ -2428,7 +2408,7 @@ adjust_clip_reg(int *rp)
24282408 if ((!clip_star .available && * rp == '*' ) ||
24292409 (!clip_plus .available && * rp == '+' ))
24302410 {
2431- msg_warn_missing_clipboard (! clip_plus . available , ! clip_star . available );
2411+ msg_warn_missing_clipboard ();
24322412 * rp = 0 ;
24332413 }
24342414}
@@ -2874,6 +2854,8 @@ clip_init_wayland(void)
28742854 if (wayland_ct == NULL )
28752855 return FAIL ;
28762856
2857+ memset (& clip_wl , 0 , sizeof (clip_wl ));
2858+
28772859 clip_wl .seat = vwl_connection_get_seat (wayland_ct , (char * )p_wse );
28782860
28792861 if (clip_wl .seat == NULL )
@@ -2891,12 +2873,14 @@ clip_init_wayland(void)
28912873 clip_wl .regular .available = true;
28922874 else
28932875 {
2876+ // Shouldn't happen
28942877 vwl_data_device_manager_discard (clip_wl .regular .manager );
28952878 clip_wl .regular .manager = NULL ;
2879+ return FAIL ;
28962880 }
28972881 }
28982882
2899- // If we still don't support the primary selection, find one for it
2883+ // If we still don't support the primary selection, try finding one for it
29002884 // specifically.
29012885 if (!(supported & WAYLAND_SELECTION_PRIMARY ))
29022886 {
@@ -2917,10 +2901,12 @@ clip_init_wayland(void)
29172901 }
29182902 }
29192903 }
2920- else if (clip_wl .regular .available )
2904+
2905+ if (clip_wl .regular .available && !clip_wl .primary .available )
29212906 {
29222907 // The protocol supports both regular and primary selections, just use
2923- // one data device manager and one data device.
2908+ // one data device manager and one data device. Or the primary selection
2909+ // is not supported, make it point to the regular selection instead.
29242910 clip_wl .primary .available = true;
29252911 clip_wl .primary .manager = clip_wl .regular .manager ;
29262912 clip_wl .primary .device = clip_wl .regular .device ;
@@ -3435,7 +3421,7 @@ clip_wl_owner_exists(Clipboard_T *cbd)
34353421 * depending on the order of values in str.
34363422 */
34373423 static clipmethod_T
3438- get_clipmethod (char_u * str , bool * plus UNUSED , bool * star UNUSED )
3424+ get_clipmethod (char_u * str )
34393425{
34403426 int len = (int )STRLEN (str ) + 1 ;
34413427 char_u * buf = alloc (len );
@@ -3460,11 +3446,7 @@ get_clipmethod(char_u *str, bool *plus UNUSED, bool *star UNUSED)
34603446 {
34613447#ifdef FEAT_WAYLAND_CLIPBOARD
34623448 if (clip_wl .regular .available || clip_wl .primary .available )
3463- {
34643449 method = CLIPMETHOD_WAYLAND ;
3465- * plus = clip_wl .regular .available ;
3466- * star = clip_wl .primary .available ;
3467- }
34683450#endif
34693451 }
34703452 }
@@ -3485,7 +3467,6 @@ get_clipmethod(char_u *str, bool *plus UNUSED, bool *star UNUSED)
34853467 // xterm_dpy will be set to NULL.
34863468 xterm_update ();
34873469 method = CLIPMETHOD_X11 ;
3488- * plus = * star = TRUE;
34893470 }
34903471#endif
34913472 }
@@ -3534,8 +3515,7 @@ clipmethod_to_str(clipmethod_T method)
35343515 char *
35353516choose_clipmethod (void )
35363517{
3537- bool regular = false, primary = false;
3538- clipmethod_T method = get_clipmethod (p_cpm , & regular , & primary );
3518+ clipmethod_T method = get_clipmethod (p_cpm );
35393519
35403520 if (method == CLIPMETHOD_FAIL )
35413521 return e_invalid_argument ;
@@ -3569,10 +3549,8 @@ choose_clipmethod(void)
35693549 // If we have a clipmethod that works now, then initialize clipboard
35703550 else if (clipmethod == CLIPMETHOD_NONE && method != CLIPMETHOD_NONE )
35713551 {
3572- clip_init_single (& clip_plus , regular );
3573- clip_init_single (& clip_star , primary );
3574- clip_plus .did_warn = false;
3575- clip_star .did_warn = false;
3552+ clip_init (TRUE);
3553+ did_warn_clipboard = false;
35763554 }
35773555 // Disown clipboard if we are switching to a new method
35783556 else if (clipmethod != CLIPMETHOD_NONE && method != clipmethod )
@@ -3590,8 +3568,8 @@ choose_clipmethod(void)
35903568 if (!gui .in_use )
35913569#endif
35923570 {
3593- clip_init_single ( & clip_plus , regular );
3594- clip_init_single ( & clip_star , primary ) ;
3571+ clip_init (TRUE );
3572+ did_warn_clipboard = false ;
35953573 }
35963574 }
35973575
0 commit comments