Remove disabled backends

This commit is contained in:
Unrud 2022-02-21 22:30:28 +01:00
parent 89131db79b
commit 2211b8a662
7 changed files with 23 additions and 88 deletions

View file

@ -19,6 +19,8 @@
package main package main
import "sort"
type PointerButton int type PointerButton int
type Key int type Key int
@ -54,12 +56,17 @@ const (
type BackendInfo struct { type BackendInfo struct {
Name string Name string
Init func() (Backend, error) Init func() (Backend, error)
priority int
} }
var Backends []BackendInfo = []BackendInfo{ var Backends []BackendInfo
{"X11", InitX11Backend},
{"RemoteDesktop portal", InitPortalBackend}, func RegisterBackend(name string, init func() (Backend, error), priority int) {
{"Windows", InitWindowsBackend}, Backends = append(Backends, BackendInfo{name, init, priority})
sort.SliceStable(Backends, func(i, j int) bool {
return Backends[i].priority < Backends[j].priority
})
} }
type UnsupportedPlatformError struct { type UnsupportedPlatformError struct {

View file

@ -48,6 +48,10 @@ type portalBackend struct {
lock sync.RWMutex lock sync.RWMutex
} }
func init() {
RegisterBackend("RemoteDesktop portal", InitPortalBackend, 1)
}
func InitPortalBackend() (Backend, error) { func InitPortalBackend() (Backend, error) {
bus, err := dbus.SessionBusPrivate() bus, err := dbus.SessionBusPrivate()
if err != nil { if err != nil {

View file

@ -1,28 +0,0 @@
// +build !portal
/*
* Copyright (c) 2018 Unrud <unrud@outlook.com>
*
* This file is part of Remote-Touchpad.
*
* Remote-Touchpad 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.
*
* Remote-Touchpad 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.
*
* You should have received a copy of the GNU General Public License
* along with Remote-Touchpad. If not, see <http://www.gnu.org/licenses/>.
*/
package main
import "errors"
func InitPortalBackend() (Backend, error) {
return nil, UnsupportedPlatformError{errors.New("disabled")}
}

View file

@ -91,6 +91,10 @@ type keybdInput struct {
type windowsBackend struct{} type windowsBackend struct{}
func init() {
RegisterBackend("Windows", InitWindowsBackend, 0)
}
func InitWindowsBackend() (Backend, error) { func InitWindowsBackend() (Backend, error) {
p := &windowsBackend{} p := &windowsBackend{}
if err := sendInputProc.Find(); err != nil { if err := sendInputProc.Find(); err != nil {

View file

@ -1,28 +0,0 @@
// +build !windows
/*
* Copyright (c) 2018 Unrud <unrud@outlook.com>
*
* This file is part of Remote-Touchpad.
*
* Remote-Touchpad 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.
*
* Remote-Touchpad 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.
*
* You should have received a copy of the GNU General Public License
* along with Remote-Touchpad. If not, see <http://www.gnu.org/licenses/>.
*/
package main
import "errors"
func InitWindowsBackend() (Backend, error) {
return nil, UnsupportedPlatformError{errors.New("disabled")}
}

View file

@ -50,6 +50,10 @@ type x11Backend struct {
scrollHorizontal, scrollVertical int scrollHorizontal, scrollVertical int
} }
func init() {
RegisterBackend("X11", InitX11Backend, 0)
}
func InitX11Backend() (Backend, error) { func InitX11Backend() (Backend, error) {
sessionType := os.Getenv("XDG_SESSION_TYPE") sessionType := os.Getenv("XDG_SESSION_TYPE")
if sessionType != "" && sessionType != "x11" { if sessionType != "" && sessionType != "x11" {

View file

@ -1,28 +0,0 @@
// +build !x11
/*
* Copyright (c) 2018 Unrud <unrud@outlook.com>
*
* This file is part of Remote-Touchpad.
*
* Remote-Touchpad 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.
*
* Remote-Touchpad 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.
*
* You should have received a copy of the GNU General Public License
* along with Remote-Touchpad. If not, see <http://www.gnu.org/licenses/>.
*/
package main
import "errors"
func InitX11Backend() (Backend, error) {
return nil, UnsupportedPlatformError{errors.New("disabled")}
}