diff --git a/base.py b/base.py index e116115..ee172f2 100644 --- a/base.py +++ b/base.py @@ -7,6 +7,7 @@ from pynput import mouse from sightfactory import SightFactory from PyQt6.QtWidgets import QApplication from pynput.mouse import Controller +import subprocess def init(): global data, sights, mousectrl, app @@ -22,6 +23,12 @@ def init(): data["sight_processes"] = {} data["mouse_distance_x"] = 0 data["mouse_distance_y"] = 0 + data["display_server"] = "" + if data["platform"]["system"] == "Linux": + args = ["echo -n $XDG_SESSION_TYPE"] + result = subprocess.check_output(args, shell=True) + data["display_server"] = result.decode('ascii') + print("D "+data["display_server"]) data["base_dir"]=os.path.abspath(os.getcwd())+os.path.sep data["template_dir"]=data["base_dir"]+"place"+os.path.sep+"templates"+os.path.sep #LOAD the template config content @@ -30,6 +37,11 @@ def init(): mouseevent = MouseEvents() start() +def frameSupported(): + if data["display_server"] == "wayland": + return False + return True + def loadConfigTemplate(): config = configparser.ConfigParser() config.sections() @@ -49,4 +61,4 @@ def start(): sights.processes(); sights.show("main"); - app.exec() \ No newline at end of file + app.exec() diff --git a/callhandler.py b/callhandler.py index 7c66172..c40ea77 100644 --- a/callhandler.py +++ b/callhandler.py @@ -22,6 +22,10 @@ class CallHandler(QObject): def getDefaultTemplate(self): return base.data["default_template"] + @pyqtSlot(result=int) + def frameSupported(self): + return base.frameSupported() + @pyqtSlot(int) def setWidth(self, width): self.sight.resize(width, self.sight.height()); @@ -43,6 +47,7 @@ class CallHandler(QObject): self.sight.addChild(new_id) """ The child remember its parent. When the child is closed the parent will be know about that. """ base.sights.get(new_id).setParent(self.sight.getId()) + print("PARENT " + str(base.sights.get(new_id).getParent())) return new_id; @pyqtSlot(str, str, bool) @@ -64,19 +69,8 @@ class CallHandler(QObject): print("Active - " + self.sight.getId()) base.data["active_sight"] = self.sight.getId() - - @pyqtSlot() def close(self): - """ CLOSE ITS CHILDREN. It doesnt close the children's children just the current parent children - will be closed. """ - for cid in self.sight.getChildren(): - base.sights.close(cid) - print("CLOSED - " + cid) - """ If the parent doesn't exist anymore! """ - if base.sights.get(self.sight.getParent()) is not None: - """ The child will be removed from his parent. So the parent wont be know about that because its child closed. """ - base.sights.get(self.sight.getParent()).removeChild(self.sight.getId()) base.sights.close(self.sight.getId()) @pyqtSlot() diff --git a/mouseevents.py b/mouseevents.py index 922877b..bb7d3a3 100644 --- a/mouseevents.py +++ b/mouseevents.py @@ -8,10 +8,12 @@ class MouseEvents(): on_click=on_click, on_scroll=on_scroll) listener.start() - + # MOUSE EVENTS/LISTENER def on_move(x, y): if base.data["move"]: + print("MOVING") + if base.data["mouse_distance_x"] == 0: base.data["mouse_distance_x"] = base.sights.get(base.data["active_sight"]).pos().x()-x if base.data["mouse_distance_y"] == 0: @@ -19,7 +21,8 @@ def on_move(x, y): x_point = x+base.data["mouse_distance_x"] y_point = y+base.data["mouse_distance_y"] - #print( str(x_point) + " x " + str(y_point)) + + print( str(x_point) + " x " + str(y_point)) base.sights.get(base.data["active_sight"]).move(x_point, y_point) def on_click(x, y, button, pressed): @@ -34,4 +37,5 @@ def on_click(x, y, button, pressed): def on_scroll(x, y, dx, dy): print('Scrolled {0} at {1}'.format( 'down' if dy < 0 else 'up', - (x, y))) \ No newline at end of file + (x, y))) + diff --git a/place/css/sight.css b/place/css/sight.css index ffc7cb3..b2273fd 100644 --- a/place/css/sight.css +++ b/place/css/sight.css @@ -19,9 +19,9 @@ body { -ms-user-select: none; /* Internet Explorer/Edge */ user-select: none; /* Non-prefixed version, currently supported by any browser but < IE9 */ } -#sight #sresize { +#sight #sresize[display="show"] { cursor: nw-resize; - width: 15px; + width: 15px; height: 15px; background-color: none; right: 0; @@ -29,13 +29,26 @@ body { bottom: 0; position: absolute; } -#sight { - border: 4px solid grey; +#sight #sresize { + display: none; +} + +#sight { display: block; width: 100%; } +#sight[display="show"] { + border: 4px solid grey; +} +#sight { + border = 0; +} +#sight #stitlebar[display="show"] { + display: block; +} #sight #stitlebar { + display: none; width: 100%; height: 25px; background-color: grey; -} \ No newline at end of file +} diff --git a/place/js/sight.js b/place/js/sight.js index f6a0198..0e7f14b 100644 --- a/place/js/sight.js +++ b/place/js/sight.js @@ -2,6 +2,13 @@ if(navigator.userAgent.indexOf("QtWebEngine") > 0) { new QWebChannel(qt.webChannelTransport, function (channel) { // now I retrieve my object window.sight = channel.objects.handler; + window.sight.frameSupported(function(result) { + if(result == 1) { + document.querySelector("#stitlebar").setAttribute("display","show") + document.querySelector("#sresize").setAttribute("display","show") + document.querySelector("#sight").setAttribute("display","show") + } + }); }); } @@ -168,6 +175,11 @@ function load(url, element) } */ $(document).ready(function(){ + if(typeof window.sight.console === "undefined") { + /* Maybe the document ready but still the window.sight didnt loaded in the time */ + location.reload(); + } + const scontent = document.querySelectorAll('[scontent]'); scontent.forEach((element) => { $("[scontent="+element.getAttribute("scontent")+"]").load("content/"+element.getAttribute("scontent")+"/content.html"); @@ -177,6 +189,7 @@ $(document).ready(function(){ // INIT the Sight from init_sight variable if (typeof init_sight !== 'undefined') { for ( const [key,value] of Object.entries( init_sight ) ) { + window.sight.console(key + " - " + value) switch(key) { case 'width': @@ -239,4 +252,4 @@ $(document).ready(function(){ $( "#sfullscreen" ).s_fullscreen(); $( "#stitlebar" ).s_titlebar(); $( "#stoggled" ).s_toggled(); -}); \ No newline at end of file +}); diff --git a/place/templates/base/css/template.css b/place/templates/base/css/template.css index d6db84a..908a270 100644 --- a/place/templates/base/css/template.css +++ b/place/templates/base/css/template.css @@ -12,8 +12,8 @@ body { font-size: larger; float: left; } -#sight { - border: 4px solid #4f9af3; +#sight[display="show"]{ + border: 4px solid #4f9af3; } #sight #content { padding: 5px; diff --git a/place/templates/base/main.html b/place/templates/base/main.html index abada09..60e72dd 100644 --- a/place/templates/base/main.html +++ b/place/templates/base/main.html @@ -50,4 +50,4 @@