1111import os
1212import platform
1313import signal
14+ from functools import partial
1415from types import SimpleNamespace
1516
1617
@@ -344,16 +345,7 @@ def consume_events_and_render_buffer():
344345 p .gl_display ()
345346
346347 gl_utils .glViewport (0 , 0 , * window_size )
347- try :
348- clipboard = glfw .get_clipboard_string (main_window ).decode ()
349- except (AttributeError , glfw .GLFWError ):
350- # clipboard is None, might happen on startup
351- clipboard = ""
352- g_pool .gui .update_clipboard (clipboard )
353348 user_input = g_pool .gui .update ()
354- if user_input .clipboard != clipboard :
355- # only write to clipboard if content changed
356- glfw .set_clipboard_string (main_window , user_input .clipboard )
357349
358350 for button , action , mods in user_input .buttons :
359351 x , y = glfw .get_cursor_pos (main_window )
@@ -674,6 +666,8 @@ def set_window_size():
674666 g_pool .plugin_by_name [default_capture_name ], default_capture_settings
675667 )
676668
669+ on_focus = partial (gl_utils .window_focus_clipboard_callback , g_pool )
670+
677671 # Register callbacks main_window
678672 glfw .set_framebuffer_size_callback (main_window , on_resize )
679673 glfw .set_key_callback (main_window , on_window_key )
@@ -682,6 +676,7 @@ def set_window_size():
682676 glfw .set_cursor_pos_callback (main_window , on_pos )
683677 glfw .set_scroll_callback (main_window , on_scroll )
684678 glfw .set_drop_callback (main_window , on_drop )
679+ glfw .set_window_focus_callback (main_window , on_focus )
685680
686681 # gl_state settings
687682 gl_utils .basic_gl_setup ()
@@ -781,16 +776,8 @@ def window_should_update():
781776 p .gl_display ()
782777
783778 gl_utils .glViewport (0 , 0 , * window_size )
784- try :
785- clipboard = glfw .get_clipboard_string (main_window ).decode ()
786- except (AttributeError , glfw .GLFWError ):
787- # clipboard is None, might happen on startup
788- clipboard = ""
789- g_pool .gui .update_clipboard (clipboard )
779+
790780 user_input = g_pool .gui .update ()
791- if user_input .clipboard != clipboard :
792- # only write to clipboard if content changed
793- glfw .set_clipboard_string (main_window , user_input .clipboard )
794781
795782 for button , action , mods in user_input .buttons :
796783 x , y = glfw .get_cursor_pos (main_window )
0 commit comments