jint AwtScrollPane::_GetOffset(void *param) { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); GetOffsetStruct *gos = (GetOffsetStruct *)param; jobject self = gos->scrollpane; jint orient = gos->orient; jint result = 0; AwtScrollPane *s = NULL; PDATA pData; JNI_CHECK_PEER_GOTO(self, ret); s = (AwtScrollPane *)pData; if (::IsWindow(s->GetHWnd())) { DTRACE_PRINTLN2("%x: WScrollPanePeer.getOffset(%d)", self, orient); s->VerifyState(); int nBar = (orient == java_awt_Adjustable_HORIZONTAL) ? SB_HORZ : SB_VERT; result = s->GetScrollPos(nBar); } ret: env->DeleteGlobalRef(self); delete gos; return result; }
static int32_t isXTestAvailable() { int32_t major_opcode, first_event, first_error; int32_t event_basep, error_basep, majorp, minorp; int32_t isXTestAvailable; /* check if XTest is available */ isXTestAvailable = XQueryExtension(awt_display, XTestExtensionName, &major_opcode, &first_event, &first_error); DTRACE_PRINTLN3("RobotPeer: XQueryExtension(XTEST) returns major_opcode = %d, first_event = %d, first_error = %d", major_opcode, first_event, first_error); if (isXTestAvailable) { /* check if XTest version is OK */ XTestQueryExtension(awt_display, &event_basep, &error_basep, &majorp, &minorp); DTRACE_PRINTLN4("RobotPeer: XTestQueryExtension returns event_basep = %d, error_basep = %d, majorp = %d, minorp = %d", event_basep, error_basep, majorp, minorp); if (majorp < 2 || (majorp == 2 && minorp < 2)) { /* bad version*/ DTRACE_PRINTLN2("XRobotPeer: XTEST version is %d.%d \n", majorp, minorp); if (majorp == 2 && minorp == 1) { DTRACE_PRINTLN("XRobotPeer: XTEST is 2.1 - no grab is available\n"); } else { isXTestAvailable = False; } } else { /* allow XTest calls even if someone else has the grab; e.g. during * a window resize operation. Works only with XTEST2.2*/ XTestGrabControl(awt_display, True); } } else { DTRACE_PRINTLN("RobotPeer: XTEST extension is unavailable"); } return isXTestAvailable; }
inline void AwtScrollbar::DoScrollCallbackCoalesce(const char* methodName, int newPos) { if (methodName == m_prevCallback && newPos == m_prevCallbackPos) { DTRACE_PRINTLN2("AwtScrollbar: ignoring duplicate callback %s(%d)", methodName, newPos); } else { DoCallback(methodName, "(I)V", newPos); m_prevCallback = methodName; m_prevCallbackPos = newPos; } }
/* * Class: sun_awt_windows_WScrollPanePeer * Method: getOffset * Signature: (I)I */ JNIEXPORT jint JNICALL Java_sun_awt_windows_WScrollPanePeer_getOffset(JNIEnv *env, jobject self, jint orient) { TRY; DTRACE_PRINTLN2("%x: WScrollPanePeer.getOffset(%d)", self, orient); PDATA pData; JNI_CHECK_PEER_RETURN_NULL(self); AwtScrollPane* pane = (AwtScrollPane *)pData; pane->VerifyState(); int nBar = (orient == java_awt_Adjustable_HORIZONTAL) ? SB_HORZ : SB_VERT; return pane->GetScrollPos(nBar); CATCH_BAD_ALLOC_RET(0); }
/* * Class: sun_awt_windows_WScrollPanePeer * Method: create * Signature: (Lsun/awt/windows/WComponentPeer;)V */ JNIEXPORT void JNICALL Java_sun_awt_windows_WScrollPanePeer_create(JNIEnv *env, jobject self, jobject parent) { TRY; DTRACE_PRINTLN2("%x: WScrollPanePeer.create(%x)", self, parent); PDATA pData; JNI_CHECK_PEER_RETURN(parent); AwtToolkit::CreateComponent(self, parent, (AwtToolkit::ComponentFactory) AwtScrollPane::Create); JNI_CHECK_PEER_CREATION_RETURN(self); ((AwtScrollPane*)pData)->VerifyState(); CATCH_BAD_ALLOC; }
static jint Win32OSSD_Lock(JNIEnv *env, SurfaceDataOps *ops, SurfaceDataRasInfo *pRasInfo, jint lockflags) { Win32SDOps *wsdo = (Win32SDOps *) ops; DTRACE_PRINTLN1("W32OSSD::Win32OSSD_Lock, lockflags = 0x%x", lockflags); wsdo->surfaceLock->Enter(); if (wsdo->invalid) { wsdo->surfaceLock->Leave(); SurfaceData_ThrowInvalidPipeException(env, "invalid sd"); return SD_FAILURE; } if (wsdo->lockType != WIN32SD_LOCK_UNLOCKED) { wsdo->surfaceLock->Leave(); JNU_ThrowInternalError(env, "Win32OSSD_Lock cannot nest locks"); return SD_FAILURE; } if (lockflags & SD_LOCK_RD_WR) { if (pRasInfo->bounds.x1 < 0) pRasInfo->bounds.x1 = 0; if (pRasInfo->bounds.y1 < 0) pRasInfo->bounds.y1 = 0; if (pRasInfo->bounds.x2 > wsdo->w) pRasInfo->bounds.x2 = wsdo->w; if (pRasInfo->bounds.y2 > wsdo->h) pRasInfo->bounds.y2 = wsdo->h; if (DDUseDDraw(wsdo)) { Win32OSSD_LockByDD(env, wsdo, lockflags, pRasInfo); } if (wsdo->lockType == WIN32SD_LOCK_UNLOCKED) { wsdo->lockFlags = lockflags; wsdo->surfaceLock->Leave(); return SD_FAILURE; } } else { // They didn't ask for a lock, so they don't get one wsdo->lockType = WIN32SD_LOCK_BY_NULL; } wsdo->lockFlags = lockflags; DTRACE_PRINTLN2("Win32OSSD_Lock: flags, type = 0x%x, %d\n", wsdo->lockFlags, wsdo->lockType); return 0; }
/* * A method for a subsytem to express its interest in a certain * manager selection. * * If owner changes, the callback_owner will be called with the screen * number and the new owning window when onwership is established, or * None if the owner is gone. * * Events in extra_mask are selected for on owning windows (exsiting * ones and on new owners when established) and callback_event will be * called with the screen number and an event. * * The function returns an array of current owners. The size of the * array is ScreenCount(awt_display). The array is "owned" by this * module and should be considered by the caller as read-only. */ const Window * awt_mgrsel_select(const char *selname, long extra_mask, void *cookie, void (*callback_event)(int, XEvent *, void *), void (*callback_owner)(int, Window, long *, void *)) { Display *dpy = awt_display; struct AwtMgrsel *mgrsel; Atom *per_scr_atoms; Window *per_scr_owners; char *namesbuf; char **names; int per_scr_sz; int nscreens = ScreenCount(dpy); int scr; Status status; DASSERT(selname != NULL); DTRACE_PRINTLN1("MG: select: %s", selname); /* buffer size for one per-screen atom name */ per_scr_sz = strlen(selname) + /* "_S" */ 2 + /* %2d */ + 2 /* '\0' */+ 1; namesbuf = malloc(per_scr_sz * nscreens); /* actual storage for names */ names = malloc(sizeof(char *) * nscreens); /* pointers to names */ per_scr_atoms = malloc(sizeof(Atom) * nscreens); per_scr_owners = malloc(sizeof(Window) * nscreens); mgrsel = malloc(sizeof(struct AwtMgrsel)); if (namesbuf == NULL || names == NULL || per_scr_atoms == NULL || per_scr_owners == NULL || mgrsel == NULL) { DTRACE_PRINTLN("MG: select: unable to allocate memory"); if (namesbuf != NULL) free(per_scr_atoms); if (names != NULL) free(names); if (per_scr_atoms != NULL) free(per_scr_atoms); if (per_scr_owners != NULL) free(per_scr_owners); if (mgrsel != NULL) free(mgrsel); return (NULL); } for (scr = 0; scr < nscreens; ++scr) { size_t sz; names[scr] = &namesbuf[per_scr_sz * scr]; sz = snprintf(names[scr], per_scr_sz, "%s_S%-d", selname, scr); DASSERT(sz < per_scr_sz); } status = XInternAtoms(dpy, names, nscreens, False, per_scr_atoms); free(names); free(namesbuf); if (status == 0) { DTRACE_PRINTLN("MG: select: XInternAtoms failed"); free(per_scr_atoms); free(per_scr_owners); return (NULL); } mgrsel->selname = strdup(selname); mgrsel->per_scr_atoms = per_scr_atoms; mgrsel->per_scr_owners = per_scr_owners; mgrsel->extra_mask = extra_mask; mgrsel->cookie = cookie; mgrsel->callback_event = callback_event; mgrsel->callback_owner = callback_owner; for (scr = 0; scr < nscreens; ++scr) { Window owner; owner = awt_mgrsel_select_per_screen(per_scr_atoms[scr], extra_mask); mgrsel->per_scr_owners[scr] = owner; #ifdef DEBUG if (owner == None) { DTRACE_PRINTLN1("MG: screen %d - None", scr); } else { DTRACE_PRINTLN2("MG: screen %d - 0x%08lx", scr, owner); } #endif } mgrsel->next = mgrsel_list; mgrsel_list = mgrsel; return (per_scr_owners); }
JNIEXPORT void JNICALL Java_sun_awt_motif_MRobotPeer_getRGBPixelsImpl( JNIEnv *env, jclass cls, jobject xgc, jint x, jint y, jint width, jint height, jintArray pixelArray) { RCmdGetPixels cmd; RResultPixelHeader result; int row; int col; unsigned int *ary; AwtGraphicsConfigDataPtr adata; DTRACE_PRINTLN7("%lx: MRobotPeer.getRGBPixelsImpl(%lx, %d, %d, %d, %d, %x)", cls, xgc, x, y, width, height, pixelArray); /* avoid a lot of work for empty rectangles */ if ( (width * height) == 0 ) { return; } DASSERT(width * height > 0); /* only allow positive size */ adata = (AwtGraphicsConfigDataPtr) JNU_GetLongFieldAsPtr(env, xgc, x11GraphicsConfigIDs.aData); DASSERT(adata != NULL); cmd.code = RCMD_GETPIXELS; cmd.screen = adata->awt_visInfo.screen; cmd.x = x; cmd.y = y; cmd.width = width; cmd.height = height; robot_writeChildCommand((RCmdBase *)&cmd); /* * For getPixels, there is data to receive * from the child process. The following sequence * must match the sequence in the getPixels method. * * The robot_readBytes function automatically provides * synchronization with the sending of data * back to us. */ DTRACE_PRINTLN("PARENT: Waiting for pixels ..."); robot_getChildResult((char *)&result, sizeof(result)); DTRACE_PRINTLN2("PARENT: Got pixels header %d x %d", result.nRows, result.nCols); if (result.code == RES_OUTOFMEMORY) { JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError"); return; } ary = (unsigned int *)XtMalloc(height * width * sizeof(jint)); if (ary == NULL) { JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError"); /* eat up the data in the pipe so things remain in sync */ robot_flushChildResult(); return; } DASSERT(result.nRows == height && result.nCols == width); robot_getChildResult((char *)ary, (jint) (height * width * sizeof (jint))); (*env)->SetIntArrayRegion(env, pixelArray, 0, height * width, (jint *)ary); XtFree((char *)ary); }