XToolkit.c revision 1224
0N/A#include <execinfo.h>
0N/A#include <jni_util.h>
0N/A#include "awt_Component.h"
0N/A#include "awt_MenuComponent.h"
0N/A#include "awt_KeyboardFocusManager.h"
0N/A#include "awt_Font.h"
0N/A#include "sun_awt_X11_XToolkit.h"
0N/A#include "java_awt_SystemColor.h"
0N/A#include "java_awt_TrayIcon.h"
static int tracing = 0;
#ifdef PRINT
#ifdef PRINT2
#ifndef HEADLESS
/* This function gets called from the static initializer for FileDialog.java
return JNI_VERSION_1_2;
"Lsun/awt/AppContext;");
#ifdef HEADLESS
return JNI_TRUE;
return JNI_FALSE;
#include <limits.h>
#include <locale.h>
#include <pthread.h>
#include <dlfcn.h>
#include <fcntl.h>
#include <poll.h>
#ifndef POLLRDNORM
static void awt_pipe_init();
static void wakeUp();
#ifndef bzero
#define TIMEOUT_TIMEDOUT 0
awt_pipe_init() {
if (awt_pipe_inited) {
static void readEnv() {
char * value;
if (env_read) return;
if (AWT_MAX_POLL_TIMEOUT == 0) {
if (AWT_FLUSH_TIMEOUT == 0) {
if (static_poll_timeout != 0) {
* Returns the amount of milliseconds similar to System.currentTimeMillis()
static jlong
awtJNI_TimeMillis(void)
struct timeval t;
gettimeofday(&t, 0);
if (static_poll_timeout != 0) return;
uint32_t taskTimeout = (nextTaskTime == -1) ? AWT_MAX_POLL_TIMEOUT : (uint32_t)max(0, (int32_t)(nextTaskTime - curTime));
uint32_t flushTimeout = (awt_next_flush_time > 0) ? (uint32_t)max(0, (int32_t)(awt_next_flush_time - curTime)) : AWT_MAX_POLL_TIMEOUT;
PRINT2("to: %d, ft: %d, to: %d, tt: %d, mil: %d\n", taskTimeout, flushTimeout, timeout, (int)nextTaskTime, (int)curTime);
JNIEXPORT void JNICALL Java_sun_awt_X11_XToolkit_waitForEvents (JNIEnv *env, jclass class, jlong nextTaskTime) {
readEnv();
wakeUp();
if (!pollFdsInited) {
if (timeout == 0) {
AWT_LOCK();
if (result == 0) {
int count;
void awt_output_flush() {
if (awt_next_flush_time == 0) {
AWT_LOCK();
wakeUp();
static void wakeUp() {
if (key) {
if (ptr) {
return ret;
#ifdef __linux__
void print_stack(void)
char **strings;
size_t i;
for (i = 0; i < size; i++)
xawt_root_shell = (Window) (*env)->CallStaticLongMethod(env, classXRootWindow, methodGetXRootWindow);
return xawt_root_shell;
const char *command;
AWT_LOCK();
AWT_UNLOCK();
c[0] = (char *)command;
AWT_UNLOCK();
int argc;
const char **cargv;
int status;
AWT_LOCK();
AWT_UNLOCK();
if (argc == 0) {
AWT_UNLOCK();
AWT_UNLOCK();
for (i = 0; i < argc; ++i) {
const char *cs;
if (status < 0) {
switch (status) {
case XNoMemory:
case XLocaleNotSupported:
case XConverterNotFound:
for (i = 0; i < argc; ++i) {
AWT_UNLOCK();
AWT_LOCK();
AWT_UNLOCK();
if (num_buttons == 0) {
return num_buttons;
DTRACE_PRINTLN3("RobotPeer: XQueryExtension(XINPUT) returns major_opcode = %d, first_event = %d, first_error = %d",
if (xinputAvailable) {
if (local_num_buttons <= 0 ) {
DTRACE_PRINTLN1("RobotPeer: XINPUT extension is unavailable, assuming %d mouse buttons", num_buttons);
if (local_num_buttons == 0 ) {
return local_num_buttons;