Add new-instance-open-target.window setting
This adds the ability to open new tabs in the last-focused window instead, which fixes #1801. Right now the only other option is probably not that useful for human users but it's required to make tests behave deterministically and consistently. (But with #881 on the roadmap, I would implement this as another choice) To this end, also make the test framework set this option to preserve the invariant against which existing tests are written: that spawning a new window would effectively also focus it.
This commit is contained in:
parent
2223a285ef
commit
6d181e5c6f
@ -227,6 +227,16 @@ def data(readonly=False):
|
|||||||
"How to open links in an existing instance if a new one is "
|
"How to open links in an existing instance if a new one is "
|
||||||
"launched."),
|
"launched."),
|
||||||
|
|
||||||
|
('new-instance-open-target.window',
|
||||||
|
SettingValue(typ.String(
|
||||||
|
valid_values=typ.ValidValues(
|
||||||
|
('last-opened', "Open new tabs in the last"
|
||||||
|
"opened window."),
|
||||||
|
('last-focused', "Open new tabs in the most"
|
||||||
|
"recently focused window.")
|
||||||
|
)), 'last-focused'),
|
||||||
|
"Which window to choose when opening links as new tabs."),
|
||||||
|
|
||||||
('log-javascript-console',
|
('log-javascript-console',
|
||||||
SettingValue(typ.String(
|
SettingValue(typ.String(
|
||||||
valid_values=typ.ValidValues(
|
valid_values=typ.ValidValues(
|
||||||
|
@ -69,7 +69,11 @@ def get_window(via_ipc, force_window=False, force_tab=False,
|
|||||||
window_to_raise = window
|
window_to_raise = window
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
window = objreg.last_window()
|
win_mode = config.get('general', 'new-instance-open-target.window')
|
||||||
|
if win_mode == 'last-focused':
|
||||||
|
window = objreg.last_focused_window()
|
||||||
|
elif win_mode == 'last-opened':
|
||||||
|
window = objreg.last_window()
|
||||||
except objreg.NoWindow:
|
except objreg.NoWindow:
|
||||||
# There is no window left, so we open a new one
|
# There is no window left, so we open a new one
|
||||||
window = MainWindow()
|
window = MainWindow()
|
||||||
|
@ -178,10 +178,7 @@ def _get_window_registry(window):
|
|||||||
app = get('app')
|
app = get('app')
|
||||||
win = app.activeWindow()
|
win = app.activeWindow()
|
||||||
elif window == 'last-focused':
|
elif window == 'last-focused':
|
||||||
try:
|
win = last_focused_window()
|
||||||
win = get('last-focused-main-window')
|
|
||||||
except KeyError:
|
|
||||||
win = last_window()
|
|
||||||
else:
|
else:
|
||||||
win = window_registry[window]
|
win = window_registry[window]
|
||||||
except (KeyError, NoWindow):
|
except (KeyError, NoWindow):
|
||||||
@ -276,6 +273,14 @@ def dump_objects():
|
|||||||
return lines
|
return lines
|
||||||
|
|
||||||
|
|
||||||
|
def last_focused_window():
|
||||||
|
"""Get the last focused window, or the last window if none."""
|
||||||
|
try:
|
||||||
|
return get('last-focused-main-window')
|
||||||
|
except KeyError:
|
||||||
|
return last_window()
|
||||||
|
|
||||||
|
|
||||||
def last_window():
|
def last_window():
|
||||||
"""Get the last opened window object."""
|
"""Get the last opened window object."""
|
||||||
if not window_registry:
|
if not window_registry:
|
||||||
|
@ -330,6 +330,7 @@ class QuteProc(testprocess.Process):
|
|||||||
settings = [
|
settings = [
|
||||||
('ui', 'message-timeout', '0'),
|
('ui', 'message-timeout', '0'),
|
||||||
('general', 'auto-save-interval', '0'),
|
('general', 'auto-save-interval', '0'),
|
||||||
|
('general', 'new-instance-open-target.window', 'last-opened')
|
||||||
]
|
]
|
||||||
if not self._webengine:
|
if not self._webengine:
|
||||||
settings.append(('network', 'ssl-strict', 'false'))
|
settings.append(('network', 'ssl-strict', 'false'))
|
||||||
|
Loading…
Reference in New Issue
Block a user