mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-23 11:51:27 +00:00
Change the way the image for the cursor gets passed on to the backend.
The old way could only work for 8 bit data. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@32492 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8343fe8a64
commit
8913452ffc
3 changed files with 85 additions and 7 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2011-03-07 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/win32/WIN32Server.m,
|
||||||
|
* Source/x11/XGServerWindow.m: Change the way the image for the cursor
|
||||||
|
gets passed on to the backend. The old way could only work for 8
|
||||||
|
bit data.
|
||||||
|
|
||||||
2011-03-05 Wolfgang Lux <wolfgang.lux@gmail.com>
|
2011-03-05 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||||
|
|
||||||
* Tools/xpbs.m (+xEvent:, +receivedEvent:type:extra:,
|
* Tools/xpbs.m (+xEvent:, +receivedEvent:type:extra:,
|
||||||
|
|
|
@ -1624,13 +1624,13 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
|
||||||
*cid = (void*)hCursor;
|
*cid = (void*)hCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) imagecursor: (NSPoint)hotp : (int) w : (int) h
|
- (void) imagecursor: (NSPoint)hotp : (NSImage *)image : (void **)cid
|
||||||
: (int)colors : (const unsigned char *)image : (void **)cid
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
HCURSOR cur;
|
HCURSOR cur;
|
||||||
BYTE *and;
|
BYTE *and;
|
||||||
BYTE *xor;
|
BYTE *xor;
|
||||||
|
int w, h;
|
||||||
|
|
||||||
xor = image;
|
xor = image;
|
||||||
cur = CreateCursor(hinstance, (int)hotp.x, (int)hotp.y, (int)w, (int)h, and, xor);
|
cur = CreateCursor(hinstance, (int)hotp.x, (int)hotp.y, (int)w, (int)h, and, xor);
|
||||||
|
|
|
@ -94,6 +94,17 @@ static int last_win_num = 0;
|
||||||
- (void *)_cid;
|
- (void *)_cid;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface NSBitmapImageRep (GSPrivate)
|
||||||
|
- (NSBitmapImageRep *) _convertToFormatBitsPerSample: (int)bps
|
||||||
|
samplesPerPixel: (int)spp
|
||||||
|
hasAlpha: (BOOL)alpha
|
||||||
|
isPlanar: (BOOL)isPlanar
|
||||||
|
colorSpaceName: (NSString*)colorSpaceName
|
||||||
|
bitmapFormat: (NSBitmapFormat)bitmapFormat
|
||||||
|
bytesPerRow: (int)rowBytes
|
||||||
|
bitsPerPixel: (int)pixelBits;
|
||||||
|
@end
|
||||||
|
|
||||||
void __objc_xgcontextwindow_linking (void)
|
void __objc_xgcontextwindow_linking (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -4156,16 +4167,76 @@ xgps_cursor_image(Display *xdpy, Drawable draw, const unsigned char *data,
|
||||||
*cid = (void *)cursor;
|
*cid = (void *)cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) imagecursor: (NSPoint)hotp : (int) w : (int) h : (int)colors
|
- (void) imagecursor: (NSPoint)hotp : (NSImage *)image : (void **)cid
|
||||||
: (const unsigned char *)image : (void **)cid
|
|
||||||
{
|
{
|
||||||
Cursor cursor;
|
Cursor cursor;
|
||||||
Pixmap source, mask;
|
Pixmap source, mask;
|
||||||
unsigned int maxw, maxh;
|
unsigned int maxw, maxh;
|
||||||
XColor fg, bg;
|
XColor fg, bg;
|
||||||
|
NSBitmapImageRep *rep;
|
||||||
|
int w, h;
|
||||||
|
int colors;
|
||||||
|
const unsigned char *data;
|
||||||
|
|
||||||
/* FIXME: We might create a blank cursor here? */
|
/* FIXME: We might create a blank cursor here? */
|
||||||
if (image == NULL || w <= 0 || h <= 0)
|
if (image == nil)
|
||||||
|
{
|
||||||
|
*cid = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
We should rather convert the image to a bitmap representation here via
|
||||||
|
the following code, but this is currently not supported by the libart backend
|
||||||
|
|
||||||
|
{
|
||||||
|
NSSize size = [image size];
|
||||||
|
|
||||||
|
[image lockFocus];
|
||||||
|
rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:
|
||||||
|
NSMakeRect(0, 0, size.width, size.height)];
|
||||||
|
AUTORELEASE(rep);
|
||||||
|
[image unlockFocus];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
rep = (NSBitmapImageRep *)[image bestRepresentationForDevice: nil];
|
||||||
|
if (!rep || ![rep respondsToSelector: @selector(samplesPerPixel)])
|
||||||
|
{
|
||||||
|
NSLog(@"NSCursor can only handle NSBitmapImageReps for now");
|
||||||
|
*cid = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Convert into something usable by the backend
|
||||||
|
rep = [rep _convertToFormatBitsPerSample: 8
|
||||||
|
samplesPerPixel: [rep hasAlpha] ? 4 : 3
|
||||||
|
hasAlpha: [rep hasAlpha]
|
||||||
|
isPlanar: NO
|
||||||
|
colorSpaceName: NSCalibratedRGBColorSpace
|
||||||
|
bitmapFormat: 0
|
||||||
|
bytesPerRow: 0
|
||||||
|
bitsPerPixel: 0];
|
||||||
|
if (rep == nil)
|
||||||
|
{
|
||||||
|
NSLog(@"Could not convert bitmap data");
|
||||||
|
*cid = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hotp.x >= [rep pixelsWide])
|
||||||
|
hotp.x = [rep pixelsWide]-1;
|
||||||
|
|
||||||
|
if (hotp.y >= [rep pixelsHigh])
|
||||||
|
hotp.y = [rep pixelsHigh]-1;
|
||||||
|
|
||||||
|
w = [rep pixelsWide];
|
||||||
|
h = [rep pixelsHigh];
|
||||||
|
colors = [rep samplesPerPixel];
|
||||||
|
data = [rep bitmapData];
|
||||||
|
|
||||||
|
if (w <= 0 || h <= 0)
|
||||||
{
|
{
|
||||||
*cid = NULL;
|
*cid = NULL;
|
||||||
return;
|
return;
|
||||||
|
@ -4178,8 +4249,8 @@ xgps_cursor_image(Display *xdpy, Drawable draw, const unsigned char *data,
|
||||||
if ((unsigned int)h > maxh)
|
if ((unsigned int)h > maxh)
|
||||||
h = maxh;
|
h = maxh;
|
||||||
|
|
||||||
source = xgps_cursor_image(dpy, ROOT, image, w, h, colors, &fg, &bg);
|
source = xgps_cursor_image(dpy, ROOT, data, w, h, colors, &fg, &bg);
|
||||||
mask = xgps_cursor_mask(dpy, ROOT, image, w, h, colors);
|
mask = xgps_cursor_mask(dpy, ROOT, data, w, h, colors);
|
||||||
bg = [self xColorFromColor: bg forScreen: defScreen];
|
bg = [self xColorFromColor: bg forScreen: defScreen];
|
||||||
fg = [self xColorFromColor: fg forScreen: defScreen];
|
fg = [self xColorFromColor: fg forScreen: defScreen];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue