178
179 protected void initGraphicsConfiguration() {
180 graphicsConfig = (X11GraphicsConfig) target.getGraphicsConfiguration();
181 graphicsConfigData = new AwtGraphicsConfigData(graphicsConfig.getAData());
182 }
183
184 void preInit(XCreateWindowParams params) {
185 super.preInit(params);
186 reparented = Boolean.TRUE.equals(params.get(REPARENTED));
187
188 target = (Component)params.get(TARGET);
189
190 initGraphicsConfiguration();
191
192 AwtGraphicsConfigData gData = getGraphicsConfigurationData();
193 X11GraphicsConfig config = (X11GraphicsConfig) getGraphicsConfiguration();
194 XVisualInfo visInfo = gData.get_awt_visInfo();
195 params.putIfNull(EVENT_MASK, XConstants.KeyPressMask | XConstants.KeyReleaseMask
196 | XConstants.FocusChangeMask | XConstants.ButtonPressMask | XConstants.ButtonReleaseMask
197 | XConstants.EnterWindowMask | XConstants.LeaveWindowMask | XConstants.PointerMotionMask
198 | XConstants.ButtonMotionMask | XConstants.ExposureMask | XConstants.StructureNotifyMask);
199
200 if (target != null) {
201 params.putIfNull(BOUNDS, new Rectangle(target.getBounds()));
202 } else {
203 params.putIfNull(BOUNDS, new Rectangle(0, 0, MIN_SIZE, MIN_SIZE));
204 }
205 params.putIfNull(BORDER_PIXEL, Long.valueOf(0));
206 getColorModel(); // fix 4948833: this call forces the color map to be initialized
207 params.putIfNull(COLORMAP, gData.get_awt_cmap());
208 params.putIfNull(DEPTH, gData.get_awt_depth());
209 params.putIfNull(VISUAL_CLASS, Integer.valueOf((int)XConstants.InputOutput));
210 params.putIfNull(VISUAL, visInfo.get_visual());
211 params.putIfNull(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWEventMask | XConstants.CWColormap);
212 Long parentWindow = (Long)params.get(PARENT_WINDOW);
213 if (parentWindow == null || parentWindow.longValue() == 0) {
214 XToolkit.awtLock();
215 try {
216 int screen = visInfo.get_screen();
217 if (screen != -1) {
218 params.add(PARENT_WINDOW, XlibWrapper.RootWindow(XToolkit.getDisplay(), screen));
264 }
265
266 public GraphicsConfiguration getGraphicsConfiguration() {
267 if (graphicsConfig == null) {
268 initGraphicsConfiguration();
269 }
270 return graphicsConfig;
271 }
272
273 public AwtGraphicsConfigData getGraphicsConfigurationData() {
274 if (graphicsConfigData == null) {
275 initGraphicsConfiguration();
276 }
277 return graphicsConfigData;
278 }
279
280 protected String[] getWMClass() {
281 return new String[] {XToolkit.getCorrectXIDString(getClass().getName()), XToolkit.getAWTAppClassName()};
282 }
283
284 void setReparented(boolean newValue) {
285 reparented = newValue;
286 }
287
288 boolean isReparented() {
289 return reparented;
290 }
291
292 static long getParentWindowID(Component target) {
293
294 ComponentPeer peer = target.getParent().getPeer();
295 Component temp = target.getParent();
296 while (!(peer instanceof XWindow))
297 {
298 temp = temp.getParent();
299 peer = temp.getPeer();
300 }
301
302 if (peer != null && peer instanceof XWindow)
303 return ((XWindow)peer).getContentWindow();
304 else return 0;
305 }
306
307
308 static XWindow getParentXWindowObject(Component target) {
309 if (target == null) return null;
977 if (compWithMouse != null) {
978 MouseEvent me = new MouseEvent(compWithMouse,
979 MouseEvent.MOUSE_EXITED, jWhen, modifiers, xce.get_x(),
980 xce.get_y(), xce.get_x_root(), xce.get_y_root(), clickCount, popupTrigger,
981 MouseEvent.NOBUTTON);
982 postEventToEventQueue(me);
983 eventLog.finest("Clearing last window ref");
984 lastWindowRef = null;
985 }
986 if (xce.get_type() == XConstants.EnterNotify) {
987 MouseEvent me = new MouseEvent(getEventSource(), MouseEvent.MOUSE_ENTERED,
988 jWhen, modifiers, xce.get_x(), xce.get_y(), xce.get_x_root(), xce.get_y_root(), clickCount,
989 popupTrigger, MouseEvent.NOBUTTON);
990 postEventToEventQueue(me);
991 }
992 }
993
994 public void doLayout(int x, int y, int width, int height) {}
995
996 public void handleConfigureNotifyEvent(XEvent xev) {
997 Rectangle oldBounds = getBounds();
998
999 super.handleConfigureNotifyEvent(xev);
1000 insLog.log(Level.FINER, "Configure, {0}, event disabled: {1}",
1001 new Object[] {xev.get_xconfigure(), isEventDisabled(xev)});
1002 if (isEventDisabled(xev)) {
1003 return;
1004 }
1005
1006 // if ( Check if it's a resize, a move, or a stacking order change )
1007 // {
1008 Rectangle bounds = getBounds();
1009 if (!bounds.getSize().equals(oldBounds.getSize())) {
1010 postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_RESIZED));
1011 }
1012 if (!bounds.getLocation().equals(oldBounds.getLocation())) {
1013 postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_MOVED));
1014 }
1015 // }
1016 }
1017
1018 public void handleMapNotifyEvent(XEvent xev) {
1019 super.handleMapNotifyEvent(xev);
1020 log.log(Level.FINE, "Mapped {0}", new Object[] {this});
1021 if (isEventDisabled(xev)) {
1022 return;
1023 }
1024 ComponentEvent ce;
1025
1026 ce = new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_SHOWN);
1027 postEventToEventQueue(ce);
1028 }
1029
1030 public void handleUnmapNotifyEvent(XEvent xev) {
1031 super.handleUnmapNotifyEvent(xev);
1032 if (isEventDisabled(xev)) {
1033 return;
1034 }
1035 ComponentEvent ce;
1036
1037 ce = new ComponentEvent(target, ComponentEvent.COMPONENT_HIDDEN);
1038 postEventToEventQueue(ce);
1039 }
1040
1041 private void dumpKeysymArray(XKeyEvent ev) {
1042 keyEventLog.fine(" "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 0))+
1043 "\n "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 1))+
1044 "\n "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 2))+
1045 "\n "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 3)));
1046 }
1047 /**
1048 Return unicode character or 0 if no correspondent character found.
1049 Parameter is a keysym basically from keysymdef.h
1050 XXX: how about vendor keys? Is there some with Unicode value and not in the list?
1051 */
1052 int keysymToUnicode( long keysym, int state ) {
1053 return XKeysym.convertKeysym( keysym, state );
1054 }
1385
1386 public Point getLocationOnScreen() {
1387 synchronized (target.getTreeLock()) {
1388 Component comp = target;
1389
1390 while (comp != null && !(comp instanceof Window)) {
1391 comp = ComponentAccessor.getParent_NoClientCode(comp);
1392 }
1393
1394 // applets, embedded, etc - translate directly
1395 // XXX: override in subclass?
1396 if (comp == null || comp instanceof sun.awt.EmbeddedFrame) {
1397 return toGlobal(0, 0);
1398 }
1399
1400 XToolkit.awtLock();
1401 try {
1402 Object wpeer = XToolkit.targetToPeer(comp);
1403 if (wpeer == null
1404 || !(wpeer instanceof XDecoratedPeer)
1405 || ((XDecoratedPeer)wpeer).configure_seen)
1406 {
1407 return toGlobal(0, 0);
1408 }
1409
1410 // wpeer is an XDecoratedPeer not yet fully adopted by WM
1411 Point pt = toOtherWindow(getContentWindow(),
1412 ((XDecoratedPeer)wpeer).getContentWindow(),
1413 0, 0);
1414
1415 if (pt == null) {
1416 pt = new Point(((XBaseWindow)wpeer).getAbsoluteX(), ((XBaseWindow)wpeer).getAbsoluteY());
1417 }
1418 pt.x += comp.getX();
1419 pt.y += comp.getY();
1420 return pt;
1421 } finally {
1422 XToolkit.awtUnlock();
1423 }
1424 }
1425 }
|
178
179 protected void initGraphicsConfiguration() {
180 graphicsConfig = (X11GraphicsConfig) target.getGraphicsConfiguration();
181 graphicsConfigData = new AwtGraphicsConfigData(graphicsConfig.getAData());
182 }
183
184 void preInit(XCreateWindowParams params) {
185 super.preInit(params);
186 reparented = Boolean.TRUE.equals(params.get(REPARENTED));
187
188 target = (Component)params.get(TARGET);
189
190 initGraphicsConfiguration();
191
192 AwtGraphicsConfigData gData = getGraphicsConfigurationData();
193 X11GraphicsConfig config = (X11GraphicsConfig) getGraphicsConfiguration();
194 XVisualInfo visInfo = gData.get_awt_visInfo();
195 params.putIfNull(EVENT_MASK, XConstants.KeyPressMask | XConstants.KeyReleaseMask
196 | XConstants.FocusChangeMask | XConstants.ButtonPressMask | XConstants.ButtonReleaseMask
197 | XConstants.EnterWindowMask | XConstants.LeaveWindowMask | XConstants.PointerMotionMask
198 | XConstants.ButtonMotionMask | XConstants.ExposureMask | XConstants.StructureNotifyMask
199 | XConstants.SubstructureNotifyMask);
200
201 if (target != null) {
202 params.putIfNull(BOUNDS, new Rectangle(target.getBounds()));
203 } else {
204 params.putIfNull(BOUNDS, new Rectangle(0, 0, MIN_SIZE, MIN_SIZE));
205 }
206 params.putIfNull(BORDER_PIXEL, Long.valueOf(0));
207 getColorModel(); // fix 4948833: this call forces the color map to be initialized
208 params.putIfNull(COLORMAP, gData.get_awt_cmap());
209 params.putIfNull(DEPTH, gData.get_awt_depth());
210 params.putIfNull(VISUAL_CLASS, Integer.valueOf((int)XConstants.InputOutput));
211 params.putIfNull(VISUAL, visInfo.get_visual());
212 params.putIfNull(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWEventMask | XConstants.CWColormap);
213 Long parentWindow = (Long)params.get(PARENT_WINDOW);
214 if (parentWindow == null || parentWindow.longValue() == 0) {
215 XToolkit.awtLock();
216 try {
217 int screen = visInfo.get_screen();
218 if (screen != -1) {
219 params.add(PARENT_WINDOW, XlibWrapper.RootWindow(XToolkit.getDisplay(), screen));
265 }
266
267 public GraphicsConfiguration getGraphicsConfiguration() {
268 if (graphicsConfig == null) {
269 initGraphicsConfiguration();
270 }
271 return graphicsConfig;
272 }
273
274 public AwtGraphicsConfigData getGraphicsConfigurationData() {
275 if (graphicsConfigData == null) {
276 initGraphicsConfiguration();
277 }
278 return graphicsConfigData;
279 }
280
281 protected String[] getWMClass() {
282 return new String[] {XToolkit.getCorrectXIDString(getClass().getName()), XToolkit.getAWTAppClassName()};
283 }
284
285 /**
286 * Current native parent of this window.
287 *
288 * Synchronization: state lock.
289 */
290 private long nativeParent = XConstants.None;
291
292 /**
293 * Get the current native parent window of this window as reported via
294 * the ReparentNotify.
295 */
296 public final long getNativeParent() {
297 synchronized (getStateLock()) {
298 return nativeParent;
299 }
300 }
301
302 /**
303 * Sets the current native parent of the window.
304 * Primarily intended to be called from the handleReparentNotifyEvent().
305 */
306 public void setNativeParent(long parent) {
307 synchronized (getStateLock()) {
308 nativeParent = parent;
309 }
310 }
311
312 /* NOTE: We have to select the SubstructureNotifyMask in order
313 * to handle the ReparentNotify event sent immediately upon
314 * mapping the window. StructureNotifyMask is not enough.
315 */
316 @Override
317 public void handleReparentNotifyEvent(XEvent xev) {
318 super.handleReparentNotifyEvent(xev);
319
320 XReparentEvent xe = xev.get_xreparent();
321
322 // Due to the SubstructureNotifyMask we should process only those
323 // events that belong to us.
324 if (xe.get_window() != getWindow()) {
325 return;
326 }
327
328 setNativeParent(xe.get_parent());
329 }
330
331 /**
332 * Returns the root window of the current window.
333 */
334 public final long getRootWindow() {
335 if (getWindow() == XConstants.None) {
336 return XConstants.None;
337 }
338 XToolkit.awtLock();
339 try {
340 XlibUtil.getWindowGeometry(getWindow(), XlibWrapper.larg1);
341 return Native.getWindow(XlibWrapper.larg1);
342 } finally {
343 XToolkit.awtUnlock();
344 }
345 }
346
347 /**
348 * Indicates whether the window is currently parented or not.
349 */
350 public final boolean isParented() {
351 long nativeParent = getNativeParent();
352 return nativeParent != XConstants.None &&
353 nativeParent != getRootWindow();
354 }
355
356 /**
357 * Indicates if this window has not yet been parented by a window manager.
358 *
359 * If the window is not expected to be parented at all (like if the WM is
360 * non-reparenting, or this is an OverrideRedirect window), this method
361 * returns false.
362 */
363 public boolean mayBeReparented() {
364 return
365 !XWM.isNonReparentingWM() &&
366 !isParented();
367 }
368
369 static long getParentWindowID(Component target) {
370
371 ComponentPeer peer = target.getParent().getPeer();
372 Component temp = target.getParent();
373 while (!(peer instanceof XWindow))
374 {
375 temp = temp.getParent();
376 peer = temp.getPeer();
377 }
378
379 if (peer != null && peer instanceof XWindow)
380 return ((XWindow)peer).getContentWindow();
381 else return 0;
382 }
383
384
385 static XWindow getParentXWindowObject(Component target) {
386 if (target == null) return null;
1054 if (compWithMouse != null) {
1055 MouseEvent me = new MouseEvent(compWithMouse,
1056 MouseEvent.MOUSE_EXITED, jWhen, modifiers, xce.get_x(),
1057 xce.get_y(), xce.get_x_root(), xce.get_y_root(), clickCount, popupTrigger,
1058 MouseEvent.NOBUTTON);
1059 postEventToEventQueue(me);
1060 eventLog.finest("Clearing last window ref");
1061 lastWindowRef = null;
1062 }
1063 if (xce.get_type() == XConstants.EnterNotify) {
1064 MouseEvent me = new MouseEvent(getEventSource(), MouseEvent.MOUSE_ENTERED,
1065 jWhen, modifiers, xce.get_x(), xce.get_y(), xce.get_x_root(), xce.get_y_root(), clickCount,
1066 popupTrigger, MouseEvent.NOBUTTON);
1067 postEventToEventQueue(me);
1068 }
1069 }
1070
1071 public void doLayout(int x, int y, int width, int height) {}
1072
1073 public void handleConfigureNotifyEvent(XEvent xev) {
1074 XConfigureEvent xe = xev.get_xconfigure();
1075
1076 // Due to the SubstructureNotifyMask we should process only those
1077 // events that belong to us.
1078 if (xe.get_window() != getWindow()) {
1079 return;
1080 }
1081
1082 Rectangle oldBounds = getBounds();
1083 super.handleConfigureNotifyEvent(xev);
1084 insLog.log(Level.FINER, "Configure, {0}, event disabled: {1}",
1085 new Object[] {xe, isEventDisabled(xev)});
1086 if (isEventDisabled(xev)) {
1087 return;
1088 }
1089
1090
1091 Rectangle bounds = getBounds();
1092 if (!bounds.getSize().equals(oldBounds.getSize())) {
1093 postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_RESIZED));
1094 }
1095 if (!bounds.getLocation().equals(oldBounds.getLocation())) {
1096 postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_MOVED));
1097 }
1098 }
1099
1100 public void handleMapNotifyEvent(XEvent xev) {
1101 super.handleMapNotifyEvent(xev);
1102 log.log(Level.FINE, "Mapped {0}", new Object[] {this});
1103 if (isEventDisabled(xev)) {
1104 return;
1105 }
1106
1107 if (xev.get_xany().get_window() != getWindow()) {
1108 return;
1109 }
1110
1111 ComponentEvent ce;
1112
1113 ce = new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_SHOWN);
1114 postEventToEventQueue(ce);
1115 }
1116
1117 public void handleUnmapNotifyEvent(XEvent xev) {
1118 super.handleUnmapNotifyEvent(xev);
1119 if (isEventDisabled(xev)) {
1120 return;
1121 }
1122 if (xev.get_xany().get_window() != getWindow()) {
1123 return;
1124 }
1125
1126 ComponentEvent ce;
1127
1128 ce = new ComponentEvent(target, ComponentEvent.COMPONENT_HIDDEN);
1129 postEventToEventQueue(ce);
1130 }
1131
1132 private void dumpKeysymArray(XKeyEvent ev) {
1133 keyEventLog.fine(" "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 0))+
1134 "\n "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 1))+
1135 "\n "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 2))+
1136 "\n "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 3)));
1137 }
1138 /**
1139 Return unicode character or 0 if no correspondent character found.
1140 Parameter is a keysym basically from keysymdef.h
1141 XXX: how about vendor keys? Is there some with Unicode value and not in the list?
1142 */
1143 int keysymToUnicode( long keysym, int state ) {
1144 return XKeysym.convertKeysym( keysym, state );
1145 }
1476
1477 public Point getLocationOnScreen() {
1478 synchronized (target.getTreeLock()) {
1479 Component comp = target;
1480
1481 while (comp != null && !(comp instanceof Window)) {
1482 comp = ComponentAccessor.getParent_NoClientCode(comp);
1483 }
1484
1485 // applets, embedded, etc - translate directly
1486 // XXX: override in subclass?
1487 if (comp == null || comp instanceof sun.awt.EmbeddedFrame) {
1488 return toGlobal(0, 0);
1489 }
1490
1491 XToolkit.awtLock();
1492 try {
1493 Object wpeer = XToolkit.targetToPeer(comp);
1494 if (wpeer == null
1495 || !(wpeer instanceof XDecoratedPeer)
1496 || !((XDecoratedPeer)wpeer).areBoundsAdjusting())
1497 {
1498 return toGlobal(0, 0);
1499 }
1500
1501 // wpeer is an XDecoratedPeer not yet fully adopted by WM
1502 Point pt = toOtherWindow(getContentWindow(),
1503 ((XDecoratedPeer)wpeer).getContentWindow(),
1504 0, 0);
1505
1506 if (pt == null) {
1507 pt = new Point(((XBaseWindow)wpeer).getAbsoluteX(), ((XBaseWindow)wpeer).getAbsoluteY());
1508 }
1509 pt.x += comp.getX();
1510 pt.y += comp.getY();
1511 return pt;
1512 } finally {
1513 XToolkit.awtUnlock();
1514 }
1515 }
1516 }
|