XlibWrapper.c revision 6447
5a3bd0ef762b8a3238869ac9963194555e39e6a7jpikus * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
5a3bd0ef762b8a3238869ac9963194555e39e6a7jpikus * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5a3bd0ef762b8a3238869ac9963194555e39e6a7jpikus * This code is free software; you can redistribute it and/or modify it
5a3bd0ef762b8a3238869ac9963194555e39e6a7jpikus * under the terms of the GNU General Public License version 2 only, as
* or visit www.oracle.com if you need additional information or have any
#include "sun_awt_X11_XlibWrapper.h"
#include <string.h>
#include <stdlib.h>
#include <jni.h>
#include <jni_util.h>
#include <jlong.h>
#include <sizecalc.h>
#include <awt.h>
#include <jvm.h>
#include <Region.h>
#define AWT_CHECK_HAVE_LOCK()
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_DefaultScreen (JNIEnv *env, jclass clazz, jlong display) {
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_ScreenOfDisplay(JNIEnv *env, jclass clazz, jlong display, jlong screen_number) {
JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_DoesBackingStore(JNIEnv *env, jclass clazz, jlong screen) {
XSetInputFocus( (Display *)jlong_to_ptr(display),(Window) window, RevertToPointerRoot, CurrentTime);
int revert_to;
return focusOwner;
(JNIEnv *env, jclass clazz, jlong display, jlong device, jlong bits_to_change, jlong values_for_bits)
(unsigned long)bits_to_change,
(unsigned long)values_for_bits);
(JNIEnv *env, jclass clazz, jlong display, jlong device, jlong event_type, jlong bits_to_change, jlong values_for_bits)
(unsigned int) event_type,
(unsigned long)bits_to_change,
(unsigned long)values_for_bits);
return XkbLibraryVersion((int *)jlong_to_ptr(lib_major_in_out), (int *)jlong_to_ptr(lib_minor_in_out));
(unsigned int) which,
(unsigned int) device_spec);
(unsigned int) which,
(JNIEnv *env, jclass clazz, jlong xkb, jint keycode, jlong mods, jlong mods_rtrn, jlong keysym_rtrn)
Bool b;
//printf("native, output: keysym:0x%0X; mods:0x%0X\n", *(unsigned int *)jlong_to_ptr(keysym_rtrn), *(unsigned int *)jlong_to_ptr(mods_rtrn));
XWindowEvent( (Display *) jlong_to_ptr(display), (Window)window, event_mask, (XEvent *) jlong_to_ptr(event_return));
if (modifier_list) {
(JNIEnv *env, jclass clazz, jlong display, jlong window, jint x , jint y , jint width, jint height) {
char *cname;
#ifdef X_HAVE_UTF8_STRING
#ifdef X_HAVE_UTF8_STRING
XChangeProperty((Display *)jlong_to_ptr(display), window, atom, tp.encoding, tp.format, PropModeReplace, tp.value, tp.nitems);
#ifdef X_HAVE_UTF8_STRING
* Signature: (JJJJJJJJJLjava/lang/String;)V
if (iscopy) {
return XGetWindowProperty((Display*) jlong_to_ptr(display), window, property, long_offset, long_length,
int status;
int actual_format;
unsigned long nitems;
unsigned long bytes_after;
unsigned char * string;
&string);
return NULL;
return NULL;
char *cname;
unsigned long atom;
(JNIEnv *env , jclass clazz, jlong display, jlong source, jlong mask, jlong fore, jlong back, jint x , jint y) {
return (jlong) XCreatePixmapCursor((Display *) jlong_to_ptr(display), (Pixmap) source, (Pixmap) mask,
(JNIEnv *env, jclass clazz, jlong display, jlong drawable, jint width, jint height, jlong width_return, jlong height_return) {
else return JNI_TRUE;
(JNIEnv *env, jclass clazz, jlong display, jlong w, jlong root_return, jlong child_return, jlong root_x_return , jlong root_y_return, jlong win_x_return, jlong win_y_return, jlong mask_return) {
Bool b;
else return JNI_FALSE;
XChangeWindowAttributes((Display *) jlong_to_ptr(display), (Window) window, (unsigned long) valuemask,
return XGetPointerMapping((Display*)jlong_to_ptr(display), (unsigned char*) jlong_to_ptr(map), buttonNumber);
return NULL;
return NULL;
(const signed char*) storage);
return res;
int kc7;
if( !kc7 ) {
return JNI_FALSE;
return JNI_TRUE;
return JNI_FALSE;
int xx;
int xx;
int32_t i;
keySyms = XGetKeyboardMapping((Display*)jlong_to_ptr(display), minKeyCode, maxKeyCode - minKeyCode + 1, &keySymsPerKeyCode);
kanaCount++;
if (env) {
return (*(XErrorHandler)jlong_to_ptr(handler))((Display*) jlong_to_ptr(display), (XErrorEvent*) jlong_to_ptr(event_ptr));
XGetErrorDatabaseText((Display *)jlong_to_ptr(display), "XRequest", buf, "Unknown", msg, sizeof(msg));
(JNIEnv *env, jclass clazz, jlong display, jobjectArray names_arr, jboolean only_if_exists, jlong atoms)
int status;
status = XInternAtoms((Display*)jlong_to_ptr(display), names, name_index, only_if_exists, (Atom*) jlong_to_ptr(atoms));
return status;
status = XGetWindowAttributes((Display*)jlong_to_ptr(display), window, (XWindowAttributes*) jlong_to_ptr(attr_ptr));
return status;
return status;
(JNIEnv *env, jclass clazz, jlong display, jlong window, jboolean propagate, jlong event_mask, jlong event)
(long) event_mask,
(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong root_return, jlong parent_return, jlong children_return, jlong nchildren_return)
(JNIEnv *env, jclass clazz, jlong display, jlong window, jint x, jint y, jint width, jint height, jlong flags) {
hints->x = x;
hints->y = y;
(long) vinfo_mask,
status = XAllocColor((Display *) jlong_to_ptr(display), (Colormap) colormap, (XColor *) jlong_to_ptr(xcolor));
else return JNI_TRUE;
time);
char* name;
return NULL;
return string;
Java_sun_awt_X11_XlibWrapper_XCreatePixmap(JNIEnv *env, jclass clazz, jlong display, jlong drawable, jint width, jint height, jint depth)
return ptr_to_jlong(XCreateImage((Display*) jlong_to_ptr(display), (Visual*) jlong_to_ptr(visual_ptr),
return ptr_to_jlong(XCreateGC((Display*) jlong_to_ptr(display), (Drawable)drawable, valuemask, (XGCValues*) jlong_to_ptr(values)));
Java_sun_awt_X11_XlibWrapper_XPutImage(JNIEnv *env, jclass clazz, jlong display, jlong drawable, jlong gc, jlong image, jint src_x, jint src_y, jint dest_x, jint dest_y, jint width, jint height)
XPutImage((Display*)jlong_to_ptr(display), (Drawable)drawable, (GC) jlong_to_ptr(gc), (XImage*) jlong_to_ptr(image), src_x, src_y,
Java_sun_awt_X11_XlibWrapper_XSetWindowBackgroundPixmap(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong pixmap)
Java_sun_awt_X11_XlibWrapper_XGetIconSizes(JNIEnv *env, jclass clazz, jlong display, jlong window, jlong ret_sizes, jlong ret_count)
return res;
return XdbeQueryExtension((Display*) jlong_to_ptr(display), (int *) jlong_to_ptr(major_version_return),
char *cname;
return JNI_TRUE;
return JNI_FALSE;
return XdbeSwapBuffers((Display*) jlong_to_ptr(display), (XdbeSwapInfo *) jlong_to_ptr(swap_info), num_windows);
// printf(" compat_state:0x%0X\n",sr.compat_state);
// printf(" compat_grab_mods:0x%0X\n",sr.compat_grab_mods);
// printf(" compat_lookup_mods:0x%0X\n",sr.compat_lookup_mods);
return XkbKeycodeToKeysym((Display*) jlong_to_ptr(display), (unsigned int)keycode, (unsigned int)group, (unsigned int)level);
static Bool
while (!exitSecondaryLoop) {
if (XCheckIfEvent((Display*) jlong_to_ptr(display), (XEvent*) jlong_to_ptr(ptr), secondary_loop_event, NULL)) {
return JNI_TRUE;
return JNI_FALSE;
int32_t i;
return NULL;
return NULL;
if (len == 0) {
return NULL;
return NULL;
if (nstrings == 0) {
goto wayout;
goto wayout;
for (i = 0; i < nstrings; i++) {
(const char *)strings[i]);
goto wayout;
goto wayout;
goto wayout;
return ret;
jobject o) {
return ptr_to_jlong(o);
if (isCopy) {
if (isCopy) {
return status;
if (above == 0) {
int numrects;
if (!pRect) {