os-js / osjs-client

OS.js Client Module
https://manual.os-js.org/
Other
31 stars 31 forks source link

Automatic focus of newly created windows #12

Closed andersevenrud closed 6 years ago

andersevenrud commented 6 years ago

@SpaceboyRoss01 pointed out in https://github.com/os-js/OS.js/issues/671 that windows does not focus automatically and perceived this as a bug.

It's actually by design, though if this is the right choice -- is up for discussion.

So I'm thinking there's three possibilities here... or fourth which is to have it focus by default, but maybe add some kind of focus stealing prevention (or honor ICCCM).

Right now you have to do, ex:

.createWindow()
  .render()
  .focus()

1. Add an option as local to application

Ex:

proc = core.make('osjs/application', {
  options: Object.assign({
    autofocusWindow: Boolean
  }, options)
});

https://github.com/os-js/osjs-client/blob/master/src/application.js#L53

2: Add as an option local to the window

Ex:

createWindow({
  focused: true
})

https://github.com/os-js/osjs-client/blob/master/src/window.js#L47

3: Add as a configuration option globally

Ex:

{
  desktop: {
    autofocusWindow: Boolean
  }
}

https://github.com/os-js/osjs-client/blob/master/src/config.js#L102

andersevenrud commented 6 years ago

After giving it some thought, I've made the default behavior to focus windows on the .createWindow() method.

If can be disabled with option.windowAutoFocus = false.