Add ctypes call for window tracking
This commit is contained in:
parent
1b1781d78f
commit
0583021023
36
usr/lib/linuxmint/mintMenu/capi.py
Normal file
36
usr/lib/linuxmint/mintMenu/capi.py
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import gi
|
||||
import ctypes
|
||||
from ctypes import *
|
||||
|
||||
libgobject = CDLL('libgobject-2.0.so.0')
|
||||
|
||||
class _PyGObject_Functions(ctypes.Structure):
|
||||
_fields_ = [
|
||||
('register_class',
|
||||
ctypes.PYFUNCTYPE(ctypes.c_void_p, ctypes.c_char_p,
|
||||
ctypes.c_int, ctypes.py_object,
|
||||
ctypes.py_object)),
|
||||
('register_wrapper',
|
||||
ctypes.PYFUNCTYPE(ctypes.c_void_p, ctypes.py_object)),
|
||||
('lookup_class',
|
||||
ctypes.PYFUNCTYPE(ctypes.py_object, ctypes.c_int)),
|
||||
('newgobj',
|
||||
ctypes.PYFUNCTYPE(ctypes.py_object, ctypes.c_void_p)),
|
||||
]
|
||||
|
||||
class PyGObjectCPAI(object):
|
||||
def __init__(self):
|
||||
PyCObject_AsVoidPtr = ctypes.pythonapi.PyCObject_AsVoidPtr
|
||||
PyCObject_AsVoidPtr.restype = ctypes.c_void_p
|
||||
PyCObject_AsVoidPtr.argtypes = [ctypes.py_object]
|
||||
addr = PyCObject_AsVoidPtr(ctypes.py_object(
|
||||
gi._gobject._PyGObject_API))
|
||||
self._api = _PyGObject_Functions.from_address(addr)
|
||||
|
||||
def pygobject_new(self, addr):
|
||||
return self._api.newgobj(addr)
|
||||
|
||||
def get_widget(ptr):
|
||||
return PyGObjectCPAI().pygobject_new(ptr)
|
@ -16,11 +16,17 @@ try:
|
||||
import traceback
|
||||
import time
|
||||
import gc
|
||||
import ctypes
|
||||
from ctypes import *
|
||||
import capi
|
||||
import xdg.Config
|
||||
except Exception, e:
|
||||
print e
|
||||
sys.exit( 1 )
|
||||
|
||||
gtk = CDLL("libgtk-x11-2.0.so.0")
|
||||
gdk = CDLL("libgdk-x11-2.0.so.0")
|
||||
|
||||
global mbindkey
|
||||
# Load the key binding lib (developped by deskbar-applet, copied into mintMenu so we don't end up with an unnecessary dependency)
|
||||
try:
|
||||
@ -489,26 +495,12 @@ class MainWindow( object ):
|
||||
# Check if the pointer is within the menu, else hide the menu
|
||||
|
||||
winatptr = Gdk.window_at_pointer()
|
||||
widget_win = widget.get_window()
|
||||
|
||||
print winatptr
|
||||
print widget_win
|
||||
|
||||
if winatptr[0] != widget_win:
|
||||
self.hide(True)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
if winatptr:
|
||||
win = winatptr[0]
|
||||
while win:
|
||||
print "xx"
|
||||
print self.window.window
|
||||
if win == self.window.window:
|
||||
break
|
||||
win = win.get_toplevels()
|
||||
win = capi.get_widget(gdk.gdk_window_get_parent (hash(win)))
|
||||
if not win:
|
||||
self.hide( True )
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user