void vkDisplay::resize_window(const unsigned int width, const unsigned int height) { #if defined(PLATFORM_LINUX) #if defined(ANDROID) m_windowWidth = width; m_windowHeight = height; #else if (width != m_windowWidth || height != m_windowHeight) { uint32_t values[2]; values[0] = width; values[1] = height; xcb_configure_window(m_pXcbConnection, m_XcbWindow, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values); xcb_flush(m_pXcbConnection); m_windowWidth = width; m_windowHeight = height; } #endif #elif defined(WIN32) if (width != m_windowWidth || height != m_windowHeight) { RECT wr = {0, 0, width, height}; AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); SetWindowPos(get_window_handle(), HWND_TOP, 0, 0, wr.right-wr.left, wr.bottom-wr.top, SWP_NOMOVE); m_windowWidth = width; m_windowHeight = height; } #endif }
static bool win_has_clipboard_text(ALLEGRO_DISPLAY *display) { if (!IsClipboardFormatAvailable(TEXT_FORMAT)) return false; if (!OpenClipboard(get_window_handle(display))) return false; CloseClipboard(); return true; }
bool widget_system_initialize() { // make sure the hWnd and hInstance variables are initialized (e.g, SDL) if (get_window_handle() == NULL) { enigma_user::show_error("Cannot initialize Win32 widget system with NULL window handle.", true); } INITCOMMONCONTROLSEX iccex; iccex.dwSize = sizeof(iccex); iccex.dwICC = ICC_STANDARD_CLASSES | ICC_LISTVIEW_CLASSES; InitCommonControlsEx(&iccex); return true; }
void windows_tray_notification::switch_to_wesnoth_window() { const HWND window = get_window_handle(); if (window == NULL) { return; } if (IsIconic(window)) { ShowWindow(window, SW_RESTORE); } SetForegroundWindow(window); }
static bool win_set_clipboard_text(ALLEGRO_DISPLAY *display, const char *text) { HWND handle = get_window_handle(display); HANDLE hMem = NULL; wchar_t *tstr = NULL; size_t size; size_t len; LPTSTR dst; if (!OpenClipboard(handle)) { ALLEGRO_DEBUG("Could not open clipboard for handle %p", handle); return false; } /* Convert the text from UTF-8 to Windows Unicode */ tstr = _al_win_utf16(text); len = wcslen(tstr); size = (len+1) * sizeof(wchar_t); /* Save the data to the clipboard */ hMem = GlobalAlloc(GMEM_MOVEABLE, size); if (!hMem) { al_free(tstr); ALLEGRO_DEBUG("GlobalAlloc failed to allocate memory for the clipboard data"); return false; } dst = (LPTSTR)GlobalLock(hMem); /* Copy the text over. Unlike SDL, do NOT convert newlines, that's for the * use to decide. */ memmove(dst, tstr, size); dst[len] = 0; GlobalUnlock(hMem); EmptyClipboard(); if (!SetClipboardData(TEXT_FORMAT, hMem)) { al_free(tstr); ALLEGRO_DEBUG("Couldn't set clipboard data"); return false; } al_free(tstr); CloseClipboard(); return true; }
void vkDisplay::resize_window(const unsigned int width, const unsigned int height) { #if defined(PLATFORM_LINUX) if (width != m_windowWidth || height != m_windowHeight) { uint32_t values[2]; values[0] = width; values[1] = height; xcb_configure_window(m_pXcbConnection, m_XcbWindow, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values); m_windowWidth = width; m_windowHeight = height; } #elif defined(WIN32) if (width != m_windowWidth || height != m_windowHeight) { SetWindowPos(get_window_handle(), HWND_TOP, 0, 0, width, height, SWP_NOMOVE); m_windowWidth = width; m_windowHeight = height; } #endif }
static char *win_get_clipboard_text(ALLEGRO_DISPLAY *display) { char *text; text = NULL; if (IsClipboardFormatAvailable(TEXT_FORMAT) && OpenClipboard(get_window_handle(display))) { HANDLE hMem; LPTSTR tstr; hMem = GetClipboardData(TEXT_FORMAT); if (hMem) { tstr = (LPTSTR)GlobalLock(hMem); text = _al_win_utf8(tstr); GlobalUnlock(hMem); } else { ALLEGRO_DEBUG("Couldn't get clipboard data"); } CloseClipboard(); } return text; }
bool windows_tray_notification::create_tray_icon() { // getting handle to a 32x32 icon, contained in "WESNOTH_ICON" icon group of wesnoth.exe resources const HMODULE wesnoth_exe = GetModuleHandle(NULL); if (wesnoth_exe == NULL) { return false; } const HRSRC group_icon_info = FindResource(wesnoth_exe, L"WESNOTH_ICON", RT_GROUP_ICON); if (group_icon_info == NULL) { return false; } HGLOBAL hGlobal = LoadResource(wesnoth_exe, group_icon_info); if (hGlobal == NULL) { return false; } const PBYTE group_icon_res = static_cast<PBYTE>(LockResource(hGlobal)); if (group_icon_res == NULL) { return false; } const int nID = LookupIconIdFromDirectoryEx(group_icon_res, TRUE, 32, 32, LR_DEFAULTCOLOR); if (nID == 0) { return false; } const HRSRC icon_info = FindResource(wesnoth_exe, MAKEINTRESOURCE(nID), MAKEINTRESOURCE(3)); if (icon_info == NULL) { return false; } hGlobal = LoadResource(wesnoth_exe, icon_info); if (hGlobal == NULL) { return false; } const PBYTE icon_res = static_cast<PBYTE>(LockResource(hGlobal)); if (icon_res == NULL) { return false; } const HICON icon = CreateIconFromResource(icon_res, SizeofResource(wesnoth_exe, icon_info), TRUE, 0x00030000); if (icon == NULL) { return false; } const HWND window = get_window_handle(); if (window == NULL) { return false; } const std::wstring& wtip = string_to_wstring(_("The Battle for Wesnoth")); // filling notification structure nid = new NOTIFYICONDATA; memset(nid, 0, sizeof(&nid)); nid->cbSize = NOTIFYICONDATA_V2_SIZE; nid->hWnd = window; nid->uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; nid->dwInfoFlags = NIIF_USER; nid->uVersion = NOTIFYICON_VERSION; nid->uCallbackMessage = WM_TRAYNOTIFY; nid->uID = ICON_ID; nid->hIcon = icon; #if _WIN32_WINNT >= 0x600 nid->hBalloonIcon = icon; #endif lstrcpy(nid->szTip, wtip.c_str()); // creating icon notification return Shell_NotifyIcon(NIM_ADD, nid) != FALSE; }