< prev index next >

src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java

Print this page




  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.awt.X11;
  27 
  28 import java.awt.*;
  29 import java.awt.event.*;

  30 import java.awt.peer.TrayIconPeer;
  31 import sun.awt.*;
  32 import java.awt.image.*;
  33 import java.security.AccessController;
  34 import java.security.PrivilegedAction;
  35 import java.lang.reflect.InvocationTargetException;
  36 import sun.util.logging.PlatformLogger;
  37 
  38 public class XTrayIconPeer implements TrayIconPeer,
  39        InfoWindow.Balloon.LiveArguments,
  40        InfoWindow.Tooltip.LiveArguments
  41 {
  42     private static final PlatformLogger ctrLog = PlatformLogger.getLogger("sun.awt.X11.XTrayIconPeer.centering");
  43 
  44     TrayIcon target;
  45     TrayIconEventProxy eventProxy;
  46     XTrayIconEmbeddedFrame eframe;
  47     TrayIconCanvas canvas;
  48     InfoWindow.Balloon balloon;
  49     InfoWindow.Tooltip tooltip;


 396         try {
 397             XToolkit.removeEventDispatcher(window, xed);
 398         } finally {
 399             XToolkit.awtUnlock();
 400         }
 401     }
 402 
 403     // Private method for testing purposes.
 404     private Point getLocationOnScreen() {
 405         return eframe.getLocationOnScreen();
 406     }
 407 
 408     public Rectangle getBounds() {
 409         Point loc = getLocationOnScreen();
 410         return new Rectangle(loc.x, loc.y, loc.x + TRAY_ICON_WIDTH, loc.y + TRAY_ICON_HEIGHT);
 411     }
 412 
 413     void addListeners() {
 414         canvas.addMouseListener(eventProxy);
 415         canvas.addMouseMotionListener(eventProxy);

 416     }
 417 
 418     long getWindow() {
 419         return AWTAccessor.getComponentAccessor()
 420                           .<XEmbeddedFramePeer>getPeer(eframe).getWindow();
 421     }
 422 
 423     public boolean isDisposed() {
 424         return isDisposed;
 425     }
 426 
 427     public String getActionCommand() {
 428         return target.getActionCommand();
 429     }
 430 
 431     static class TrayIconEventProxy implements MouseListener, MouseMotionListener {
 432         XTrayIconPeer xtiPeer;
 433 
 434         TrayIconEventProxy(XTrayIconPeer xtiPeer) {
 435             this.xtiPeer = xtiPeer;




  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.awt.X11;
  27 
  28 import java.awt.*;
  29 import java.awt.event.*;
  30 import java.awt.peer.ComponentPeer;
  31 import java.awt.peer.TrayIconPeer;
  32 import sun.awt.*;
  33 import java.awt.image.*;
  34 import java.security.AccessController;
  35 import java.security.PrivilegedAction;
  36 import java.lang.reflect.InvocationTargetException;
  37 import sun.util.logging.PlatformLogger;
  38 
  39 public class XTrayIconPeer implements TrayIconPeer,
  40        InfoWindow.Balloon.LiveArguments,
  41        InfoWindow.Tooltip.LiveArguments
  42 {
  43     private static final PlatformLogger ctrLog = PlatformLogger.getLogger("sun.awt.X11.XTrayIconPeer.centering");
  44 
  45     TrayIcon target;
  46     TrayIconEventProxy eventProxy;
  47     XTrayIconEmbeddedFrame eframe;
  48     TrayIconCanvas canvas;
  49     InfoWindow.Balloon balloon;
  50     InfoWindow.Tooltip tooltip;


 397         try {
 398             XToolkit.removeEventDispatcher(window, xed);
 399         } finally {
 400             XToolkit.awtUnlock();
 401         }
 402     }
 403 
 404     // Private method for testing purposes.
 405     private Point getLocationOnScreen() {
 406         return eframe.getLocationOnScreen();
 407     }
 408 
 409     public Rectangle getBounds() {
 410         Point loc = getLocationOnScreen();
 411         return new Rectangle(loc.x, loc.y, loc.x + TRAY_ICON_WIDTH, loc.y + TRAY_ICON_HEIGHT);
 412     }
 413 
 414     void addListeners() {
 415         canvas.addMouseListener(eventProxy);
 416         canvas.addMouseMotionListener(eventProxy);
 417         eframe.addMouseListener(eventProxy);
 418     }
 419 
 420     long getWindow() {
 421         return AWTAccessor.getComponentAccessor()
 422                           .<XEmbeddedFramePeer>getPeer(eframe).getWindow();
 423     }
 424 
 425     public boolean isDisposed() {
 426         return isDisposed;
 427     }
 428 
 429     public String getActionCommand() {
 430         return target.getActionCommand();
 431     }
 432 
 433     static class TrayIconEventProxy implements MouseListener, MouseMotionListener {
 434         XTrayIconPeer xtiPeer;
 435 
 436         TrayIconEventProxy(XTrayIconPeer xtiPeer) {
 437             this.xtiPeer = xtiPeer;


< prev index next >