/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
{
private static final PlatformLogger ctrLog = PlatformLogger.getLogger("sun.awt.X11.XTrayIconPeer.centering");
boolean isTrayIconDisplayed;
long eframeParentID;
};
volatile boolean isDisposed;
boolean isParentWindowLocated;
throws AWTException
{
eventProxy = new TrayIconEventProxy(this);
eframe = new XTrayIconEmbeddedFrame();
// Fix for 6317038: as EmbeddedFrame is instance of Frame, it is blocked
// by modal dialogs, but in the case of TrayIcon it shouldn't. So we
// set ModalExclusion property on it.
return null;
}
});
} else {
parentXED = new XEventDispatcher() {
// It's executed under AWTLock.
return;
}
// On Metacity the EmbeddedFrame's parent window bounds are larger
// than TrayIcon size required (that is we need a square but a rectangle
// is provided by the Panel Notification Area). The parent's background color
// differs from the Panel's one. To hide the background we resize parent
// window so that it fits the EmbeddedFrame.
// However due to resizing the parent window it loses centering in the Panel.
// We center it when discovering that some of its side is of size greater
// than the fixed value. Centering is being done by "X" (when the parent's width
// is greater) and by "Y" (when the parent's height is greater).
// Actually we need this workaround until we could detect taskbar color.
// If both the height and the width differ from the fixed size then WM
// must level at least one side to the fixed size. For some reason it may take
// a few hops (even after reparenting) and we have to skip the intermediate ones.
XTrayIconPeer.this);
return;
XTrayIconPeer.this);
ex_width = 0;
XTrayIconPeer.this);
ex_height = 0;
// If moving by both "X" and "Y".
// When some tray icon gets removed from the tray, a Java icon may be repositioned.
// In this case the parent window also lose centering. We have to restore it.
if (ex_height != 0) {
XTrayIconPeer.this);
} else if (ex_width != 0) {
XTrayIconPeer.this);
} else {
XTrayIconPeer.this);
}
}
isParentWindowLocated = true;
}
};
}
eframeXED = new XEventDispatcher() {
// It's executed under AWTLock.
return;
}
if (isTrayIconDisplayed) { // most likely Notification Area was removed
public void run() {
}
});
}
return;
}
if (!isTrayIconDisplayed) {
isTrayIconDisplayed = true;
}
}
};
// Wait till the EmbeddedFrame is reparented
try {
while (!isTrayIconDisplayed) {
try {
} catch (InterruptedException e) {
break;
}
break;
}
}
} finally {
}
// This is unlikely to happen.
{
throw new AWTException("TrayIcon couldn't be displayed.");
}
eframe.setVisible(true);
updateImage();
addListeners();
}
public void dispose() {
disposeOnEDT();
} else {
try {
public void run() {
disposeOnEDT();
}
});
} catch (InterruptedException ie) {
} catch (InvocationTargetException ite) {}
}
}
private void disposeOnEDT() {
// All actions that is to be synchronized with disposal
// should be executed either under AWTLock, or on EDT.
// isDisposed value must be checked.
isDisposed = true;
isTrayIconDisplayed = false;
}
}
}
return tooltipString;
}
public void updateImage() {
public void run() {
}
};
} else {
r.run();
}
}
// Check if the tray icon is in the bounds of a screen.
{
}
}
// It's synchronized with disposal by EDT.
public void showPopupMenu(int x, int y) {
if (isDisposed())
return;
}
}
}
}
}
// ******************************************************************
// ******************************************************************
if (window == 0) {
return;
}
try {
} finally {
}
}
if (window == 0) {
return;
}
try {
} finally {
}
}
// Private method for testing purposes.
return eframe.getLocationOnScreen();
}
}
void addListeners() {
}
long getWindow() {
}
public boolean isDisposed() {
return isDisposed;
}
return target.getActionCommand();
}
}
//prevent DRAG events from being posted with TrayIcon source(CR 6565779)
return;
}
// Event handling is synchronized with disposal by EDT.
if (xtiPeer.isDisposed()) {
return;
}
if (e.isPopupTrigger()) {
}
// This is a hack in order to set non-Component source to MouseEvent
// instance.
// In some cases this could lead to unpredictable result (e.g. when
// other class tries to cast source field to Component).
// We already filter DRAG events out (CR 6565779).
}
{
e.getModifiers());
}
}
handleEvent(e);
}
handleEvent(e);
}
handleEvent(e);
}
handleEvent(e);
}
handleEvent(e);
}
handleEvent(e);
}
handleEvent(e);
}
}
// ***************************************
// Special embedded frame for tray icon
// ***************************************
public XTrayIconEmbeddedFrame(){
super(XToolkit.getDefaultRootWindow(), true, true);
}
public boolean isUndecorated() {
return true;
}
public boolean isResizable() {
return false;
}
// embedded frame for tray icon shouldn't be disposed by anyone except tray icon
public void dispose(){
}
public void realDispose(){
super.dispose();
}
};
// ***************************************
// Classes for painting an image on canvas
// ***************************************
boolean autosize;
}
// Invoke on EDT.
boolean old_autosize = autosize;
}
}
}
// Invoke on EDT.
observer = new IconObserver();
}
repaintImage(true);
}
// Invoke on EDT.
Graphics g = getGraphics();
if (g != null) {
try {
if (isVisible()) {
if (doClear) {
update(g);
} else {
paint(g);
}
}
} finally {
g.dispose();
}
}
}
// Invoke on EDT.
try {
} finally {
}
}
}
}
public boolean imageUpdate(final Image image, final int flags, int x, int y, int width, int height) {
!IconCanvas.this.isVisible())
{
return false;
}
{
public void run() {
repaintImage(false);
}
});
}
}
}
}
}