Added a way to set WM_CLASS
This commit is contained in:
parent
d1fcc6e37f
commit
8abb45e77a
@ -25,6 +25,8 @@ type window struct {
|
||||
onClose func ()
|
||||
skipChildDrawCallback bool
|
||||
|
||||
title, application string
|
||||
|
||||
modalParent *window
|
||||
hasModal bool
|
||||
|
||||
@ -182,6 +184,7 @@ func (window *window) Child () (child tomo.Element) {
|
||||
}
|
||||
|
||||
func (window *window) SetTitle (title string) {
|
||||
window.title = title
|
||||
ewmh.WmNameSet (
|
||||
window.backend.connection,
|
||||
window.xWindow.Id,
|
||||
@ -196,6 +199,17 @@ func (window *window) SetTitle (title string) {
|
||||
title)
|
||||
}
|
||||
|
||||
func (window *window) SetApplicationName (name string) {
|
||||
window.application = name
|
||||
icccm.WmClassSet (
|
||||
window.backend.connection,
|
||||
window.xWindow.Id,
|
||||
&icccm.WmClass {
|
||||
Instance: name,
|
||||
Class: name,
|
||||
})
|
||||
}
|
||||
|
||||
func (window *window) SetIcon (sizes []image.Image) {
|
||||
wmIcons := []ewmh.WmIcon { }
|
||||
|
||||
@ -247,6 +261,7 @@ func (window *window) NewModal (width, height int) (tomo.Window, error) {
|
||||
[]string { "_NET_WM_STATE_MODAL" })
|
||||
modal.modalParent = window
|
||||
window.hasModal = true
|
||||
modal.inheritProperties(window)
|
||||
return modal, err
|
||||
}
|
||||
|
||||
@ -260,9 +275,14 @@ func (window mainWindow) NewPanel (width, height int) (tomo.Window, error) {
|
||||
panel.xWindow.Id,
|
||||
window.xWindow.Id)
|
||||
panel.setType("UTILITY")
|
||||
panel.inheritProperties(window.window)
|
||||
return panel, err
|
||||
}
|
||||
|
||||
func (window *window) inheritProperties (parent *window) {
|
||||
window.SetApplicationName(parent.application)
|
||||
}
|
||||
|
||||
func (window *window) setType (ty string) error {
|
||||
return ewmh.WmWindowTypeSet (
|
||||
window.backend.connection,
|
||||
|
11
window.go
11
window.go
@ -18,13 +18,19 @@ type Window interface {
|
||||
// method might have no effect with some backends.
|
||||
SetTitle (string)
|
||||
|
||||
// SetApplicationName sets the name of the application that this window
|
||||
// belongs to. This method might have no effect with some backends.
|
||||
SetApplicationName (string)
|
||||
|
||||
// SetIcon taks in a list different sizes of the same icon and selects
|
||||
// the best one to display on the window title bar, dock, or whatever is
|
||||
// applicable for the given backend. This method might have no effect
|
||||
// for some backends.
|
||||
SetIcon (sizes []image.Image)
|
||||
|
||||
// NewModal creates a new modal dialog window.
|
||||
// NewModal creates a new modal dialog window. The resulting window will
|
||||
// inherit this window's application name and icon, but these can be
|
||||
// manually overridden.
|
||||
NewModal (width, height int) (window Window, err error)
|
||||
|
||||
// Copy puts data into the clipboard.
|
||||
@ -56,6 +62,7 @@ type MainWindow interface {
|
||||
|
||||
// NewPanel creates a panel window that is semantically tied to this
|
||||
// window. This is intended to be used for utility windows, tool bars,
|
||||
// torn-off menus, etc.
|
||||
// torn-off menus, etc. The resulting window will inherit this window's
|
||||
// application name and icon, but these can be manually overridden.
|
||||
NewPanel (width, height int) (window Window, err error)
|
||||
}
|
||||
|
Reference in New Issue
Block a user