-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: do not use clipboard on X11 #42
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ def grouper(iterable, n, fillvalue=None): | |
|
||
|
||
class EmojiPicker(Gtk.Window): | ||
def __init__(self, open_time, update_accelerator, update_theme, show_welcome): | ||
def __init__(self, open_time, current_window, update_accelerator, update_theme, show_welcome): | ||
Gtk.Window.__init__( | ||
self, | ||
title="Emote", | ||
|
@@ -29,6 +29,7 @@ def __init__(self, open_time, update_accelerator, update_theme, show_welcome): | |
deletable=False, | ||
name="emote_window", | ||
) | ||
self.current_window = current_window | ||
self.set_default_size(500, 450) | ||
self.set_keep_above(True) | ||
self.dialog_open = False | ||
|
@@ -541,7 +542,7 @@ def on_emoji_btn_event(self, btn, event): | |
self.show_emoji_preview(emoji) | ||
|
||
def on_emoji_append(self, emoji): | ||
"""Append the selected emoji to the clipboard""" | ||
"""Append the selected emoji to the current selection""" | ||
print(f"Appending {emoji} to selection") | ||
self.emoji_append_list.append(emoji) | ||
|
||
|
@@ -551,38 +552,30 @@ def on_emoji_append(self, emoji): | |
self.previewed_emoji_shortcode_label.set_max_width_chars(20) | ||
|
||
self.update_emoji_append_list_preview() | ||
|
||
self.copy_to_clipboard("".join(self.emoji_append_list)) | ||
self.add_emoji_to_recent(emoji) | ||
|
||
def on_emoji_select(self, emoji): | ||
""" | ||
Copy the selected emoji to the clipboard, close the picker window and | ||
make the user's system perform a paste after 150ms, pasting the emoji | ||
to the currently focussed application window. | ||
|
||
If we have been appending other emojis first, add this final one first. | ||
Append the given emoji to the current selection. | ||
Then, close the picker window and: | ||
- for X11, make the user's system "type" the selected characters | ||
into the currently focussed application window; | ||
- for Wayland, copy the selected characters to the clipboard. | ||
""" | ||
self.hide() | ||
|
||
if len(self.emoji_append_list) > 0: | ||
self.on_emoji_append(emoji) | ||
else: | ||
print(f"Selecting {emoji}") | ||
self.add_emoji_to_recent(emoji) | ||
self.copy_to_clipboard(emoji) | ||
|
||
self.on_emoji_append(emoji) | ||
self.destroy() | ||
|
||
time.sleep(0.15) | ||
|
||
if not config.is_wayland: | ||
os.system("xdotool key ctrl+v") | ||
emojis = "".join(self.emoji_append_list) | ||
if not config.is_wayland and self.current_window: | ||
os.system(f"xdotool windowfocus --sync '{self.current_window}' type --args 1 '{emojis}'") | ||
else: | ||
self.copy_to_clipboard(emojis) | ||
|
||
def add_emoji_to_recent(self, emoji): | ||
user_data.update_recent_emojis(emoji) | ||
emojis.update_recent_category() | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change should probably be reverted. |
||
def copy_to_clipboard(self, content): | ||
cb = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) | ||
cb.set_text(content, -1) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on what versions of python are supported, it might be easier to use
subprocess.check_output()
withtext=True
.