Repository: godotengine/godot
File: platform/windows/display_server_windows.cpp (C++)

Code before:
	}

	return false;
}

void DisplayServerWindows::window_request_attention(WindowID p_window) {
	_THREAD_SAFE_METHOD_

	ERR_FAIL_COND(!windows.has(p_window));
	const WindowData &wd = windows[p_window];

	FLASHWINFO info;
	info.cbSize = sizeof(FLASHWINFO);
	info.hwnd = wd.hWnd;
	info.dwFlags = FLASHW_ALL;
	info.dwTimeout = 0;
	info.uCount = 2;
	FlashWindowEx(&info);
}

void DisplayServerWindows::window_set_taskbar_progress_value(float p_value, WindowID p_window) {
	_THREAD_SAFE_METHOD_

	ERR_FAIL_COND(!windows.has(p_window));
	const WindowData &wd = windows[p_window];

	if (taskbar == nullptr) {
		if (CoCreateInstance(CLSID_TaskbarList, 0, CLSCTX_INPROC_SERVER, IID_ITaskbarList, (void **)&taskbar) != S_OK) {
			taskbar = nullptr;
			return;
		} else {
			taskbar->HrInit();
		}
	}

	taskbar->SetProgressValue(wd.hWnd, Math::round(p_value * 100000), 100000);
}

void DisplayServerWindows::window_set_taskbar_progress_state(ProgressState p_state, WindowID p_window) {
	_THREAD_SAFE_METHOD_

	ERR_FAIL_COND(!windows.has(p_window));
	const WindowData &wd = windows[p_window];

	if (taskbar == nullptr) {
		if (CoCreateInstance(CLSID_TaskbarList, 0, CLSCTX_INPROC_SERVER, IID_ITaskbarList, (void **)&taskbar) != S_OK) {
			taskbar = nullptr;
			return;
		} else {
			taskbar->HrInit();
		}

Review comment (suggestion):
It would make sense to save `state` in `WindowData` when it's changed in `window_set_taskbar_progress_state` and check if it's set to `PROGRESS_STATE_NOPROGRESS`, otherwise it will switch to normal even if was not set directly. It should also save value and reapply it on state change to work consistently.


```suggestion
	wd.progress_value = p_value;
	if (wd.progress_state == PROGRESS_STATE_NOPROGRESS`) {
		return;
	}
```

Code after:
	}

	return false;
}

void DisplayServerWindows::window_request_attention(WindowID p_window) {
	_THREAD_SAFE_METHOD_

	ERR_FAIL_COND(!windows.has(p_window));
	const WindowData &wd = windows[p_window];

	FLASHWINFO info;
	info.cbSize = sizeof(FLASHWINFO);
	info.hwnd = wd.hWnd;
	info.dwFlags = FLASHW_ALL;
	info.dwTimeout = 0;
	info.uCount = 2;
	FlashWindowEx(&info);
}

void DisplayServerWindows::window_set_taskbar_progress_value(float p_value, WindowID p_window) {
	_THREAD_SAFE_METHOD_

	ERR_FAIL_COND(!windows.has(p_window));
	WindowData &wd = windows[p_window];
	wd.progress_value = p_value;
	if (wd.progress_state == PROGRESS_STATE_NOPROGRESS) {
		return;
	}
	if (taskbar == nullptr) {
		if (CoCreateInstance(CLSID_TaskbarList, 0, CLSCTX_INPROC_SERVER, IID_ITaskbarList, (void **)&taskbar) != S_OK) {
			taskbar = nullptr;
			return;
		} else {
			taskbar->HrInit();
		}
	}

	taskbar->SetProgressValue(wd.hWnd, Math::round(p_value * 100000), 100000);
}

void DisplayServerWindows::window_set_taskbar_progress_state(ProgressState p_state, WindowID p_window) {
	_THREAD_SAFE_METHOD_

	ERR_FAIL_COND(!windows.has(p_window));
	WindowData &wd = windows[p_window];
	wd.progress_state = p_state;
	if (taskbar == nullptr) {
		if (CoCreateInstance(CLSID_TaskbarList, 0, CLSCTX_INPROC_SERVER, IID_ITaskbarList, (void **)&taskbar) != S_OK) {
			taskbar = nullptr;
			return;