Set region window above all

This commit is contained in:
itdominator 2023-04-30 11:59:20 -05:00
parent 2be09d4af9
commit b527d8ed9f
4 changed files with 68 additions and 1 deletions

View File

@ -1,9 +1,11 @@
# Python imports
import signal
import os
# Lib imports
# Application imports
from utils.debugging import debug_signal_handler
from utils.ipc_server import IPCServer
from core.window import Window
@ -14,10 +16,11 @@ class AppLaunchException(Exception):
class Application(IPCServer):
''' Create Settings and Controller classes. Bind signal to Builder. Inherit from Builtins to bind global methods and classes.'''
""" docstring for Application. """
def __init__(self, args, unknownargs):
super(Application, self).__init__()
if not settings.is_trace_debug():
try:
self.create_ipc_listener()
@ -32,4 +35,14 @@ class Application(IPCServer):
raise AppLaunchException(f"{app_name} IPC Server Exists: Will send path(s) to it and close...")
try:
# kill -SIGUSR2 <pid> from Linux/Unix or SIGBREAK signal from Windows
signal.signal(
vars(signal).get("SIGBREAK") or vars(signal).get("SIGUSR1"),
debug_signal_handler
)
except ValueError:
# Typically: ValueError: signal only works in main thread
...
Window(args, unknownargs)

View File

@ -26,6 +26,7 @@ class RegionWindow(Gtk.Window):
def _setup_styling(self):
self.set_default_size(600, 480)
self.set_keep_above(True)
self.set_deletable(False)
self.set_decorated(False)
self.set_resizable(True)

52
src/utils/debugging.py Normal file
View File

@ -0,0 +1,52 @@
# Python imports
# Lib imports
# Application imports
# Break into a Python console upon SIGUSR1 (Linux) or SIGBREAK (Windows:
# CTRL+Pause/Break). To be included in all production code, just in case.
def debug_signal_handler(signal, frame):
del signal
del frame
try:
import rpdb2
logger.debug("\n\nStarting embedded RPDB2 debugger. Password is 'foobar'\n\n")
rpdb2.start_embedded_debugger("foobar", True, True)
rpdb2.setbreak(depth=1)
return
except StandardError:
...
try:
from rfoo.utils import rconsole
logger.debug("\n\nStarting embedded rconsole debugger...\n\n")
rconsole.spawn_server()
return
except StandardError as ex:
...
try:
from pudb import set_trace
logger.debug("\n\nStarting PuDB debugger...\n\n")
set_trace(paused = True)
return
except StandardError as ex:
...
try:
import pdb
logger.debug("\n\nStarting embedded PDB debugger...\n\n")
pdb.Pdb(skip=['gi.*']).set_trace()
return
except StandardError as ex:
...
try:
import code
code.interact()
except StandardError as ex:
logger.debug(f"{ex}, returning to normal program flow...")

View File

@ -41,6 +41,7 @@ class StartCheckMixin:
def _write_new_pid(self):
pid = os.getpid()
self._write_pid(pid)
print(f"{app_name} PID: {pid}")
def _clean_pid(self):
os.unlink(self._PID_FILE)