mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ebiten: add RunGameOptions.X11ClassName and X11InstanceName
Closes #2904
This commit is contained in:
parent
c72e609158
commit
60725eba86
@ -475,6 +475,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
op.InitUnfocused = !*flagInitFocused
|
op.InitUnfocused = !*flagInitFocused
|
||||||
op.ScreenTransparent = *flagTransparent
|
op.ScreenTransparent = *flagTransparent
|
||||||
|
op.X11ClassName = "Window-Size"
|
||||||
|
op.X11InstanceName = "window-size"
|
||||||
|
|
||||||
const title = "Window Size (Ebitengine Demo)"
|
const title = "Window Size (Ebitengine Demo)"
|
||||||
ww := int(float64(g.width) * initScreenScale)
|
ww := int(float64(g.width) * initScreenScale)
|
||||||
|
@ -110,6 +110,8 @@ const (
|
|||||||
Stereo = Hint(0x0002100C)
|
Stereo = Hint(0x0002100C)
|
||||||
TransparentFramebuffer = Hint(0x0002000A)
|
TransparentFramebuffer = Hint(0x0002000A)
|
||||||
Visible = Hint(0x00020004)
|
Visible = Hint(0x00020004)
|
||||||
|
X11ClassName = Hint(0x00024001)
|
||||||
|
X11InstanceName = Hint(0x00024002)
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -225,10 +225,14 @@ func WindowHint(target Hint, hint int) error {
|
|||||||
// Setting these hints requires no platform specific headers or functions.
|
// Setting these hints requires no platform specific headers or functions.
|
||||||
//
|
//
|
||||||
// This function must only be called from the main thread.
|
// This function must only be called from the main thread.
|
||||||
func WindowHintString(hint Hint, value string) {
|
func WindowHintString(hint Hint, value string) error {
|
||||||
str := C.CString(value)
|
str := C.CString(value)
|
||||||
defer C.free(unsafe.Pointer(str))
|
defer C.free(unsafe.Pointer(str))
|
||||||
C.glfwWindowHintString(C.int(hint), str)
|
C.glfwWindowHintString(C.int(hint), str)
|
||||||
|
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateWindow creates a window and its associated context. Most of the options
|
// CreateWindow creates a window and its associated context. Most of the options
|
||||||
|
@ -284,6 +284,10 @@ func WindowHint(hint Hint, value int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WindowHintString is not implemented.
|
// WindowHintString is not implemented.
|
||||||
|
func WindowHintString(hint Hint, value string) error {
|
||||||
|
// Do nothing.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (w *Window) Destroy() error {
|
func (w *Window) Destroy() error {
|
||||||
if !_glfw.initialized {
|
if !_glfw.initialized {
|
||||||
|
@ -144,6 +144,8 @@ type RunOptions struct {
|
|||||||
ScreenTransparent bool
|
ScreenTransparent bool
|
||||||
SkipTaskbar bool
|
SkipTaskbar bool
|
||||||
SingleThread bool
|
SingleThread bool
|
||||||
|
X11ClassName string
|
||||||
|
X11InstanceName string
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitialWindowPosition returns the position for centering the given second width/height pair within the first width/height pair.
|
// InitialWindowPosition returns the position for centering the given second width/height pair within the first width/height pair.
|
||||||
|
@ -1083,6 +1083,14 @@ func (u *UserInterface) initOnMainThread(options *RunOptions) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := glfw.WindowHintString(glfw.X11ClassName, options.X11ClassName); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := glfw.WindowHintString(glfw.X11InstanceName, options.X11InstanceName); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// On macOS, window decoration should be initialized once after buffers are swapped (#2600).
|
// On macOS, window decoration should be initialized once after buffers are swapped (#2600).
|
||||||
if runtime.GOOS != "darwin" {
|
if runtime.GOOS != "darwin" {
|
||||||
decorated := glfw.False
|
decorated := glfw.False
|
||||||
|
22
run.go
22
run.go
@ -267,6 +267,12 @@ type RunGameOptions struct {
|
|||||||
//
|
//
|
||||||
// The default (zero) value is false, which means that the single thread mode is disabled.
|
// The default (zero) value is false, which means that the single thread mode is disabled.
|
||||||
SingleThread bool
|
SingleThread bool
|
||||||
|
|
||||||
|
// X11DisplayName is a class name in the ICCCM WM_CLASS window property.
|
||||||
|
X11ClassName string
|
||||||
|
|
||||||
|
// X11InstanceName is an instance name in the ICCCM WM_CLASS window property.
|
||||||
|
X11InstanceName string
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunGameWithOptions starts the main loop and runs the game with the specified options.
|
// RunGameWithOptions starts the main loop and runs the game with the specified options.
|
||||||
@ -675,18 +681,34 @@ func SetInitFocused(focused bool) {
|
|||||||
var initUnfocused int32 = 0
|
var initUnfocused int32 = 0
|
||||||
|
|
||||||
func toUIRunOptions(options *RunGameOptions) *ui.RunOptions {
|
func toUIRunOptions(options *RunGameOptions) *ui.RunOptions {
|
||||||
|
const (
|
||||||
|
defaultX11ClassName = "Ebitengine-Application"
|
||||||
|
defaultX11InstanceName = "ebitengine-application"
|
||||||
|
)
|
||||||
|
|
||||||
if options == nil {
|
if options == nil {
|
||||||
return &ui.RunOptions{
|
return &ui.RunOptions{
|
||||||
InitUnfocused: atomic.LoadInt32(&initUnfocused) != 0,
|
InitUnfocused: atomic.LoadInt32(&initUnfocused) != 0,
|
||||||
ScreenTransparent: atomic.LoadInt32(&screenTransparent) != 0,
|
ScreenTransparent: atomic.LoadInt32(&screenTransparent) != 0,
|
||||||
|
X11ClassName: defaultX11ClassName,
|
||||||
|
X11InstanceName: defaultX11InstanceName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if options.X11ClassName == "" {
|
||||||
|
options.X11ClassName = defaultX11ClassName
|
||||||
|
}
|
||||||
|
if options.X11InstanceName == "" {
|
||||||
|
options.X11InstanceName = defaultX11InstanceName
|
||||||
|
}
|
||||||
return &ui.RunOptions{
|
return &ui.RunOptions{
|
||||||
GraphicsLibrary: ui.GraphicsLibrary(options.GraphicsLibrary),
|
GraphicsLibrary: ui.GraphicsLibrary(options.GraphicsLibrary),
|
||||||
InitUnfocused: options.InitUnfocused,
|
InitUnfocused: options.InitUnfocused,
|
||||||
ScreenTransparent: options.ScreenTransparent,
|
ScreenTransparent: options.ScreenTransparent,
|
||||||
SkipTaskbar: options.SkipTaskbar,
|
SkipTaskbar: options.SkipTaskbar,
|
||||||
SingleThread: options.SingleThread,
|
SingleThread: options.SingleThread,
|
||||||
|
X11ClassName: options.X11ClassName,
|
||||||
|
X11InstanceName: options.X11InstanceName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user