Skip to content

Commit b118044

Browse files
committed
Wayland multimonitor management
1 parent 68866c9 commit b118044

12 files changed

+38
-8
lines changed

src/main/java/org/dpsoftware/FireflyLuciferin.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,6 @@ public void start(Stage stage) throws Exception {
224224
if (!NativeExecutor.isLinux()) {
225225
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
226226
}
227-
// If this instance spawns new instances, don't launch grabbers here.
228-
if (!(MainSingleton.getInstance().spawnInstances && MainSingleton.getInstance().config.getMultiMonitor() > 1)) {
229-
launchGrabberAndConsumers();
230-
}
231227
scheduleCheckForNightMode();
232228
StorageManager storageManager = new StorageManager();
233229
storageManager.updateConfigFile(MainSingleton.getInstance().config);
@@ -252,6 +248,10 @@ public void start(Stage stage) throws Exception {
252248
}
253249
grabberManager.getFPS();
254250
imageProcessor.calculateBorders();
251+
// If this instance spawns new instances, don't launch grabbers here.
252+
if (!(MainSingleton.getInstance().spawnInstances && MainSingleton.getInstance().config.getMultiMonitor() > 1)) {
253+
launchGrabberAndConsumers();
254+
}
255255
// If multi monitor, first instance, single instance, start message server
256256
if (CommonUtility.isSingleDeviceMainInstance()) {
257257
MessageServer messageServer = new MessageServer();

src/main/java/org/dpsoftware/NativeExecutor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,15 @@ public static boolean isLinux() {
204204
return com.sun.jna.Platform.isLinux();
205205
}
206206

207+
/**
208+
* Check if Wayland
209+
*
210+
* @return if it's Wayland
211+
*/
212+
public static boolean isWayland() {
213+
return isLinux() && System.getenv(Constants.DISPLAY_MANAGER_CHK).equalsIgnoreCase(Constants.WAYLAND);
214+
}
215+
207216
/**
208217
* Single point to fake the OS if needed
209218
*

src/main/java/org/dpsoftware/config/Constants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ public class Constants {
290290
public static final String CUDA_ERROR_TITLE = "cuda.error.title";
291291
public static final String CUDA_ERROR_HEADER = "cuda.error.header";
292292
public static final String CUDA_ERROR_CONTEXT = "cuda.error.context";
293+
public static final String WAYLAND_SCREEN_REC_PERMISSION = "wayland.screen.rec.permission";
294+
public static final String WAYLAND_SCREEN_REC_PERMISSION_CONTEXT = "wayland.screen.rec.permission.context";
293295
public static final String START = "tray.icon.start";
294296
public static final String STOP = "tray.icon.stop";
295297
public static final String STOP_STR = "STOP";

src/main/java/org/dpsoftware/gui/controllers/ModeTabController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void initDefaultValues() {
181181
} else if (NativeExecutor.isMac()) {
182182
captureMethod.setValue(Configuration.CaptureMethod.AVFVIDEOSRC);
183183
} else {
184-
if (System.getenv(Constants.DISPLAY_MANAGER_CHK).equalsIgnoreCase(Constants.WAYLAND)) {
184+
if (NativeExecutor.isWayland()) {
185185
captureMethod.setValue(Configuration.CaptureMethod.PIPEWIREXDG);
186186
} else {
187187
captureMethod.setValue(Configuration.CaptureMethod.XIMAGESRC);

src/main/java/org/dpsoftware/managers/PipelineManager.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
*/
2222
package org.dpsoftware.managers;
2323

24+
import javafx.scene.control.Alert;
2425
import lombok.SneakyThrows;
2526
import lombok.extern.slf4j.Slf4j;
2627
import org.dpsoftware.MainSingleton;
28+
import org.dpsoftware.NativeExecutor;
2729
import org.dpsoftware.audio.*;
2830
import org.dpsoftware.config.Configuration;
2931
import org.dpsoftware.config.Constants;
@@ -87,12 +89,9 @@ record XdgStreamDetails(Integer streamId, FileDescriptor fileDescriptor) {
8789
public static XdgStreamDetails getXdgStreamDetails() {
8890
CompletableFuture<String> sessionHandleMaybe = new CompletableFuture<>();
8991
CompletableFuture<Integer> streamIdMaybe = new CompletableFuture<>();
90-
9192
DBusConnection dBusConnection = DBusConnectionBuilder.forSessionBus().build(); // cannot free/close this for the duration of the capture
92-
9393
DbusScreenCast screenCastIface = dBusConnection.getRemoteObject("org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop", DbusScreenCast.class);
9494
String handleToken = UUID.randomUUID().toString().replaceAll("-", "");
95-
9695
DBusMatchRule matchRule = new DBusMatchRule("signal", "org.freedesktop.portal.Request", "Response");
9796
dBusConnection.addGenericSigHandler(matchRule, signal -> {
9897
try {
@@ -136,6 +135,12 @@ public static XdgStreamDetails getXdgStreamDetails() {
136135
selectSourcesMap.put("restore_token", new Variant<>(restoreToken));
137136
}
138137
screenCastIface.SelectSources(receivedSessionHandle, selectSourcesMap);
138+
if (NativeExecutor.isWayland() && (MainSingleton.getInstance().config.getScreenCastRestoreToken() == null || MainSingleton.getInstance().config.getScreenCastRestoreToken().isEmpty())) {
139+
DisplayManager displayManager = new DisplayManager();
140+
String displayName = displayManager.getDisplayName(MainSingleton.getInstance().whoAmI - 1);
141+
MainSingleton.getInstance().guiManager.showAlert(Constants.FIREFLY_LUCIFERIN, CommonUtility.getWord(Constants.WAYLAND_SCREEN_REC_PERMISSION).replace("{0}", displayName),
142+
CommonUtility.getWord(Constants.WAYLAND_SCREEN_REC_PERMISSION_CONTEXT).replace("{0}", displayName), Alert.AlertType.INFORMATION);
143+
}
139144
screenCastIface.Start(receivedSessionHandle, "", Collections.emptyMap());
140145
var c = streamIdMaybe.thenApply(streamId -> {
141146
FileDescriptor fileDescriptor = screenCastIface.OpenPipeWireRemote(receivedSessionHandle, Collections.emptyMap()); // block until stream started before calling OpenPipeWireRemote

src/main/resources/messagebundle_de.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ mqtt.error.context=Luciferin kann keine Verbindung zum MQTT-Server herstellen, b
265265
cuda.error.title=Plugin-Fehler
266266
cuda.error.header=GStreamer-Plugins nicht gefunden.
267267
cuda.error.context=Ihr System verfügt nicht über alle erforderlichen Plugins zum Ausführen von NVIDIA CUDA.\nBitte überprüfen Sie das WIKI des Projekts, um zu erfahren, wie Sie alle erforderlichen Abhängigkeiten installieren.
268+
wayland.screen.rec.permission=Luciferin benötigt die Erlaubnis, Ihre\n{0}
269+
wayland.screen.rec.permission.context=In einem Popup werden Sie um Erlaubnis zum Aufzeichnen Ihres Bildschirms gebeten.\nBitte wählen Sie „{0}“\nund klicken Sie dann auf die Schaltfläche „Teilen“.
268270
click.ok.download=\nKlicke auf “OK”, um die neue Version herunterzuladen und zu installieren.
269271
click.ok.download.linux=\nKlicke auf “OK”, um die neue Version in \n~/Documents/FireflyLuciferin herunterzuladen.\n
270272
once.download.finished=Sobald der Download abgeschlossen ist,\nwechsle bitte zu diesem Ordner und installiere das Programm manuell.

src/main/resources/messagebundle_en.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ mqtt.error.context=Luciferin is unable to connect to the MQTT server, please cor
265265
cuda.error.title=Plugins error
266266
cuda.error.header=GStreamer plugins not found.
267267
cuda.error.context=Your system does not have all the required plugins to run NVIDIA CUDA.\nPlease check the project's WIKI to learn how to install all the required dependencies.
268+
wayland.screen.rec.permission=Luciferin needs the permission to record your\n{0}
269+
wayland.screen.rec.permission.context=A popup will ask you for the permission to record your screen,\nplease select the "{0}"\nand then click the "Share" button.
268270
click.ok.download=\nClick Ok to download and install the new version.
269271
click.ok.download.linux=\nClick Ok to download new version in your\n~/Documents/FireflyLuciferin folder.\n
270272
once.download.finished=Once the download is finished,\nplease go to that folder and install it manually.

src/main/resources/messagebundle_es.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ mqtt.error.context=Luciferin no puede conectarse al servidor MQTT, por favor, co
264264
cuda.error.title=Error de plugins
265265
cuda.error.header=Complementos de GStreamer no encontrados.
266266
cuda.error.context=Su sistema no tiene todos los complementos necesarios para ejecutar NVIDIA CUDA.\nConsulte el WIKI del proyecto para saber cómo instalar todas las dependencias necesarias.
267+
wayland.screen.rec.permission=Luciferin necesita permiso para grabar tu\n{0}
268+
wayland.screen.rec.permission.context=Una ventana emergente le pedirá permiso para grabar su pantalla.\nSeleccione "{0}"\ny luego haga clic en el botón "Compartir".
267269
click.ok.download=\nPulse OK para descatgar e instalar la nueva versión.
268270
click.ok.download.linux=\nPulse OK para descargar la nueva versión en su carpeta\n~/Documents/FireflyLuciferin.\n
269271
once.download.finished=Cuando haya terminado la descarga,\npor favor, vaya a dicha carpeta e instálelo manualmente.

src/main/resources/messagebundle_fr.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ mqtt.error.context=Luciferin n'arrive pas à se connecter au serveur MQTT, merci
265265
cuda.error.title=Erreur de plugin
266266
cuda.error.header=Plugins GStreamer introuvables.
267267
cuda.error.context=Votre système ne dispose pas de tous les plugins requis pour exécuter NVIDIA CUDA.\nVeuillez consulter le WIKI du projet pour savoir comment installer toutes les dépendances requises.
268+
wayland.screen.rec.permission=Luciferin a besoin de l'autorisation pour enregistrer votre\n{0}
269+
wayland.screen.rec.permission.context=Une fenêtre contextuelle vous demandera l'autorisation d'enregistrer votre écran.\nVeuillez sélectionner "{0}"\npuis cliquez sur le bouton "Partager".
268270
click.ok.download=\nCliquer sur Ok pour télécharger et installer la nouvelle version.
269271
click.ok.download.linux=\nCliquez sur OK pour télécharger la nouvelle version dans votre répertoire\n~/Documents/FireflyLuciferin\n
270272
once.download.finished=Une fois le téléchargement terminé,\nveuillez accéder à ce dossier et l'installer manuellement.

src/main/resources/messagebundle_hu.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ mqtt.error.context=Luciferin nem tud csatlakozni az MQTT szerverhez, ellenőrizd
265265
cuda.error.title=Plugin hiba
266266
cuda.error.header=A GStreamer bővítmények nem találhatók.
267267
cuda.error.context=Rendszere nem rendelkezik az NVIDIA CUDA futtatásához szükséges összes beépülő modullal.\nKérjük, ellenőrizze a projekt WIKI-jét, hogy megtudja, hogyan telepítheti az összes szükséges függőséget.
268+
wayland.screen.rec.permission=A Luciferinnek engedélyre van szüksége az Ön\n{0}
269+
wayland.screen.rec.permission.context=Egy felugró ablak engedélyt kér a képernyő rögzítésére,\nkérjük, válassza ki a(z) "{0}" lehetőséget\n, majd kattintson a "Megosztás" gombra.
268270
click.ok.download=\nAz új verzió telepítéséhez klikkelj az OK-ra.
269271
click.ok.download.linux=\nAz új verziójú \n~/Documents/FireflyLuciferin mappában taláható firmware telepítéséhez klikkelj az OK-ra.\n
270272
once.download.finished=A letöltés végeztével,\n kérlek telepítsed manuálisan a letöltési mappából.

src/main/resources/messagebundle_it.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ mqtt.error.context=Luciferin non riesce a connettersi al server MQTT. Per favore
265265
cuda.error.title=Errore dei plugin
266266
cuda.error.header=Plugin GStreamer non trovati.
267267
cuda.error.context=Il tuo sistema non dispone di tutti i plugin necessari per eseguire NVIDIA CUDA.\nControlla il WIKI del progetto per sapere come installare tutte le dipendenze richieste.
268+
wayland.screen.rec.permission=Luciferin ha bisogno del permesso per registrare il tuo\n{0}
269+
wayland.screen.rec.permission.context=Un popup ti chiederà l'autorizzazione per registrare il tuo schermo,\nseleziona "{0}"\n quindi fai clic sul pulsante "Condividi".
268270
click.ok.download=\nClicca Ok per scaricare e installare la nuova versione.
269271
click.ok.download.linux=\nClicca Ok per scaricare la nuova versione nella seguente\n~/Documents/FireflyLuciferin cartella.\n
270272
once.download.finished=Quando il download sarà terminato,\nvai in quella cartella e installa manualmente.

src/main/resources/messagebundle_ru.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ mqtt.error.context=Luciferin не удается подключиться к с
265265
cuda.error.title=Ошибка плагинов
266266
cuda.error.header=Плагины GStreamer не найдены.
267267
cuda.error.context=В вашей системе нет всех необходимых плагинов для запуска NVIDIA CUDA.\nПожалуйста, проверьте WIKI проекта, чтобы узнать, как установить все необходимые зависимости.
268+
wayland.screen.rec.permission=Люциферину необходимо разрешение на запись вашего\n{0}
269+
wayland.screen.rec.permission.context=Всплывающее окно запросит разрешение на запись вашего экрана.\nвыберите «{0}»\nи нажмите кнопку «Поделиться».
268270
click.ok.download=\nНажмите «ОК», чтобы загрузить и установить новую версию.
269271
click.ok.download.linux=\nНажмите «ОК», чтобы загрузить новую версию в папку \n~/Documents/FireflyLuciferin.\n
270272
once.download.finished=Когда загрузка будет завершена,\nперейдите в эту папку и установите программу вручную.

0 commit comments

Comments
 (0)