Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate typedefs for Win32 callbacks #826

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 56 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,61 @@
## 5.3.0-wip

- Migrate away from `.elementAt` (#XXX)
- Bump minimum required Dart version to `3.3.0`
- Migrate away from `.elementAt` (#825)
- Bump minimum required Dart version to `3.3.0` (#825)
- Deprecate `CallWndProc` typedef in favor of `HOOKPROC` (#826)
- Deprecate `CCHookProc` typedef in favor of `LPCCHOOKPROC` (#826)
- Deprecate `CFHookProc` typedef in favor of `LPCFHOOKPROC` (#826)
- Deprecate `DlgProc` typedef in favor of `DLGPROC` (#826)
- Deprecate `DrawStateProc` typedef in favor of `DRAWSTATEPROC` (#826)
- Deprecate `DrawTextCallback` typedef in favor of `DTT_CALLBACK_PROC` (#826)
- Deprecate `EnumPageFilesProc` typedef in favor of
`PENUM_PAGE_FILE_CALLBACK` (#826)
- Deprecate `EnumFontFamExProc` typedef in favor of `FONTENUMPROC` (#826)
- Deprecate `EnumResNameProc` typedef in favor of `ENUMRESNAMEPROC` (#826)
- Deprecate `EnumResTypeProc` typedef in favor of `ENUMRESTYPEPROC` (#826)
- Deprecate `EnumWindowsProc` typedef in favor of `WNDENUMPROC` (#826)
- Deprecate `ExcepInfoProc` typedef in favor of
`LPEXCEPFINO_DEFERRED_FILLIN` (#826)
- Deprecate `FRHookProc` typedef in favor of `LPFRHOOKPROC` (#826)
- Deprecate `HandlerRoutine` typedef in favor of `PHANDLER_ROUTINE` (#826)
- Deprecate `LphandlerFunction` typedef in favor of `LPHANDLER_FUNCTION` (#826)
- Deprecate `LphandlerFunctionEx` typedef in favor of
`LPHANDLER_FUNCTION_EX` (#826)
- Deprecate `LpoverlappedCompletionRoutine` in favor of
`LPOVERLAPPED_COMPLETION_ROUTINE` (#826)
- Deprecate `LpserviceMainFunctionw` in favor of
`LPSERVICE_MAIN_FUNCTION` (#826)
- Deprecate `MidiInProc` typedef in favor of `MIDIINPROC` (#826)
- Deprecate `MidiOutProc` typedef in favor of `MIDIOUTPROC` (#826)
- Deprecate `MonitorEnumProc` typedef in favor of `MONITORENUMPROC` (#826)
- Deprecate `OFNHookProc` typedef in favor of `LPOFNHOOKPROC` (#826)
- Deprecate `OpenCardCheckProc` typedef in favor of `LPOCNCHKPROC` (#826)
- Deprecate `OpenCardConnProc` typedef in favor of `LPOCNCONNPROC` (#826)
- Deprecate `OpenCardDisconnProc` typedef in favor of `LPOCNDSCPROC` (#826)
- Deprecate `OutputProc` typedef in favor of `GRAYSTRINGPROC` (#826)
- Deprecate `PfnAuthenticationCallbackEx` in favor of
`PFN_AUTHENTICATION_CALLBACK_EX` (#826)
- Deprecate `PfnbluetoothGattEventCallback` in favor of
`PFN_BLUETOOTH_GATT_EVENT_CALLBACK` (#826)
- Deprecate `PfnBluetoothEnumAttributesCallback` in favor of
`PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK` (#826)
- Deprecate `PfnDeviceCallback` typedef in favor of `PFN_DEVICE_CALLBACK` (#826)
- Deprecate `PfnScNotifyCallbackFunction` in favor of
`PFN_SC_NOTIFY_CALLBACK` (#826)
- Deprecate `SendAsyncProc` typedef in favor of `SENDASYNCPROC` (#826)
- Deprecate `SpNotifyCallback` typedef in favor of `SPNOTIFYCALLBACK` (#826)
- Deprecate `SubclassProc` typedef in favor of `SUBCLASSPROC` (#826)
- Deprecate `SymEnumSymbolsProc` in favor of
`PSYM_ENUMERATESYMBOLS_CALLBACK` (#826)
- Deprecate `TaskDialogCallbackProc` typedef in favor of
`PFTASKDIALOGCALLBACK` (#826)
- Deprecate `ThreadProc` typedef in favor of `LPTHREAD_START_ROUTINE` (#826)
- Deprecate `TimerProc` typedef in favor of `TIMERPROC` (#826)
- Deprecate `WindowProc` typedef in favor of `WNDPROC` (#826)
- Deprecate `WlanNotificationCallback` in favor of
`WLAN_NOTIFICATION_CALLBACK` (#826)
- **Note**: You can automatically migrate your code to use the new typedefs by
running `dart fix --apply` in your terminal.

## 5.2.0

Expand Down
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include: package:dartwindows_lints/analysis_options.yaml

analyzer:
exclude: [example/explorer/**]
exclude: ['example/explorer/**', 'test_fixes/**']
errors:
todo: ignore

Expand Down
2 changes: 1 addition & 1 deletion example/customtitlebar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ void main() {
// Register the window class.
final windowClassName = 'WIN32_CUSTOM_TITLEBAR_EXAMPLE'.toNativeUtf16();

final lpfnWndProc = NativeCallable<WindowProc>.isolateLocal(
final lpfnWndProc = NativeCallable<WNDPROC>.isolateLocal(
mainWindowProc,
exceptionalReturn: 0,
);
Expand Down
2 changes: 1 addition & 1 deletion example/customwin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void winMain(int hInstance, List<String> args, int nShowCmd) {
// Register the window class.
final className = TEXT('Sample Window Class');

final lpfnWndProc = NativeCallable<WindowProc>.isolateLocal(
final lpfnWndProc = NativeCallable<WNDPROC>.isolateLocal(
mainWindowProc,
exceptionalReturn: 0,
);
Expand Down
2 changes: 1 addition & 1 deletion example/dialogbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void main() {
windowSystemClass: 0x0081, // edit
text: 'Enter text');

final lpDialogFunc = NativeCallable<DlgProc>.isolateLocal(
final lpDialogFunc = NativeCallable<DLGPROC>.isolateLocal(
dialogReturnProc,
exceptionalReturn: 0,
);
Expand Down
2 changes: 1 addition & 1 deletion example/dump.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Map<String, int> getExports(int hProcess, String module) {

final mask = '*'.toNativeUtf16();

final callback = NativeCallable<SymEnumSymbolsProc>.isolateLocal(
final callback = NativeCallable<PSYM_ENUMERATESYMBOLS_CALLBACK>.isolateLocal(
_enumSymbolProc,
exceptionalReturn: 0,
);
Expand Down
2 changes: 1 addition & 1 deletion example/fonts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int enumerateFonts(
void main() {
final hDC = GetDC(NULL);
final searchFont = calloc<LOGFONT>()..ref.lfCharSet = ANSI_CHARSET;
final lpProc = NativeCallable<EnumFontFamExProc>.isolateLocal(
final lpProc = NativeCallable<FONTENUMPROC>.isolateLocal(
enumerateFonts,
exceptionalReturn: 0,
);
Expand Down
2 changes: 1 addition & 1 deletion example/hello.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void winMain(int hInstance, List<String> args, int nShowCmd) {
// Register the window class.
final className = TEXT('Sample Window Class');

final lpfnWndProc = NativeCallable<WindowProc>.isolateLocal(
final lpfnWndProc = NativeCallable<WNDPROC>.isolateLocal(
mainWindowProc,
exceptionalReturn: 0,
);
Expand Down
4 changes: 2 additions & 2 deletions example/hooks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ int mainWindowProc(int hWnd, int uMsg, int wParam, int lParam) {
void main() => initApp(winMain);

void winMain(int hInstance, List<String> args, int nShowCmd) {
final lpfn = NativeCallable<CallWndProc>.isolateLocal(
final lpfn = NativeCallable<HOOKPROC>.isolateLocal(
lowlevelKeyboardHookProc,
exceptionalReturn: 0,
);

keyHook = SetWindowsHookEx(WH_KEYBOARD_LL, lpfn.nativeFunction, NULL, 0);

final lpfnWndProc = NativeCallable<WindowProc>.isolateLocal(
final lpfnWndProc = NativeCallable<WNDPROC>.isolateLocal(
mainWindowProc,
exceptionalReturn: 0,
);
Expand Down
11 changes: 5 additions & 6 deletions example/magnifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ void main() => initApp(winMain);

/// Entry point for the application
void winMain(int hInstance, List<String> args, int nCmdShow) {
final lpfnWndProc = NativeCallable<WindowProc>.isolateLocal(hostWndProc,
exceptionalReturn: 0);
final lpfnWndProc =
NativeCallable<WNDPROC>.isolateLocal(hostWndProc, exceptionalReturn: 0);

if (MagInitialize() == FALSE ||
!setupMagnifier(hInstance, lpfnWndProc.nativeFunction)) {
Expand All @@ -43,7 +43,7 @@ void winMain(int hInstance, List<String> args, int nCmdShow) {
ShowWindow(hwndHost, nCmdShow);
UpdateWindow(hwndHost);

final lpTimerFunc = NativeCallable<TimerProc>.isolateLocal(updateMagWindow);
final lpTimerFunc = NativeCallable<TIMERPROC>.isolateLocal(updateMagWindow);

// Create a timer to update the control
final timerId =
Expand Down Expand Up @@ -109,7 +109,7 @@ int hostWndProc(int hWnd, int message, int wParam, int lParam) {
/// Registers the window class for the window that contains the magnification
/// control.
int registerHostWindowClass(
int hInstance, Pointer<NativeFunction<WindowProc>> lpfnWndProc) {
int hInstance, Pointer<NativeFunction<WNDPROC>> lpfnWndProc) {
final wcex = calloc<WNDCLASSEX>()
..ref.cbSize = sizeOf<WNDCLASSEX>()
..ref.style = CS_HREDRAW | CS_VREDRAW
Expand All @@ -122,8 +122,7 @@ int registerHostWindowClass(
return RegisterClassEx(wcex);
}

bool setupMagnifier(
int hInst, Pointer<NativeFunction<WindowProc>> lpfnWndProc) {
bool setupMagnifier(int hInst, Pointer<NativeFunction<WNDPROC>> lpfnWndProc) {
// Set bounds of host window according to screen size
hostWindowRect
..ref.top = 0
Expand Down
2 changes: 1 addition & 1 deletion example/monitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void printMonitorCapabilities(int capabilitiesBitmask) {
void main() {
var result = FALSE;

final lpfnEnum = NativeCallable<MonitorEnumProc>.isolateLocal(
final lpfnEnum = NativeCallable<MONITORENUMPROC>.isolateLocal(
enumMonitorCallback,
exceptionalReturn: 0,
);
Expand Down
4 changes: 2 additions & 2 deletions example/notepad/notepad.dart
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ int mainWindowProc(int hwnd, int message, int wParam, int lParam) {
case IDM_APP_ABOUT:
final pDialog = NotepadResources.loadAboutBox();

final lpDialogFunc = NativeCallable<DlgProc>.isolateLocal(
final lpDialogFunc = NativeCallable<DLGPROC>.isolateLocal(
dialogReturnProc,
exceptionalReturn: 0,
);
Expand Down Expand Up @@ -293,7 +293,7 @@ void main() {
// Register the window class.
final className = TEXT(APP_NAME);

final lpfnWndProc = NativeCallable<WindowProc>.isolateLocal(
final lpfnWndProc = NativeCallable<WNDPROC>.isolateLocal(
mainWindowProc,
exceptionalReturn: 0,
);
Expand Down
2 changes: 1 addition & 1 deletion example/paint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void winMain(int hInstance, List<String> args, int nShowCmd) {
// Register the window class.
final className = TEXT('Simple Paint Sample');

final lpfnWndProc = NativeCallable<WindowProc>.isolateLocal(
final lpfnWndProc = NativeCallable<WNDPROC>.isolateLocal(
mainWindowProc,
exceptionalReturn: 0,
);
Expand Down
2 changes: 1 addition & 1 deletion example/scroll.dart
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void winMain(int hInstance, List<String> args, int nShowCmd) {
// Register the window class.
final className = TEXT('Scrollbar Sample');

final lpfnWndProc = NativeCallable<WindowProc>.isolateLocal(
final lpfnWndProc = NativeCallable<WNDPROC>.isolateLocal(
mainWindowProc,
exceptionalReturn: 0,
);
Expand Down
2 changes: 1 addition & 1 deletion example/shell_notify_icon/_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const EVENT_TRAY_NOTIFY = WM_APP + 1;
typedef LocalWndProc = bool Function(
int hWnd, int uMsg, int wParam, int lParam);

final lpfnWndProc = NativeCallable<WindowProc>.isolateLocal(
final lpfnWndProc = NativeCallable<WNDPROC>.isolateLocal(
_appWndProc,
exceptionalReturn: 0,
);
Expand Down
2 changes: 1 addition & 1 deletion example/snake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ void winMain(int hInstance, List<String> args, int nShowCmd) {
// Register the window class.
final className = TEXT('WinSnakeWindowClass');

final lpfnWndProc = NativeCallable<WindowProc>.isolateLocal(
final lpfnWndProc = NativeCallable<WNDPROC>.isolateLocal(
mainWindowProc,
exceptionalReturn: 0,
);
Expand Down
2 changes: 1 addition & 1 deletion example/tetris/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ late Canvas canvas;
void main() {
final szAppName = 'Tetris'.toNativeUtf16();

final lpfnWndProc = NativeCallable<WindowProc>.isolateLocal(
final lpfnWndProc = NativeCallable<WNDPROC>.isolateLocal(
mainWindowProc,
exceptionalReturn: 0,
);
Expand Down
2 changes: 1 addition & 1 deletion example/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int enumWindowsProc(int hWnd, int lParam) {
/// List the window handle and text for all top-level desktop windows
/// in the current session.
void enumerateWindows() {
final lpEnumFunc = NativeCallable<EnumWindowsProc>.isolateLocal(
final lpEnumFunc = NativeCallable<WNDENUMPROC>.isolateLocal(
enumWindowsProc,
exceptionalReturn: 0,
);
Expand Down
Loading