From ee8ae40cd02d4989eabb408d65cc2ff0a689051e Mon Sep 17 00:00:00 2001 From: Clement Lefebvre Date: Fri, 28 Apr 2017 12:45:07 +0100 Subject: [PATCH] Remove more ctypes --- usr/lib/linuxmint/mintMenu/keybinding.py | 7 ------- usr/lib/linuxmint/mintMenu/mintMenu.py | 5 +---- .../mintMenu/plugins/applications.py | 7 ------- .../linuxmint/mintMenu/plugins/easybuttons.py | 7 ------- usr/lib/linuxmint/mintMenu/plugins/places.py | 2 -- usr/lib/linuxmint/mintMenu/pointerMonitor.py | 19 +++++++++---------- 6 files changed, 10 insertions(+), 37 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/keybinding.py b/usr/lib/linuxmint/mintMenu/keybinding.py index f7cbd1d..ca50863 100644 --- a/usr/lib/linuxmint/mintMenu/keybinding.py +++ b/usr/lib/linuxmint/mintMenu/keybinding.py @@ -31,8 +31,6 @@ from Xlib.display import Display from Xlib import X, error from gi.repository import Gtk, Gdk, GdkX11, GObject, GLib import threading -import ctypes -from ctypes import * SPECIAL_MODS = (["Super_L", ""], ["Super_R", ""], @@ -169,11 +167,6 @@ class GlobalKeyBinding(GObject.GObject, threading.Thread): self.ungrab() self.display.close() -class KeymapKey(Structure): - _fields_ = [("keycode", c_uint), - ("group", c_int), - ("level", c_int)] - class KeybindingWidget(Gtk.Box): __gsignals__ = { 'accel-edited': (GObject.SignalFlags.RUN_LAST, None, ()), diff --git a/usr/lib/linuxmint/mintMenu/mintMenu.py b/usr/lib/linuxmint/mintMenu/mintMenu.py index f604f40..3092455 100755 --- a/usr/lib/linuxmint/mintMenu/mintMenu.py +++ b/usr/lib/linuxmint/mintMenu/mintMenu.py @@ -14,8 +14,6 @@ import gettext import traceback import time import gc -import ctypes -from ctypes import * import xdg.Config import keybinding import pointerMonitor @@ -753,9 +751,8 @@ class MenuWin( object ): ourWidth = self.mainwin.window.get_size()[0] ourHeight = self.mainwin.window.get_size()[1] + self.mainwin.offset - x = c_int() - y = c_int() # Get the dimensions/position of the widgetToAlignWith + print(self.applet.get_window().get_origin()) entryX = self.applet.get_window().get_origin().x entryY = self.applet.get_window().get_origin().y diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py index 2d6da86..d184132 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.py +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py @@ -13,8 +13,6 @@ import threading import commands import subprocess import filecmp -import ctypes -from ctypes import * from easybuttons import * from execute import Execute from easygsettings import EasyGSettings @@ -149,11 +147,6 @@ class SuggestionButton ( Gtk.Button ): def set_icon_size (self, size): self.image.set_pixel_size( size ) -class TargetEntry(Structure): - _fields_ = [("target", c_char_p), - ("flags", c_int), - ("info", c_int)] - class pluginclass( object ): TARGET_TYPE_TEXT = 80 toButton = ( Gtk.TargetEntry.new( "text/uri-list", 0, TARGET_TYPE_TEXT ), Gtk.TargetEntry.new( "text/uri-list", 0, TARGET_TYPE_TEXT ) ) diff --git a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py index 19941d7..409868e 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py +++ b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py @@ -10,8 +10,6 @@ from execute import * import xdg.DesktopEntry import xdg.Menu from filemonitor import monitor as filemonitor -import ctypes -from ctypes import * class IconManager(GObject.GObject): @@ -232,11 +230,6 @@ class easyButton( Gtk.Button ): #[ iW, iH ] = iconManager.getIconSize( self.iconSize ) self.buttonImage.set_size_request( self.iconSize, self.iconSize ) -class TargetEntry(Structure): - _fields_ = [("target", c_char_p), - ("flags", c_int), - ("info", c_int)] - class ApplicationLauncher( easyButton ): def __init__( self, desktopFile, iconSize): diff --git a/usr/lib/linuxmint/mintMenu/plugins/places.py b/usr/lib/linuxmint/mintMenu/plugins/places.py index d00c9ae..720edb0 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/places.py +++ b/usr/lib/linuxmint/mintMenu/plugins/places.py @@ -6,8 +6,6 @@ import string import gettext import commands import time -import ctypes -from ctypes import * from easybuttons import * from easygsettings import EasyGSettings diff --git a/usr/lib/linuxmint/mintMenu/pointerMonitor.py b/usr/lib/linuxmint/mintMenu/pointerMonitor.py index caaa754..67c2410 100644 --- a/usr/lib/linuxmint/mintMenu/pointerMonitor.py +++ b/usr/lib/linuxmint/mintMenu/pointerMonitor.py @@ -7,10 +7,6 @@ from Xlib.display import Display from Xlib import X, error from gi.repository import Gtk, Gdk, GObject, GLib import threading -import ctypes -from ctypes import * - -gdk = CDLL("libgdk-3.so.0") class PointerMonitor(GObject.GObject, threading.Thread): __gsignals__ = { @@ -27,9 +23,7 @@ class PointerMonitor(GObject.GObject, threading.Thread): # Receives GDK windows def addWindowToMonitor(self, window): - gdk.gdk_x11_drawable_get_xid.argtypes = [c_void_p] - xWindow = self.display.create_resource_object("window", gdk.gdk_x11_drawable_get_xid(hash(window))) - self.windows.append(xWindow) + self.windows.append(window) def grabPointer(self): self.root.grab_button(X.AnyButton, X.AnyModifier, True, X.ButtonPressMask, X.GrabModeSync, X.GrabModeAsync, 0, 0) @@ -54,9 +48,14 @@ class PointerMonitor(GObject.GObject, threading.Thread): if event.type == X.ButtonPress: # Check if pointer is inside monitored windows for w in self.windows: - p = w.query_pointer() - g = w.get_geometry() - if p.win_x >= 0 and p.win_y >= 0 and p.win_x <= g.width and p.win_y <= g.height: + if Gtk.check_version (3, 20, 0) is None: + pdevice = Gdk.Display.get_default().get_default_seat().get_pointer() + else: + pdevice = Gdk.Display.get_default().get_device_manager().get_client_pointer() + p = self.get_window().get_device_position(pdevice) + g = self.get_size() + + if p.x >= 0 and p.y >= 0 and p.x <= g.width and p.y <= g.height: break else: # Is outside, so activate