2362N/A * Copyright (c) 1995, 2007, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 2362N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A#
endif /* !HEADLESS */ 0N/A/* JNI field and method ids */ /* implement a "putback queue" -- see comments on awt_put_back_event() */ /* Font information to feed Motif widgets. */ "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1";
/* If the default font is a single font. */ /* If the default font is multiple fonts. */ }
/* awt_set_poll_timeout */ * Gets the best timeout for the next call to poll() or select(). * If timedOut is True, we assume that our previous timeout elapsed * with no events/timers arriving. Therefore, we can increase the /* add 1/16 (plus 1, in case the division truncates to 0) */ }
/* awt_get_poll_timeout() */ return 0;
/* to keep compiler happy */ /* Like XKeysymToKeycode, but ensures that keysym is the primary * symbol on the keycode returned. Returns zero otherwise. * NB: TODO: hope it will return False if XkbIgnoreExtension was called! /* Assign meaning - alt, meta, etc. - to X modifiers mod1 ... mod5. * Only consider primary symbols on keycodes attached to modifiers. for (i = 0; i <
nkeys; ++i) {
/* for each keycode attached to this modifier */ for(i = 0; i <
nkeys; i++) {
/* awt_next_flush_time affects awt_get_poll_timeout(), so set * the variable *after* calling the function. /* write to the utility pipe to wake up the event }
/* awt_output_flush() */ /* fix for 4053856, robi.khan@eng couldn't find peer corresponding to widget but the widget may be child of one with a peer, so recurse up the hierarchy */ /* found peer attached to ancestor of given widget, so set widget return value as well */ for (i = 0; i <
3; i++) {
/* If this function returns False, that means that it has not pre-posted this event to Java. The caller will then dispatch the event to Motif, and our handlers will be called to post it to Java. If this function returns true, then this function has posted this event to java before returning. The caller will not dispatch it to Motif; it will be dispatched to Motif via the putbackQueue after it has been /* Fix for 4328561 by ibd@sparc.spb.su If the widget is a Choice, the widget with focus is probably lying outside the current widget's sub-hierarchy, so we have to go up the /* In this case, focus widget should be CascadeButtonGadget type, but we should send the events to its parent */ /* If something went wrong, restore the original status */ /* if focus owner is null, redirect key events to focused window */ /* If we are on a non-choice widget, process events in a normal way */ * If a menu is up (not just a popup menu), prevent awt components from * getting any events until the menu is popped down. * Before this fix, the fact that mouse/button events were * preposted to the Java event queue was causing the ButtonRelease * (needed to pop menu down) to be seen by the menu's parent and /* If we are on a choice, dispatch the events to widget, but do not * dispatch the events if we are on popped up menu. /* Fix for 4328557 by ibd@sparc.spb.su * If we are dragging mouse from choice and are currently outside * of it, dispatch events to the choice - the source of dragging. /* If the keyboard is grabbed by a popup (such as a choice) during a time when a focus proxy is in effect, the abovefocusIsOnMenu test will not detect the sitation because the focus will be on the proxy. But we need events to go to Motif first, so that the grab can be undone when appropriate. */ /* If it's a keyboard event, we need to find the peer associated */ /* with the widget that has the focus rather than the widget */ /* associated with the window in the X event. */ * Do not post the enter/leave event if it's on a subwidget /* If we found a widget and a suitable peer (either the focus peer above or the one associated with the widget then we * Fix for bug 4173714 - java.awt.button behaves differently under * Component should not get any events when it's disabled. }
/* shouldDispatchToWidget() */ "notifyToolkitThreadBusy",
"()V");
"notifyToolkitThreadFree",
"()V");
}
/* awtAutoShutdownClass == NULL*/ * This is the main Xt event loop for the AWT. * Because java applications are multithreaded, but X and Xt * are thread-dumb, we must make special considerations to * make ensure that the X/Xt libraries are not entered by * multiple threads simultaneously. * The biggest difference between the standard Xt loop * and this loop is that we go to great lengths never to block * in the X libraries. We poll() on the X event pipe, waiting * for events, rather than simply calling XtAppNextEvent() and * blocking. If this thread were to block in XtAppNextEvent(), * no other thread could enter (e.g., to perform a paint or /* only privileged thread should be running here */ /* The pipe where X events arrive */ /* We execute events while locked, unlocking only when waiting /* Create the AWT utility pipe. See the comments on awt_pipe_init() */ * Need to flush here in case data on the connection was read * before we acquired the monitor. * I don't get this, but I'm too chicken to remove it. -jethro 2Sep98 * ACTUALLY PROCESS EVENTS /* process all events in the queue */ /* numEventsHandled = 0; */ }
/* end while awt_events_pending() */ /* At this point, we have exhausted the event queue */ /* print the number of events handled in parens */ /* Here, we wait for X events, outside of the X libs. When * it's likely that an event is waiting, we process the queue /* If we ever exit the loop, must unlock the toolkit */ }
/* awt_MToolkit_loop() */ * Creates the AWT utility pipe. This pipe exists solely so that * we can cause the main event thread to wake up from a poll() or * select() by writing to this pipe. ** the write wakes us up from the infinite sleep, which ** then we cause a delay of AWT_FLUSHTIME and then we /* set the pipe to be non-blocking */ // Returns a local ref to a decorated owner of the target, // or NULL if the target is Frame or Dialog itself. // The local ref returned should be deleted by the caller. /* the owner of a Window is in its parent field */ /* we may have a chain of Windows; go up the chain till we find the owning Frame or Dialog */ /* go up the hierarchy until we find a window */ // Window which contains focus owner when focus proxy is enabled // Window which works as proxy for input events for real focus owner. printf(
" nulling out proxy; putting back event" }
else /* FocusIn on Frame or Dialog */ {
}
else /* FocusOut on Frame or Dialog */{
/* If it's a FocusIn, allow it to process, then set /* If it's a FocusOut on a Window, discard it unless it's an event generated by us. */ if (
status == 0)
return False;
/* should be an error of some sort? */ * Returns focusability of the corresponding Java Window object // If the window doesn't have shell consider it focusable as all windows // are focusable by default * Processes and removes one X/Xt event from the Xt event queue. * Handles events pushed back via awt_put_back_event() FIRST, * then new events on the X queue // There is a pushed-back event - handle it first printf(
"putback FocusOut on window %d, mode %d, " "detail %d, send_event %d\n",
* Fix for BugTraq ID 4041235, 4100167: * First check that the event still has a widget, because * the widget may have been destroyed by another thread. * if we get here, the event could be one of * - notification that a "container" of * any of our embedded frame has been moved * - event understandable by XFilterEvent * - for one of our old widget which has gone away /* an embedded frame container has been moved? */ /* manager selections related event? */ * Fix for BugTraq ID 4196573: * Call XFilterEvent() to give a chance to X Input * Method to process this event before being /* There is an X event on the queue. */ /* Fix for BugTraq ID 4048060. Dispatch scrolling events immediately to the ScrollBar widget to prevent spurious continuous scrolling. Otherwise, if the application is busy, the ButtonRelease event is not dispatched in time to prevent a ScrollBar timeout from expiring, and restarting the continuous scrolling timer. /* Use XNextEvent instead of XtAppNextEvent, because XtAppNextEvent processes timers before getting the next X event, causing a race condition, since the TimerEvent callback in the ScrollBar widget restarts the continuous // This is the event on scrollbar. Key, Motion, // generate Ungrab after Java mouse event // This is an event on one of our widgets. Key, // should generate Ungrab after Java mouse event /* if (grabbed_widget != NULL && !eventInsideGrabbed(&xev)) { */ /* this could be moved to shouldDispatchToWidget */ /* if there is a proxy in effect, dispatch key events /* Key event should be posted to the top-level // See comment above - "after time" is here. // Check for xembed on this window. If it is active and this is not XEmbed focus // event(send_event = 0) then we should skip it /* In general, we need to to block out focus events that are caused by keybaord grabs initiated by dragging the title bar or the scrollbar. But we need to let through the ones that are aimed at choice boxes or menus. So we keep track of when the keyboard is grabbed by a popup. */ /* trueFocusWindow should never be None here, but if things ever get skewed, we want to be able to recover rather than crash */ /* beartrap -- remove before shipping */ /* printf("trueFocusWindow None in processOneEvent;\n"); */ /* printf("Please file a bug\n"); */ printf(
"null peer -- shouldn't see in java handler\n");
/* Find the top-level component */ printf(
"Focus event directed at a frame; frame = %d\n",
printf(
"Focus event directed at a window; window = %d\n",
/* There must be a timer, alternate input, or signal event. */ }
/* processOneEvent() */ * Waits for X/Xt events to appear on the pipe. Returns only when * it is likely (but not definite) that there are events waiting to * This routine also flushes the outgoing X queue, when the * awt_next_flush_time has been reached. * If fdAWTPipe is greater or equal than zero the routine also * checks if there are events pending on the putback queue. }
/* end while awt_events_pending() == 0 *//************************************************************************* ** WE USE EITHER select() OR poll(), DEPENDING ON THE USE_SELECT ** ** COMPILE-TIME CONSTANT. ** *************************************************************************/ * Performs select() on both the X pipe and our AWT utility pipe. * Returns when data arrives or the operation times out. * Not all Xt events come across the X pipe (e.g., timers * and alternate inputs), so we must time out every now and * then to check the Xt event queue. * The fdAWTPipe will be empty when this returns. /* Fixed 4250354 7/28/99 ssi@sparc.spb.su * Cleaning up Global Refs in case of No Events // be sure other threads get a chance // set the appropriate time values. The DASSERT() in // MToolkit_run() makes sure that this will not overflow /* reset tick if this was not a time out */ /* select() timed out -- update timeout value */ /* There is data on the AWT pipe - empty it */ * Polls both the X pipe and our AWT utility pipe. Returns * when there is data on one of the pipes, or the operation times * Not all Xt events come across the X pipe (e.g., timers * and alternate inputs), so we must time out every now and * then to check the Xt event queue. * The fdAWTPipe will be empty when this returns. /* Fixed 4250354 7/28/99 ssi@sparc.spb.su * Cleaning up Global Refs in case of No Events /* print the poll timeout time in brackets */ /* ACTUALLY DO THE POLL() */ // be sure other threads get a chance /* poll() timed out -- update timeout value */ /* There is data on the AWT pipe - empty it */ * Pushes an X event back on the queue to be handled * Ignores the request if event is NULL /* not enough room - alloc 50% more space */ /* always increase by at least min increment */ // wake up the event loop, if it's sleeping }
/* awt_put_back_event() */ * Gets the next event that has been pushed back onto the queue. * Returns 0 and fills in xev_out if successful /* remove it from the queue */ /* Too much space -- delete it and rebuild later */ /* more than 1 event in queue - shift all events to the left */ /* We don't free the allocated memory until the queue becomes empty, just 'cause it's easier that way. */ /* NOTE: use memmove(), because the memory blocks overlap */ }
/* awt_get_next_put_back_event() */ * Determines whether or not there are X or Xt events pending. * Looks at the putbackQueue. /* if we have not allocate an array, do it first */ /* find the position of the shell in the array */ /* remove the found element */ * Simply waits for terminateFn() to return True. Waits on the * awt lock and is notified to check its state by the main event * loop whenever the Xt event queue is empty. * NOTE: when you use this routine check if it can be called on the event * dispatch thread during drag-n-drop operation and update * secondary_loop_event() predicate to prevent deadlock. * fix for bug #4088106 - ugly text boxes and grayed out looking text /* use the default procedure to calculate colors */ /* check if there is enought free color cells */ /* find the closest matches currently available */ * Read _XSETTINGS_SETTINGS property from _XSETTINGS selection owner * and pass its value to the java world for processing. /* Returns of XGetWindowProperty */ * As toolkit cannot yet cope with per-screen desktop properties, * only report XSETTINGS changes on the default screen. This * should be "good enough" for most cases. * use the appropriate one. DTRACE_PRINTLN(
"XS: _XSETTINGS_SETTINGS is not of type _XSETTINGS_SETTINGS");
/* ok, propagate xsettings to the toolkit for processing */ * Event handler for events on XSETTINGS selection owner. * We are interested in PropertyNotify only. /* XXX: notify toolkit to reset to "defaults"? */ * Owner of XSETTINGS selection changed on the given screen. /* XXX: reset to defaults??? */ * Returns a reference to the class java.awt.Component. /* exception already thrown */ * Returns a reference to the class java.awt.MenuComponent. /* exception already thrown */ * Class: sun_awt_motif_MToolkit * Note: The MToolkit object depends on the static initializer * of X11GraphicsEnvironment to initialize the connection to "*enableThinThickness: True",
"*XmFileSelectionBox.fileFilterStyle: XmFILTER_HIDDEN_FILES",
"*XmFileSelectionBox.pathMode: XmPATH_MODE_RELATIVE",
"*XmFileSelectionBox.resizePolicy: XmRESIZE_GROW",
"*XmFileSelectionBox*dirTextLabelString: Enter path or folder name:",
"*XmFileSelectionBox*applyLabelString: Update",
"*XmFileSelectionBox*selectionLabelString: Enter file name:",
"*XmFileSelectionBox*dirListLabelString: Folders",
NULL /* Must be NULL terminated */ /* Need to make sure this is deleted someplace! */ "current locale is not supported in X11, locale is set to C");
"getDefaultMotifFontSet",
"-monotype-arial-regular-r-normal--*-140-*-*-p-*-iso8859-1";
/* fprintf(stderr, "motifFontList: %s\n", motifFontList); */ /* Root shell widget that serves as a parent for all AWT top-levels. */ * Find the correct awt_multiclick_time to use. We normally * would call XtMultiClickTime() and wouldn't have to do * anything special, but because OpenWindows defines its own * version (OpenWindows.MultiClickTimeout), we need to * determine out which resource to use. * We do this by searching in order for: * 1) an explicit definition of multiClickTime * (this is the resource that XtGetMultiClickTime uses) * if that fails, search for: * 2) an explicit definition of Openwindows.MultiClickTimeout * 3) use the fallback provided by XtGetMultiClickTime() * (which is 200 milliseconds... I looked at the source :-) "OpenWindows",
"MultiClickTimeout");
/* Note: OpenWindows.MultiClickTimeout is in tenths of a second, so we need to multiply by 100 to convert to * Create the cursor for TextArea scrollbars... * fix for bug #4088106 - ugly text boxes and grayed out looking text * Class: sun_awt_motif_MToolkit * in performSelect(), we multiply the timeout by 1000. Make sure * that the maximum value will not cause an overflow. * Class: sun_awt_motif_MToolkit * Class: sun_awt_motif_MToolkit * Method: getScreenResolution * Class: sun_awt_motif_MToolkit * Class: sun_awt_motif_MToolkit * Method: getScreenHeight * Class: sun_awt_motif_MToolkit * Class: sun_awt_motif_MToolkit * Class: sun_awt_motif_MToolkit * Method: getLockingKeyStateNative * Class: sun_awt_motif_MToolkit * Method: loadSystemColors * initialize array of pixels * Create phantom widgets in order to determine the default * colors; this is somewhat inelegant, however it is the simplest * and most reliable way to determine the system's default colors XtSetMappedWhenManaged(frame, False); * Convert pixel values to RGB /* Get current System Colors */ * Fill systemColor array with new rgb values printf("SystemColor[%d] = %x\n", i, rgb); /* Duplicate system colors. If color allocation is unsuccessful, system colors will be approximated with matched colors */ * Class: sun_awt_motif_MToolkit * Method: isDynamicLayoutSupportedNative * Note: there doesn't seem to be a protocol for querying the WM * about its opaque resize settings, so this function just returns * whether there is a solid resize option available for that WM. * Class: sun_awt_motif_MToolkit * Method: isFrameStateSupported * Class: sun_awt_motif_MToolkit * Method: getMulticlickTime * Class: sun_awt_motif_MToolkit "unable to intern _XSETTINGS_SETTINGS");
"parseXSettings",
"(I[B)V");
"sun.awt.motif.MToolkit.parseXSettings");
"unable to regiser _XSETTINGS with mgrsel");
* Returns true if the current thread is privileged. Currently, * only the main event loop thread is considered to be privileged. // AWT_LOCK is held by calling function // Calling function will call AWT_LOCK_WAIT instead of AWT_UNLOCK // AWT_LOCK must be held by the calling method * Class: sun_awt_motif_MToolkit