public void dispatchEvent(XEvent xev) { if (eventLog.isLoggable(Level.FINEST)) eventLog.finest(xev.toString()); int type = xev.get_type(); if (isDisposed()) { return; } switch (type) { case VisibilityNotify: handleVisibilityEvent(xev); break; case ClientMessage: handleClientMessage(xev); break; case Expose: case GraphicsExpose: handleExposeEvent(xev); break; case ButtonPress: case ButtonRelease: handleButtonPressRelease(xev); break; case MotionNotify: handleMotionNotify(xev); break; case KeyPress: handleKeyPress(xev); break; case KeyRelease: handleKeyRelease(xev); break; case EnterNotify: case LeaveNotify: handleXCrossingEvent(xev); break; case ConfigureNotify: handleConfigureNotifyEvent(xev); break; case MapNotify: handleMapNotifyEvent(xev); break; case UnmapNotify: handleUnmapNotifyEvent(xev); break; case ReparentNotify: handleReparentNotifyEvent(xev); break; case PropertyNotify: handlePropertyNotify(xev); break; case DestroyNotify: handleDestroyNotify(xev); break; case CreateNotify: handleCreateNotify(xev); break; } }
private boolean processProxyModeEvent(XEvent ev) { if (getProxyModeSourceWindow() == 0) { return false; } if (ev.get_type() != (int) XConstants.ClientMessage) { return false; } if (logger.isLoggable(PlatformLogger.Level.FINEST)) { logger.finest(" proxyModeSourceWindow=" + getProxyModeSourceWindow() + " ev=" + ev); } XClientMessageEvent xclient = ev.get_xclient(); Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols(); while (dragProtocols.hasNext()) { XDragSourceProtocol dragProtocol = (XDragSourceProtocol) dragProtocols.next(); if (dragProtocol.processProxyModeEvent(xclient, getProxyModeSourceWindow())) { return true; } } return false; }
void handleConfigureNotify(XEvent xev) { if (isXEmbedActive()) { XConfigureEvent ev = xev.get_xconfigure(); if (xembedLog.isLoggable(PlatformLogger.FINER)) xembedLog.finer("Bounds change on client: " + ev); if (xev.get_xany().get_window() == handle) { childResized(); } } }
public void dispatchEvent(XEvent ev) { super.dispatchEvent(ev); switch (ev.get_type()) { case XConstants.CreateNotify: XCreateWindowEvent cr = ev.get_xcreatewindow(); if (xembedLog.isLoggable(PlatformLogger.FINEST)) { xembedLog.finest("Message on embedder: " + cr); } if (xembedLog.isLoggable(PlatformLogger.FINER)) { xembedLog.finer( "Create notify for parent " + Long.toHexString(cr.get_parent()) + ", window " + Long.toHexString(cr.get_window())); } embedChild(cr.get_window()); break; case XConstants.DestroyNotify: XDestroyWindowEvent dn = ev.get_xdestroywindow(); if (xembedLog.isLoggable(PlatformLogger.FINEST)) { xembedLog.finest("Message on embedder: " + dn); } if (xembedLog.isLoggable(PlatformLogger.FINER)) { xembedLog.finer("Destroy notify for parent: " + dn); } childDestroyed(); break; case XConstants.ReparentNotify: XReparentEvent rep = ev.get_xreparent(); if (xembedLog.isLoggable(PlatformLogger.FINEST)) { xembedLog.finest("Message on embedder: " + rep); } if (xembedLog.isLoggable(PlatformLogger.FINER)) { xembedLog.finer( "Reparent notify for parent " + Long.toHexString(rep.get_parent()) + ", window " + Long.toHexString(rep.get_window()) + ", event " + Long.toHexString(rep.get_event())); } if (rep.get_parent() == getWindow()) { // Reparented into us - embed it embedChild(rep.get_window()); } else { // Reparented out of us - detach it childDestroyed(); } break; } }
public void handleConfigureNotifyEvent(XEvent xev) { assert (SunToolkit.isAWTLockHeldByCurrentThread()); XConfigureEvent xe = xev.get_xconfigure(); if (xembedLog.isLoggable(PlatformLogger.Level.FINE)) { xembedLog.fine(xe.toString()); } // fix for 5063031 // if we use super.handleConfigureNotifyEvent() we would get wrong // size and position because embedded frame really is NOT a decorated one checkIfOnNewScreen( toGlobal(new Rectangle(xe.get_x(), xe.get_y(), xe.get_width(), xe.get_height()))); Rectangle oldBounds = getBounds(); synchronized (getStateLock()) { x = xe.get_x(); y = xe.get_y(); width = xe.get_width(); height = xe.get_height(); dimensions.setClientSize(width, height); dimensions.setLocation(x, y); } if (!getLocation().equals(oldBounds.getLocation())) { handleMoved(dimensions); } reconfigureContentWindow(dimensions); }
/** Activate automatic grab on first ButtonPress, deactivate on full mouse release */ public void handleButtonPressRelease(XEvent xev) { XButtonEvent xbe = xev.get_xbutton(); final int buttonState = xbe.get_state() & (Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask); switch (xev.get_type()) { case ButtonPress: if (buttonState == 0) { XAwtState.setAutoGrabWindow(this); } break; case ButtonRelease: if (isFullRelease(buttonState, xbe.get_button())) { XAwtState.setAutoGrabWindow(null); } break; } }
public void dispatchEvent(XEvent ev) { if (ev.get_type() == XConstants.SelectionNotify) { final XSelectionEvent xse = ev.get_xselection(); XClipboard clipboard = null; synchronized (XClipboard.classLock) { if (targetsAtom2Clipboard != null && !targetsAtom2Clipboard.isEmpty()) { XToolkit.removeEventDispatcher(XWindow.getXAWTRootWindow().getWindow(), this); return; } final long propertyAtom = xse.get_property(); clipboard = targetsAtom2Clipboard.get(propertyAtom); } if (null != clipboard) { clipboard.checkChange(xse); } } }
public void handleCreateNotify(XEvent xev) { XAnyEvent xany = xev.get_xany(); if (xany.get_window() != getWindow()) { synchronized (getStateLock()) { children.add(xany.get_window()); } } }
public void handlePropertyNotify(XEvent xev) { XPropertyEvent msg = xev.get_xproperty(); if (XPropertyCache.isCachingSupported()) { XPropertyCache.clearCache(window, XAtom.get(msg.get_atom())); } if (eventLog.isLoggable(Level.FINER)) { eventLog.log(Level.FINER, "{0}", new Object[] {String.valueOf(msg)}); } }
public void handleFocusEvent(XEvent xev) { super.handleFocusEvent(xev); XFocusChangeEvent xfe = xev.get_xfocus(); // If we somehow received focus events forward it instead to proxy // FIXME: Shouldn't we instead check for inferrior? focusLog.finer("Received focus event on shell: " + xfe); // focusProxy.xRequestFocus(); }
/** * Dispatches event to the grab Window or event source window depending on whether the grab is * active and on the event type */ static void dispatchToWindow(XEvent ev) { XBaseWindow target = XAwtState.getGrabWindow(); if (target == null || !isGrabbedEvent(ev, target)) { target = XToolkit.windowToXWindow(ev.get_xany().get_window()); } if (target != null && target.checkInitialised()) { target.dispatchEvent(ev); } }
protected boolean isEventDisabled(XEvent e) { if (embedder != null && embedder.isActive()) { switch (e.get_type()) { case XConstants.FocusIn: case XConstants.FocusOut: return true; } } return super.isEventDisabled(e); }
public void handleConfigureNotifyEvent(XEvent xev) { XConfigureEvent xe = xev.get_xconfigure(); if (insLog.isLoggable(Level.FINER)) { insLog.log(Level.FINER, "Configure, {0}", new Object[] {String.valueOf(xe)}); } x = xe.get_x(); y = xe.get_y(); width = xe.get_width(); height = xe.get_height(); }
/** * ************************************************************************************* END OF I * N S E T S C O D E * ************************************************************************************ */ protected boolean isEventDisabled(XEvent e) { switch (e.get_type()) { // Do not generate MOVED/RESIZED events since we generate them by ourselves case ConfigureNotify: return true; case EnterNotify: case LeaveNotify: // Disable crossing event on outer borders of Frame so // we receive only one set of cross notifications(first set is from content window) return true; default: return super.isEventDisabled(e); } }
public void handleDestroyNotify(XEvent xev) { XAnyEvent xany = xev.get_xany(); if (xany.get_window() == getWindow()) { XToolkit.removeFromWinMap(getWindow(), this); if (XPropertyCache.isCachingSupported()) { XPropertyCache.clearCache(getWindow()); } } if (xany.get_window() != getWindow()) { synchronized (getStateLock()) { children.remove(xany.get_window()); } } }
public void dispatchEvent(XEvent xev) { int type = xev.get_type(); switch (type) { case XConstants.PropertyNotify: handlePropertyNotify(xev); break; case XConstants.ConfigureNotify: handleConfigureNotify(xev); break; case XConstants.ClientMessage: handleClientMessage(xev); break; } }
public void handleClientMessage(XEvent xev) { super.handleClientMessage(xev); XClientMessageEvent cl = xev.get_xclient(); if ((wm_protocols != null) && (cl.get_message_type() == wm_protocols.getAtom())) { if (cl.get_data(0) == wm_delete_window.getAtom()) { handleQuit(); } else if (cl.get_data(0) == wm_take_focus.getAtom()) { handleWmTakeFocus(cl); } } else if (cl.get_message_type() == resize_request.getAtom()) { reshape( (int) cl.get_data(0), (int) cl.get_data(1), (int) cl.get_data(2), (int) cl.get_data(3), (int) cl.get_data(4), true); } }
static boolean isGrabbedEvent(XEvent ev, XBaseWindow target) { switch (ev.get_type()) { case ButtonPress: case ButtonRelease: case MotionNotify: case KeyPress: case KeyRelease: return true; case LeaveNotify: case EnterNotify: // We shouldn't dispatch this events to the grabbed components (see 6317481) // But this logic is important if the grabbed component is top-level (see realSync) return (target instanceof XWindowPeer); default: return false; } }
protected boolean isEventDisabled(XEvent e) { switch (e.get_type()) { // Override parentFrame to receive MouseEnter/Exit case XConstants.EnterNotify: case XConstants.LeaveNotify: return false; // We handle ConfigureNotify specifically in XDecoratedPeer case XConstants.ConfigureNotify: return true; // We don't want SHOWN/HIDDEN on content window since it will duplicate XDecoratedPeer case XConstants.MapNotify: case XConstants.UnmapNotify: return true; default: return super.isEventDisabled(e) || parentFrame.isEventDisabled(e); } }
public void handlePropertyNotify(XEvent xev) { if (isXEmbedActive()) { XPropertyEvent ev = xev.get_xproperty(); if (xembedLog.isLoggable(PlatformLogger.FINER)) xembedLog.finer("Property change on client: " + ev); if (ev.get_atom() == XAtom.XA_WM_NORMAL_HINTS) { childResized(); } else if (ev.get_atom() == XEmbedInfo.getAtom()) { processXEmbedInfo(); } else if (ev.get_atom() == XDnDConstants.XA_XdndAware.getAtom()) { XDropTargetRegistry.getRegistry().unregisterXEmbedClient(getWindow(), xembed.handle); if (ev.get_state() == XConstants.PropertyNewValue) { XDropTargetRegistry.getRegistry().registerXEmbedClient(getWindow(), xembed.handle); } } } else { xembedLog.finer("XEmbed is not active"); } }
public void handleClientMessage(XEvent xev) { super.handleClientMessage(xev); XClientMessageEvent msg = xev.get_xclient(); if (xembedLog.isLoggable(PlatformLogger.FINER)) xembedLog.finer("Client message to embedder: " + msg); if (msg.get_message_type() == xembed.XEmbed.getAtom()) { if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine(xembed.XEmbedMessageToString(msg)); } if (isXEmbedActive()) { switch ((int) msg.get_data(1)) { case XEMBED_REQUEST_FOCUS: requestXEmbedFocus(); break; case XEMBED_FOCUS_NEXT: focusNext(); break; case XEMBED_FOCUS_PREV: focusPrev(); break; case XEMBED_REGISTER_ACCELERATOR: registerAccelerator(msg.get_data(2), msg.get_data(3), msg.get_data(4)); break; case XEMBED_UNREGISTER_ACCELERATOR: unregisterAccelerator(msg.get_data(2)); break; case NON_STANDARD_XEMBED_GTK_GRAB_KEY: grabKey(msg.get_data(3), msg.get_data(4)); break; case NON_STANDARD_XEMBED_GTK_UNGRAB_KEY: ungrabKey(msg.get_data(3), msg.get_data(4)); break; } } else { xembedLog.finer("But XEmbed is not Active!"); } }
public void handleConfigureNotifyEvent(XEvent xev) { assert (SunToolkit.isAWTLockHeldByCurrentThread()); XConfigureEvent xe = xev.get_xconfigure(); if (insLog.isLoggable(Level.FINE)) { insLog.log(Level.FINE, "Configure notify {0}", new Object[] {String.valueOf(xe)}); } // XXX: should really only consider synthetic events, but if (isReparented()) { configure_seen = true; } if (!isMaximized() && (xe.get_serial() == reparent_serial || xe.get_window() != getShell()) && !no_reparent_artifacts) { insLog.fine("- reparent artifact, skipping"); return; } no_reparent_artifacts = false; /** * When there is a WM we receive some CN before being visible and after. We should skip all CN * which are before being visible, because we assume the gravity is in action while it is not * yet. * * <p>When there is no WM we receive CN only _before_ being visible. We should process these * CNs. */ if (!isVisible() && XWM.getWMID() != XWM.NO_WM) { insLog.fine(" - not visible, skipping"); return; } /* * Some window managers configure before we are reparented and * the send event flag is set! ugh... (Enlighetenment for one, * possibly MWM as well). If we haven't been reparented yet * this is just the WM shuffling us into position. Ignore * it!!!! or we wind up in a bogus location. */ int runningWM = XWM.getWMID(); if (insLog.isLoggable(Level.FINE)) { insLog.log( Level.FINE, "reparented={0}, visible={1}, WM={2}, decorations={3}", new Object[] {isReparented(), isVisible(), runningWM, getDecorations()}); } if (!isReparented() && isVisible() && runningWM != XWM.NO_WM && !XWM.isNonReparentingWM() && getDecorations() != winAttr.AWT_DECOR_NONE) { insLog.fine("- visible but not reparented, skipping"); return; } // Last chance to correct insets if (!insets_corrected && getDecorations() != winAttr.AWT_DECOR_NONE) { long parent = XlibUtil.getParentWindow(window); Insets correctWM = (parent != -1) ? XWM.getWM().getInsets(this, window, parent) : null; if (insLog.isLoggable(Level.FINER)) { if (correctWM != null) { insLog.finer("Configure notify - insets : " + correctWM); } else { insLog.finer("Configure notify - insets are still not available"); } } if (correctWM != null) { handleCorrectInsets(correctWM); } else { // Only one attempt to correct insets is made (to lower risk) // if insets are still not available we simply set the flag insets_corrected = true; } } updateChildrenSizes(); // Bounds of the window Rectangle targetBounds = new Rectangle( ComponentAccessor.getX((Component) target), ComponentAccessor.getY((Component) target), ComponentAccessor.getWidth((Component) target), ComponentAccessor.getHeight((Component) target)); Point newLocation = targetBounds.getLocation(); if (xe.get_send_event() || runningWM == XWM.NO_WM || XWM.isNonReparentingWM()) { // Location, Client size + insets newLocation = new Point(xe.get_x() - currentInsets.left, xe.get_y() - currentInsets.top); } else { // CDE/MWM/Metacity/Sawfish bug: if shell is resized using // top or left border, we don't receive synthetic // ConfigureNotify, only the one from X with zero // coordinates. This is the workaround to get real // location, 6261336 switch (XWM.getWMID()) { case XWM.CDE_WM: case XWM.MOTIF_WM: case XWM.METACITY_WM: case XWM.SAWFISH_WM: { Point xlocation = queryXLocation(); if (log.isLoggable(Level.FINE)) { log.log(Level.FINE, "New X location: {0}", new Object[] {String.valueOf(xlocation)}); } if (xlocation != null) { newLocation = xlocation; } break; } default: break; } } WindowDimensions newDimensions = new WindowDimensions( newLocation, new Dimension(xe.get_width(), xe.get_height()), copy(currentInsets), true); if (insLog.isLoggable(Level.FINER)) { insLog.log( Level.FINER, "Insets are {0}, new dimensions {1}", new Object[] {String.valueOf(currentInsets), String.valueOf(newDimensions)}); } checkIfOnNewScreen(newDimensions.getBounds()); Point oldLocation = getLocation(); dimensions = newDimensions; if (!newLocation.equals(oldLocation)) { handleMoved(newDimensions); } reconfigureContentWindow(newDimensions); updateChildrenSizes(); }
public void handleReparentNotifyEvent(XEvent xev) { XReparentEvent xe = xev.get_xreparent(); if (insLog.isLoggable(Level.FINE)) insLog.fine(xe.toString()); reparent_serial = xe.get_serial(); XToolkit.awtLock(); try { long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber()); if (isEmbedded()) { setReparented(true); insets_corrected = true; return; } Component t = (Component) target; if (getDecorations() == winAttr.AWT_DECOR_NONE) { setReparented(true); insets_corrected = true; reshape(dimensions, SET_SIZE, false); } else if (xe.get_parent() == root) { configure_seen = false; insets_corrected = false; /* * We can be repareted to root for two reasons: * . setVisible(false) * . WM exited */ if (isVisible()) { /* WM exited */ /* Work around 4775545 */ XWM.getWM().unshadeKludge(this); insLog.fine("- WM exited"); } else { insLog.fine(" - reparent due to hide"); } } else { /* reparented to WM frame, figure out our insets */ setReparented(true); insets_corrected = false; // Check if we have insets provided by the WM Insets correctWM = getWMSetInsets(null); if (correctWM != null) { if (insLog.isLoggable(Level.FINER)) { insLog.log( Level.FINER, "wm-provided insets {0}", new Object[] {String.valueOf(correctWM)}); } // If these insets are equal to our current insets - no actions are necessary Insets dimInsets = dimensions.getInsets(); if (correctWM.equals(dimInsets)) { insLog.finer("Insets are the same as estimated - no additional reshapes necessary"); no_reparent_artifacts = true; insets_corrected = true; applyGuessedInsets(); return; } } else { correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent()); if (correctWM != null) { if (insLog.isLoggable(Level.FINER)) { insLog.log(Level.FINER, "correctWM {0}", new Object[] {String.valueOf(correctWM)}); } } else { insLog.log( Level.FINER, "correctWM insets are not available, waiting for configureNotify"); } } if (correctWM != null) { handleCorrectInsets(correctWM); } } } finally { XToolkit.awtUnlock(); } }
/** * The caller must own awtLock. * * @returns true if the even was processed and shouldn't be passed along. */ private boolean doProcessEvent(XEvent ev) { assert XToolkit.isAWTLockHeldByCurrentThread(); if (processProxyModeEvent(ev)) { return true; } if (!dndInProgress) { return false; } switch (ev.get_type()) { case XConstants.ClientMessage: { XClientMessageEvent xclient = ev.get_xclient(); return processClientMessage(xclient); } case XConstants.DestroyNotify: { XDestroyWindowEvent xde = ev.get_xdestroywindow(); /* Target crashed during drop processing - cleanup. */ if (!dragInProgress && dragProtocol != null && xde.get_window() == dragProtocol.getTargetWindow()) { cleanup(XConstants.CurrentTime); return true; } /* Pass along */ return false; } } if (!dragInProgress) { return false; } /* Process drag-only messages. */ switch (ev.get_type()) { case XConstants.KeyRelease: case XConstants.KeyPress: { XKeyEvent xkey = ev.get_xkey(); long keysym = XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), xkey.get_keycode(), 0); switch ((int) keysym) { case (int) XKeySymConstants.XK_Escape: { if (ev.get_type() == (int) XConstants.KeyRelease) { cleanup(xkey.get_time()); } break; } case (int) XKeySymConstants.XK_Control_R: case (int) XKeySymConstants.XK_Control_L: case (int) XKeySymConstants.XK_Shift_R: case (int) XKeySymConstants.XK_Shift_L: { XlibWrapper.XQueryPointer( XToolkit.getDisplay(), xkey.get_root(), XlibWrapper.larg1, // root XlibWrapper.larg2, // subwindow XlibWrapper.larg3, // x_root XlibWrapper.larg4, // y_root XlibWrapper.larg5, // x XlibWrapper.larg6, // y XlibWrapper.larg7); // modifiers XMotionEvent xmotion = new XMotionEvent(); try { xmotion.set_type(XConstants.MotionNotify); xmotion.set_serial(xkey.get_serial()); xmotion.set_send_event(xkey.get_send_event()); xmotion.set_display(xkey.get_display()); xmotion.set_window(xkey.get_window()); xmotion.set_root(xkey.get_root()); xmotion.set_subwindow(xkey.get_subwindow()); xmotion.set_time(xkey.get_time()); xmotion.set_x(xkey.get_x()); xmotion.set_y(xkey.get_y()); xmotion.set_x_root(xkey.get_x_root()); xmotion.set_y_root(xkey.get_y_root()); xmotion.set_state((int) Native.getLong(XlibWrapper.larg7)); // we do not use this field, so it's unset for now // xmotion.set_is_hint(???); xmotion.set_same_screen(xkey.get_same_screen()); // It's safe to use key event as motion event since we use only their common // fields. processMouseMove(xmotion); } finally { xmotion.dispose(); } break; } } return true; } case XConstants.ButtonPress: return true; case XConstants.MotionNotify: processMouseMove(ev.get_xmotion()); return true; case XConstants.ButtonRelease: { XButtonEvent xbutton = ev.get_xbutton(); /* * Ignore the buttons above 20 due to the bit limit for * InputEvent.BUTTON_DOWN_MASK. * One more bit is reserved for FIRST_HIGH_BIT. */ if (xbutton.get_button() > SunToolkit.MAX_BUTTONS_SUPPORTED) { return true; } /* * On some X servers it could happen that ButtonRelease coordinates * differ from the latest MotionNotify coordinates, so we need to * process it as a mouse motion. */ XMotionEvent xmotion = new XMotionEvent(); try { xmotion.set_type(XConstants.MotionNotify); xmotion.set_serial(xbutton.get_serial()); xmotion.set_send_event(xbutton.get_send_event()); xmotion.set_display(xbutton.get_display()); xmotion.set_window(xbutton.get_window()); xmotion.set_root(xbutton.get_root()); xmotion.set_subwindow(xbutton.get_subwindow()); xmotion.set_time(xbutton.get_time()); xmotion.set_x(xbutton.get_x()); xmotion.set_y(xbutton.get_y()); xmotion.set_x_root(xbutton.get_x_root()); xmotion.set_y_root(xbutton.get_y_root()); xmotion.set_state(xbutton.get_state()); // we do not use this field, so it's unset for now // xmotion.set_is_hint(???); xmotion.set_same_screen(xbutton.get_same_screen()); // It's safe to use key event as motion event since we use only their common fields. processMouseMove(xmotion); } finally { xmotion.dispose(); } if (xbutton.get_button() == XConstants.buttons[0] || xbutton.get_button() == XConstants.buttons[1]) { // drag is initiated with Button1 or Button2 pressed and // ended on release of either of these buttons (as the same // behavior was with our old Motif DnD-based implementation) removeDnDGrab(xbutton.get_time()); dragInProgress = false; if (dragProtocol != null && targetAction != DnDConstants.ACTION_NONE) { /* * ACTION_NONE indicates that either the drop target rejects the * drop or it haven't responded yet. The latter could happen in * case of fast drag, slow target-server connection or slow * drag notifications processing on the target side. */ processDrop(xbutton); } else { cleanup(xbutton.get_time()); } } return true; } } return false; }
public void handleReparentNotifyEvent(XEvent xev) { if (eventLog.isLoggable(Level.FINER)) { XReparentEvent msg = xev.get_xreparent(); eventLog.finer(msg.toString()); } }
public void handleClientMessage(XEvent xev) { if (eventLog.isLoggable(Level.FINER)) { XClientMessageEvent msg = xev.get_xclient(); eventLog.finer(msg.toString()); } }