Remove disabled backends
This commit is contained in:
parent
89131db79b
commit
2211b8a662
7 changed files with 23 additions and 88 deletions
15
backend.go
15
backend.go
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package main
|
||||
|
||||
import "sort"
|
||||
|
||||
type PointerButton int
|
||||
type Key int
|
||||
|
||||
|
|
@ -54,12 +56,17 @@ const (
|
|||
type BackendInfo struct {
|
||||
Name string
|
||||
Init func() (Backend, error)
|
||||
|
||||
priority int
|
||||
}
|
||||
|
||||
var Backends []BackendInfo = []BackendInfo{
|
||||
{"X11", InitX11Backend},
|
||||
{"RemoteDesktop portal", InitPortalBackend},
|
||||
{"Windows", InitWindowsBackend},
|
||||
var Backends []BackendInfo
|
||||
|
||||
func RegisterBackend(name string, init func() (Backend, error), priority int) {
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,10 @@ type portalBackend struct {
|
|||
lock sync.RWMutex
|
||||
}
|
||||
|
||||
func init() {
|
||||
RegisterBackend("RemoteDesktop portal", InitPortalBackend, 1)
|
||||
}
|
||||
|
||||
func InitPortalBackend() (Backend, error) {
|
||||
bus, err := dbus.SessionBusPrivate()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -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")}
|
||||
}
|
||||
|
|
@ -91,6 +91,10 @@ type keybdInput struct {
|
|||
|
||||
type windowsBackend struct{}
|
||||
|
||||
func init() {
|
||||
RegisterBackend("Windows", InitWindowsBackend, 0)
|
||||
}
|
||||
|
||||
func InitWindowsBackend() (Backend, error) {
|
||||
p := &windowsBackend{}
|
||||
if err := sendInputProc.Find(); err != nil {
|
||||
|
|
|
|||
|
|
@ -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")}
|
||||
}
|
||||
|
|
@ -50,6 +50,10 @@ type x11Backend struct {
|
|||
scrollHorizontal, scrollVertical int
|
||||
}
|
||||
|
||||
func init() {
|
||||
RegisterBackend("X11", InitX11Backend, 0)
|
||||
}
|
||||
|
||||
func InitX11Backend() (Backend, error) {
|
||||
sessionType := os.Getenv("XDG_SESSION_TYPE")
|
||||
if sessionType != "" && sessionType != "x11" {
|
||||
|
|
|
|||
|
|
@ -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")}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue