mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-24 04:11:28 +00:00
Changes to prevent inconsistent main/key state and move alphablend to a separate function call.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@29722 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
92fdccd8d3
commit
588ae69c45
3 changed files with 99 additions and 16 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2010-02-24 16:45-EST Gregory John Casamento <greg.casamento@gmail.com>
|
||||||
|
|
||||||
|
* Source/win32/WIN32Server.m: Added a boolean to control if
|
||||||
|
callbacks are honored so that we can ignore the
|
||||||
|
SetActiveWindow(...) call when windows are resigned. Otherwise
|
||||||
|
this causes some issues and could result in an inconsistent state.
|
||||||
|
* Source/winlib/WIN32GState.m: Moved AlphaBlend to seperate
|
||||||
|
function so that it can be called elsewhere.
|
||||||
|
|
||||||
2010-02-20 Fred Kiefer <FredKiefer@gmx.de>
|
2010-02-20 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/gsc/GSStreamContext.m
|
* Source/gsc/GSStreamContext.m
|
||||||
|
|
|
@ -60,6 +60,8 @@
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static BOOL _enableCallbacks = YES;
|
||||||
|
|
||||||
static NSEvent *process_key_event(WIN32Server *svr,
|
static NSEvent *process_key_event(WIN32Server *svr,
|
||||||
HWND hwnd, WPARAM wParam,
|
HWND hwnd, WPARAM wParam,
|
||||||
LPARAM lParam, NSEventType eventType);
|
LPARAM lParam, NSEventType eventType);
|
||||||
|
@ -1429,7 +1431,9 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
|
||||||
}
|
}
|
||||||
if (state == GSTitleBarMain)
|
if (state == GSTitleBarMain)
|
||||||
{
|
{
|
||||||
|
_enableCallbacks = NO;
|
||||||
SetActiveWindow((HWND)winNum);
|
SetActiveWindow((HWND)winNum);
|
||||||
|
_enableCallbacks = YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1991,5 +1995,10 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
|
||||||
{
|
{
|
||||||
WIN32Server *ctxt = (WIN32Server *)GSCurrentServer();
|
WIN32Server *ctxt = (WIN32Server *)GSCurrentServer();
|
||||||
|
|
||||||
|
if(_enableCallbacks == NO)
|
||||||
|
{
|
||||||
|
return (LRESULT)NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return [ctxt windowEventProc: hwnd : uMsg : wParam : lParam];
|
return [ctxt windowEventProc: hwnd : uMsg : wParam : lParam];
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,79 @@ RECT GSViewRectToWin(WIN32GState *s, NSRect r)
|
||||||
return GSWindowRectToMS(s, r);
|
return GSWindowRectToMS(s, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* get_bits(HDC dc,
|
||||||
|
int w,
|
||||||
|
int h,
|
||||||
|
HBITMAP *bitmap)
|
||||||
|
{
|
||||||
|
void *bits = NULL;
|
||||||
|
BITMAPINFO info;
|
||||||
|
HDC cDC;
|
||||||
|
|
||||||
|
info.bmiHeader.biSize = sizeof(BITMAPINFO);
|
||||||
|
info.bmiHeader.biWidth = w;
|
||||||
|
info.bmiHeader.biHeight = h;
|
||||||
|
info.bmiHeader.biPlanes = 1;
|
||||||
|
info.bmiHeader.biBitCount = 32;
|
||||||
|
info.bmiHeader.biCompression = BI_RGB;
|
||||||
|
info.bmiHeader.biSizeImage = 0;
|
||||||
|
info.bmiHeader.biXPelsPerMeter = 0;
|
||||||
|
info.bmiHeader.biYPelsPerMeter = 0;
|
||||||
|
info.bmiHeader.biClrUsed = 0;
|
||||||
|
info.bmiHeader.biClrImportant = 0;
|
||||||
|
|
||||||
|
if(!(cDC = CreateCompatibleDC(dc)))
|
||||||
|
{
|
||||||
|
NSLog(@"Could not create compatible DC");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!(*bitmap = CreateDIBSection(dc, (LPBITMAPINFO)&info,
|
||||||
|
DIB_RGB_COLORS, &bits,
|
||||||
|
NULL, 0)))
|
||||||
|
{
|
||||||
|
NSLog(@"Could not create bit map from DC");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectObject(cDC, *bitmap);
|
||||||
|
|
||||||
|
return bits;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL alpha_blend_source_over(HDC destDC,
|
||||||
|
HDC srcDC,
|
||||||
|
RECT rectFrom,
|
||||||
|
int x, int y, int w, int h,
|
||||||
|
float delta)
|
||||||
|
{
|
||||||
|
BOOL success = YES;
|
||||||
|
|
||||||
|
#ifdef USE_ALPHABLEND
|
||||||
|
// Use (0..1) fraction to set a (0..255) alpha constant value
|
||||||
|
BYTE SourceConstantAlpha = (BYTE)(delta * 255);
|
||||||
|
BLENDFUNCTION blendFunc
|
||||||
|
= {AC_SRC_OVER, 0, SourceConstantAlpha, AC_SRC_ALPHA};
|
||||||
|
|
||||||
|
/* There is actually a very real chance this could fail, even on
|
||||||
|
computers that supposedly support it. It's not known why it
|
||||||
|
fails though... */
|
||||||
|
success = AlphaBlend(destDC,
|
||||||
|
x, y, w, h,
|
||||||
|
srcDC,
|
||||||
|
rectFrom.left, rectFrom.top,
|
||||||
|
w, h, blendFunc);
|
||||||
|
// #else
|
||||||
|
// HBITMAP sbitmap;
|
||||||
|
// HBITMAP dbitmap;
|
||||||
|
// unsigned char *sbits = (unsigned char *)get_bits(srcDC,w,h,&sbitmap);
|
||||||
|
// unsigned char *dbits = (unsigned char *)get_bits(destDC,w,h,&dbitmap);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
@interface WIN32GState (WinOps)
|
@interface WIN32GState (WinOps)
|
||||||
- (void) setStyle: (HDC)hDC;
|
- (void) setStyle: (HDC)hDC;
|
||||||
- (void) restoreStyle: (HDC)hDC;
|
- (void) restoreStyle: (HDC)hDC;
|
||||||
|
@ -238,22 +311,13 @@ RECT GSViewRectToWin(WIN32GState *s, NSRect r)
|
||||||
{
|
{
|
||||||
case NSCompositeSourceOver:
|
case NSCompositeSourceOver:
|
||||||
{
|
{
|
||||||
#ifdef USE_ALPHABLEND
|
success = alpha_blend_source_over(hDC,
|
||||||
// Use (0..1) fraction to set a (0..255) alpha constant value
|
|
||||||
BYTE SourceConstantAlpha = (BYTE)(delta * 255);
|
|
||||||
BLENDFUNCTION blendFunc
|
|
||||||
= {AC_SRC_OVER, 0, SourceConstantAlpha, AC_SRC_ALPHA};
|
|
||||||
success = AlphaBlend(hDC,
|
|
||||||
x, y, w, h,
|
|
||||||
sourceDC,
|
sourceDC,
|
||||||
rectFrom.left, rectFrom.top,
|
rectFrom,
|
||||||
w, h, blendFunc);
|
x, y, w, h,
|
||||||
/* There is actually a very real chance this could fail, even on
|
delta);
|
||||||
computers that supposedly support it. It's not known why it
|
|
||||||
fails though... */
|
|
||||||
if (success)
|
if (success)
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
case NSCompositeCopy:
|
case NSCompositeCopy:
|
||||||
{
|
{
|
||||||
|
@ -291,6 +355,7 @@ RECT GSViewRectToWin(WIN32GState *s, NSRect r)
|
||||||
op: (NSCompositingOperation)op
|
op: (NSCompositingOperation)op
|
||||||
{
|
{
|
||||||
float gray;
|
float gray;
|
||||||
|
BOOL success = NO;
|
||||||
|
|
||||||
// FIXME: This is taken from the xlib backend
|
// FIXME: This is taken from the xlib backend
|
||||||
[self DPScurrentgray: &gray];
|
[self DPScurrentgray: &gray];
|
||||||
|
|
Loading…
Reference in a new issue