diff options
| author | bryan <bryan@veltar.systems> | 2026-08-27 14:20:38 +0200 |
|---|---|---|
| committer | bryan <bryan@veltar.systems> | 2026-08-27 14:20:38 +0200 |
| commit | d0d5af28bd64ce74bf67f314db54f9d3e2fff73d (patch) | |
| tree | b52d80ae7464763c8fbe65e1eb4681c9feda5d46 /selc.c | |
| parent | f92c62127cdbe6fb0831e911c5c6dc2b5db7a7c4 (diff) | |
| download | selc-master.tar.gz selc-master.zip | |
SendInput of Ctrl+C typed a stray c or sent SIGINT into
Alacritty and Zed. Those apps ignore WM_COPY, so they are
left alone.
Diffstat (limited to 'selc.c')
| -rw-r--r-- | selc.c | 65 |
1 files changed, 4 insertions, 61 deletions
@@ -42,9 +42,7 @@ static void attachio(int force); static int samewin(HWND a, HWND b); static int isclient(HWND hw, POINT pt); static int ispass(HWND hw); -static int skipctrlc(HWND hw); static int goodsel(const struct Sel *s); -static void sendctrlc(void); static void docopy(void); static void request(int kbd); static LRESULT CALLBACK mouseproc(int code, WPARAM wp, LPARAM lp); @@ -132,24 +130,6 @@ ispass(HWND hw) } static int -skipctrlc(HWND hw) -{ - char cls[64]; - HWND root; - int i; - - root = GetAncestor(hw, GA_ROOT); - if (!root) - root = hw; - if (!GetClassNameA(root, cls, (int)sizeof(cls))) - return 0; - for (i = 0; i < (int)LEN(nocctrlc); i++) - if (strcmp(cls, nocctrlc[i]) == 0) - return 1; - return 0; -} - -static int goodsel(const struct Sel *s) { HWND a, b; @@ -164,36 +144,6 @@ goodsel(const struct Sel *s) } static void -sendctrlc(void) -{ - INPUT in[4]; - int n, ctrl; - - ctrl = (GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0; - memset(in, 0, sizeof(in)); - n = 0; - if (!ctrl) { - in[n].type = INPUT_KEYBOARD; - in[n].ki.wVk = VK_CONTROL; - n++; - } - in[n].type = INPUT_KEYBOARD; - in[n].ki.wVk = 'C'; - n++; - in[n].type = INPUT_KEYBOARD; - in[n].ki.wVk = 'C'; - in[n].ki.dwFlags = KEYEVENTF_KEYUP; - n++; - if (!ctrl) { - in[n].type = INPUT_KEYBOARD; - in[n].ki.wVk = VK_CONTROL; - in[n].ki.dwFlags = KEYEVENTF_KEYUP; - n++; - } - SendInput((UINT)n, in, sizeof(INPUT)); -} - -static void docopy(void) { HWND fg, foc; @@ -219,19 +169,12 @@ docopy(void) seq = GetClipboardSequenceNumber(); SendMessageTimeoutA(foc, WM_COPY, 0, 0, SMTO_ABORTIFHUNG | SMTO_NORMAL, COPYTO, &dummy); - if (GetClipboardSequenceNumber() != seq) { - if (verbose) + if (verbose) { + if (GetClipboardSequenceNumber() != seq) fprintf(stderr, "selc: WM_COPY\n"); - goto done; - } - if (skipctrlc(foc) || skipctrlc(fg)) { - if (verbose) - fprintf(stderr, "selc: skip Ctrl+C\n"); - goto done; + else + fprintf(stderr, "selc: no copy\n"); } - sendctrlc(); - if (verbose) - fprintf(stderr, "selc: Ctrl+C\n"); done: if (attached) AttachThreadInput(mine, tid, FALSE); |
