Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-monitor support #41

Merged
merged 22 commits into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
76bdb27
Refactor Browser, added BrowserWindow and create a window per display
JezerM Apr 19, 2022
49744b2
Fix naming
JezerM Apr 19, 2022
6807710
Added more globals
JezerM Apr 19, 2022
4b24ca0
Adapted code to work with new refactor and new globals
JezerM Apr 19, 2022
01df422
Added index.yml configuration loader, and set primary/secondary html …
JezerM Apr 19, 2022
e24465a
Rebuild resources in Makefile when bundle.js files are updated
JezerM Apr 20, 2022
156253b
Disconnect init_bridge method once page is loaded
JezerM Apr 21, 2022
3b22844
Remove unnecessary prints
JezerM Apr 21, 2022
eb5f586
Added some util Classes with some refactor
JezerM May 8, 2022
b253741
Added GreeterComm class to facilitate multi-monitor communication
JezerM Jun 8, 2022
e2aafb4
Moved BrowserWindow and its abstraction interfaces to other source files
JezerM Jun 9, 2022
251fa83
Added a window_metadata_to_dict function
JezerM Jun 9, 2022
818326b
Some general improvements
JezerM Jun 9, 2022
443755e
Merge branch 'master' into multi-monitor
JezerM Jun 9, 2022
d8fee3d
Rename NodyBroadcastEvent to GreeterBroadcastEvent
JezerM Jun 9, 2022
07b92dd
nody-greeter themes with typescript were copied over here
JezerM Jun 9, 2022
5beac35
Added nody-greeter-types submodule into ts-types
JezerM Jun 9, 2022
e7e1f62
Fix import paths in typescript themes
JezerM Jun 9, 2022
df83147
Remove print
JezerM Jun 9, 2022
4299177
Update Makefile to compile typescript themes
JezerM Jun 9, 2022
7de93af
Update requirements in README
JezerM Jun 9, 2022
531763b
Update github action
JezerM Jun 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ runs:
-
name: Checkout
uses: actions/checkout@v2
with:
submodules: true
-
name: Install dependencies
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ node_modules/
package-lock.json

# vscode
.vscode/
.vscode/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "ts-types"]
path = ts-types
url = [email protected]:JezerM/nody-greeter-types.git
28 changes: 24 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ $(build/web-greeter): src/*

# Resources
bundle.js := ${BUILD_DIR}/web-greeter/resources/js/bundle.js
bundle/ThemeUtils := ${REPO_DIR}/src/resources/js/ThemeUtils.js
bundle/GreeterComm := ${REPO_DIR}/src/resources/js/GreeterComm.js
bundle/bootstrap := ${REPO_DIR}/src/resources/js/bootstrap.js

$(bundle.js): $(build/web-greeter)
$(bundle.js): $(build/web-greeter) $(bundle/ThemeUtils) $(bundle/bootstrap) $(bundle/GreeterComm)
@cd build/web-greeter/resources/js; \
cat ThemeUtils.js bootstrap.js > bundle.js
cat ${bundle/ThemeUtils} ${bundle/bootstrap} ${bundle/GreeterComm} > bundle.js

resources.py := ${BUILD_DIR}/web-greeter/resources.py

Expand Down Expand Up @@ -103,22 +106,39 @@ build_completions: $(zshcompletiondir_local) $(bashcompletiondir_local)
THEMES_DIR := $(abspath ${DESTDIR_PREFIX}/share/web-greeter/themes)
THEMES_DIR_LOCAL := $(abspath ${INSTALL_PREFIX}/share/web-greeter/themes)
themes/gruvbox := $(abspath ${THEMES_DIR_LOCAL}/gruvbox)
themes/gruvbox/js := $(abspath ${REPO_DIR}/themes/gruvbox/js)
themes/dracula := $(abspath ${THEMES_DIR_LOCAL}/dracula)
themes/dracula/js := $(abspath ${REPO_DIR}/themes/dracula/js)
themes/simple := $(abspath ${THEMES_DIR_LOCAL}/simple)
themes/_vendor := $(abspath ${INSTALL_PREFIX}/share/web-greeter/_vendor)

$(THEMES_DIR_LOCAL): $(INSTALL_ROOT)
@mkdir -p "${THEMES_DIR_LOCAL}"

$(themes/gruvbox): $(THEMES_DIR_LOCAL) themes/gruvbox/*
$(themes/gruvbox/js): themes/gruvbox/ts
@tsc --build themes/gruvbox
@echo " Gruvbox theme compiled"

$(themes/dracula/js): themes/dracula/ts
@tsc --build themes/dracula
@echo " Dracula theme compiled"

$(themes/gruvbox): $(THEMES_DIR_LOCAL) $(themes/gruvbox/js) themes/gruvbox
@if [ -d "${themes/gruvbox}" ]; then \
rm -rf "${themes/gruvbox}"; \
fi
@cp -r "${REPO_DIR}/themes/gruvbox" "${themes/gruvbox}"
@echo " Gruvbox theme copied"
$(themes/dracula): $(THEMES_DIR_LOCAL) themes/dracula/*
$(themes/dracula): $(THEMES_DIR_LOCAL) $(themes/dracula/js) themes/dracula
@if [ -d "${themes/dracula}" ]; then \
rm -rf "${themes/dracula}"; \
fi
@cp -r "${REPO_DIR}/themes/dracula" "${themes/dracula}"
@echo " Dracula theme copied"
$(themes/simple): $(THEMES_DIR_LOCAL) themes/simple/*
@cp -r "${REPO_DIR}/themes/simple" "${themes/simple}"
@echo " Simple theme copied"

$(themes/_vendor): $(INSTALL_ROOT) themes/_vendor/*
@cp -r "${REPO_DIR}/themes/_vendor" "${themes/_vendor}"
@echo " Theme vendors copied"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ apt install ./web-greeter-VER-DISTRO.deb

- rsync
- make
- tsc (`npm i -g typescript`)
- pyrcc5 (Should be installed with above dependencies)
- base-devel (build-essential)

Expand Down
13 changes: 8 additions & 5 deletions src/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,16 @@ def parse(argv):
from browser.browser import Browser
from bridge import Greeter, Config, ThemeUtils

globales.LDMGreeter = Greeter()
globales.LDMGreeterConfig = Config()
globales.LDMThemeUtils = ThemeUtils(globales.LDMGreeter)

config.load_theme_config()
config.ensure_theme()

globales.greeter = Browser()
browser = globales.greeter

browser.greeter = Greeter()
browser.greeter_config = Config()
browser.theme_utils = ThemeUtils(browser.greeter)

browser.load()
# browser.load()
browser.show()
browser.run()
6 changes: 3 additions & 3 deletions src/bindings/screensaver.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ class ScreenSaver:
saved: bool = False

def __init__(self):
dir = os.path.dirname(os.path.realpath(__file__))
libname = os.path.join(dir, "_screensaver.so")
directory = os.path.dirname(os.path.realpath(__file__))
libname = os.path.join(directory, "_screensaver.so")
self.clib = ctypes.CDLL(libname)
self.clib.get_screensaver.restype = ScreenSaverDataPointer

def get_screensaver(self):
"""Gets screensaver data"""
data: ScreenSaverDataPointer = self.clib.get_screensaver()
if data is None:
return
return None
contents: ScreenSaverData = data.contents
return contents

Expand Down
86 changes: 86 additions & 0 deletions src/bridge/GreeterComm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#
# Greeter.py
#
# Copyright © 2021 JezerM
#
# This file is part of Web Greeter.
#
# Web Greeter is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Web Greeter is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# The following additional terms are in effect as per Section 7 of the license:
#
# The preservation of all legal notices and author attributions in
# the material or in the Appropriate Legal Notices displayed
# by works containing it is required.
#
# You should have received a copy of the GNU General Public License
# along with Web Greeter; If not, see <http://www.gnu.org/licenses/>.

# pylint: disable=wrong-import-position


from typing import List

from PyQt5.QtCore import QVariant

# This Application
from browser.window import WindowAbstract
from browser.bridge import Bridge, BridgeObject
from bridge import window_metadata_to_dict

import globales

communications: List = []

def communication_emit(window, data):
"""Emit broadcast_signal for each GreeterComm element in communications"""
for comm in communications:
# print(window)
comm.broadcast_signal.emit(window, data)

class GreeterComm(BridgeObject):
# pylint: disable=no-self-use,missing-function-docstring,too-many-public-methods,invalid-name
"""Greeter Communication bridge class, known as `greeter_comm` in javascript"""

broadcast_signal = Bridge.signal(QVariant, QVariant, arguments=("window", "data"))

noop_signal = Bridge.signal()
window: WindowAbstract

def __init__(self, window, *args, **kwargs):
super().__init__(name='Comm', *args, **kwargs)
self.window = window

communications.append(self)

@Bridge.prop(QVariant, notify=noop_signal)
def window_metadata(self):
for win in globales.greeter.windows:
if self.window.meta.id == win.meta.id:
meta = window_metadata_to_dict(win.meta)
# print(meta)
return meta

return {}

@Bridge.method(QVariant)
def broadcast(self, data):
self.noop_signal.emit()
communication_emit(self.window_metadata, data)

def destroy(self):
global communications
comms = []
for obj in communications:
if obj != self:
comms.append(obj)

communications = comms
35 changes: 35 additions & 0 deletions src/bridge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
# You should have received a copy of the GNU General Public License
# along with Web Greeter; If not, see <http://www.gnu.org/licenses/>.

import math
import sys
from typing import Literal
from logger import logger

def language_to_dict(lang):
Expand Down Expand Up @@ -116,7 +119,39 @@ def battery_to_dict(battery):
logger.warn(e)
return {}

def inf_to_infinity(num: float):
"""Converts a math.inf to "infinity" or "-infinity" """
if not math.isinf(num):
return num
if num > 0:
return "infinity"
return "-infinity"

def window_metadata_to_dict(metadata):
"""Returns a dict from WindowMetadata object"""
if not metadata:
return {}
return {
"id": metadata.id,
"is_primary": metadata.is_primary,
"overallBoundary": {
"minX": metadata.overallBoundary.minX,
"maxX": inf_to_infinity(metadata.overallBoundary.maxX),
"minY": metadata.overallBoundary.minY,
"maxY": inf_to_infinity(metadata.overallBoundary.maxY),
},
"position": {
"x": metadata.position.x,
"y": metadata.position.y,
},
"size": {
"width": metadata.size.width,
"height": metadata.size.height,
},
}

# pylint: disable=wrong-import-position
from .Greeter import Greeter
from .Config import Config
from .ThemeUtils import ThemeUtils
from .GreeterComm import GreeterComm
Loading