如何停止/解决Java应用程序窃取Linux窗口管理器的焦点 [英] How do I stop/workaround Java apps stealing focus in Linux window managers

查看:176
本文介绍了如何停止/解决Java应用程序窃取Linux窗口管理器的焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想要在Java中快速构建小部件的原型。我们将它们覆盖在用专有第三方图形软件包编写的显示屏上。我们发现Java GUI会将键盘焦点从窗口管理器中移走。



窗口管理器是fvwm,我试过配置它,所以Java应用程序设置为不获得焦点,此外,如果它有把焦点拿走,并把它交给另一个GUI。

如果我运行这个与Java应用程序它不工作(只要鼠标在Java GUI上,它有键盘焦点) - 如果我交换一些标准的X GUI小部件(XEyes)来代替Java GUI,它就像一个魅力。这有助于缓解Java的声明(由fvwm的人维护)Java不尊重ICCCM。



我想知道其他人是否已经解决了这个问题,如果是的话如何。到目前为止,我有几个选择如何尝试和解决这个问题:
$ b $ 1 1)twiddle Java设置,希望如果我关掉焦点,那么它可能会返回焦点控制窗口管理器(到目前为止,我已经尝试过setFocusable(false)在父JFrame上,这是行不通的。 /webnotes/trouble/TSG-Desktop/html/awt.html#gdaaorel =noreferrer> http://java.sun.com/javase/6/webnotes/trouble/TSG-Desktop/html/awt.html #gdaao 表示我应该改为Window.setFocusableWindowState(false)有问题的图形用户界面还没有在窗口中重做,但我也不完全相信,Java将重新分配焦点



2)使用JNI在Java程序中进行低级别的X调用。我认为这可能会工作,但是,我从来没有玩过低水平的X.我不确定我应该使用什么样的调用(XtSetKeyboardFocus()应该是危险的)或者我怎样才能识别我操作的图形用户界面(在这方面fvwm是很好的,因为他们有一个图形用户界面,让你点击另一个图形用户界面,并找出它的名称和类)

)使用更强的窗口管理器。一些不使用ICCCM的窗口管理器可能会更好地处理Java。当然,有很多管理者,我不知道该集中注意力。同样的,许多人似乎都很少指定应用程序的重点(大多数人似乎只关心广泛的政策)。最后,原型(prototype)被重写了一个JWindow而不是一个JFrame,当JWindow调用了setFocusableWindowState(false)时,Java返回了焦点...问题解决了。


We want to quickly prototype widgets in Java. We overlay them on top of a display written in a proprietary 3rd party graphics package. We find that the Java GUI steals keyboard focus away from the window manager.

The window manager is fvwm, I've tried configuring it so the Java app is setup not to get focus, and furthermore if it ever does get focus to take it away and give it to the other GUI.

If I run this with the Java app it doesn't work (whenever the mouse is over the Java GUI it has keyboard focus)- if I swap some standard X GUI widget (XEyes) in place of the Java GUI it works like a charm. This lends some creedence to the claim (maintained by the people at fvwm) that Java is not respecting the ICCCM.

I'm wondering if other people have solved this problem and if so how. So far I have a few choices for how to try and fix this:

1) twiddle Java settings, hoping that if I turn off focus there maybe it will hand back focus control to the window manager (so far I've tried "setFocusable(false)" on the parent JFrame. This didn't work. A thread "http://java.sun.com/javase/6/webnotes/trouble/TSG-Desktop/html/awt.html#gdaao" indicated I should instead do "Window.setFocusableWindowState(false)" The GUI in question hasn't been redone in a Window yet but I'm also not completely convinced that Java will relenquish the focus

2) make low level X calls in the Java program using JNI. I think this would probably work, but, I've never played much with low level X. I'm unsure what calls I should be using (XtSetKeyboardFocus() is supposed to be dangerous to call...) or how I can identify the GUI's I'm operating on (in this respect fvwm was nice since they had a GUI that allowed you to click on another GUI and find out its "name" and "class")

3) use a "stronger" window manager. Some window managers that don't use ICCCM might be able to deal with Java better. Of course, there are a plethora of managers, and I'm not sure what to concentrate on. Likewise many seem to be short on specifying focus by app (most seem only to care about broad policies).

解决方案

Finally the prototype was reworked in a JWindow rather than a JFrame, and when that JWindow had setFocusableWindowState(false) called on it Java did hand back focus... problem solved.

这篇关于如何停止/解决Java应用程序窃取Linux窗口管理器的焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆