diff --git a/backends/x/window.go b/backends/x/window.go index d50d5b6..10f26e8 100644 --- a/backends/x/window.go +++ b/backends/x/window.go @@ -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, diff --git a/window.go b/window.go index 58645be..2400c3f 100644 --- a/window.go +++ b/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) }