scottkirkwood / key-mon

Automatically exported from code.google.com/p/key-mon
Apache License 2.0
141 stars 38 forks source link

key-mon freezes on 1st mouse click. #96

Closed eGax closed 2 years ago

eGax commented 2 years ago

I've installed with: $ pip install git+https://github.com/scottkirkwood/key-mon

When I run key-mon all is well until the 1st mouse click I make and it freeze key-mon. It no longer registers anything I do:

image

I can right click and get the menu still and quit it, but the sub-menu names are prefixed with a _:

image Right after it freezes, these line appear if I run it in a terminal window:

   ~  key-mon                                                                                                                                                                                                                                                             
Traceback (most recent call last):
  File "/home/retro/.local/lib/python3.10/site-packages/keymon/key_mon.py", line 478, in on_idle
    self.handle_event(event)
  File "/home/retro/.local/lib/python3.10/site-packages/keymon/key_mon.py", line 503, in handle_event
    self.handle_mouse_button(event.code, event.value)
  File "/home/retro/.local/lib/python3.10/site-packages/keymon/key_mon.py", line 664, in handle_mouse_button
    self.mouse_indicator_win.center_on_cursor()
  File "/home/retro/.local/lib/python3.10/site-packages/keymon/shaped_window.py", line 88, in center_on_cursor
    self.show()
  File "/home/retro/.local/lib/python3.10/site-packages/keymon/shaped_window.py", line 101, in show
    pm = gtk.gdk.Pixmap(None, self.get_size()[0], self.get_size()[1], 1)
NameError: name 'gtk' is not defined. Did you mean: 'Gtk'?

I'm running it on Manjaro Linux KDE Plasma.

naclomi commented 2 years ago

Also having this issue, on Linux Mint 20.2 Cinnamon

scottkirkwood commented 2 years ago

Thanks, I missed this bug in the beginning of march. I'm not seeing this issue right now (but another issue). Clearly something has changed with GTK that has affected the old code.

scottkirkwood commented 2 years ago

I installed Linux Mint 20.3 Cinnamon 64 bit on a virtual machine and pip installed key-mon and it worked for me. Unable to reproduce. :-(

naclomi commented 2 years ago

Not sure of all the intricacies involved, but it looks like GDK pixmaps are being/have been phased out, and so maybe depending on various library versions the missing object is just not present? https://docs.gtk.org/gtk3/migrating-2to3.html#replace-gdkpixmap-by-cairo-surfaces For what it's worth, this bug only happens to me when I have the 'Highly visible click' feature enabled.

eGax commented 2 years ago

I installed Linux Mint 20.3 Cinnamon 64 bit on a virtual machine and pip installed key-mon and it worked for me. Unable to reproduce. :-(

I'm not using Linux Mint so I have no input on that.

scottkirkwood commented 2 years ago

So I did reproduce the bug when turning on the "Highly visible click" feature. If you turn it off it doesn't crash (at least on my machine). As naclomi@ mentioned, it's related to pixmap that is being deprecated. I'm going to have to read about that and figure out how to fix it. I also see some other minor bugs like the menus having underscores instead of the character being bolded.

naclomi commented 2 years ago

Had a spare minute and looked into it. Based on this deprecation warning: https://github.com/ruby-gnome/ruby-gnome/blob/master/gtk3/lib/gtk3/deprecated.rb#L1043 It seems that input_shape_combine_mask was replaced with input_shape_combine_region, with the latter now taking a Cairo "Region" rather than a pixmap, which is a purpose-built data structure for interaction masks: https://pycairo.readthedocs.io/en/latest/reference/region.html Submitted pull request #97 to fix this. Since the purpose of the code seems to be to set the clickable region to effectively null, I just send input_shape_combine_region an empty region.

scottkirkwood commented 2 years ago

This is fixed, thanks for all the help.