SWT Shell is not raised above in xfwm4

梦想的初衷 提交于 2019-12-08 06:08:57

问题


I have problem with xfwm4. Using following code:

Shell s = windowVector.get(0).getShell();
s.setActive();

Shell window that is covered by other shells is not raised above. Using kwin (KDE window manager) it works correctly. Shell is created using following constructor:

shell = new Shell(mainShell, SWT.NO_TRIM | SWT.MODELESS);

In both cases SWT method:

OS.gdk_window_focus (window, OS.GDK_CURRENT_TIME);

is called but in xfwm4 shell get focus and is NOT raised above all other shell windows (in my application). Is this bug in xfwm4? Maybe some configuration issue or I am missig something.

EDIT:

I might be not precise. Shell that i try to setActive is "under" other child shells. Following code explains and simplfy what I am trying to achieve:

Shell mainShell = new Shell(Display.getDefault(), SWT.NO_TRIM);
mainShell.setBounds(0, 0, 300, 200);
mainShell.open();
final Shell shell1 = new Shell(mainShell, SWT.NO_TRIM | SWT.MODELESS);
shell1.setBounds(0, 0, 300, 200);
shell1.open();
Shell shell2 = new Shell(mainShell, SWT.NO_TRIM | SWT.MODELESS);
shell2.setBounds(0, 0, 300, 200);
shell2.open();
Thread thread = new Thread() {

    @Override
    public void run() {
        try {
                Thread.sleep(2000);
                System.out.println("Raise shell1 above");
                shell1.setActive();
        }
        catch(InterruptedException e) {
            e.printStackTrace();
        }
    }
};
thread.start();
while( !mainShell.isDisposed()) {
    if( !Display.getDefault().readAndDispatch()) {
        Display.getDefault().sleep();
    }
}
Display.getDefault().dispose();

This code works correctly in kwin, in xfwm4 shell1 stays "under" shell2 and remains hidden.


回答1:


I can't speak about xfwm4 specifically but yes, many window managers have some form of input stealing prevention.

You don't want any random application being allowed to steal your focus or force your attention away from what you are doing.

How they implement this behaviour differs between window managers however. Most should (ideally) allow the currently focused application to give focus to a newly created window of that application but I imagine not all do that.



来源:https://stackoverflow.com/questions/25892951/swt-shell-is-not-raised-above-in-xfwm4

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!