Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Commit

Permalink
feat: 移除 "显示托盘图标" 功能
Browse files Browse the repository at this point in the history
  • Loading branch information
kitty-panics committed Apr 7, 2023
1 parent 156cdd3 commit d423d9b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 75 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Virtual Desktop Manager for Windows
Features:
- resource friendly, exe is <10kb on disk and uses <1mb memory while running
- 9 virtual desktops (more if you change a constant and recompile the code)
- shows only a tray icon with the number of the desktop you are on

Hotkeys:

Expand Down
74 changes: 0 additions & 74 deletions virgo.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,10 @@ typedef struct {
unsigned count;
} Windows;

typedef struct {
NOTIFYICONDATA nid;
HBITMAP hBitmap;
HFONT hFont;
HWND hwnd;
HDC mdc;
unsigned bitmapWidth;
} Trayicon;

typedef struct {
unsigned current;
unsigned handle_hotkeys;
Windows desktops[NUM_DESKTOPS];
Trayicon trayicon;
HWND pinned[NUM_PINNED];
HWND focused[NUM_DESKTOPS];
} Virgo;
Expand Down Expand Up @@ -68,67 +58,6 @@ static void *stb__sbgrowf(void *arr, unsigned increment, unsigned itemsize)
}
}

static HICON trayicon_draw(Trayicon *t, char *text, unsigned len)
{
ICONINFO iconInfo;
HBITMAP hOldBitmap;
HFONT hOldFont;
hOldBitmap = (HBITMAP)SelectObject(t->mdc, t->hBitmap);
hOldFont = (HFONT)SelectObject(t->mdc, t->hFont);
TextOut(t->mdc, t->bitmapWidth / 4, 0, text, len);
SelectObject(t->mdc, hOldBitmap);
SelectObject(t->mdc, hOldFont);
iconInfo.fIcon = TRUE;
iconInfo.xHotspot = iconInfo.yHotspot = 0;
iconInfo.hbmMask = iconInfo.hbmColor = t->hBitmap;
return CreateIconIndirect(&iconInfo);
}

static void trayicon_init(Trayicon *t)
{
HDC hdc;
t->hwnd =
CreateWindowA("STATIC", "virgo", 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
t->bitmapWidth = GetSystemMetrics(SM_CXSMICON);
t->nid.cbSize = sizeof(t->nid);
t->nid.hWnd = t->hwnd;
t->nid.uID = 100;
t->nid.uFlags = NIF_ICON;
hdc = GetDC(t->hwnd);
t->hBitmap = CreateCompatibleBitmap(hdc, t->bitmapWidth, t->bitmapWidth);
t->mdc = CreateCompatibleDC(hdc);
ReleaseDC(t->hwnd, hdc);
SetBkColor(t->mdc, RGB(0x00, 0x00, 0x00));
SetTextColor(t->mdc, RGB(0x00, 0xFF, 0x00));
t->hFont = CreateFont(-MulDiv(11, GetDeviceCaps(t->mdc, LOGPIXELSY), 72), 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("Arial"));
t->nid.hIcon = trayicon_draw(t, "1", 1);
Shell_NotifyIcon(NIM_ADD, &t->nid);
}

static void trayicon_set(Trayicon *t, unsigned number)
{
char snumber[2];
if (number > 9) {
return;
}
snumber[0] = number + '0';
snumber[1] = 0;
DestroyIcon(t->nid.hIcon);
t->nid.hIcon = trayicon_draw(t, snumber, 1);
Shell_NotifyIcon(NIM_MODIFY, &t->nid);
}

static void trayicon_deinit(Trayicon *t)
{
Shell_NotifyIcon(NIM_DELETE, &t->nid);
DestroyIcon(t->nid.hIcon);
DeleteObject(t->hBitmap);
DeleteObject(t->hFont);
DeleteDC(t->mdc);
DestroyWindow(t->hwnd);
}

static void windows_mod(Windows *wins, unsigned state)
{
unsigned i;
Expand Down Expand Up @@ -303,7 +232,6 @@ static void virgo_init(Virgo *v)
'S');
register_hotkey(i * 2 + 2, MOD_ALT | MOD_CONTROL | MOD_SHIFT | MOD_NOREPEAT,
'P');
trayicon_init(&v->trayicon);
}

static void virgo_deinit(Virgo *v)
Expand All @@ -313,7 +241,6 @@ static void virgo_deinit(Virgo *v)
windows_show(&v->desktops[i]);
sb_free(v->desktops[i].windows);
}
trayicon_deinit(&v->trayicon);
}

static void virgo_move_to_desk(Virgo *v, unsigned desk)
Expand Down Expand Up @@ -346,7 +273,6 @@ static void virgo_go_to_desk(Virgo *v, unsigned desk)
windows_show(&v->desktops[desk]);
SetForegroundWindow(v->focused[desk]);
v->current = desk;
trayicon_set(&v->trayicon, v->current + 1);
}

void __main(void) __asm__("__main");
Expand Down

0 comments on commit d423d9b

Please sign in to comment.