From d08f994e191ce21e1e3497f038b23c281540768d Mon Sep 17 00:00:00 2001 From: Larpon Date: Thu, 4 Mar 2021 09:49:40 +0100 Subject: [PATCH] clipboard: ensure public method access after #9062. Fixes #9089 (#9107) --- vlib/clipboard/clipboard_darwin.c.v | 13 +++++++------ vlib/clipboard/clipboard_windows.c.v | 12 ++++++------ vlib/clipboard/dummy/dummy_clipboard.v | 12 ++++++------ vlib/clipboard/x11/clipboard.c.v | 10 +++++----- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/vlib/clipboard/clipboard_darwin.c.v b/vlib/clipboard/clipboard_darwin.c.v index 168c2378ae..b2ac704533 100644 --- a/vlib/clipboard/clipboard_darwin.c.v +++ b/vlib/clipboard/clipboard_darwin.c.v @@ -4,6 +4,7 @@ module clipboard #include #flag -framework Cocoa #include "@VROOT/vlib/clipboard/clipboard_darwin.m" + pub struct Clipboard { pb voidptr last_cb_serial i64 @@ -24,22 +25,22 @@ fn new_clipboard() &Clipboard { return cb } -fn (cb &Clipboard) check_availability() bool { +pub fn (cb &Clipboard) check_availability() bool { return cb.pb != C.NULL } -fn (mut cb Clipboard) clear() { +pub fn (mut cb Clipboard) clear() { cb.foo = 0 cb.set_text('') //#[cb->pb clearContents]; } -fn (mut cb Clipboard) free() { +pub fn (mut cb Clipboard) free() { cb.foo = 0 // nothing to free } -fn (cb &Clipboard) has_ownership() bool { +pub fn (cb &Clipboard) has_ownership() bool { if cb.last_cb_serial == 0 { return false } @@ -49,11 +50,11 @@ fn (cb &Clipboard) has_ownership() bool { fn C.OSAtomicCompareAndSwapLong() -fn (mut cb Clipboard) set_text(text string) bool { +pub fn (mut cb Clipboard) set_text(text string) bool { return C.darwin_set_pasteboard_text(cb.pb, text) } -fn (mut cb Clipboard) get_text() string { +pub fn (mut cb Clipboard) get_text() string { cb.foo = 0 if isnil(cb.pb) { return '' diff --git a/vlib/clipboard/clipboard_windows.c.v b/vlib/clipboard/clipboard_windows.c.v index 35a17423c1..b1f696d7bd 100644 --- a/vlib/clipboard/clipboard_windows.c.v +++ b/vlib/clipboard/clipboard_windows.c.v @@ -104,15 +104,15 @@ fn new_clipboard() &Clipboard { return cb } -fn (cb &Clipboard) check_availability() bool { +pub fn (cb &Clipboard) check_availability() bool { return cb.hwnd != C.HWND(C.NULL) } -fn (cb &Clipboard) has_ownership() bool { +pub fn (cb &Clipboard) has_ownership() bool { return C.GetClipboardOwner() == cb.hwnd } -fn (mut cb Clipboard) clear() { +pub fn (mut cb Clipboard) clear() { if !cb.get_clipboard_lock() { return } @@ -121,7 +121,7 @@ fn (mut cb Clipboard) clear() { cb.foo = 0 } -fn (mut cb Clipboard) free() { +pub fn (mut cb Clipboard) free() { C.DestroyWindow(cb.hwnd) cb.foo = 0 } @@ -143,7 +143,7 @@ fn to_wide(text string) C.HGLOBAL { return buf } -fn (mut cb Clipboard) set_text(text string) bool { +pub fn (mut cb Clipboard) set_text(text string) bool { cb.foo = 0 buf := to_wide(text) if !cb.get_clipboard_lock() { @@ -164,7 +164,7 @@ fn (mut cb Clipboard) set_text(text string) bool { return true } -fn (mut cb Clipboard) get_text() string { +pub fn (mut cb Clipboard) get_text() string { cb.foo = 0 if !cb.get_clipboard_lock() { return '' diff --git a/vlib/clipboard/dummy/dummy_clipboard.v b/vlib/clipboard/dummy/dummy_clipboard.v index cd3314396e..a3f4f35362 100644 --- a/vlib/clipboard/dummy/dummy_clipboard.v +++ b/vlib/clipboard/dummy/dummy_clipboard.v @@ -19,30 +19,30 @@ pub fn new_primary() &Clipboard { return &Clipboard{} } -fn (mut cb Clipboard) set_text(text string) bool { +pub fn (mut cb Clipboard) set_text(text string) bool { cb.text = text cb.is_owner = true cb.got_text = true return true } -fn (mut cb Clipboard) get_text() string { +pub fn (mut cb Clipboard) get_text() string { return cb.text } -fn (mut cb Clipboard) clear() { +pub fn (mut cb Clipboard) clear() { cb.text = '' cb.is_owner = false } -fn (mut cb Clipboard) free() { +pub fn (mut cb Clipboard) free() { } -fn (cb &Clipboard) has_ownership() bool { +pub fn (cb &Clipboard) has_ownership() bool { return cb.is_owner } -fn (cb &Clipboard) check_availability() bool { +pub fn (cb &Clipboard) check_availability() bool { // This is a dummy clipboard implementation, // which can be always used, although it does not do much... return true diff --git a/vlib/clipboard/x11/clipboard.c.v b/vlib/clipboard/x11/clipboard.c.v index c8a439d0af..bd00fbef26 100644 --- a/vlib/clipboard/x11/clipboard.c.v +++ b/vlib/clipboard/x11/clipboard.c.v @@ -198,18 +198,18 @@ fn new_x11_clipboard(selection AtomType) &Clipboard { return cb } -fn (cb &Clipboard) check_availability() bool { +pub fn (cb &Clipboard) check_availability() bool { return cb.display != C.NULL } -fn (mut cb Clipboard) free() { +pub fn (mut cb Clipboard) free() { C.XDestroyWindow(cb.display, cb.window) cb.window = C.Window(C.None) // FIX ME: program hangs when closing display // XCloseDisplay(cb.display) } -fn (mut cb Clipboard) clear() { +pub fn (mut cb Clipboard) clear() { cb.mutex.@lock() C.XSetSelectionOwner(cb.display, cb.selection, C.Window(C.None), C.CurrentTime) C.XFlush(cb.display) @@ -218,7 +218,7 @@ fn (mut cb Clipboard) clear() { cb.mutex.unlock() } -fn (cb &Clipboard) has_ownership() bool { +pub fn (cb &Clipboard) has_ownership() bool { return cb.is_owner } @@ -243,7 +243,7 @@ pub fn (mut cb Clipboard) set_text(text string) bool { return cb.is_owner } -fn (mut cb Clipboard) get_text() string { +pub fn (mut cb Clipboard) get_text() string { if cb.window == C.Window(C.None) { return '' }