win32u: Move get_scroll_info_ptr implementation from user32.

This commit is contained in:
Jacek Caban 2022-07-04 00:07:04 +02:00 committed by Alexandre Julliard
parent 5f93b3ca93
commit 4de61c465f
6 changed files with 66 additions and 90 deletions

View file

@ -31,17 +31,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(scroll);
typedef struct scroll_info SCROLLBAR_INFO, *LPSCROLLBAR_INFO;
typedef struct scroll_bar_win_data SCROLLBAR_WNDDATA;
/* data for window that has (one or two) scroll bars */
typedef struct
{
SCROLLBAR_INFO horz;
SCROLLBAR_INFO vert;
} WINSCROLLBAR_INFO, *LPWINSCROLLBAR_INFO;
#define SCROLLBAR_MAGIC 0x5c6011ba
/* Overlap between arrows and thumb */
#define SCROLL_ARROW_THUMB_OVERLAP 0
@ -54,71 +43,11 @@ const struct builtin_class_descr SCROLL_builtin_class =
L"ScrollBar", /* name */
CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC, /* style */
WINPROC_SCROLLBAR, /* proc */
sizeof(SCROLLBAR_WNDDATA), /* extra */
sizeof(struct scroll_bar_win_data), /* extra */
IDC_ARROW, /* cursor */
0 /* brush */
};
/***********************************************************************
* SCROLL_GetInternalInfo
* Returns pointer to internal SCROLLBAR_INFO structure for nBar
* or NULL if failed (f.i. scroll bar does not exist yet)
* If alloc is TRUE and the struct does not exist yet, create it.
*/
SCROLLBAR_INFO *SCROLL_GetInternalInfo( HWND hwnd, INT nBar, BOOL alloc )
{
SCROLLBAR_INFO *infoPtr = NULL;
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return NULL;
switch(nBar)
{
case SB_HORZ:
if (wndPtr->pScroll) infoPtr = &((LPWINSCROLLBAR_INFO)wndPtr->pScroll)->horz;
break;
case SB_VERT:
if (wndPtr->pScroll) infoPtr = &((LPWINSCROLLBAR_INFO)wndPtr->pScroll)->vert;
break;
case SB_CTL:
if (wndPtr->cbWndExtra >= sizeof(SCROLLBAR_WNDDATA))
{
SCROLLBAR_WNDDATA *data = (SCROLLBAR_WNDDATA*)wndPtr->wExtra;
if (data->magic == SCROLLBAR_MAGIC)
infoPtr = &data->info;
}
if (!infoPtr) WARN("window is not a scrollbar control\n");
break;
case SB_BOTH:
WARN("with SB_BOTH\n");
break;
}
if (!infoPtr && alloc)
{
WINSCROLLBAR_INFO *winInfoPtr;
if (nBar != SB_HORZ && nBar != SB_VERT)
WARN("Cannot initialize nBar=%d\n",nBar);
else if ((winInfoPtr = HeapAlloc( GetProcessHeap(), 0, sizeof(WINSCROLLBAR_INFO) )))
{
/* Set default values */
winInfoPtr->horz.minVal = 0;
winInfoPtr->horz.curVal = 0;
winInfoPtr->horz.page = 0;
/* From MSDN and our own tests:
* max for a standard scroll bar is 100 by default. */
winInfoPtr->horz.maxVal = 100;
winInfoPtr->horz.flags = ESB_ENABLE_BOTH;
winInfoPtr->vert = winInfoPtr->horz;
wndPtr->pScroll = winInfoPtr;
infoPtr = nBar == SB_HORZ ? &winInfoPtr->horz : &winInfoPtr->vert;
}
}
WIN_ReleasePtr( wndPtr );
return infoPtr;
}
/***********************************************************************
* SCROLL_DrawArrows

View file

@ -135,11 +135,6 @@ static void WINAPI unregister_imm( HWND hwnd )
imm_unregister_window( hwnd );
}
static void CDECL free_win_ptr( WND *win )
{
HeapFree( GetProcessHeap(), 0, win->pScroll );
}
static NTSTATUS try_finally( NTSTATUS (CDECL *func)( void *), void *arg,
void (CALLBACK *finally_func)( BOOL ))
{
@ -157,8 +152,6 @@ static const struct user_callbacks user_funcs =
ImmProcessKey,
ImmTranslateMessage,
NtWaitForMultipleObjects,
free_win_ptr,
SCROLL_GetInternalInfo,
notify_ime,
post_dde_message,
unpack_dde_message,

View file

@ -2379,7 +2379,7 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
if (!win) return 0;
free( win->text );
win->text = NULL;
if (user_callbacks) user_callbacks->free_win_ptr( win );
free( win->pScroll );
win->pScroll = NULL;
release_win_ptr( win );
break;

View file

@ -35,8 +35,6 @@ struct user_callbacks
BOOL (WINAPI *pImmProcessKey)(HWND, HKL, UINT, LPARAM, DWORD);
BOOL (WINAPI *pImmTranslateMessage)(HWND, UINT, WPARAM, LPARAM);
NTSTATUS (WINAPI *pNtWaitForMultipleObjects)(ULONG,const HANDLE*,BOOLEAN,BOOLEAN,const LARGE_INTEGER*);
void (CDECL *free_win_ptr)( struct tagWND *win );
struct scroll_info *(CDECL *get_scroll_info)( HWND hwnd, INT nBar, BOOL alloc );
void (CDECL *notify_ime)( HWND hwnd, UINT param );
BOOL (CDECL *post_dde_message)( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid,
DWORD type );
@ -97,7 +95,7 @@ typedef struct tagWND
POINT min_pos; /* Position for minimized window */
POINT max_pos; /* Position for maximized window */
WCHAR *text; /* Window text */
void *pScroll; /* Scroll-bar info */
struct win_scroll_bar_info *pScroll; /* Scroll-bar info */
DWORD dwStyle; /* Window style (from CreateWindow) */
DWORD dwExStyle; /* Extended style (from CreateWindowEx) */
UINT_PTR wIDmenu; /* ID or hmenu (from CreateWindow) */

View file

@ -62,13 +62,69 @@ static struct SCROLL_TRACKING_INFO g_tracking_info;
/* Is the moving thumb being displayed? */
static BOOL scroll_moving_thumb = FALSE;
/* data for window that has (one or two) scroll bars */
struct win_scroll_bar_info
{
struct scroll_info horz;
struct scroll_info vert;
};
#define SCROLLBAR_MAGIC 0x5c6011ba
static struct scroll_info *get_scroll_info_ptr( HWND hwnd, int bar, BOOL alloc )
{
struct scroll_info *ret = NULL;
user_lock();
if (user_callbacks) ret = user_callbacks->get_scroll_info( hwnd, bar, alloc );
if (!ret) user_unlock();
return ret;
struct scroll_info *info = NULL;
WND *win = get_win_ptr( hwnd );
if (!win || win == WND_OTHER_PROCESS || win == WND_DESKTOP) return NULL;
switch (bar)
{
case SB_HORZ:
if (win->pScroll) info = &win->pScroll->horz;
break;
case SB_VERT:
if (win->pScroll) info = &win->pScroll->vert;
break;
case SB_CTL:
if (win->cbWndExtra >= sizeof(struct scroll_bar_win_data))
{
struct scroll_bar_win_data *data = (struct scroll_bar_win_data *)win->wExtra;
if (data->magic == SCROLLBAR_MAGIC) info = &data->info;
}
if (!info) WARN( "window is not a scrollbar control\n" );
break;
case SB_BOTH:
WARN( "with SB_BOTH\n" );
break;
}
if (!info && alloc)
{
struct win_scroll_bar_info *win_info;
if (bar != SB_HORZ && bar != SB_VERT)
WARN("Cannot initialize bar=%d\n",bar);
else if ((win_info = malloc( sizeof(struct win_scroll_bar_info) )))
{
/* Set default values */
win_info->horz.minVal = 0;
win_info->horz.curVal = 0;
win_info->horz.page = 0;
/* From MSDN and our own tests:
* max for a standard scroll bar is 100 by default. */
win_info->horz.maxVal = 100;
win_info->horz.flags = ESB_ENABLE_BOTH;
win_info->vert = win_info->horz;
win->pScroll = win_info;
info = bar == SB_HORZ ? &win_info->horz : &win_info->vert;
}
}
if (info) user_lock();
release_win_ptr( win );
return info;
}
static void release_scroll_info_ptr( struct scroll_info *info )

View file

@ -4662,7 +4662,7 @@ static void free_window_handle( HWND hwnd )
}
SERVER_END_REQ;
user_unlock();
if (user_callbacks) user_callbacks->free_win_ptr( win );
free( win->pScroll );
free( win->text );
free( win );
}
@ -4865,7 +4865,7 @@ void destroy_thread_windows(void)
register_window_surface( win->surface, NULL );
window_surface_release( win->surface );
}
if (user_callbacks) user_callbacks->free_win_ptr( win );
free( win->pScroll );
free( win->text );
free( win );
}