[kaffe] CVS kaffe (jserv): Qt AWT backend cleanup

Kaffe CVS cvs-commits at kaffe.org
Fri Jul 9 19:05:28 PDT 2004


PatchSet 4921 
Date: 2004/07/10 01:58:26
Author: jserv
Branch: HEAD
Tag: (none) 
Log:
Qt AWT backend cleanup

	* libraries/clib/awt/qt/imggif.cc,
	libraries/clib/awt/qt/imgjpeg.cc,
	libraries/clib/awt/qt/imgpng.cc:
	removed.

	* libraries/clib/awt/qt/Makefile.am,
	libraries/clib/awt/qt/Makefile.in:
	Remove useless imggif.cc, imgjpeg.cc, and imgpng.cc
	because Qt AWT backend handles images via Qt toolkit.
	Update copyright note.

	* libraries/clib/awt/qt/cbd.cc,
	libraries/clib/awt/qt/clr.cc,
	libraries/clib/awt/qt/evt.cc,
	libraries/clib/awt/qt/evt.h,
	libraries/clib/awt/qt/fnt.cc,
	libraries/clib/awt/qt/gra.cc,
	libraries/clib/awt/qt/img.cc,
	libraries/clib/awt/qt/keysyms.h,
	libraries/clib/awt/qt/tlk.cc,
	libraries/clib/awt/qt/tlkprops.h,
	libraries/clib/awt/qt/toolkit.h,
	libraries/clib/awt/qt/wnd.cc:
	Clean up X specific comments and macros for advanced
	refactoring.
	Better way to dump debug messages.
	Update copyright note.

Members: 
	ChangeLog:1.2487->1.2488 
	libraries/clib/awt/qt/Makefile.am:1.8->1.9 
	libraries/clib/awt/qt/Makefile.in:1.58->1.59 
	libraries/clib/awt/qt/cbd.cc:1.2->1.3 
	libraries/clib/awt/qt/clr.cc:1.3->1.4 
	libraries/clib/awt/qt/evt.cc:1.5->1.6 
	libraries/clib/awt/qt/evt.h:1.1->1.2 
	libraries/clib/awt/qt/fnt.cc:1.3->1.4 
	libraries/clib/awt/qt/gra.cc:1.2->1.3 
	libraries/clib/awt/qt/img.cc:1.4->1.5 
	libraries/clib/awt/qt/keysyms.h:1.2->1.3 
	libraries/clib/awt/qt/tlk.cc:1.3->1.4 
	libraries/clib/awt/qt/tlkprops.h:1.1->1.2 
	libraries/clib/awt/qt/toolkit.h:1.3->1.4 
	libraries/clib/awt/qt/wnd.cc:1.3->1.4 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2487 kaffe/ChangeLog:1.2488
--- kaffe/ChangeLog:1.2487	Fri Jul  9 16:19:21 2004
+++ kaffe/ChangeLog	Sat Jul 10 01:58:26 2004
@@ -1,3 +1,33 @@
+2004-07-10  Jim Huang  <jserv at kaffe.org>
+
+	* libraries/clib/awt/qt/imggif.cc,
+	libraries/clib/awt/qt/imgjpeg.cc,
+	libraries/clib/awt/qt/imgpng.cc:
+	removed.
+	
+	* libraries/clib/awt/qt/Makefile.am,
+	libraries/clib/awt/qt/Makefile.in:
+	Remove useless imggif.cc, imgjpeg.cc, and imgpng.cc
+	because Qt AWT backend handles images via Qt toolkit.
+	Update copyright note.
+
+	* libraries/clib/awt/qt/cbd.cc,
+	libraries/clib/awt/qt/clr.cc,
+	libraries/clib/awt/qt/evt.cc,
+	libraries/clib/awt/qt/evt.h,
+	libraries/clib/awt/qt/fnt.cc,
+	libraries/clib/awt/qt/gra.cc,
+	libraries/clib/awt/qt/img.cc,
+	libraries/clib/awt/qt/keysyms.h,
+	libraries/clib/awt/qt/tlk.cc,
+	libraries/clib/awt/qt/tlkprops.h,
+	libraries/clib/awt/qt/toolkit.h,
+	libraries/clib/awt/qt/wnd.cc:
+	Clean up X specific comments and macros for advanced
+	refactoring.
+	Better way to dump debug messages.
+	Update copyright note.
+
 2004-07-09  Dalibor Topic  <robilad at kaffe.org>
 
 	* libraries/javalib/profiles/default/coreawt.files,
Index: kaffe/libraries/clib/awt/qt/Makefile.am
diff -u kaffe/libraries/clib/awt/qt/Makefile.am:1.8 kaffe/libraries/clib/awt/qt/Makefile.am:1.9
--- kaffe/libraries/clib/awt/qt/Makefile.am:1.8	Thu Jan 15 02:29:42 2004
+++ kaffe/libraries/clib/awt/qt/Makefile.am	Sat Jul 10 01:58:25 2004
@@ -1,8 +1,11 @@
-# QT-embedded-based AWT support for standard Java libraries
+# Qt AWT backend for Kaffe
 #
 # Copyright (c) 2001-2002
-#	Dialogue Technologies, Inc.  All rights reserved.
-# Author: Murphy Chen, Ken-Hao Liu
+#	Murphy Chen, Ken-Hao Liu from Dialogue Technologies, Inc.
+#	All rights reserved.
+#
+# Copyright (c) 2002, 2003, 2004
+#	Kaffe.org contributors, see ChangeLog for details.  All rights reserved.
 #
 # See the file "license.terms" for information on usage and redistribution 
 # of this file. 
@@ -50,9 +53,6 @@
 
 CLEANFILES = so_locations $(BUILT_SOURCES)
 
-EXTRA_DIST = evt.h \
-	imggif.cc \
-	imgjpeg.cc \
-	imgpng.cc
+EXTRA_DIST = evt.h
 
 
Index: kaffe/libraries/clib/awt/qt/Makefile.in
diff -u kaffe/libraries/clib/awt/qt/Makefile.in:1.58 kaffe/libraries/clib/awt/qt/Makefile.in:1.59
--- kaffe/libraries/clib/awt/qt/Makefile.in:1.58	Wed Jul  7 19:34:42 2004
+++ kaffe/libraries/clib/awt/qt/Makefile.in	Sat Jul 10 01:58:25 2004
@@ -14,14 +14,17 @@
 
 @SET_MAKE@
 
-# QT-embedded-based AWT support for standard Java libraries
+# Qt AWT backend for Kaffe
 #
 # Copyright (c) 2001-2002
-#	Dialogue Technologies, Inc.  All rights reserved.
-# Author: Murphy Chen, Ken-Hao Liu
+#	Murphy Chen, Ken-Hao Liu from Dialogue Technologies, Inc.
+#	All rights reserved.
 #
-# See the file "license.terms" for information on usage and redistribution 
-# of this file. 
+# Copyright (c) 2002, 2003, 2004
+#	Kaffe.org contributors, see ChangeLog for details.  All rights reserved.
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file.
 
 
 SOURCES = $(libawt_la_SOURCES) $(nodist_libawt_la_SOURCES)
@@ -387,10 +390,7 @@
 
 BUILT_SOURCES = $(libawt_la_MOC)
 CLEANFILES = so_locations $(BUILT_SOURCES)
-EXTRA_DIST = evt.h \
-	imggif.cc \
-	imgjpeg.cc \
-	imgpng.cc
+EXTRA_DIST = evt.h
 
 all: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) all-am
Index: kaffe/libraries/clib/awt/qt/cbd.cc
diff -u kaffe/libraries/clib/awt/qt/cbd.cc:1.2 kaffe/libraries/clib/awt/qt/cbd.cc:1.3
--- kaffe/libraries/clib/awt/qt/cbd.cc:1.2	Mon Dec  2 14:35:53 2002
+++ kaffe/libraries/clib/awt/qt/cbd.cc	Sat Jul 10 01:58:25 2004
@@ -4,6 +4,9 @@
  * Copyright (c) 1998
  *      Transvirtual Technologies, Inc.  All rights reserved.
  *
+ * Copyright (c) 2002, 2003, 2004
+ *	Kaffe.org contributors, see ChangeLog for details.  All rights reserved.
+ *
  * See the file "license.terms" for information on usage and redistribution 
  * of this file. 
  */
@@ -22,132 +25,14 @@
 typedef void ClipBoard;
 QString cbdText;
 int cbdDirty;
-/*****************************************************************************************
- * internal event handling functions
- *  (note that non of them gets back to Java via events (->return 0);
- */
-#if 0
-jobject
-selectionClear ( JNIEnv* env, Toolkit* X )
-{
-  env->CallStaticVoidMethod( NativeClipboard, lostOwnership);
-
-  return 0; /* don't pass event to Java */
-}
-jobject
-selectionRequest ( JNIEnv* env, Toolkit* X )
-{
-  //XEvent     e;
-  char       *mime;
-  jstring    jMimeType;
-  jbyteArray jData;
-  jbyte      *data;
-  jboolean   isCopy;
-  int        len;
-  //Atom       target = X->event.xselectionrequest.target;
-
-  if ( target == JAVA_OBJECT )
-	mime = "application/x-java-serialized-object";
-  else if ( target == XA_STRING )
-	mime = "text/plain; charset=unicode";
-  else
-	mime = XGetAtomName( X->dsp, target);
 
-  jMimeType = env->NewStringUTF( (const char*) mime);
-  jData = env->CallStaticObjectMethod( NativeClipboard, getNativeData, jMimeType);
-
-  if ( jData ) {
-	data = env->GetByteArrayElements( jData, &isCopy);
-	len = env->GetArrayLength( jData);
-
-	//XChangeProperty( X->dsp,
-	//				 X->event.xselectionrequest.requestor,
-	//				 X->event.xselectionrequest.property,
-	//				 X->event.xselectionrequest.target,
-	//				 8, PropModeReplace, data, len);
-
-	env->ReleaseByteArrayElements( jData, data, JNI_ABORT);
-	//e.xselection.property  = X->event.xselectionrequest.property;
-  }
-  else {
-	//e.xselection.property  = None;  /* format not supported */
-  }
-/*
-  e.xselection.type      = SelectionNotify;
-  e.xselection.requestor = X->event.xselectionrequest.requestor;
-  e.xselection.selection = X->event.xselectionrequest.selection;
-  e.xselection.target    = target;
-  e.xselection.time      = X->event.xselectionrequest.time;
-
-  XSendEvent( X->dsp, e.xselection.requestor, False, 0, &e);
-*/
-  return 0; /* don't pass event to Java */
-}
-#endif
-
-/*
- * this is the low level helper - get the raw data of the requested 'target' format
- * returns :
- *   -1 if there is no selection owner
- *    0 if the owner cannot prvide the requested format
- *    length of *pData otherwise
- */
-#if 0
-static int
-getRawData ( Toolkit* X, Atom target, unsigned char** pData )
-{
-
-  int              i, format;
-  unsigned long    len = 8191, remain = 1;
-  Atom             type;
-  XEvent           e;
-
-  XConvertSelection( X->dsp, XA_PRIMARY, target, SELECTION_DATA, X->cbdOwner, CurrentTime);
-
-  for ( i=0; i<2; i++ ) {
-	XSync( X->dsp, False);
-	if ( XCheckTypedWindowEvent( X->dsp, X->cbdOwner, SelectionNotify, &e) ){
-	  if ( e.xselection.property == None )  /* target type not supported by owner */
-		return 0;
-
-	  while ( remain ) {
-		len += remain;
-		XGetWindowProperty( X->dsp, X->cbdOwner, SELECTION_DATA, 0, len, False,
-							AnyPropertyType, &type, &format, &len, &remain, pData);
-	  }
-	  return len;
-	}
-	sleep( 1);
-  }
-  return -1; /* no selection owner at all */
-}
-#endif
-
-/*****************************************************************************************
+/**
  * exported functions
  */
 
 jobject
 Java_java_awt_Toolkit_cbdInitClipboard ( JNIEnv* env, jclass clazz )
 {
-#if 0
-  unsigned long mask = 0;
-  XSetWindowAttributes attrs;
-
-  attrs.override_redirect = True;
-  mask |= CWOverrideRedirect;
-
-  /*
-   * We need an appropriate native owner/requestor (Window) since
-   * Java requestors/owners can be non-native Windows. We also
-   * don't want to introduce artificial events (with all their
-   * required infrastructure)
-   */
-  X->cbdOwner = XCreateWindow( X->dsp, X->root, -10000, -10000, 1, 1, 0, CopyFromParent,
-							   InputOutput, CopyFromParent, mask, &attrs);
-
-#endif
-
   NativeClipboard = env->FindClass( "java/awt/NativeClipboard");
   lostOwnership   = env->GetStaticMethodID( NativeClipboard,
 											   "lostOwnership", "()V");
@@ -157,8 +42,6 @@
 												  "createTransferable",
 												  "(Ljava/lang/String;[B)Ljava/awt/datatransfer/Transferable;");
 
-//  SELECTION_DATA   = XInternAtom( X->dsp, "SELECTION_DATA", False);
-//  JAVA_OBJECT      = XInternAtom( X->dsp, "application/x-java-serialized-object", False);
   return 0;
 }
 
@@ -173,14 +56,6 @@
 
   cbdDirty = 1;  
   return 1;
-
-#if 0
-  XSetSelectionOwner( X->dsp, XA_PRIMARY, X->cbdOwner, CurrentTime);
-  if ( XGetSelectionOwner( X->dsp, XA_PRIMARY) != X->cbdOwner )
-        return 0;
-  else
-        return 1;
-#endif
 }
 
 
@@ -229,7 +104,6 @@
 	jMimeType = env->NewStringUTF( (const char*)mime);
 	jdata = env->NewByteArray( ret);
 	env->SetByteArrayRegion( jdata, 0, ret, (jbyte*)data);
-	//XFree( data);
 
 	return env->CallStaticObjectMethod( NativeClipboard, createTransferable,
 										   jMimeType, jdata);
@@ -287,3 +161,4 @@
 #endif
   return NULL;
 }
+
Index: kaffe/libraries/clib/awt/qt/clr.cc
diff -u kaffe/libraries/clib/awt/qt/clr.cc:1.3 kaffe/libraries/clib/awt/qt/clr.cc:1.4
--- kaffe/libraries/clib/awt/qt/clr.cc:1.3	Tue Jun  3 23:32:07 2003
+++ kaffe/libraries/clib/awt/qt/clr.cc	Sat Jul 10 01:58:25 2004
@@ -4,6 +4,9 @@
  * Copyright (c) 1998
  *      Transvirtual Technologies, Inc.  All rights reserved.
  *
+ * Copyright (c) 2002, 2003, 2004
+ *	Kaffe.org contributors, see ChangeLog for details.  All rights reserved.
+ *
  * See the file "license.terms" for information on usage and redistribution 
  * of this file. 
  */
@@ -26,23 +29,18 @@
 extern QApplication *qapp;
 #endif
 
-/********************************************************************************
- * auxiliary functions
- */
-
-
-/********************************************************************************
+/**
  * common funcs
  */
 
 void initColorMapping(JNIEnv* env, jclass clazz,  Toolkit* X)
 {
-//  qapp->setColorSpec(QApplication::NormalColor);
+  // qapp->setColorSpec(QApplication::NormalColor);
   X->colorMode = QApplication::ManyColor;
 }
 
 
-/********************************************************************************
+/**
  * exported functions
  */
 
@@ -56,10 +54,9 @@
   if ( !X->colorMode )
 	initColorMapping( env, clazz, X);
 
-//  uint pixel = QColor(JRED(rgb), JGREEN(rgb), JBLUE(rgb)).pixel();
-//  AWT_DBG(printf("clrGetPixelValue: %8x -> %x (%d)\n", rgb, pixel, pixel));
+  // uint pixel = QColor(JRED(rgb), JGREEN(rgb), JBLUE(rgb)).pixel();
+  // AWT_DBG(qDebug("clrGetPixelValue: %8x -> %x (%d)\n", rgb, pixel, pixel));
 
-//  return pixel;
   return rgb;
 }
 
@@ -136,3 +133,4 @@
 
   return cm;
 }
+
Index: kaffe/libraries/clib/awt/qt/evt.cc
diff -u kaffe/libraries/clib/awt/qt/evt.cc:1.5 kaffe/libraries/clib/awt/qt/evt.cc:1.6
--- kaffe/libraries/clib/awt/qt/evt.cc:1.5	Tue Jun  3 23:32:07 2003
+++ kaffe/libraries/clib/awt/qt/evt.cc	Sat Jul 10 01:58:25 2004
@@ -4,6 +4,9 @@
  * Copyright (c) 1998
  *      Transvirtual Technologies, Inc.  All rights reserved.
  *
+ * Copyright (c) 2002, 2003, 2004
+ *	Kaffe.org contributors, see ChangeLog for details.  All rights reserved.
+ *
  * See the file "license.terms" for information on usage and redistribution 
  * of this file. 
  */
@@ -90,13 +93,11 @@
 }
 
 bool EventDispatcher::eventFilter(QObject* o, QEvent* e) {
-//  AWT_DBG(printf("event type=%d widget=%p\n", e->type(), o));
+  DBG(AWT, qDebug("event type=%d widget=%p\n", e->type(), o));
   QEvent* newEvent = NULL;
   EventPacket* packet = NULL;
   bool processed = false;
 
-//  getSourceIdx(X, o);
-
   if(X->srcIdx == 0)
     return QWidget::eventFilter(o, e);
 
@@ -115,7 +116,7 @@
     }
 
     case QEvent::Show: {
-      AWT_DBG(printf("Event Show: srcIdx=%d\n", X->srcIdx));
+      DBG(AWT, qDebug("Event Show: srcIdx=%d\n", X->srcIdx));
 
 #if (QT_VERSION < 300)
       newEvent = (QEvent*) new QShowEvent(true);
@@ -129,7 +130,7 @@
     }
     
     case QEvent::Hide: {
-      AWT_DBG(printf("Event Hid: srcIdx=%d\n", X->srcIdx));
+      DBG(AWT, qDebug("Event Hid: srcIdx=%d\n", X->srcIdx));
 
 #if (QT_VERSION < 300)
       newEvent = (QEvent*) new QHideEvent(true);
@@ -144,7 +145,7 @@
     
     case QEvent::FocusIn:
     case QEvent::FocusOut: {
-      AWT_DBG(printf("Event Focus: srcIdx=%d\n", X->srcIdx));
+      DBG(AWT, qDebug("Event Focus: srcIdx=%d\n", X->srcIdx));
       QFocusEvent* tmpFocusEvent = (QFocusEvent*)e;
       newEvent = (QEvent*) new QFocusEvent(tmpFocusEvent->type());
       ((QFocusEvent*)newEvent)->setReason(tmpFocusEvent->reason());
@@ -154,7 +155,7 @@
 
     case QEvent::KeyPress:
     case QEvent::KeyRelease: {
-      AWT_DBG(printf("Event Key: srcIdx=%d\n", X->srcIdx));
+      DBG(AWT, qDebug("Event Key: srcIdx=%d\n", X->srcIdx));
       QKeyEvent* tmpKeyEvent = (QKeyEvent*)e;
       newEvent = (QEvent*) new QKeyEvent(tmpKeyEvent->type(),tmpKeyEvent->key(),
 	tmpKeyEvent->ascii(), tmpKeyEvent->state(), tmpKeyEvent->text(),
@@ -166,7 +167,7 @@
     case QEvent::MouseButtonPress:
     case QEvent::MouseButtonRelease:
     case QEvent::MouseMove: {
-      AWT_DBG(printf("Event MouseButton: srcIdx=%d\n", X->srcIdx));
+      DBG(AWT, qDebug("Event MouseButton: srcIdx=%d\n", X->srcIdx));
       QMouseEvent* tmpMouseEvent = (QMouseEvent*)e;
       newEvent = (QEvent*) new QMouseEvent(tmpMouseEvent->type(),
         tmpMouseEvent->pos(), tmpMouseEvent->button(),
@@ -175,7 +176,7 @@
       break;
     }
     case QEvent::Paint: {
-      AWT_DBG(printf("Event Paint: srcIdx=%d\n", X->srcIdx));
+      DBG(AWT, qDebug("Event Paint: srcIdx=%d\n", X->srcIdx));
       QPaintEvent* tmpPaintEvent = (QPaintEvent*)e;
       newEvent = (QEvent*) new QPaintEvent(tmpPaintEvent->rect(),
         tmpPaintEvent->erased());
@@ -183,7 +184,7 @@
       break;
     }
     case QEvent::Move: {
-      AWT_DBG(printf("Event Move: srcIdx=%d\n", X->srcIdx));
+      DBG(AWT, qDebug("Event Move: srcIdx=%d\n", X->srcIdx));
       QPoint data(((QWidget*)o)->width(), ((QWidget*)o)->height());
       QMoveEvent* tmpMoveEvent = (QMoveEvent*)e;
       // Hide width/height in oldPos of newEvent
@@ -193,7 +194,7 @@
       break;
     }
     case QEvent::Resize: {
-      AWT_DBG(printf("Event Resize: srcIdx=%d\n", X->srcIdx));
+      DBG(AWT, qDebug("Event Resize: srcIdx=%d\n", X->srcIdx));
       QSize data(((QWidget*)o)->x(), ((QWidget*)o)->y());
       QResizeEvent* tmpResizeEvent = (QResizeEvent*)e;
       // Hide x/y in oldSize of newEvent
@@ -217,12 +218,8 @@
 void forwardFocus ( int cmd, void* wnd );  /* from wnd.c */
 
 
-/*****************************************************************************
- *
- */
-
-
-/* X-to-Java key modifier mapping
+/**
+ * Qt-X-Java key modifier mapping
  *                                     altGr   : PC
  *     shift       -    ctrl     alt    meta   : Java
  *     Shift    Lock    Ctrl    Mod1    Mod3   : X      symbol
@@ -281,369 +278,20 @@
   }
 };
 #endif
-#if 0
-static jobject
-keyNotify ( JNIEnv* env, Toolkit* X )
-{
-  KeySym          keysym;
-  XComposeStatus  ioStatus;
-  int             n, keyCode, keyChar, mod, idx;
-
-  /*
-   * We should eventually support input methods here.
-   * Note that 'keysym' is queried separately (with a standard state), to
-   * ensure the "one physical key -> one keycode" invariant
-   */
-  n = XLookupString( &X->event.xkey, X->buf, X->nBuf, 0, &ioStatus);
-  keysym = XKeycodeToKeysym( X->dsp, X->event.xkey.keycode, 0);
-
-  if ( (keysym >= 0xff00) || (n == 0) ) {
-	keyCode = FKeyCode[keysym & 0xff];
-	/*
-	 * There are some "control keys" that should generate KEY_TYPED events
-	 * (enter, cancel, backspace, del, tab). This is flagged by a negative keyCode
-	 * value and leads to non-zero keyChars
-	 */
-	if ( keyCode < 0 ){
-	  keyChar = keyCode = -keyCode;
-	}
-	else {  /* a "pure" function key */
-	  keyChar = 0;
-	}
-
-  }
-  else {
-	keyChar = (unsigned char)X->buf[0];
-	keyCode = LKeyCode[keysym & 0xff];
-  }
-
-  X->evtId = (X->event.xany.type == KeyPress)? KEY_PRESSED : KEY_RELEASED;
-  mod = keyMod( X->event.xkey.state);
-
-  if ( X->fwdIdx >= 0 ) {
-	/*
-	 * watch out - we still might have key events for a already
-	 * unregistered forwardee in the queue (since we fake X, we can't rely on it
-	 * to remove key events for a destroyed forwardee)
-	 */
-	if ( !checkSource( X, X->fwdIdx) )
-	  return 0;
-	idx = X->fwdIdx;
-  }
-  else {
-	idx = X->srcIdx;
-  }
-
-  return env->CallStaticObjectMethod( KeyEvent, getKeyEvent,
-                      idx, X->evtId, keyCode, keyChar, mod);
-}
-
-
-static jobject
-buttonNotify ( JNIEnv* env, Toolkit* X )
-{
-  if ( X->event.xany.type == ButtonPress ) {
-	X->evtId = MOUSE_PRESSED;
-
-	if ( (X->windows[X->srcIdx].w == X->focus) && (X->fwdIdx >= 0) )
-	  forwardFocus( FWD_REVERT, X->event.xany.window);
-  }
-}
-
-
-static jobject
-mouseNotify ( JNIEnv* env, Toolkit* X )
-{
-  X->evtId = (X->event.xany.type == EnterNotify) ? MOUSE_ENTERED : MOUSE_EXITED;
-
-  return env->CallStaticObjectMethod(  MouseEvent, getMouseEvent,
-    X->srcIdx, X->evtId,
-    0, X->event.xcrossing.x, X->event.xcrossing.y);
-}
-
-
-static jobject
-focusNotify ( JNIEnv* env, Toolkit* X )
-{
-  return 0;
-#if 0
-  int et = X->event.xany.type;
-  int idx = (X->focusFwd) ? X->fwdIdx : X->srcIdx;
-
-  /*
-   * get rid of all these fancy intermediate focus events (the real thing should
-   * come last), but be aware of that we might get events for already unregistered windows
-   * (in case the app isn't particulary careful with disposing windows), ending up in
-   * ArrayOutOfBoundsExceptions in the getFocusEvent
-   */
-  while ( XCheckMaskEvent( X->dsp, FocusChangeMask, &X->event) ){
-	X->pending--;
-	if ( getSourceIdx( X, X->event.xfocus.window) >= 0 ) {
-	  et = X->event.xany.type;
-	  idx = (X->focusFwd) ? X->fwdIdx : X->srcIdx;
-	}
-  }
-
-  if ( et == FocusIn ) {
-	X->evtId = FOCUS_GAINED;
-	X->focus = X->event.xany.window;
-  }
-  else {
-	X->evtId = FOCUS_LOST;
-	X->focus = 0;
-  }
-
-  /*
-   * No matter what the focus change is - if we get a REAL focus notification,
-   * it means that we will end focus forwarding (which is done on the owner-basis,
-   * not by means of a global grab mode)
-   */
-  resetFocusForwarding( X);
-
-  if ( checkSource( X, idx) ){
-	return env->CallStaticObjectMethod( FocusEvent, getFocusEvent, idx,
-										   X->evtId, JNI_FALSE);
-  }
-  else {
-	return 0;
-  }
-#endif
-}
-
-static jobject
-destroyNotify ( JNIEnv* env, Toolkit* X )
-{
-  /*
-   * We should get this just for windows which have been destroyed from an
-   * external client, since removeNotify() calls evtUnregisterSource() (i.e.
-   * removes windows properly from the dispatch table)
-   */
-  X->windows[X->srcIdx].flags &= ~WND_MAPPED;
-
-  return env->CallStaticObjectMethod( WMEvent, getWMEvent,
-				 X->srcIdx, (X->evtId = WM_KILLED));
-}
-
-
-static jobject
-mapNotify ( JNIEnv* env, Toolkit* X )
-{
-  int id = 0;
-
-  if ( X->event.xany.type == MapNotify ) {
-	if ( (X->windows[X->srcIdx].flags & WND_MAPPED) == 0 ){
-	  id = WINDOW_DEICONIFIED;
-	  X->windows[X->srcIdx].flags |= WND_MAPPED;
-	}
-  }
-  else {
-	if ( (X->windows[X->srcIdx].flags & WND_MAPPED) != 0 ){
-	  id = WINDOW_ICONIFIED;
-	  X->windows[X->srcIdx].flags &= ~WND_MAPPED;
-	}
-  }
-
-  if ( id ) {
-	return env->CallStaticObjectMethod( WindowEvent, getWindowEvent,
-		   X->srcIdx, id);
-  }
-  else {
-	// we do the ComponentEvent show/hide in Java
-	return 0;
-  }
-}
-
-static jobject
-clientMessage ( JNIEnv* env, Toolkit* X )
-{
-  return 0;
-#if 0
-  if ( X->windows[X->srcIdx].flags & WND_DESTROYED ){
-	/* we lost him, Jim */
-	return 0;
-  }
-
-  if ( X->event.xclient.message_type == WM_PROTOCOLS ) {
-	if ( X->event.xclient.data.l[0] == WM_DELETE_WINDOW ) {
-	  return env->CallStaticObjectMethod( WindowEvent, getWindowEvent,
-											 X->srcIdx, (X->evtId = WINDOW_CLOSING));
-	}
-	else if ( X->event.xclient.data.l[0] == WM_TAKE_FOCUS ) {
-	  XSetInputFocus( X->dsp, X->event.xany.window, RevertToParent, CurrentTime);
-	}
-  }
-
-  /*
-   * This is a workaround for the common problem of requesting the focus for not
-   * yet mapped windows (resulting in BadMatch errors)
-   */
-  else if ( X->event.xclient.message_type == RETRY_FOCUS ) {
-	if ( X->windows[X->srcIdx].flags & WND_MAPPED ) {
-	  XSetInputFocus( X->dsp, (Window)X->event.xclient.window, RevertToParent, CurrentTime);
-	  if ( X->event.xclient.data.l[1] ) {
-		/* we have a pending forward request, too */
-		forwardFocus( FWD_SET, X->event.xclient.data.l[1]);
-	  }
-	}
-  }
-
-  /*
-   * This is a workaround for X not having "owned" windows (popups), which do
-   * not "shade" the titlebar of their owner (i.e. don't indicate a change in
-   * the activeWindow). The only way to implement this reliable (w/o playing
-   * around with a window manager) is to not let these popups select on
-   * key events at all. But rather than to expose this to the Java side (like
-   * the JDK does), we hide this in the native layer
-   */
-  else if ( X->event.xclient.message_type == FORWARD_FOCUS ) {
-	switch ( X->event.xclient.data.l[0] ){
-	case FWD_SET:
-	  DBG( AWT_EVT, printf("FWD_SET: %lx (%d) %lx\n", X->event.xany.window, X->srcIdx, X->windows[X->srcIdx].owner));
-
-	  if ( (X->srcIdx != X->fwdIdx) && (X->focus == X->windows[X->srcIdx].owner) ){
-		X->fwdIdx = X->srcIdx;
-		X->focusFwd = X->event.xany.window;
-		return env->CallStaticObjectMethod( FocusEvent, getFocusEvent,
-											   X->srcIdx, FOCUS_GAINED, JNI_TRUE);
-	  }
-	  else {
-		return 0;
-	  }
-
-	case FWD_CLEAR:
-	  DBG( AWT_EVT, printf("FWD_CLEAR: %lx (%d) %lx\n", X->event.xany.window, X->srcIdx, X->windows[X->srcIdx].owner));
-
-	  if ( X->fwdIdx >= 0 ) {
-		resetFocusForwarding( X);
-		return env->CallStaticObjectMethod( FocusEvent, getFocusEvent,
-											   X->srcIdx, FOCUS_LOST, JNI_FALSE);
-	  }
-	  else {
-		return 0;
-	  }
-
-	case FWD_REVERT:
-	  DBG( AWT_EVT, printf("FWD_REVERT: %lx\n", X->event.xany.window));
-	  if ( X->event.xany.window == X->focus ) {
-		resetFocusForwarding( X);
-		return env->CallStaticObjectMethod( FocusEvent, getFocusEvent,
-											   X->srcIdx, FOCUS_GAINED, JNI_FALSE);
-	  }
-	}
-  }
-  return 0;
-#endif
-}
-
-static jobject
-reparentNotify ( JNIEnv* env, Toolkit* X )
-{
-  Window    window, parent, root;
-  jclass    clazz = 0;
-  jmethodID setDecoInsets = 0;
-  int       left, top, right, bottom;
-  int       x, y, w, h, bw, d;
-  int       xc, yc, wc, hc;
-  DecoInset *in = 0;
-  XSizeHints wmHints;
-  long      supHints;
-
-  if ( X->frameInsets.guess || X->dialogInsets.guess ) {
-	window = X->event.xreparent.window;
-	parent = X->event.xreparent.parent;
-
-	XGetGeometry( X->dsp, parent, &root, &x, &y, &w, &h, &bw, &d);
-	XGetGeometry( X->dsp, window, &root, &xc, &yc, &wc, &hc, &bw, &d);
-
-	left   = X->event.xreparent.x;
-	top    = X->event.xreparent.y;
-	right  = w - wc - left;
-	bottom = h - hc - top;
-
-	if ( (X->windows[X->srcIdx].flags & WND_DIALOG) && X->dialogInsets.guess ) {
-	  in = &(X->dialogInsets);
-	  if ( (left != in->left) || (top != in->top) ||
-		   (right != in->right) || (bottom != in->bottom) ){
-		clazz = env->FindClass( "java/awt/Dialog");
-		setDecoInsets = env->GetStaticMethodID( clazz, "setDecoInsets","(IIIII)V");
-	  }
-	  in->guess = 0;
-	}
-	else if ( X->frameInsets.guess ) {
-	  in = &(X->frameInsets);
-	  if ( (left != in->left) || (top != in->top) ||
-		   (right != in->right) || (bottom != in->bottom) ){
-		clazz = env->FindClass( "java/awt/Frame");
-		setDecoInsets = env->GetStaticMethodID( clazz, "setDecoInsets","(IIIII)V");
-	  }
-	  in->guess = 0;
-	}
-
-	if ( clazz ) {
-	  wc -= (left + right) - (in->left + in->right);
-	  hc -= (top + bottom) - (in->top + in->bottom);
-
-	  XCheckTypedWindowEvent( X->dsp, window, ConfigureNotify, &X->event);
-	  XCheckTypedWindowEvent( X->dsp, window, Expose, &X->event);
-	  XResizeWindow( X->dsp, window, wc, hc);
-
-	  in->left = left;
-	  in->top = top;
-	  in->right = right;
-	  in->bottom = bottom;
-
-	  env->CallStaticVoidMethod( clazz, setDecoInsets, 
-									in->top, in->left, in->bottom, in->right, X->srcIdx);
-
-	  /* check if this was a resize locked window (which has to be locked again) */
-	  XGetWMNormalHints( X->dsp, window, &wmHints, &supHints);
-	  if ( wmHints.min_width == wmHints.max_width ){
-		wmHints.min_width = wmHints.max_width = wc;
-		wmHints.min_height = wmHints.max_height = hc;
-		XSetWMNormalHints( X->dsp, window, &wmHints);
-	  }
-	}
-  }
-
-  return NULL;
-}
-
-typedef jobject (*EventFunc)(JNIEnv*,Toolkit*);
-
-static EventFunc  processEvent[LASTEvent] = {
-  keyNotify,            /* KeyPress                 2 */
-  keyNotify,            /* KeyRelease               3 */
-  mouseNotify,          /* EnterNotify              7 */
-  mouseNotify,          /* LeaveNotify              8 */
-  focusNotify,          /* FocusIn                  9 */
-  focusNotify,          /* FocusOut                10 */
-  destroyNotify,        /* DestroyNotify           17 */
-  mapNotify,            /* UnmapNotify             18 */
-  mapNotify,            /* MapNotify               19 */
-  reparentNotify,       /* ReparentNotify          21 */
-  selectionClear,       /* SelectionClear          29 */
-  selectionRequest,     /* SelectionRequest        30 */
-  clientMessage,        /* ClientMessage           33 */
-};
-#endif
-
-/*******************************************************************************
- *
- */
 
 jobject Java_java_awt_Toolkit_evtInit(JNIEnv* env, jclass clazz)
 {
   jclass Component;
 
-  AWT_DBG(printf("evtInit\n"));
+  DBG(AWT, qDebug("evtInit\n"));
 
   if ( ComponentEvent != NULL ){
-    AWT_DBG(printf("evtInit called twice\n"));
+    DBG(AWT, qDebug("evtInit called twice\n"));
     return NULL;
   }
 
   if(qapp == NULL) {
-    AWT_DBG(printf("evtInit: qapp not initialized!\n"));
+    DBG(AWT, qDebug("evtInit: qapp not initialized!\n"));
   }
 
   eventDispatcher = new EventDispatcher();
@@ -714,7 +362,7 @@
       
 
     case QEvent::Destroy: {
-      AWT_DBG(printf("processing Destroy: SrcIdx=%d\n", index));
+      DBG(AWT, qDebug("processing Destroy: SrcIdx=%d\n", index));
       /*
        * We should get this just for windows which have been destroyed from an
        * external client, since removeNotify() calls evtUnregisterSource() (i.e.
@@ -728,13 +376,13 @@
     }
     
     case QEvent::Reparent: {
-      AWT_DBG(printf("processing Reparent: SrcIdx=%d\n", index));
+      DBG(AWT, qDebug("processing Reparent: SrcIdx=%d\n", index));
       return NULL;
     }
 
     case QEvent::FocusIn:
     case QEvent::FocusOut: {
-      AWT_DBG(printf("processing %s: SrcIdx=%d\n",(event->type() == QEvent::FocusIn)?"FocusIn":"FocusOut",index));
+      DBG(AWT, qDebug("processing %s: SrcIdx=%d\n",(event->type() == QEvent::FocusIn)?"FocusIn":"FocusOut",index));
       int evtId;
       int et = event->type();
       if ( et == QEvent::FocusIn ) {
@@ -756,7 +404,7 @@
 
     case QEvent::KeyPress:
     case QEvent::KeyRelease: { 
-      AWT_DBG(printf("processing %s: SrcIdx=%d\n",(event->type() == QEvent::KeyPress)?"KeyPress":"KeyRelease",index));
+      DBG(AWT, qDebug("processing %s: SrcIdx=%d\n",(event->type() == QEvent::KeyPress)?"KeyPress":"KeyRelease",index));
       QKeyEvent *keyEvent = (QKeyEvent*)event;
       int             n, keyCode, keyChar, mod;
       
@@ -793,7 +441,7 @@
       int evtId = (((QEvent*)keyEvent)->type() == QEvent::KeyPress)? KEY_PRESSED : KEY_RELEASED;
       mod = keyMod(keyEvent->state());
       
-      AWT_DBG(printf("KeyEvent: idx=%d keyCode=%d keyChar=%c mod=%d\n", index, keyCode,keyChar,mod));
+      DBG(AWT, qDebug("KeyEvent: idx=%d keyCode=%d keyChar=%c mod=%d\n", index, keyCode,keyChar,mod));
 
       return env->CallStaticObjectMethod( KeyEvent, getKeyEvent,
                                           index, evtId, keyCode, keyChar, mod);
@@ -801,7 +449,7 @@
     }
     
     case QEvent::MouseButtonPress: {
-      AWT_DBG(printf("processing MouseButtonPress Event SrcIdx=%d\n", index));
+      DBG(AWT, qDebug("processing MouseButtonPress Event SrcIdx=%d\n", index));
       QMouseEvent* mouseEvent = (QMouseEvent*)event;
       // check the diff between event.xbutton.button and QMouseEvent::button()
       if (checkSource( X, index) ){
@@ -816,7 +464,7 @@
         mouseEvent->x(), mouseEvent->y());
     }
     case QEvent::MouseButtonRelease: {
-      AWT_DBG(printf("processing MouseButtonRelease Event SrcIdx=%d\n", index));
+      DBG(AWT, qDebug("processing MouseButtonRelease Event SrcIdx=%d\n", index));
       QMouseEvent* mouseEvent = (QMouseEvent*)event;
       // check the diff between event.xbutton.button and QMouseEvent::button()
       return env->CallStaticObjectMethod(MouseEvent, getMouseEvent,
@@ -824,21 +472,21 @@
         mouseEvent->x(), mouseEvent->y());
     }
     case QEvent::MouseMove: {
-      AWT_DBG(printf("processing MouseMove Event SrcIdx=%d\n", index));
+      DBG(AWT, qDebug("processing MouseMove Event SrcIdx=%d\n", index));
       QMouseEvent* mouseEvent = (QMouseEvent*)event;
       return env->CallStaticObjectMethod(MouseEvent, getMouseEvent,
         index, MOUSE_MOVED, 0,
         mouseEvent->x(), mouseEvent->y());
     }
     case QEvent::Paint: {
-      AWT_DBG(printf("processing Paint Event SrcIdx=%d\n", index));
+      DBG(AWT, qDebug("processing Paint Event SrcIdx=%d\n", index));
       QPaintEvent* paintEvent = (QPaintEvent*)event;
       QRect rect=paintEvent->rect();
       return env->CallStaticObjectMethod(PaintEvent, getPaintEvent,
         index, UPDATE, rect.x(), rect.y(), rect.width(), rect.height());
     }
     case QEvent::Move: {
-      AWT_DBG(printf("processing Move Event SrcIdx=%d\n", index));
+      DBG(AWT, qDebug("processing Move Event SrcIdx=%d\n", index));
       QMoveEvent* moveEvent = (QMoveEvent*)event;
       QPoint pos, data;
       pos = moveEvent->pos();
@@ -847,7 +495,7 @@
         index, COMPONENT_RESIZED, pos.x(), pos.y(), data.x(), data.y());
     }
     case QEvent::Resize: {
-      AWT_DBG(printf("processing Resize Event SrcIdx=%d\n", index));
+      DBG(AWT, qDebug("processing Resize Event SrcIdx=%d\n", index));
       QResizeEvent* resizeEvent = (QResizeEvent*)event;
       QSize size, data;
       size = resizeEvent->size();
@@ -867,7 +515,7 @@
   QEvent *event;
   int index;
 
-  //AWT_DBG(printf("getNextEvent..\n"));
+  DBG(AWT, qDebug("getNextEvent..\n"));
   pollJavaClipboard(env);
 
   if (g_event_queue.count()) {
@@ -879,7 +527,6 @@
     delete packet;
   }

*** Patch too long, truncated ***




More information about the kaffe mailing list