diff options
| author | Po Lu | 2022-02-11 02:37:38 +0000 |
|---|---|---|
| committer | Po Lu | 2022-02-11 02:37:38 +0000 |
| commit | c7bde988068786a5e6e00d91cf3165b8a3ce0fde (patch) | |
| tree | d0be165be18ff6fc625ffce98e69fa1a8c475d5f /src | |
| parent | 2469e036035f8f5baa78e1557c61df019d8fd572 (diff) | |
| download | emacs-c7bde988068786a5e6e00d91cf3165b8a3ce0fde.tar.gz emacs-c7bde988068786a5e6e00d91cf3165b8a3ce0fde.zip | |
Improve reliability of selection ownership on Haiku
* src/haiku_select.cc (count_clipboard, count_primary)
(count_secondary): Initialize to -1
(BClipboard_set_system_data)
(BClipboard_set_primary_selection_data)
(BClipboard_set_secondary_selection_data): Store count before
saving to the the clipboard.
(BClipboard_owns_clipboard, BClipboard_owns_primary)
(BClipboard_owns_secondary): Adjust tests accordingly.
Diffstat (limited to 'src')
| -rw-r--r-- | src/haiku_select.cc | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/haiku_select.cc b/src/haiku_select.cc index d39000d8bbe..011ad58036f 100644 --- a/src/haiku_select.cc +++ b/src/haiku_select.cc | |||
| @@ -29,9 +29,9 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 29 | static BClipboard *primary = NULL; | 29 | static BClipboard *primary = NULL; |
| 30 | static BClipboard *secondary = NULL; | 30 | static BClipboard *secondary = NULL; |
| 31 | static BClipboard *system_clipboard = NULL; | 31 | static BClipboard *system_clipboard = NULL; |
| 32 | static unsigned long count_clipboard = 0; | 32 | static int64 count_clipboard = -1; |
| 33 | static unsigned long count_primary = 0; | 33 | static int64 count_primary = -1; |
| 34 | static unsigned long count_secondary = 0; | 34 | static int64 count_secondary = -1; |
| 35 | 35 | ||
| 36 | int selection_state_flag; | 36 | int selection_state_flag; |
| 37 | 37 | ||
| @@ -176,8 +176,8 @@ BClipboard_set_system_data (const char *type, const char *data, | |||
| 176 | if (!system_clipboard) | 176 | if (!system_clipboard) |
| 177 | return; | 177 | return; |
| 178 | 178 | ||
| 179 | BClipboard_set_data (system_clipboard, type, data, len, clear); | ||
| 180 | count_clipboard = system_clipboard->SystemCount (); | 179 | count_clipboard = system_clipboard->SystemCount (); |
| 180 | BClipboard_set_data (system_clipboard, type, data, len, clear); | ||
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | void | 183 | void |
| @@ -187,8 +187,8 @@ BClipboard_set_primary_selection_data (const char *type, const char *data, | |||
| 187 | if (!primary) | 187 | if (!primary) |
| 188 | return; | 188 | return; |
| 189 | 189 | ||
| 190 | BClipboard_set_data (primary, type, data, len, clear); | ||
| 191 | count_primary = primary->SystemCount (); | 190 | count_primary = primary->SystemCount (); |
| 191 | BClipboard_set_data (primary, type, data, len, clear); | ||
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | void | 194 | void |
| @@ -198,8 +198,8 @@ BClipboard_set_secondary_selection_data (const char *type, const char *data, | |||
| 198 | if (!secondary) | 198 | if (!secondary) |
| 199 | return; | 199 | return; |
| 200 | 200 | ||
| 201 | BClipboard_set_data (secondary, type, data, len, clear); | ||
| 202 | count_secondary = secondary->SystemCount (); | 201 | count_secondary = secondary->SystemCount (); |
| 202 | BClipboard_set_data (secondary, type, data, len, clear); | ||
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | void | 205 | void |
| @@ -229,22 +229,25 @@ BClipboard_secondary_targets (char **buf, int len) | |||
| 229 | bool | 229 | bool |
| 230 | BClipboard_owns_clipboard (void) | 230 | BClipboard_owns_clipboard (void) |
| 231 | { | 231 | { |
| 232 | return (count_clipboard | 232 | return (count_clipboard >= 0 |
| 233 | == system_clipboard->SystemCount ()); | 233 | && (count_clipboard + 1 |
| 234 | == system_clipboard->SystemCount ())); | ||
| 234 | } | 235 | } |
| 235 | 236 | ||
| 236 | bool | 237 | bool |
| 237 | BClipboard_owns_primary (void) | 238 | BClipboard_owns_primary (void) |
| 238 | { | 239 | { |
| 239 | return (count_primary | 240 | return (count_primary >= 0 |
| 240 | == primary->SystemCount ()); | 241 | && (count_primary + 1 |
| 242 | == primary->SystemCount ())); | ||
| 241 | } | 243 | } |
| 242 | 244 | ||
| 243 | bool | 245 | bool |
| 244 | BClipboard_owns_secondary (void) | 246 | BClipboard_owns_secondary (void) |
| 245 | { | 247 | { |
| 246 | return (count_secondary | 248 | return (count_secondary >= 0 |
| 247 | == secondary->SystemCount ()); | 249 | && (count_secondary + 1 |
| 250 | == secondary->SystemCount ())); | ||
| 248 | } | 251 | } |
| 249 | 252 | ||
| 250 | void | 253 | void |