当窗口已经有焦点时,如何让窗口移动到Gnome中其他窗口的顶部?

时间:2022-03-02 07:31:54

I have an application that sends the focus to other windows but those windows then don't automatically display themselves in the foreground, i.e. on top of all the other windows. Where can I configure the preferences of my window manager so that this is the default behaviour?

我有一个应用程序将焦点发送到其他窗口,但那些窗口然后不会自动显示在前台,即在所有其他窗口的顶部。我在哪里可以配置窗口管理器的首选项,以便这是默认行为?

In particular I'm using the Ctrl-0 and Ctrl-Shft-0 shortcuts in the MATLAB IDE to move between the command window and the editor window and although the focus seems to be transferred the new window doesn't automatically redraw itself in the foreground.

特别是我在MATLAB IDE中使用Ctrl-0和Ctrl-Shft-0快捷方式在命令窗口和编辑器窗口之间移动,虽然焦点似乎被转移,但新窗口不会自动重绘前景。

Thanks

3 个解决方案

#1


Not sure of a key binding off hand that does it, but if you alt-click on a window (which allows you to drag a window) it should come to the front.

不确定是否有一个关键的绑定,但如果你在一个窗口(允许你拖动一个窗口)上按住alt键,它应该会出现在前面。

As codeDr suggests, MATLAB is also kind of bad about repainting its windows. If you draw to a figure while code is executing, the figure does not update unless you execute drawnow or have some similar pause in the execution to allow the GUI to repaint. Since we're talking about MATLAB, the figure command will also cause the indicated figure to come to the front (in fact, it's harder to get it to not come to the front). So you could do figure(gcf) to bring the current figure to the front, or save the figure number with h = figure; and then later do figure(h). Incidentally, if you want to switch current figures without switching focus, set(0, 'CurrentFigure', h) should set h to the current figure.

正如codeDr建议的那样,MATLAB对于重新绘制窗口也有点不好。如果在执行代码时绘制到图形,则图形不会更新,除非您执行drawow或在执行中有一些类似的暂停以允许GUI重绘。由于我们讨论的是MATLAB,因此figure命令也会使指示的数字出现在前面(事实上,它更难以让它不到前面)。所以你可以做图(gcf)把当前的数字带到前面,或用h = figure保存图号;然后做图(h)。顺便提一下,如果你想在不切换焦点的情况下切换当前数字,设置(0,'CurrentFigure',h)应该将h设置为当前数字。

#2


Your window manager (probably Metacity?) implements focus-stealing prevention so that rogue apps don't pop up windows that would disturb your typing. Matlab needs to raise its window, and give it the input focus with the correct timestamp. If this is being done from a KeyPress event handler, the timestamp for setting the input focus would be the timestamp from the KeyPress event (i.e. the timestamp of the user-generated event that caused a window to be raised/focused).

您的窗口管理器(可能是Metacity?)实现了防止焦点窃取,以便恶意应用程序不会弹出会干扰您输入的窗口。 Matlab需要提高窗口,并使用正确的时间戳给它输入焦点。如果这是从KeyPress事件处理程序完成的,则用于设置输入焦点的时间戳将是来自KeyPress事件的时间戳(即,导致窗口被提升/聚焦的用户生成事件的时间戳)。

To politely give the input focus to a window, google for _NET_ACTIVE_WINDOW.

礼貌地将输入焦点提供给窗口,谷歌为_NET_ACTIVE_WINDOW。

#3


Usually when the window doesn't repaint, it means that the application's main application loop isn't running to refresh the window. Could it be that Matlab is doing some computation or disk activity when you are switching between windows?

通常当窗口没有重新绘制时,这意味着应用程序的主应用程序循环没有运行来刷新窗口。当你在窗口之间切换时,Matlab会做一些计算或磁盘活动吗?

#1


Not sure of a key binding off hand that does it, but if you alt-click on a window (which allows you to drag a window) it should come to the front.

不确定是否有一个关键的绑定,但如果你在一个窗口(允许你拖动一个窗口)上按住alt键,它应该会出现在前面。

As codeDr suggests, MATLAB is also kind of bad about repainting its windows. If you draw to a figure while code is executing, the figure does not update unless you execute drawnow or have some similar pause in the execution to allow the GUI to repaint. Since we're talking about MATLAB, the figure command will also cause the indicated figure to come to the front (in fact, it's harder to get it to not come to the front). So you could do figure(gcf) to bring the current figure to the front, or save the figure number with h = figure; and then later do figure(h). Incidentally, if you want to switch current figures without switching focus, set(0, 'CurrentFigure', h) should set h to the current figure.

正如codeDr建议的那样,MATLAB对于重新绘制窗口也有点不好。如果在执行代码时绘制到图形,则图形不会更新,除非您执行drawow或在执行中有一些类似的暂停以允许GUI重绘。由于我们讨论的是MATLAB,因此figure命令也会使指示的数字出现在前面(事实上,它更难以让它不到前面)。所以你可以做图(gcf)把当前的数字带到前面,或用h = figure保存图号;然后做图(h)。顺便提一下,如果你想在不切换焦点的情况下切换当前数字,设置(0,'CurrentFigure',h)应该将h设置为当前数字。

#2


Your window manager (probably Metacity?) implements focus-stealing prevention so that rogue apps don't pop up windows that would disturb your typing. Matlab needs to raise its window, and give it the input focus with the correct timestamp. If this is being done from a KeyPress event handler, the timestamp for setting the input focus would be the timestamp from the KeyPress event (i.e. the timestamp of the user-generated event that caused a window to be raised/focused).

您的窗口管理器(可能是Metacity?)实现了防止焦点窃取,以便恶意应用程序不会弹出会干扰您输入的窗口。 Matlab需要提高窗口,并使用正确的时间戳给它输入焦点。如果这是从KeyPress事件处理程序完成的,则用于设置输入焦点的时间戳将是来自KeyPress事件的时间戳(即,导致窗口被提升/聚焦的用户生成事件的时间戳)。

To politely give the input focus to a window, google for _NET_ACTIVE_WINDOW.

礼貌地将输入焦点提供给窗口,谷歌为_NET_ACTIVE_WINDOW。

#3


Usually when the window doesn't repaint, it means that the application's main application loop isn't running to refresh the window. Could it be that Matlab is doing some computation or disk activity when you are switching between windows?

通常当窗口没有重新绘制时,这意味着应用程序的主应用程序循环没有运行来刷新窗口。当你在窗口之间切换时,Matlab会做一些计算或磁盘活动吗?