-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #815 from troycurtisjr/xinitthreads
Call XInitThreads() before any other GUI code initializes.
- Loading branch information
Showing
6 changed files
with
55 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" | ||
Module for detecting different states with respect to Wayland. | ||
These functions are in a standalone module to minimize the dependencies so that | ||
ulauncher.utils.xinit can safely use it. | ||
""" | ||
import os | ||
|
||
|
||
def is_wayland(): | ||
return os.environ.get('XDG_SESSION_TYPE', '').lower() == 'wayland' | ||
|
||
|
||
def is_wayland_compatibility_on(): | ||
""" | ||
In this mode user won't be able to set app hotkey via preferences | ||
Set hotkey in OS Settings > Devices > Keyboard > Add Hotkey > Command: ulauncher-toggle | ||
GDK_BACKEND is typically unset in Wayland sessions to allow GTK apps to self-select | ||
""" | ||
return is_wayland() and (gdk_backend() == '' or gdk_backend().lower().startswith('wayland')) | ||
|
||
|
||
def gdk_backend(): | ||
return os.environ.get('GDK_BACKEND', '') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" | ||
Simple module to call XInitThreads() to properly support multi-threaded X11 applications. | ||
""" | ||
from ulauncher.utils.wayland import is_wayland_compatibility_on | ||
|
||
|
||
if not is_wayland_compatibility_on(): | ||
from ctypes import cdll | ||
|
||
# Using libX11.so.6 may seem a bit hard-coded, but a quick search on the Internet indicates | ||
# discussion of this ABI version back to before 2009, 12 years prior to when this code was added. | ||
# Also, with most of the development focus on Wayland, the chance of a ABI version bump in X11 is | ||
# exceptionally small. Therefore, no additional fancy discovery methods are necessary. | ||
x11 = cdll.LoadLibrary("libX11.so.6") | ||
|
||
# In order to use any X11 calls from multiple threads, the X11 library must be initialized to use | ||
# mutex protection. XInitThreads() sets this up and must be called before any other X11 | ||
# initialization is performed. Since this always needs to be called before other imports anyway, | ||
# this module does the init at module import time. | ||
x11.XInitThreads() |