List of usage examples for java.awt Event Event
Event
From source file:com.jcraft.weirdx.DDXWindowImpSwing.java
public void mouseEntered(MouseEvent e) { if (window != null && window.getFrame() != null) { java.awt.Window frame = window.getFrame(); if ((frame instanceof java.awt.Frame) && frame == e.getSource()) { try { if (window.isRealized()) { XWindow.setInputFocus(window.client, window.id, 1, (int) System.currentTimeMillis(), false); }/* w w w .j a v a 2s . c o m*/ } catch (Exception ee) { LOG.error(ee); } return; } } String str = CopyPaste.getString(); if (!CopyPaste.isOwner() && str != null) { synchronized (window.screen.root) { Property p = window.screen.root.getProperty(); while (p != null) { if (p.propertyName == 9) break; p = p.next; } if (p != null) { p.data = str.getBytes(); p.size = p.data.length; } } Selection sel = Selection.getSelection(1); // PRIMARY if (sel != null && sel.client != null) { int time = (int) System.currentTimeMillis(); Event event = new Event(); event.mkSelectionClear(time, sel.wid, sel.selection); try { sel.client.sendEvent(event, 1, Event.NoEventMask, Event.NoEventMask, null); } catch (Exception ee) { //System.out.println(ee); } ; sel.window = window.screen.root; sel.wid = window.screen.root.id; sel.lastTimeChanged = time; sel.client = null; } CopyPaste.setString(str); } if (window.id == window.screen.rootId) { return; } if (window.isMapped()) { requestFocus(); XWindow.focus.win = window.id; } int x = e.getX() + window.x; int y = e.getY() + window.y; XWindow.sprite.hot.x = x; XWindow.sprite.hot.y = y; int mod = e.getModifiers(); int state = 0; if ((mod & InputEvent.BUTTON1_MASK) != 0) state |= (1 << 8); if ((mod & InputEvent.BUTTON2_MASK) != 0) state |= (1 << 9); if ((mod & InputEvent.BUTTON3_MASK) != 0) state |= (1 << 10); if ((mod & InputEvent.SHIFT_MASK) != 0) state |= 1; if ((mod & InputEvent.CTRL_MASK) != 0) state |= 4; // alt -> state|=8; Client client = window.client; if (client == null || client == serverClient) return; event.mkEnterNotify(0, // Ancestor window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 0, // Normal 0x1 | 0x02 // focus|same-screen ); try { XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1); } catch (Exception ee) { } }
From source file:com.jcraft.weirdx.DDXWindowImp.java
public void mouseEntered(MouseEvent e) { if (window == null) return;//from w w w . ja va 2 s . c o m if (window.getFrame() != null) { java.awt.Window frame = window.getFrame(); if ((frame instanceof java.awt.Frame) && frame == e.getSource()) { try { if (window.isRealized()) { XWindow.setInputFocus(window.client, window.id, 1, (int) System.currentTimeMillis(), false); } } catch (Exception ee) { LOG.error(ee); } return; } } String str = CopyPaste.getString(); if (!CopyPaste.isOwner() && str != null) { synchronized (window.screen.root) { Property p = window.screen.root.getProperty(); while (p != null) { if (p.propertyName == 9) break; p = p.next; } if (p != null) { p.data = str.getBytes(); p.size = p.data.length; } } Selection sel = Selection.getSelection(1); // PRIMARY if (sel != null && sel.client != null) { int time = (int) System.currentTimeMillis(); Event event = new Event(); event.mkSelectionClear(time, sel.wid, sel.selection); try { sel.client.sendEvent(event, 1, Event.NoEventMask, Event.NoEventMask, null); } catch (Exception ee) { //System.out.println(ee); } ; sel.window = window.screen.root; sel.wid = window.screen.root.id; sel.lastTimeChanged = time; sel.client = null; } CopyPaste.setString(str); } if (window.id == window.screen.rootId) { return; } if (window.isMapped()) { requestFocus(); XWindow.focus.win = window.id; } int x = e.getX() + window.x; int y = e.getY() + window.y; XWindow.sprite.hot.x = x; XWindow.sprite.hot.y = y; int mod = e.getModifiers(); int state = 0; if ((mod & InputEvent.BUTTON1_MASK) != 0) state |= (1 << 8); if ((mod & InputEvent.BUTTON2_MASK) != 0) state |= (1 << 9); if ((mod & InputEvent.BUTTON3_MASK) != 0) state |= (1 << 10); if ((mod & InputEvent.SHIFT_MASK) != 0) state |= 1; if ((mod & InputEvent.CTRL_MASK) != 0) state |= 4; // alt -> state|=8; Client client = window.client; if (client == null || client == serverClient) return; event.mkEnterNotify(0, // Ancestor window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 0, // Normal 0x1 | 0x02 // focus|same-screen ); try { XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1); } catch (Exception ee) { } }
From source file:com.jcraft.weirdx.XWindow.java
private void crushTree() throws IOException { XWindow child, sib, cparent;//from w ww . j a va2 s. c o m if ((child = firstChild) == null) return; while (true) { if (child.firstChild != null) { child = child.firstChild; continue; } while (true) { cparent = child.parent; if (child.substrSend()) { Event event = new Event(); event.mkDestroyNotify(child.id, child.id); try { child.sendEvent(event, 1, null); } catch (Exception e) { //System.out.println("crush: exception -> "+e); } } try { XResource.freeResource(child.id, XResource.RT_WINDOW); } catch (Exception e) { //System.out.println("crush: exception -> "+e); } sib = child.nextSib; child.attr &= ~viewable; if ((child.attr & realized) != 0) { child.attr &= ~realized; child.attr |= visibility; child.ddxwindow.setVisible(false); if (screen.windowmode != WeirdX.InBrowser && child.hasFrame()) { child.getFrame().setVisible(false); } } try { child.free(); } catch (Exception e) { //System.out.println("crush: exception -> "+e); } if ((child = sib) != null) break; child = cparent; child.firstChild = null; child.lastChild = null; if (child == this) return; } } }
From source file:com.jcraft.weirdx.XWindow.java
void delete() throws IOException { synchronized (LOCK) { try {/*from w w w . j a v a 2s .c o m*/ unmapWindow(false); } catch (Exception e) { } try { crushTree(); } catch (Exception e) { } if (id != 0 && parent != null && substrSend()) { Event event = new Event(); event.mkDestroyNotify(id, id); try { sendEvent(event, 1, null); } catch (Exception e) { } } if (parent != null) { if (parent.firstChild == this) parent.firstChild = nextSib; if (parent.lastChild == this) parent.lastChild = prevSib; if (nextSib != null) nextSib.prevSib = prevSib; if (prevSib != null) prevSib.nextSib = nextSib; } parent = null; nextSib = null; prevSib = null; firstChild = null; lastChild = null; prevSib = null; try { free(); } catch (Exception e) { } } }
From source file:com.jcraft.weirdx.XWindow.java
private void unmapWindow(boolean fromConfigure) throws IOException { Screen screen = this.screen; boolean wasRealized = ((this.attr & realized) != 0); boolean wasViewable = ((this.attr & viewable) != 0); XWindow layerWin = this; if ((this.attr & mapped) == 0) return;//from w ww .j a va2 s . co m if (parent == null) return; if (substrSend()) { Event event = new Event(); event.mkUnmapNotify(id, (fromConfigure ? 1 : 0)); try { sendEvent(event, 1, null); } catch (Exception e) { } } this.attr &= ~mapped; if (wasRealized) { this.unrealizeTree(fromConfigure); } if (wasRealized && !fromConfigure) { restructured(); } }
From source file:com.jcraft.weirdx.XWindow.java
@SuppressWarnings("static-access") static void enter_leaveEvent(int type, int mode, int detail, XWindow win, int child) throws IOException { int mask;/* w w w .j a v a2 s . c o m*/ Grab grab = XWindow.grab; if (grab != null) { mask = (win == grab.window) ? grab.eventMask : 0; if ((grab.attr & grab.ownerEvents) != 0) { mask |= win.getEventMask(grab.getClient()); } } else { mask = win.eventMask | win.getOtherEventMask(); } if ((mask & Event.filters[type]) != 0) { Event event = new Event(); event.fixUpEventFromWindow(win, 0, sprite.hot.x, sprite.hot.y, false); int flags = 0; flags = (event.getSameScreen() != 0 ? 2 : 0); flags |= 1; mode = 0; event.mkPointer(type, detail, (int) System.currentTimeMillis(), child, sprite.hot.x, sprite.hot.y, sprite.hot.state, mode, flags); try { if (grab != null) { if (grab.getClient() != null) grab.getClient().sendEvent(event, 1, mask, Event.filters[type], grab); } else { win.sendEvent(event, 1, Event.filters[type], null, 0); } } catch (Exception e) { //System.out.println("enter_leaveEvent: exception -> "+e); } } if ((type == Event.EnterNotify) && ((mask & Event.KeymapStateMask) != 0)) { // KeymapNotify } }
From source file:com.jcraft.weirdx.XWindow.java
private void sendVisibilityNotify() throws IOException { Event event = new Event(); event.mkVisibilityNotify(id, (attr & visibility) >> visibilityOffset); sendEvent(event, 1, null);// ww w . java 2 s . com }
From source file:com.jcraft.weirdx.XWindow.java
private void resizeChildrenWinSize(int dx, int dy, int dw, int dh) throws IOException { boolean resized = (dw != 0 || dh != 0); for (XWindow sib = firstChild; sib != null; sib = sib.nextSib) { if (resized && (((sib.attr & winGravity) >> winGravityOffset) > NorthWestGravity)) { int newx = sib.origin.x; int newy = sib.origin.y; gravityTranslate(newx, newy, newx - dx, newy - dy, dw, dh, (sib.attr & winGravity) >> winGravityOffset, gpoint); if (gpoint.x != sib.origin.x || gpoint.y != sib.origin.y) { Event event = new Event(); event.mkGravityNotify(sib.id, sib.id, gpoint.x - sib.borderWidth, gpoint.y - sib.borderWidth); sib.sendEvent(event, 1, null); sib.origin.x = gpoint.x; sib.origin.y = gpoint.y; }//from w w w . j a va 2 s.c om } sib.x = x + sib.origin.x; sib.y = y + sib.origin.y; if (sib.ddxwindow != null) // ?? sib.ddxwindow.setLocation(sib.origin.x - sib.borderWidth + sib.parent.borderWidth, sib.origin.y - sib.borderWidth + sib.parent.borderWidth); XWindow child = sib.firstChild; if (child != null) { while (true) { child.x = child.parent.x + child.origin.x; child.y = child.parent.y + child.origin.y; if (child.ddxwindow != null) // ?? child.ddxwindow.setLocation(child.origin.x - child.borderWidth + child.parent.borderWidth, child.origin.y - child.borderWidth + child.parent.borderWidth); if (child.firstChild != null) { child = child.firstChild; continue; } while (child.nextSib == null && (child != sib)) child = child.parent; if (child == sib) break; child = child.nextSib; } } } }
From source file:com.jcraft.weirdx.XWindow.java
void sendFocusEvent(Client c, int type, int mode, int detail) throws IOException { Event event = (c != null) ? c.cevent : new Event(); if (type == Event.FocusIn) { event.mkFocusIn(detail, id, mode); } else if (type == Event.FocusOut) { event.mkFocusOut(detail, id, mode); } else {/*from w w w .j av a 2s . co m*/ return; } sendEvent(event, 1, Event.filters[type], null, 0); }
From source file:com.jcraft.weirdx.XWindow.java
private void addWindowListener(java.awt.Frame foo) { final java.awt.Frame frame = foo; frame.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosed(java.awt.event.WindowEvent e) { }//w ww. j a v a2s. c o m public void windowClosing(java.awt.event.WindowEvent e) { int message_type = XAtom.find("WM_PROTOCOLS"); int del = XAtom.find("WM_DELETE_WINDOW"); synchronized (XWindow.LOCK) { Property p = getProperty(); while (p != null) { if (p.propertyName == message_type) break; p = p.next; } if (p != null && p.data != null) { } else { try { getClient().closeDown(); } catch (Exception ee) { } return; } } if (message_type == 0 || del == 0) return; Event event = new Event(); event.mkClientMessage(id, message_type); byte[] eb = event.event; eb[1] = 32; eb[12] = (byte) (del >>> 24); //protocol eb[13] = (byte) (del >>> 16); eb[14] = (byte) (del >>> 8); eb[15] = (byte) (del); int tm = (int) System.currentTimeMillis(); eb[16] = (byte) (tm >>> 24); //time eb[17] = (byte) (tm >>> 16); eb[18] = (byte) (tm >>> 8); eb[19] = (byte) (tm); eb[20] = eb[21] = eb[22] = eb[23] = 0; eb[24] = eb[25] = eb[26] = eb[27] = 0; eb[28] = eb[29] = eb[30] = eb[31] = 0; eb[0] |= 0x80; try { sendEvent(event, 1, Event.NoEventMask, null, 0); } catch (Exception ee) { } } }); }