< prev index next >
src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp
Print this page
@@ -29,13 +29,14 @@
#include "awt_Robot.h"
#include "sun_awt_windows_WRobotPeer.h"
#include "java_awt_event_InputEvent.h"
#include <winuser.h>
-AwtRobot::AwtRobot( jobject peer )
+AwtRobot::AwtRobot(jobject peer, int screen)
{
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+ m_deviceIndex = screen;
m_peerObject = env->NewWeakGlobalRef(peer);
JNU_CHECK_EXCEPTION(env);
JNI_SET_PDATA(peer, this);
}
@@ -78,16 +79,18 @@
// value itself is now passed, cast as a PVOID so as to
// compile. -bchristi 10/02/2001
(PVOID)newSpeed,
SPIF_SENDCHANGE);
- int primaryIndex = AwtWin32GraphicsDevice::GetDefaultDeviceIndex();
Devices::InstanceAccess devices;
- AwtWin32GraphicsDevice *device = devices->GetDevice(primaryIndex);
+ AwtWin32GraphicsDevice *device = devices->GetDevice(m_deviceIndex);
- x = (device == NULL) ? x : device->ScaleUpX(x);
- y = (device == NULL) ? y : device->ScaleUpY(y);
+ RECT rect = {0, 0, 0, 0};
+ MonitorBounds(AwtWin32GraphicsDevice::GetMonitor(m_deviceIndex), &rect);
+
+ x = rect.left + (device == NULL ? x : device->ScaleUpX(x));
+ y = rect.top + (device == NULL ? y : device->ScaleUpY(y));
POINT curPos;
::GetCursorPos(&curPos);
x -= curPos.x;
y -= curPos.y;
@@ -202,11 +205,13 @@
void AwtRobot::GetRGBPixels(jint x, jint y, jint width, jint height, jintArray pixelArray)
{
DASSERT(width > 0 && height > 0);
- HDC hdcScreen = ::CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
+ MONITORINFOEX *pMonInfo =
+ (LPMONITORINFOEX)AwtWin32GraphicsDevice::GetMonitorInfo(m_deviceIndex);
+ HDC hdcScreen = ::CreateDC(TEXT("DISPLAY"), pMonInfo->szDevice, NULL, NULL);
HDC hdcMem = ::CreateCompatibleDC(hdcScreen);
HBITMAP hbitmap;
HBITMAP hOldBitmap;
HPALETTE hOldPalette = NULL;
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
@@ -216,18 +221,16 @@
if (hbitmap == NULL) {
throw std::bad_alloc();
}
hOldBitmap = (HBITMAP)::SelectObject(hdcMem, hbitmap);
- // REMIND: not multimon-friendly...
- int primaryIndex = AwtWin32GraphicsDevice::GetDefaultDeviceIndex();
hOldPalette =
- AwtWin32GraphicsDevice::SelectPalette(hdcMem, primaryIndex);
- AwtWin32GraphicsDevice::RealizePalette(hdcMem, primaryIndex);
+ AwtWin32GraphicsDevice::SelectPalette(hdcMem, m_deviceIndex);
+ AwtWin32GraphicsDevice::RealizePalette(hdcMem, m_deviceIndex);
Devices::InstanceAccess devices;
- AwtWin32GraphicsDevice *device = devices->GetDevice(primaryIndex);
+ AwtWin32GraphicsDevice *device = devices->GetDevice(m_deviceIndex);
int sWidth = (device == NULL) ? width : device->ScaleUpX(width);
int sHeight = (device == NULL) ? height : device->ScaleUpY(height);
// copy screen image to offscreen bitmap
// CAPTUREBLT flag is required to capture WS_EX_LAYERED windows' contents
@@ -367,15 +370,15 @@
//////////////////////////////////////////////////////////////////////////////////////////////
// Native method declarations
//
JNIEXPORT void JNICALL Java_sun_awt_windows_WRobotPeer_create(
- JNIEnv * env, jobject self)
+ JNIEnv * env, jobject self, jint screen)
{
TRY;
- new AwtRobot(self);
+ new AwtRobot(self, screen);
CATCH_BAD_ALLOC;
}
JNIEXPORT void JNICALL Java_sun_awt_windows_WRobotPeer__1dispose(
< prev index next >