diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-04-12 18:44:55 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-04-12 18:44:55 +0200 |
commit | 6636cbff81061bc270e4d21659fa3fba8eb3c87b (patch) | |
tree | 394c6de2cc718d320f92c2d3cd863f88c40bcfd7 /Selection.py | |
parent | 4659883ba00bd499f41f4cc1a5f96e4bdd5ac9de (diff) | |
download | pylock-6636cbff81061bc270e4d21659fa3fba8eb3c87b.tar pylock-6636cbff81061bc270e4d21659fa3fba8eb3c87b.zip |
Create installation script using distutils
Diffstat (limited to 'Selection.py')
-rw-r--r-- | Selection.py | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/Selection.py b/Selection.py deleted file mode 100644 index 11a7285..0000000 --- a/Selection.py +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright (c) 2012-2013, Matthias Schiffer <mschiffer@universe-factory.net> -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -import ctypes -import ctypes.util - -from gi.repository import Gdk, GdkX11 - - -XEvent_p = ctypes.c_void_p -display_p = ctypes.c_void_p -xid = ctypes.c_ulong -x11_bool = ctypes.c_int -x11_time = ctypes.c_ulong -status = ctypes.c_int - - -libX11 = ctypes.util.find_library('X11') -if libX11 == None: - raise OSError('libX11 could not be found.') -libX11 = ctypes.cdll.LoadLibrary(libX11) - -libX11.XSetSelectionOwner.argtypes = display_p, xid, xid, x11_time -libX11.XSetSelectionOwner.restype = ctypes.c_int -libX11.XGetSelectionOwner.argtypes = display_p, xid -libX11.XGetSelectionOwner.restype = xid - - -display = Gdk.Display.get_default() -dpy_p = display_p(hash(GdkX11.X11Display.get_xdisplay(display))) -atomPylockWindow = GdkX11.x11_get_xatom_by_name("PYLOCK_WINDOW") - - -def get(): - return libX11.XGetSelectionOwner(dpy_p, atomPylockWindow) - -def acquire(window): - if get() != 0: - return False - - window.realize() - xid = GdkX11.X11Window.get_xid(window.get_window()) - libX11.XSetSelectionOwner(dpy_p, atomPylockWindow, xid, 0) - - return (get() == xid) |