From 94e5b7a477f79702462735fad9e63caf31434df0 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 30 Jan 2021 13:54:18 -0600 Subject: [PATCH] windows: Add some code to put something in the tray. --- basis/ui/backend/windows/windows.factor | 42 +++++++++++++++++++------ basis/windows/shell32/shell32.factor | 3 +- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index 0cc51099cd..90da2b30d4 100644 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -1,16 +1,17 @@ ! Copyright (C) 2005, 2006 Doug Coleman. ! Portions copyright (C) 2007, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien alien.data alien.strings arrays ascii assocs -calendar classes classes.struct colors combinators continuations fry -io io.crlf io.encodings.utf16n kernel libc literals locals make math -math.bitwise namespaces sequences sets specialized-arrays strings -threads ui ui.backend ui.clipboards ui.event-loop ui.gadgets -ui.gadgets.private ui.gadgets.worlds ui.gestures ui.pixel-formats -ui.private windows.dwmapi windows.errors windows.gdi32 -windows.kernel32 windows.messages windows.offscreen windows.opengl32 -windows.types windows.user32 assocs.extras byte-arrays -io.encodings.string ; +USING: accessors alien alien.c-types alien.data alien.strings +arrays ascii assocs assocs.extras byte-arrays calendar classes +classes.struct colors combinators continuations io io.crlf +io.encodings.string io.encodings.utf16n io.encodings.utf8 kernel +libc literals make math math.bitwise namespaces sequences sets +specialized-arrays strings threads ui ui.backend ui.clipboards +ui.event-loop ui.gadgets ui.gadgets.private ui.gadgets.worlds +ui.gestures ui.pixel-formats ui.private windows.dwmapi +windows.errors windows.gdi32 windows.kernel32 windows.messages +windows.offscreen windows.opengl32 windows.shell32 windows.types +windows.user32 ; FROM: unicode => upper-surrogate? under-surrogate? ; SPECIALIZED-ARRAY: POINT QUALIFIED-WITH: alien.c-types c @@ -799,6 +800,27 @@ CONSTANT: fullscreen-flags flags{ WS_CAPTION WS_BORDER WS_THICKFRAME } [ drop SW_RESTORE ShowWindow win32-error=0/f ] } 2cleave ; +: ensure-null-terminated ( str -- str' ) + dup ?last 0 = [ "\0" append ] unless ; inline + +: add-tray-icon ( title -- ) + NIM_ADD + NOTIFYICONDATA + NOTIFYICONDATA heap-size >>cbSize + NOTIFYICON_VERSION_4 over timeout-version>> uVersion<< + NIF_TIP NIF_ICON bitor >>uFlags + world get handle>> hWnd>> >>hWnd + f GetModuleHandle "APPICON" native-string>alien LoadIcon >>hIcon + rot ensure-null-terminated utf8 encode >>szTip + Shell_NotifyIcon win32-error=0/f ; + +: remove-tray-icon ( -- ) + NIM_DELETE + NOTIFYICONDATA + NOTIFYICONDATA heap-size >>cbSize + world get handle>> hWnd>> >>hWnd + Shell_NotifyIcon win32-error=0/f ; + M: windows-ui-backend (set-fullscreen) [ enter-fullscreen ] [ exit-fullscreen ] if ; diff --git a/basis/windows/shell32/shell32.factor b/basis/windows/shell32/shell32.factor index 1dbd925463..89dd6a89ca 100644 --- a/basis/windows/shell32/shell32.factor +++ b/basis/windows/shell32/shell32.factor @@ -369,6 +369,7 @@ CONSTANT: NIN_BALLOONHIDE $[ WM_USER 3 + ] CONSTANT: NIN_BALLOONTIMEOUT $[ WM_USER 4 + ] CONSTANT: NIN_BALLOONUSERCLICK $[ WM_USER 5 + ] +UNION-STRUCT: timeout-version-union { uTimeout UINT } { uVersion UINT } ; STRUCT: NOTIFYICONDATA { cbSize DWORD } { hWnd HWND } @@ -380,7 +381,7 @@ STRUCT: NOTIFYICONDATA { dwState DWORD } { dwStateMask DWORD } { szInfo TCHAR[256] } - { uTimeout UINT } ! { uVersion UINT } ! c-union here1 + { timeout-version timeout-version-union } ! { uVersion UINT } ! c-union here1 { szInfoTitle TCHAR[64] } { dwInfoFlags DWORD } { guidItem GUID } -- 2.34.1