diff options
author | Po Lu <luangruo@yahoo.com> | 2022-05-23 01:57:19 +0000 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-05-23 01:57:19 +0000 |
commit | 7a709b36ef1a2b184fd1b3e2f1ddf2b98b6f3bcc (patch) | |
tree | 8b4d2bb1626a26985c40a7e6c6fbf76d7e0c4b2c /src/haiku_select.cc | |
parent | 42e48f788ac6c7934466fe75b19644045594e5dd (diff) | |
download | emacs-7a709b36ef1a2b184fd1b3e2f1ddf2b98b6f3bcc.tar.gz emacs-7a709b36ef1a2b184fd1b3e2f1ddf2b98b6f3bcc.tar.bz2 emacs-7a709b36ef1a2b184fd1b3e2f1ddf2b98b6f3bcc.zip |
Fix `gui-backend-selection-owner-p' on Haiku
* src/haiku_select.cc (be_update_clipboard_count): New function.
(be_set_clipboard_data): Update clipboard counts.
(BClipboard_owns_clipboard, clipboard_owner_p)
(BClipboard_owns_primary, primary_owner_p)
(BClipboard_owns_secondary, secondary_owner_p): Rename functions
somewhat.
(be_clipboard_owner_p): New function.
* src/haikuselect.c (Fhaiku_selection_put)
(Fhaiku_selection_owner_p): Update selection counts as well.
* src/haikuselect.h: Update prototypes.
Diffstat (limited to 'src/haiku_select.cc')
-rw-r--r-- | src/haiku_select.cc | 63 |
1 files changed, 57 insertions, 6 deletions
diff --git a/src/haiku_select.cc b/src/haiku_select.cc index 43b71138b33..764001f62b0 100644 --- a/src/haiku_select.cc +++ b/src/haiku_select.cc @@ -28,11 +28,23 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #include "haikuselect.h" +/* The clipboard object representing the primary selection. */ static BClipboard *primary = NULL; + +/* The clipboard object representing the secondary selection. */ static BClipboard *secondary = NULL; + +/* The clipboard object used by other programs, representing the + clipboard. */ static BClipboard *system_clipboard = NULL; + +/* The number of times the system clipboard has changed. */ static int64 count_clipboard = -1; + +/* The number of times the primary selection has changed. */ static int64 count_primary = -1; + +/* The number of times the secondary selection has changed. */ static int64 count_secondary = -1; static BClipboard * @@ -178,6 +190,25 @@ be_set_clipboard_data_1 (BClipboard *cb, const char *type, const char *data, cb->Unlock (); } +void +be_update_clipboard_count (enum haiku_clipboard id) +{ + switch (id) + { + case CLIPBOARD_CLIPBOARD: + count_clipboard = system_clipboard->SystemCount (); + break; + + case CLIPBOARD_PRIMARY: + count_primary = primary->SystemCount (); + break; + + case CLIPBOARD_SECONDARY: + count_secondary = secondary->SystemCount (); + break; + } +} + char * be_find_clipboard_data (enum haiku_clipboard id, const char *type, ssize_t *len) @@ -190,6 +221,8 @@ void be_set_clipboard_data (enum haiku_clipboard id, const char *type, const char *data, ssize_t len, bool clear) { + be_update_clipboard_count (id); + be_set_clipboard_data_1 (get_clipboard_object (id), type, data, len, clear); } @@ -202,30 +235,48 @@ be_get_clipboard_targets (enum haiku_clipboard id, char **targets, len); } -bool -BClipboard_owns_clipboard (void) +static bool +clipboard_owner_p (void) { return (count_clipboard >= 0 && (count_clipboard + 1 == system_clipboard->SystemCount ())); } -bool -BClipboard_owns_primary (void) +static bool +primary_owner_p (void) { return (count_primary >= 0 && (count_primary + 1 == primary->SystemCount ())); } -bool -BClipboard_owns_secondary (void) +static bool +secondary_owner_p (void) { return (count_secondary >= 0 && (count_secondary + 1 == secondary->SystemCount ())); } +bool +be_clipboard_owner_p (enum haiku_clipboard clipboard) +{ + switch (clipboard) + { + case CLIPBOARD_PRIMARY: + return primary_owner_p (); + + case CLIPBOARD_SECONDARY: + return secondary_owner_p (); + + case CLIPBOARD_CLIPBOARD: + return clipboard_owner_p (); + } + + abort (); +} + void init_haiku_select (void) { |