summaryrefslogtreecommitdiffstats
path: root/window.c
AgeCommit message (Collapse)Author
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
2019-01-23Add Xresources capabilitynoamcore
2018-10-15Set window title only once at startupBert Münnich
Putting image info in the title predates the info bar; it no longer seems necessary. Fixes issue #318.
2018-04-11Initialize window bar buffers to empty stringBert Münnich
Fixes issue #308.
2017-12-07Simplify drawing of bar textBert Münnich
Non-fitting text is truncated by simply cutting it off. win_textwidth() has been replaced by a simple macro wrapper around win_draw_text() with a maximum width of zero, which results in a dry-run that still calculates the number of pixels used by the text, much like snprintf(3) with a buffer length of zero.
2017-12-07Replace utf8codepoint with Chris Wellons' utf8_decodeBert Münnich
Code under a different license should be kept in a separate file. This implemention is a single header file with ~65 lines, so it better fits this requirement.
2017-12-07win_textwidth is no longer needed outside window.cBert Münnich
2017-12-07Try to match a fallback font if neededSquibby
Fixes #276 Instead of rendering the entire filename at once, Xft will let us do it character by character. This will allow sxiv to query fontconfig for a font that can provide any missing codepoints, if needed. A known issue of this patch is that the "..." dots rendering will not work properly for very long multibyte filenames. That is because we cannot easily predict the final width of the rendered filename before drawing it. I couldn't figure out a clean way to deal with this, so I ended up just truncating the offending filenames.
2017-10-16One header file for type definitions and function declarationsBert Münnich
2017-10-06Improve mouse supportBert Münnich
None of the mouse mappings uses a keyboard modifier, making it possible to access the most basic features by only using the mouse. Next/previous image with left button depending on cursor position, middle button for dragging, right button for switching to thumnail mode and wheel for zooming. Users can keep the old behaviour by simply not adapting the changes to the buttons array in config.def.h to their config.h file.
2017-10-05Own win method for mouse cursor locationBert Münnich