Prima
view release on metacpan or search on metacpan
win32/global.c view on Meta::CPAN
BOOL b;
if ( DwmIsCompositionEnabled(&b) != S_OK) goto NOPE;
return b;
} else {
HKEY hKey;
DWORD valSize = 256, valType = REG_SZ, dw = 0;
NOPE:
if ( LOBYTE(LOWORD(guts.version)) > 5 )
return 1;
valType = REG_DWORD;
valSize = sizeof(DWORD);
if ( RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\DWM", 0, KEY_READ, &hKey) == 0 ) {
if ( RegQueryValueEx( hKey, "CompositionPolicy", NULL, &valType, ( LPBYTE)&dw, &valSize) != 0 )
dw = 1;
RegCloseKey( hKey);
return dw == 0;
} else
return 0;
}
}
Bool
read_console_input( WINHANDLE hConsoleInput, PINPUT_RECORD lpBuffer, DWORD nLength, LPDWORD lpNumberOfEventsRead, USHORT wFlags)
{
return ReadConsoleInputExW( hConsoleInput, lpBuffer, nLength, lpNumberOfEventsRead, wFlags);
}
static void
load_function(HMODULE module, void ** ptr, const char * name)
{
(*ptr) = (void*) GetProcAddress(module, name);
}
BOOL WINAPI
win32_ctrlhandler(DWORD dwCtrlType)
{
PostThreadMessage( guts. main_thread_id, WM_SIGNAL, dwCtrlType, 0);
return FALSE;
}
Bool
window_subsystem_init( char * error_buf)
{
WNDCLASSW wc;
HDC dc;
HBITMAP hbm;
OSVERSIONINFO os = { sizeof( OSVERSIONINFO)};
GdiplusStartupInput gdiplusStartupInputDef = { 1, NULL, FALSE, FALSE };
guts. version = GetVersion();
GetVersionEx( &os);
guts. utf8_prepend_0x202D =
(( os.dwMajorVersion > 5) || (os.dwMajorVersion == 5 && os.dwMinorVersion > 1)) ?
1 : 0;
guts. alloc_utf8_to_wchar_visual =
guts. utf8_prepend_0x202D ?
alloc_utf8_to_wchar_visual :
alloc_utf8_to_wchar;
guts. main_thread_id = GetCurrentThreadId();
guts. error_mode = SetErrorMode( SEM_FAILCRITICALERRORS);
guts. desktop_window = GetDesktopWindow();
std_arrow_cursor = LoadCursor( NULL, IDC_ARROW);
memset( &wc, 0, sizeof( wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = ( WNDPROC) generic_app_handler;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = guts. instance;
wc.hIcon = LoadIcon( guts. instance, IDI_APPLICATION);
wc.hCursor = LoadCursor( NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)NULL;
wc.lpszClassName = L"GenericApp";
RegisterClassW( &wc);
memset( &wc, 0, sizeof( wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = ( WNDPROC) generic_frame_handler;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = guts. instance;
wc.hIcon = LoadIcon( guts. instance, IDI_APPLICATION);
wc.hCursor = std_arrow_cursor;
wc.hbrBackground = (HBRUSH)NULL;
wc.lpszClassName = L"GenericFrame";
RegisterClassW( &wc);
memset( &wc, 0, sizeof( wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = ( WNDPROC) layered_frame_handler;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = guts. instance;
wc.hIcon = LoadIcon( guts. instance, IDI_APPLICATION);
wc.hCursor = std_arrow_cursor;
wc.hbrBackground = (HBRUSH)NULL;
wc.lpszClassName = L"LayeredFrame";
RegisterClassW( &wc);
memset( &wc, 0, sizeof( wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = ( WNDPROC) generic_view_handler;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = guts. instance;
wc.hIcon = LoadIcon( guts. instance, IDI_APPLICATION);
wc.hCursor = NULL; // LoadCursor( NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)NULL;
wc.lpszClassName = L"Generic";
RegisterClassW( &wc);
mgr_styli = hash_create();
mgr_fonts = hash_create();
mgr_patterns = hash_create();
mgr_menu = hash_create();
mgr_images = hash_create();
mgr_registry = hash_create();
mgr_myfonts = hash_create();
mgr_menu_bitmaps = hash_create();
mgr_scripts = hash_create();
create_font_hash();
win32/global.c view on Meta::CPAN
while ( w && w != self) {
if ( !dsys( w) options. aptClipOwner) {
hasCO = true;
break;
}
w = (( PWidget) w)-> owner;
}
if ( !hasCO) {
var self-> set_selected( self, true);
}
// else we do not select any widget, but still have a chance to resize frame :)
}
break;
case WM_SIZE:
if ( !is_apt( aptIgnoreSizeMessages)) {
int state = wsNormal;
Bool doWSChange = false;
if (( int) mp1 == SIZE_RESTORED) {
state = wsNormal;
if ( sys s. window. state != state)
doWSChange = true;
} else if (( int) mp1 == SIZE_MAXIMIZED) {
state = wsMaximized;
doWSChange = true;
} else if (( int) mp1 == SIZE_MINIMIZED) {
state = wsMinimized;
doWSChange = true;
}
if ( doWSChange) {
ev.gen.i = sys s.window.state = state;
ev.cmd = cmWindowState;
}
}
break;
case WM_SYNCMOVE: {
Handle parent = v-> self-> get_parent(( Handle) v);
if ( parent) {
Point pos = var self-> get_origin( self);
ev. cmd = cmMove;
ev. gen. P = pos;
if ( pos. x == var pos. x && pos. y == var pos. y) ev. cmd = 0;
}
break;
}
case WM_MOVE: {
Handle parent = v-> self-> get_parent(( Handle) v);
if ( parent) {
Point sz = CWidget(parent)-> get_size( parent);
ev. cmd = cmMove;
ev. gen . P. x = ( short) LOWORD( mp2);
ev. gen . P. y = sz. y - ( short) HIWORD( mp2) - sys y_override;
}
break;
}
// case WM_SYSCHAR:return 1;
case WM_TIMER:
if ( mp1 == TID_USERMAX) {
POINT p;
HWND wp;
if ( last_mouse_over && !GetCapture() && ( PObject( last_mouse_over)-> stage == csNormal)) {
HWND desktop = HWND_DESKTOP;
GetCursorPos( &p);
wp = WindowFromPoint( p);
if ( wp) {
POINT xp = p;
MapWindowPoints( desktop, wp, &xp, 1);
wp = ChildWindowFromPointEx( wp, xp, CWP_SKIPINVISIBLE);
} else
wp = ChildWindowFromPointEx( wp, p, CWP_SKIPINVISIBLE);
if ( wp != ( HWND)(( PWidget) last_mouse_over)-> handle)
{
HWND old = ( HWND)(( PWidget) last_mouse_over)-> handle;
Handle s;
last_mouse_over = NULL_HANDLE;
SendMessage( old, WM_MOUSEEXIT, 0, 0);
s = hwnd_to_view( wp);
if ( s && ( HWND)(( PWidget) s)-> handle == wp)
{
MapWindowPoints( desktop, wp, &p, 1);
SendMessage( wp, WM_MOUSEENTER, 0, MAKELPARAM( p. x, p. y));
last_mouse_over = s;
} else if ( guts. mouse_timer) {
guts. mouse_timer = 0;
if ( !KillTimer( dsys(prima_guts.application)handle, TID_USERMAX)) apiErr;
}
}
}
return 0;
} else {
int id = mp1 - 1;
if ( id >= 0 && id < time_defs_count) {
ev. gen. H = ( Handle) time_defs[ id]. item;
if ( ev. gen. H) {
v = ( PWidget)( self = ev. gen. H);
ev. cmd = cmTimer;
}
}
}
break;
case WM_GETMINMAXINFO: {
LPMINMAXINFO l = ( LPMINMAXINFO) mp2;
Point min = var self-> get_sizeMin( self);
Point max = var self-> get_sizeMax( self);
Point bor = get_window_borders( sys s. window. border_style);
int dy = 0 +
(( sys s. window. border_icons & biTitleBar) ? GetSystemMetrics( SM_CYCAPTION) : 0) +
( PWindow(self)-> menu ? GetSystemMetrics( SM_CYMENU) : 0);
l-> ptMinTrackSize. x = min. x + bor.x * 2;
l-> ptMinTrackSize. y = min. y + bor.y * 2 + dy;
l-> ptMaxTrackSize. x = max. x + bor.x * 2;
l-> ptMaxTrackSize. y = max. y + bor.y * 2 + dy;
break;
}
case WM_WINDOWPOSCHANGED:
if ( !is_apt(aptIgnoreSizeMessages)) {
LPWINDOWPOS l = ( LPWINDOWPOS) mp2;
if (( l-> flags & SWP_NOZORDER) == 0)
PostMessage( win, WM_ZORDERSYNC, 0, 0);
if (( l-> flags & SWP_NOSIZE) == 0) {
RECT r;
GetClientRect( win, &r);
sys y_override = r. bottom - r. top;
SendMessage( win, WM_SYNCMOVE, 0, 0);
}
if ( l-> flags & SWP_HIDEWINDOW) SendMessage( win, WM_SETVISIBLE, 0, 0);
if ( l-> flags & SWP_SHOWWINDOW) SendMessage( win, WM_SETVISIBLE, 1, 0);
{
RECT r;
GetClientRect( win, &r);
SetWindowPos(( HWND) var handle, 0, 0, 0, r. right, r.bottom, SWP_NOZORDER);
}
}
break;
}
if ( hiStage)
ret = DefWindowProcW( win, msg, mp1, mp2);
if ( ev. cmd) v-> self-> message( self, &ev); else ev. cmd = orgMsg;
( run in 1.365 second using v1.01-cache-2.11-cpan-39bf76dae61 )