aboutsummaryrefslogtreecommitdiffstats
path: root/window.c
AgeCommit message (Collapse)Author
2022-10-19code-style: misc changes (#374)NRK
* ensure static variables comes after non-static ones * remove depreciated DATA32 type * prefer `sizeof(expression)` over `sizeof(Type)`. * silence a -Wsign warning * {gif,webp} loader: use a pointer to reduce code-noise * gif loader: allocate in one place Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/374 Reviewed-by: TAAPArthur <taaparthur@noreply.codeberg.org>
2022-08-16code-style: various cleanups (#356)NRK
* run_key_handler: make the logic easier to follow * remove timeout_t the typedef is not needed. inline the declaration similar to the other static structs. * simplify estrdup reuse emalloc, instead of calling malloc and null-checking. * win_clear: initialize `e` right away * process_bindings: explicitly check against NULL most pointer checks in the codebase do explicit check. * use a named constant instead of magic number also changes the padding from 3 to 4 bytes according to [0]. but i couldn't find any situtation where this mattered, so perhaps the current padding is enough. but doesn't hurt adding one more byte. [0]: https://nullprogram.com/blog/2017/10/06/ Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/356 Reviewed-by: explosion-mental <explosion-mental@noreply.codeberg.org>
2022-07-15fix: -Wsign-compare warnings (#336)NRK
mixing signed and unsigned types in comparison can end up having unintended results. for example: if (-1 < 1U) printf("true\n"); else printf("false\n"); previously we silenced these warnings, instead just fix them properly via necessary casting, and in cases where the value cannot be negative (e.g width/height members) make them unsigned. Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/336 Reviewed-by: explosion-mental <explosion-mental@noreply.codeberg.org>
2022-07-05reject empty xresources (#340)NRK
currently, in case of an empty xresources we would fail to init: nsxiv: Error allocating color '' instead, just reject empty value and use the fallback. Closes: https://codeberg.org/nsxiv/nsxiv/issues/339 Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/340 Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr> Co-authored-by: NRK <nrk@disroot.org> Co-committed-by: NRK <nrk@disroot.org>
2022-07-03check for utf8_decode errors (#327)NRK
utf8_decode() may return an errors, in which case the returned codepoint might be garbage. the issue can be tested by adding the following to `image-info` which produces invalid utf8 sequences: base64 -d << EOF 9JCAgPSQgIH0kICC9JCAg/SQgIT0kICF9JCAhvSQgIf0kICI9JCAifSQgIr0kICL9JCAjPSQgI30 kICO9JCAj/SQgJD0kICR9JCAkvSQgJP0kICU9JCAlfSQgJb0kICX9JCAmPSQgJn0kICa9JCAm/SQ gJz0kICd9JCAnvSQgJ8= EOF on my system, this leads to the statusbar being filled with empty boxes. check for returned error and skip the iteration. Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/327 Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2022-06-28sort and group includesNRK
* includes are sorted alphabetically * their grouping and layout is the following: - nsxiv.h will be the first include - followed by any internal headers (e.g "commands.h" "config.h") - followed by system headers (<stdlib.h> etc) - followed by third party headers (X.h libwebp etc) * also add `llvm-include-order` check to clang-tidy so that it can catch unsorted includes during CI.
2022-06-25fix: don't use reserved identifiersNRK
identifiers beginning with an underscore is reserved by the C standard.
2022-06-02code-style: simplify window title related codeNRK
instead of dancing around with some `init` parameter, directly give `win_set_title()` what it needs. `get_win_title()` now also does *just* what the name says. this simplifies things quite a bit and the functions now do what their name implies more closely instead of doing some `init` dance internally.
2022-06-01avoid doing dynamic allocation for bar buffers (#279)N-R-K
just use a static buffer since the size is constant and doesn't change. as opposed to using malloc, this also sets the buffer's initial memory region to 0 by default. also remove BAR_{L,R}_LEN from nsxiv.h, not needed after commit b4268fbf38d1f8433c73999466e116e68c7f81e7
2022-05-03Declare every extern function/variable in `nsxiv.h` (#268)N-R-K
with a couple exceptions as they cause too many -Wshadow warnings. also moves the `extcmd_t` typedef on top for cosmetic purposes. also enable `-Wmissing-prototypes` in the ci
2022-04-10fix: correctly close the font (#250)N-R-K
currently we immediately close the font on win_init_font(), which was introduced in 0d8dcfd. this was probably not correct since we use `font` later in win_draw_text(). instead, the font should be closed at exit/cleanup.
2022-03-31Improve starting in fullscreen modeKim Woelders
Instead of effectively first mapping the window at regular size and then fullscreening it, tell the WM to map the window at fullscreen size by setting _NET_WM_STATE_FULLSCREEN before mapping the window.
2022-03-31Correct setting of _NET_WM_PIDKim Woelders
The property _NET_WM_PID is a CARDINAL which per definition has format 32, whatever the size of pid_t may be. CARDINALS (and other format 32 items) must always be passed to Xlib in long's, whatever the size of long may be.
2022-03-02fix: window title not working on certain WMsNRK
not all WMs support `_NET_WM_NAME` and `_NET_WM_ICON_NAME` this patch sets `WM_NAME` and `WM_ICON_NAME` inside win_set_title() Closes: https://github.com/nsxiv/nsxiv/issues/233
2022-03-02always initialize window titleNRK
before if exec/win-title didn't exist then window title wouldn't be set. this patch makes it so window title is always set to something.
2022-03-02code-style: slight cleanupsNRK
* put TOP_STATUSBAR under the HAVE_LIBFONTS guard * change get_win_title param to take unsigned char ptr * init UTF8_STRING like other atoms
2022-02-26add config.h option for top statusbar (#231)N-R-K
Closes: https://github.com/nsxiv/nsxiv/issues/230 Co-authored-by: mamg22 <45301823+mamg22@users.noreply.github.com>
2022-02-23use win-title script for customizing window title (#213)N-R-K
this removes the cli flag `-T` as well as related config.h options. Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2022-02-13update copyright yearNRK
2022-01-06fix -Wwrite-strings related warningsNRK
2021-12-01fix: send implicit_mod to process_bindings (#176)N-R-K
* fix: send implicit_mod to process_bindings this solves the edge case where someone might have `ShiftMask + A` in their keybindings compared to a plain `A`. Closes: https://github.com/nsxiv/nsxiv/pull/166#issuecomment-978853136 * code-style: smuggle small style fix in win_draw_bar now mimics autoreload_nop.c functions
2021-11-20mark functions and vars as static (#146)N-R-K
the goal here to mark functions and variables not used outside the translation unit as static. main reason for this is cleanliness. however as a side-effect this can help compilers optimize better as it now has guarantee that a certain function won't be called outside of that translation unit. one other side-effect of this is that accessing these vars/function from config.h is now different. if one wants to access a static var/func from different translation unit in config.h, he would have to create a wrapper function under the right ifdef. for static functions one would also need to forward declare it. here's a dummy example of accessing the function `run_key_handler` from config.h under _MAPPINGS_CONFIG ``` static void run_key_handler(const char *, unsigned); bool send_with_ctrl(arg_t key) { run_key_handler(XKeysymToString(key), ControlMask); return false; } ```
2021-10-29Add colors and fonts to config.h (#115)Arthur Williams
Adds a set of config vars to control window fg/bg, bar fg/bg, mark color and bar font. This allows everything that can be done from .Xresources to be configurable from config.h. Co-authored-by: N-R-K <79544946+N-R-K@users.noreply.github.com>
2021-10-28code-style: general cleanups (#137)N-R-K
* tns_clean_cache: remove unused function arg * remove malloc casting * improve consistency use sizeof(T) at the end * avoid comparing integers of different signedness * use Window type for embed and parent * remove unnecessary comparisons * remove cpp style comments * improve consistency: remove comma from the end of enumerator list * Removed useless _IMAGE_CONFIG defines * consistency: use the same order as snprintf * Resolve c89 warnings Co-authored-by: uidops <uidops@protonmail.com> Co-authored-by: Arthur Williams <taaparthur@gmail.com>
2021-10-28update copyright notice (#139)eylles
2021-10-28fix: memory leak due to not destroying XrmDatabase (#134)N-R-K
2021-10-27Add default key-binding for DRAG_RELATIVE (#117)LuXu
Ctrl-Button1 now has a relative drag using the XC_fleur cursor. XC_fleur is normally the cursor for "size all" action, which has 4 arrows pointing to 4 directions. Co-authored-by: NRK <nrk@disroot.org>
2021-10-12Fix behaviour when TrueColor / 24 bit depth is not available (#114)miseran
* Fix regression introduced in c7ca547 which made nsxiv not start in non-TrueColor X server. * Introduce a new fix for embedding into tabbed-alpha. * Fixes a visual glitch from original sxiv when drawing transparent images in 8 bit depth. In 8 bit PseudoColor, `.pixel` is just an index into the 256 defined colors and thus trying to extract rgb bits from it would result in visual glitch. The values `.color.red` on the other hand and so on are always integers between 0 and 0xFFFF representing the color as expected. * Use XColor for win_bg/fg and mrk_fg Co-authored-by: NRK <nrk@disroot.org>
2021-10-11code-style: fix consistency issues all over the codebase (#94)Berke Kocaoğlu
* remove duplicate comment * remove empty tabs and blank lines * move macros and globals ontop * comment to seprate function implementation * fix alignment * switch to *argv[] similar to other suckless code * kill all empty last lines * append comment to endif * reuse existing ARRLEN macro * comment fall through * use while (true) everywhere Co-authored-by: NRK <nrk@disroot.org>
2021-10-09Make statusbar optional (#95)Arthur Williams
libXft and libfontconfig are now optional dependencies which can be disabled via `HAVE_LIBFONTS=0`. Disabling them means disabling the statusbar. This also does not search for freetype2 header if disabled. Co-authored-by: NRK <nrk@disroot.org>
2021-09-21code-style: use constant length array (#79)N-R-K
currently the code-base doesn't make use of variable length array despite being -std=c99. it was irresponsible of me to introduce VLA in here. since this function will be called quite often, i did not want to make calls to malloc and free as they have some overhead. 512 should be sufficient enough and probably is far bigger than any window title bar can display anyways.
2021-09-16add .mark.foreground to XresourcesNRK
since we're already allowing both window and bar colors to be customizable, it doesn't make sense to not allow so for mark color.
2021-09-16Fix font memory leak. (#57)Sam Whitehead
* Fix font memory leak. This memory leak has always been present in sxiv. The font opened on window.c:58 was never closed, so I closed it, fixing a 2kB memory leak. * document changes Co-authored-by: NRK <nrk@disroot.org>
2021-09-16change .font to .bar.font for consistency (#48)N-R-K
2021-09-16Rename, Update Docs and Prepare for Release (#9)Berke Kocaoğlu
Co-authored-by: Guilherme Rugai Freire <41879254+GRFreire@users.noreply.github.com> Co-authored-by: N-R-K <79544946+N-R-K@users.noreply.github.com> Co-authored-by: NRK <nrk@disroot.org> Co-authored-by: Arthur Williams <taaparthur@gmail.com> Co-authored-by: eylles <ed.ylles1997@gmail.com>
2021-09-16set title based on prefix and suffix (#23)qsmodo
Co-authored-by: Guilherme Rugai Freire <41879254+GRFreire@users.noreply.github.com> Co-authored-by: NRK <nrk@disroot.org> Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2021-09-16Custom bar colors (#10)Guilherme Freire
* set bar and text colors independently * change xresources to Program.class.resource * rename color variables to win/bar_bg/fg * change default bar colors to match window colors
2021-09-16Set the _NET_WM_PID and WM_CLIENT_MACHINE X properties (#13)eylles
Set the _NET_WM_PID and WM_CLIENT_MACHINE X properties Co-authored-by: Leon Kowarschick <lkowarschick@gmail.com> Co-authored-by: Kian Kasad <kian@kasad.com> Co-authored-by: NRK <nrk@disroot.org>
2021-09-16Fix in tabbed with alpha patch (#3)Berke Kocaoğlu
* Fix in tabbed with alpha patch Co-authored-by: Jared Forrest <jared_forrest@mailbox.org>
2021-09-16Added ICCCM WM_HINTSArthur Williams
When the window is mapped, some ICCCM WM_HINTS are set. The input field is set to true and state is set to NormalState. To quote the spec, "The input field is used to communicate to the window manager the input focus model used by the client" and "[c]lients with the Passive and Locally Active models should set the input flag to True". sxiv falls under the Passive Input model, since it expects keyboard input, but only listens for key events on its single, top-level window instead of subordinate windows (Locally Active) or the root window (Globally Active). From the end users prospective, all EWMH/ICCCM compliant WMs (especially the minimalistic ones) will allow the user to focus sxiv, which will allow sxiv to receive key events. If the input field is not set, WMs are allowed to assume that sxiv doesn't require focus.
2020-01-16Fix memory leak in win_res()Bert Münnich
Fixes issue #372.
2019-07-16Do not keep track of fullscreen stateBert Münnich
There is no more need for this after the removal of the special color handling for fullscreen mode in commit 2886876.
2019-07-16Use normal win colors in fullscreen modeBert Münnich
Fixes issues #361 and #367
2019-04-19Change colors and font only via X resourcesBert Münnich
2019-04-19Add Xresources font supportvxid
2019-03-15Match fallback font FC_SIZE to original fontFoldex
2019-01-23Align compile-time color options with X resource colorsBert Münnich
Two colors are more than enough!
2019-01-23Simplify X resource retrievalBert Münnich
Also makes the color names in config.def.h constant again.
2019-01-23Support X resource entries with Sxiv class nameBert Münnich
2019-01-23Fix code style of merged codeBert Münnich