src/solaris/classes/sun/awt/X11/XTrayIconPeer.java

Print this page




  89             public Object run() {
  90                 eframe.setModalExclusionType(Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
  91                 return null;
  92             }
  93         });
  94 
  95 
  96         if (XWM.getWMID() != XWM.METACITY_WM) {
  97             parentXED = dummyXED; // We don't like to leave it 'null'.
  98 
  99         } else {
 100             parentXED = new XEventDispatcher() {
 101                 // It's executed under AWTLock.
 102                 public void dispatchEvent(XEvent ev) {
 103                     if (isDisposed() || ev.get_type() != XConstants.ConfigureNotify) {
 104                         return;
 105                     }
 106 
 107                     XConfigureEvent ce = ev.get_xconfigure();
 108 
 109                     if (ctrLog.isLoggable(PlatformLogger.FINE)) {
 110                         ctrLog.fine("ConfigureNotify on parent of {0}: {1}x{2}+{3}+{4} (old: {5}+{6})",
 111                                 XTrayIconPeer.this, ce.get_width(), ce.get_height(),
 112                                 ce.get_x(), ce.get_y(), old_x, old_y);
 113                     }
 114 
 115                     // A workaround for Gnome/Metacity (it doesn't affect the behaviour on KDE).
 116                     // On Metacity the EmbeddedFrame's parent window bounds are larger
 117                     // than TrayIcon size required (that is we need a square but a rectangle
 118                     // is provided by the Panel Notification Area). The parent's background color
 119                     // differs from the Panel's one. To hide the background we resize parent
 120                     // window so that it fits the EmbeddedFrame.
 121                     // However due to resizing the parent window it loses centering in the Panel.
 122                     // We center it when discovering that some of its side is of size greater
 123                     // than the fixed value. Centering is being done by "X" (when the parent's width
 124                     // is greater) and by "Y" (when the parent's height is greater).
 125 
 126                     // Actually we need this workaround until we could detect taskbar color.
 127 
 128                     if (ce.get_height() != TRAY_ICON_HEIGHT && ce.get_width() != TRAY_ICON_WIDTH) {
 129 
 130                         // If both the height and the width differ from the fixed size then WM
 131                         // must level at least one side to the fixed size. For some reason it may take
 132                         // a few hops (even after reparenting) and we have to skip the intermediate ones.
 133                         if (ctrLog.isLoggable(PlatformLogger.FINE)) {
 134                             ctrLog.fine("ConfigureNotify on parent of {0}. Skipping as intermediate resizing.",
 135                                     XTrayIconPeer.this);
 136                         }
 137                         return;
 138 
 139                     } else if (ce.get_height() > TRAY_ICON_HEIGHT) {
 140 
 141                         if (ctrLog.isLoggable(PlatformLogger.FINE)) {
 142                             ctrLog.fine("ConfigureNotify on parent of {0}. Centering by \"Y\".",
 143                                     XTrayIconPeer.this);
 144                         }
 145 
 146                         XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), eframeParentID,
 147                                                       ce.get_x(),
 148                                                       ce.get_y()+ce.get_height()/2-TRAY_ICON_HEIGHT/2,
 149                                                       TRAY_ICON_WIDTH,
 150                                                       TRAY_ICON_HEIGHT);
 151                         ex_height = ce.get_height();
 152                         ex_width = 0;
 153 
 154                     } else if (ce.get_width() > TRAY_ICON_WIDTH) {
 155 
 156                         if (ctrLog.isLoggable(PlatformLogger.FINE)) {
 157                             ctrLog.fine("ConfigureNotify on parent of {0}. Centering by \"X\".",
 158                                     XTrayIconPeer.this);
 159                         }
 160 
 161                         XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), eframeParentID,
 162                                                       ce.get_x()+ce.get_width()/2 - TRAY_ICON_WIDTH/2,
 163                                                       ce.get_y(),
 164                                                       TRAY_ICON_WIDTH,
 165                                                       TRAY_ICON_HEIGHT);
 166                         ex_width = ce.get_width();
 167                         ex_height = 0;
 168 
 169                     } else if (isParentWindowLocated && ce.get_x() != old_x && ce.get_y() != old_y) {
 170                         // If moving by both "X" and "Y".
 171                         // When some tray icon gets removed from the tray, a Java icon may be repositioned.
 172                         // In this case the parent window also lose centering. We have to restore it.
 173 
 174                         if (ex_height != 0) {
 175 
 176                             if (ctrLog.isLoggable(PlatformLogger.FINE)) {
 177                                 ctrLog.fine("ConfigureNotify on parent of {0}. Move detected. Centering by \"Y\".",
 178                                         XTrayIconPeer.this);
 179                             }
 180 
 181                             XlibWrapper.XMoveWindow(XToolkit.getDisplay(), eframeParentID,
 182                                                     ce.get_x(),
 183                                                     ce.get_y() + ex_height/2 - TRAY_ICON_HEIGHT/2);
 184 
 185                         } else if (ex_width != 0) {
 186 
 187                             if (ctrLog.isLoggable(PlatformLogger.FINE)) {
 188                                 ctrLog.fine("ConfigureNotify on parent of {0}. Move detected. Centering by \"X\".",
 189                                         XTrayIconPeer.this);
 190                             }
 191 
 192                             XlibWrapper.XMoveWindow(XToolkit.getDisplay(), eframeParentID,
 193                                                     ce.get_x() + ex_width/2 - TRAY_ICON_WIDTH/2,
 194                                                     ce.get_y());
 195                         } else {
 196                             if (ctrLog.isLoggable(PlatformLogger.FINE)) {
 197                                 ctrLog.fine("ConfigureNotify on parent of {0}. Move detected. Skipping.",
 198                                         XTrayIconPeer.this);
 199                             }
 200                         }
 201                     }
 202                     old_x = ce.get_x();
 203                     old_y = ce.get_y();
 204                     isParentWindowLocated = true;
 205                 }
 206             };
 207         }
 208         eframeXED = new XEventDispatcher() {
 209                 // It's executed under AWTLock.
 210                 XTrayIconPeer xtiPeer = XTrayIconPeer.this;
 211 
 212                 public void dispatchEvent(XEvent ev) {
 213                     if (isDisposed() || ev.get_type() != XConstants.ReparentNotify) {
 214                         return;
 215                     }
 216 




  89             public Object run() {
  90                 eframe.setModalExclusionType(Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
  91                 return null;
  92             }
  93         });
  94 
  95 
  96         if (XWM.getWMID() != XWM.METACITY_WM) {
  97             parentXED = dummyXED; // We don't like to leave it 'null'.
  98 
  99         } else {
 100             parentXED = new XEventDispatcher() {
 101                 // It's executed under AWTLock.
 102                 public void dispatchEvent(XEvent ev) {
 103                     if (isDisposed() || ev.get_type() != XConstants.ConfigureNotify) {
 104                         return;
 105                     }
 106 
 107                     XConfigureEvent ce = ev.get_xconfigure();
 108 
 109                     if (ctrLog.isLoggable(PlatformLogger.Level.FINE)) {
 110                         ctrLog.fine("ConfigureNotify on parent of {0}: {1}x{2}+{3}+{4} (old: {5}+{6})",
 111                                 XTrayIconPeer.this, ce.get_width(), ce.get_height(),
 112                                 ce.get_x(), ce.get_y(), old_x, old_y);
 113                     }
 114 
 115                     // A workaround for Gnome/Metacity (it doesn't affect the behaviour on KDE).
 116                     // On Metacity the EmbeddedFrame's parent window bounds are larger
 117                     // than TrayIcon size required (that is we need a square but a rectangle
 118                     // is provided by the Panel Notification Area). The parent's background color
 119                     // differs from the Panel's one. To hide the background we resize parent
 120                     // window so that it fits the EmbeddedFrame.
 121                     // However due to resizing the parent window it loses centering in the Panel.
 122                     // We center it when discovering that some of its side is of size greater
 123                     // than the fixed value. Centering is being done by "X" (when the parent's width
 124                     // is greater) and by "Y" (when the parent's height is greater).
 125 
 126                     // Actually we need this workaround until we could detect taskbar color.
 127 
 128                     if (ce.get_height() != TRAY_ICON_HEIGHT && ce.get_width() != TRAY_ICON_WIDTH) {
 129 
 130                         // If both the height and the width differ from the fixed size then WM
 131                         // must level at least one side to the fixed size. For some reason it may take
 132                         // a few hops (even after reparenting) and we have to skip the intermediate ones.
 133                         if (ctrLog.isLoggable(PlatformLogger.Level.FINE)) {
 134                             ctrLog.fine("ConfigureNotify on parent of {0}. Skipping as intermediate resizing.",
 135                                     XTrayIconPeer.this);
 136                         }
 137                         return;
 138 
 139                     } else if (ce.get_height() > TRAY_ICON_HEIGHT) {
 140 
 141                         if (ctrLog.isLoggable(PlatformLogger.Level.FINE)) {
 142                             ctrLog.fine("ConfigureNotify on parent of {0}. Centering by \"Y\".",
 143                                     XTrayIconPeer.this);
 144                         }
 145 
 146                         XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), eframeParentID,
 147                                                       ce.get_x(),
 148                                                       ce.get_y()+ce.get_height()/2-TRAY_ICON_HEIGHT/2,
 149                                                       TRAY_ICON_WIDTH,
 150                                                       TRAY_ICON_HEIGHT);
 151                         ex_height = ce.get_height();
 152                         ex_width = 0;
 153 
 154                     } else if (ce.get_width() > TRAY_ICON_WIDTH) {
 155 
 156                         if (ctrLog.isLoggable(PlatformLogger.Level.FINE)) {
 157                             ctrLog.fine("ConfigureNotify on parent of {0}. Centering by \"X\".",
 158                                     XTrayIconPeer.this);
 159                         }
 160 
 161                         XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), eframeParentID,
 162                                                       ce.get_x()+ce.get_width()/2 - TRAY_ICON_WIDTH/2,
 163                                                       ce.get_y(),
 164                                                       TRAY_ICON_WIDTH,
 165                                                       TRAY_ICON_HEIGHT);
 166                         ex_width = ce.get_width();
 167                         ex_height = 0;
 168 
 169                     } else if (isParentWindowLocated && ce.get_x() != old_x && ce.get_y() != old_y) {
 170                         // If moving by both "X" and "Y".
 171                         // When some tray icon gets removed from the tray, a Java icon may be repositioned.
 172                         // In this case the parent window also lose centering. We have to restore it.
 173 
 174                         if (ex_height != 0) {
 175 
 176                             if (ctrLog.isLoggable(PlatformLogger.Level.FINE)) {
 177                                 ctrLog.fine("ConfigureNotify on parent of {0}. Move detected. Centering by \"Y\".",
 178                                         XTrayIconPeer.this);
 179                             }
 180 
 181                             XlibWrapper.XMoveWindow(XToolkit.getDisplay(), eframeParentID,
 182                                                     ce.get_x(),
 183                                                     ce.get_y() + ex_height/2 - TRAY_ICON_HEIGHT/2);
 184 
 185                         } else if (ex_width != 0) {
 186 
 187                             if (ctrLog.isLoggable(PlatformLogger.Level.FINE)) {
 188                                 ctrLog.fine("ConfigureNotify on parent of {0}. Move detected. Centering by \"X\".",
 189                                         XTrayIconPeer.this);
 190                             }
 191 
 192                             XlibWrapper.XMoveWindow(XToolkit.getDisplay(), eframeParentID,
 193                                                     ce.get_x() + ex_width/2 - TRAY_ICON_WIDTH/2,
 194                                                     ce.get_y());
 195                         } else {
 196                             if (ctrLog.isLoggable(PlatformLogger.Level.FINE)) {
 197                                 ctrLog.fine("ConfigureNotify on parent of {0}. Move detected. Skipping.",
 198                                         XTrayIconPeer.this);
 199                             }
 200                         }
 201                     }
 202                     old_x = ce.get_x();
 203                     old_y = ce.get_y();
 204                     isParentWindowLocated = true;
 205                 }
 206             };
 207         }
 208         eframeXED = new XEventDispatcher() {
 209                 // It's executed under AWTLock.
 210                 XTrayIconPeer xtiPeer = XTrayIconPeer.this;
 211 
 212                 public void dispatchEvent(XEvent ev) {
 213                     if (isDisposed() || ev.get_type() != XConstants.ReparentNotify) {
 214                         return;
 215                     }
 216