From c3659a46bdad915a19bdcd03583f15b6a372e41b Mon Sep 17 00:00:00 2001 From: megacz Date: Fri, 30 Jan 2004 06:50:19 +0000 Subject: [PATCH] 2002/08/24 22:50:45 darcs-hash:20040130065019-2ba56-2e29ea843d895b7c613a7e5304ae0786045b07b2.gz --- CHANGES | 2 + src/org/xwt/plat/POSIX.cc | 89 ++++++++++++++++++++++++--------------------- 2 files changed, 50 insertions(+), 41 deletions(-) diff --git a/CHANGES b/CHANGES index 18039a5..73c2879 100644 --- a/CHANGES +++ b/CHANGES @@ -391,4 +391,6 @@ 24-Aug megacz HTTP.java, SOAP.java: fixed bug which caused miscalculation of the Content-Length header. +24-Aug megacz POSIX.java: fixed cut/paste bug + diff --git a/src/org/xwt/plat/POSIX.cc b/src/org/xwt/plat/POSIX.cc index 720ed6c..919fc58 100644 --- a/src/org/xwt/plat/POSIX.cc +++ b/src/org/xwt/plat/POSIX.cc @@ -467,44 +467,6 @@ void org::xwt::plat::POSIX$X11Surface::dispatchEvent(gnu::gcj::RawData* ev) { } else if (e->type == FocusIn) { Focused(1); } else if (e->type == FocusOut) { Focused(0); - } else if (e->type == SelectionNotify) { - XSelectionEvent* xsn = (XSelectionEvent*)(e); - if (xsn->property == None) org::xwt::plat::POSIX::clipboard = JvNewStringLatin1("", 0); - else { - Atom returntype; - int returnformat; - unsigned long numitems; - unsigned char* ret; - unsigned long bytes_after; - XGetWindowProperty(display, xsn->requestor, xsn->property, 0, 4096, - True, AnyPropertyType, &returntype, &returnformat, - &numitems, &bytes_after, &ret); - org::xwt::plat::POSIX::clipboard = - (returntype == None ? JvNewStringLatin1("", 0) : JvNewStringLatin1((char*)ret, strlen((char*)ret))); - } - org::xwt::plat::POSIX::waiting_for_selection_event->release(); - - } else if (e->type == SelectionRequest) { - XSelectionRequestEvent* xsr = (XSelectionRequestEvent*)(e); - XSelectionEvent xsn; - xsn.type = SelectionNotify; - xsn.serial = xsr->serial; - xsn.send_event = True; - xsn.display = display; - xsn.requestor = xsr->requestor; - xsn.selection = xsr->selection; - xsn.target = xsr->target; - xsn.property = xsr->property; - xsn.time = xsr->time; - - int len = min(1024, JvGetStringUTFLength(org::xwt::plat::POSIX::clipboard)); - char buf[len + 1]; - JvGetStringUTFRegion(org::xwt::plat::POSIX::clipboard, 0, len, buf); - buf[len] = '\0'; - - XChangeProperty(display, xsr->requestor, xsr->property, xsr->target, 8, PropModeReplace, (unsigned char*)buf, len + 1); - XSendEvent(display, xsr->requestor, True, 0, (XEvent*)(&xsn)); - } else if (e->type == KeyPress || e->type == KeyRelease) { XKeyEvent *xbe = (XKeyEvent*)(e); @@ -686,13 +648,58 @@ void org::xwt::plat::POSIX::spawnChildProcess(JArray* cmd) { } } +static void dispatchSelectionEvent(XEvent* e) { + if (e->type == SelectionNotify) { + XSelectionEvent* xsn = (XSelectionEvent*)(e); + if (xsn->property == None) org::xwt::plat::POSIX::clipboard = JvNewStringLatin1("", 0); + else { + Atom returntype; + int returnformat; + unsigned long numitems; + unsigned char* ret; + unsigned long bytes_after; + XGetWindowProperty(display, xsn->requestor, xsn->property, 0, 4096, + True, AnyPropertyType, &returntype, &returnformat, + &numitems, &bytes_after, &ret); + org::xwt::plat::POSIX::clipboard = + (returntype == None ? JvNewStringLatin1("", 0) : JvNewStringLatin1((char*)ret, strlen((char*)ret))); + } + org::xwt::plat::POSIX::waiting_for_selection_event->release(); + + } else if (e->type == SelectionRequest) { + XSelectionRequestEvent* xsr = (XSelectionRequestEvent*)(e); + XSelectionEvent xsn; + xsn.type = SelectionNotify; + xsn.serial = xsr->serial; + xsn.send_event = True; + xsn.display = display; + xsn.requestor = xsr->requestor; + xsn.selection = xsr->selection; + xsn.target = xsr->target; + xsn.property = xsr->property; + xsn.time = xsr->time; + + int len = min(1024, JvGetStringUTFLength(org::xwt::plat::POSIX::clipboard)); + char buf[len + 1]; + JvGetStringUTFRegion(org::xwt::plat::POSIX::clipboard, 0, len, buf); + buf[len] = '\0'; + + XChangeProperty(display, xsr->requestor, xsr->property, xsr->target, 8, PropModeReplace, (unsigned char*)buf, len + 1); + XSendEvent(display, xsr->requestor, True, 0, (XEvent*)(&xsn)); + } +} + void org::xwt::plat::POSIX::eventThread() { XEvent e; while(true) { XNextEvent(display, &e); - org::xwt::plat::POSIX$X11Surface* surface = - (org::xwt::plat::POSIX$X11Surface*)windowToSurfaceMap->get(new java::lang::Long(((XAnyEvent*)&e)->window)); - if (surface != NULL) surface->dispatchEvent((gnu::gcj::RawData*)&e); + if (e.type == SelectionNotify || e.type == SelectionRequest) { + dispatchSelectionEvent(&e); + } else { + org::xwt::plat::POSIX$X11Surface* surface = + (org::xwt::plat::POSIX$X11Surface*)windowToSurfaceMap->get(new java::lang::Long(((XAnyEvent*)&e)->window)); + if (surface != NULL) surface->dispatchEvent((gnu::gcj::RawData*)&e); + } } } -- 1.7.10.4