Commit Graph

180 Commits (next)

Author SHA1 Message Date
Diana Thayer 94b1e76af4 degendered terms 2015-03-11 21:41:43 -07:00
Michael Stapelberg 3c5df50c54 Merge branch 'master' of https://github.com/ton/i3 into ton-master 2015-03-01 16:50:37 +01:00
Ton van den Heuvel 014aa7ff74 Fix incorrect y-offset for text in i3bar
When using Pango to draw text in i3bar, the y-offset of the text is
incorrectly calculated in case all characters in the string to draw are
smaller than the cached font height. Fixes #1494.
2015-02-26 21:58:42 +01:00
Tony Crisci e18e2b9f98 i3bar: use Pango markup
Parse text within workspace buttons and the i3bar statusline as Pango
markup. This lets people specify things like font weight, text color,
background color, font size, and font family in the text of i3bar.

fixes #1468
2015-02-12 14:45:34 -05:00
Tony Crisci e91a9174e2 libi3: free previous font on font load
When loading a new font with `load_font`, free the previously loaded
font with `free_font`.

If no font is loaded, `free_font` will simply return (instead of
crashing because of a double free).
2015-02-10 15:11:40 -05:00
aszlig 9058fc44e6 Allow to validate the config file without X.
We're going to call parse_configuration() very early if -C is given on
the command line. Instead of the previous "only_check_config", which has
been a global variable, we now simply pass use_nagbar as false if we're
just validating.

This causes the whole parsing to run without X and of course without
starting nagbar and displaying the errors to standard out/error instead.

The return code of parse_configuration() is now a boolean which
represents whether an error occured during parsing and the programs exit
code is returned accordingly.

Although the config parser still has a lot of side-effects, we now can
parse without the need to have an XCB connection. A nicer implementation
would be to just set the new font and load it just after we're done
parsing, but to ensure we don't break functionality we just load a dummy
FONT_TYPE_NONE if XCB isn't available. The main reason for going this
route is that it's a bit difficult to test fonts in a distribution
agnostic way without bundling fonts with i3 (or Xdummy to be more
exact).

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
2014-08-25 19:34:26 +02:00
Michael Stapelberg 33d1d5d3c6 Treat everything up to 120 dpi as 96 dpi (Thanks jefvel)
See the comment in the source for rationale.
2014-08-23 16:02:30 +02:00
Michael Stapelberg 9200094203 format **/*.c with clang-format-3.5
This has multiple effects:

1) The i3 codebase is now consistently formatted. clang-format uncovered
   plenty of places where inconsistent code made it into our code base.

2) When writing code, you don’t need to think or worry about our coding
   style. Write it in yours, then run clang-format-3.5

3) When submitting patches, we don’t need to argue about coding style.

The basic idea is that we don’t want to care about _how_ we write the
code, but _what_ it does :). The coding style that we use is defined in
the .clang-format config file and is based on the google style, but
adapted in such a way that the number of modifications to the i3 code
base is minimal.
2014-06-15 19:07:02 +02:00
Tony Crisci 7e564713f9 Don't ELOG ipc EOF
Receiving EOF from a client is not an error, but rather a standard way a
client may disconnect from the IPC. This should rather be logged from
a consumer of the libi3 ipc_recv_message() function as a normal client
disconnect event.

fixes #1252
2014-06-08 13:54:55 +02:00
Michael Stapelberg 3760a48abe truncate DPI to an integer before multiplying (Thanks eeemsi)
This fixes i3bar workspace button rendering on non-DPI screens
(oldschool!)
2014-04-26 22:50:31 +02:00
Michael Stapelberg c79c49f69d libi3: add logical_px() for Retina display support 2014-04-26 17:17:37 +02:00
Peter Boström 9c15b9504e Fix clang -Wextra except -Wunused-parameter.
Cleared all warnings that occur when passing
CFLAGS="-Wall -Wextra -Wno-unused-parameter" to make using clang 3.3 on
Linux x86-64.
2014-01-02 22:15:33 +01:00
Michael Stapelberg 0883dfbe14 only LOG() the DPI when it changes, DLOG() it otherwise (Thanks lkraav)
This avoids flooding stdout every time some text (e.g. a window
decoration) is drawn, yet leaves the message in place when it’s actually
relevant (upon DPI changes).

fixes #1115
2013-12-24 10:35:56 +01:00
Lancelot SIX eca5e4598a libi3/root_atom_contents: handle data of arbitrary length
Handle data fetched from xcb_get_property_unchecked with arbitrary
length. This avoids having to rely on PATH_MAX macro where it is not
necessary.
2013-11-26 19:58:35 +01:00
Lancelot SIX 18cfc36408 libi3/root_atom_contents: Free xcb reply structures
Free memory allocated during xcb calls.
2013-11-24 13:52:31 +01:00
Lancelot SIX f22995393a Remove references to PATH_MAX macro
Since the macro PATH_MAX is not defined on every system (GNU/Hurd being
one of those who do not define it), we remove all references to this
macro. Instead, we use a buffer of arbitraty size and grow it when
needed to contain paths.
2013-11-24 13:50:29 +01:00
Michael Stapelberg d3beff2339 make i3bar use libi3’s root_atom_contents()
This removes code duplication, which will be useful for a subsequent
commit.

Furthermore, we now don’t open X11 connections unnecessarily in some
corner cases.
2013-11-22 15:48:45 +01:00
Michael Stapelberg 5a4efd04c1 refactor previous commit’s new code into a function, add log message 2013-11-18 23:17:44 +01:00
Bas Pape 1d6450f0e8 libi3/font: Set DPI for the pango context
The pango font specification accepts a font size in points, but pango
defaults to a DPI of 96. Create a default PangoContext (which
internally creates a default PangoCairoFontMap as usual) and set the
DPI to the value of the root Screen manually.

Fixes #1115
2013-11-18 23:12:08 +01:00
Quentin Glidic a49dfaf26c libi3/font: Draw the text at the expected place
When drawing a text with Pango, shift it to the top according to the top
if the glyph if taller than expected
We always shift of (height - savedHeight) which is a no-op for normal glyphs

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2013-09-30 22:51:52 +02:00
Michael Stapelberg 0bfcf1a762 Improve error message when $XDG_RUNTIME_DIR is not writable 2013-09-25 19:33:28 +02:00
Michael Stapelberg 6582da9939 Merge branch 'master' into next 2013-06-29 19:28:41 +02:00
Michael Stapelberg cecadbfdfe Bugfix: fix bus error on OpenBSD/sparc64 (Thanks tobiasu)
fixes #1034
2013-06-29 19:28:13 +02:00
Michael Stapelberg 75206db3a1 Bugfix: s/i3bar/i3-nagbar/ (Thanks badboy) 2013-06-10 23:23:22 +02:00
Michael Stapelberg cbdc8c33dd remove unused pathlen (Thanks gcc) 2013-06-10 23:10:46 +02:00
Michael Stapelberg 57b43d84f9 retab! get_exe_path.c
We seriously need auto-formatting.
2013-06-10 23:08:42 +02:00
Michael Stapelberg 3930615104 Bugfix: sizeof(destpath)-1 to have space for the trailing NUL (Thanks Merovius) 2013-06-10 23:08:17 +02:00
Michael Stapelberg d51173b2ba i3-nagbar: take our terminal execution kludge to the next level
Please read commit 2bf80528bd first.
Then read the comment within the code of this commit.
Then run in circles and cry loudly.

fixes #1002
fixes #1026
2013-06-10 22:55:39 +02:00
Michael Stapelberg fa1b436fca Bugfix: mark IPC fd CLOEXEC (Thanks Layus)
Without this fix, children of i3bar would inherit the file descriptor of
the IPC connection to i3. Therefore, even if i3bar exits with SIGSEGV,
the connection to i3 stays open. Because nobody actually reads any
messages by i3, the buffer will fill up and i3 can’t deliver any more
messages, and thus busy-loops at that point.

fixes #995
2013-04-14 10:12:21 +02:00
Michael Stapelberg 62b0df0640 Make i3-nagbar use the same font as configured for i3 2013-01-26 09:55:38 +01:00
Michael Stapelberg dcb8ac84f8 ipc_recv_message: store message_type, don’t compare. add distinct EOF retval
Also use ELOG, which requires i3-msg to provide logging functions.
2013-01-23 18:51:39 +01:00
Michael Stapelberg 7b0d75ee0a ipc_send_message: use stack frame with fixed size 2013-01-11 19:09:41 +01:00
Michael Stapelberg fc0e80ee7f Merge branch 'master' into next 2013-01-09 18:11:17 +01:00
Michael Stapelberg f5b7bfb12e Bugfix: fix IPC messages writes with low buffer sizes (Thanks jasper, dcoppa)
Use the following command to reproduce this bug:

    echo 4096 | sudo tee /proc/sys/net/core/wmem_default

Then just switch workspaces with some windows on it and i3bar would
exit due to malformed IPC messages.

This bug hits OpenBSD users (and possibly other BSDs) due to their lower
default buffer size.

fixes #896
2013-01-09 18:11:03 +01:00
Michael Stapelberg 9882a4dc09 fix formatting in get_process_filename.c 2012-12-24 16:57:30 +01:00
Michael Stapelberg b3d7531947 refactor both i3-nagbar starts into src/util.c
With this change, libev >= 4 is a hard dependency. It should be present
in all major linux distributions (even the latest ubuntu LTS).
2012-12-24 16:53:20 +01:00
Kacper Kowalik (Xarthisius) ef81bd183b Repect AR environment variable 2012-12-17 10:24:42 +01:00
Quentin Glidic f0d2d84b1c libi3/font: Use "pango:" prefix to avoid confusion
Also add a user-friendly font description syntax to userguide
2012-11-07 21:23:21 +01:00
Michael Stapelberg e4019caf7e clean old and new libi3 (Thanks SardemFF7) 2012-09-20 10:55:26 +02:00
Michael Stapelberg b9fde552d0 fix make clean targets 2012-09-19 18:05:51 +02:00
Michael Stapelberg 4636eb840d fix compilation with older xcb-util with -DXCB_COMPAT (Thanks okraits) 2012-09-03 14:55:27 +02:00
Michael Stapelberg 125bf09e70 pango: divide by PANGO_SCALE to get a "normal" font size 2012-08-13 13:39:58 +02:00
Michael Stapelberg 2896ae8057 logging: make libi3 use verboselog()/errorlog(), provide it in each caller
While this is a bit ugly, it makes the log messages end up where they
are supposed to: in the shmlog/stdout in case of i3 and on stdout in
case of utilities such as i3-input
2012-08-13 13:27:16 +02:00
Quentin Glidic 310f542937 libi3/font: Log the used font 2012-08-13 11:39:30 +02:00
Fernando Tarlá Cardoso Lemos 6ff3f7abad libi3: Implement Pango rendering 2012-08-13 11:39:30 +02:00
Fernando Tarlá Cardoso Lemos ec17a26b0e libi3: Rework font to support multiple backends 2012-08-13 11:39:29 +02:00
Fernando Tarlá Cardoso Lemos 5d8ccc5912 libi3: Introduce get_visualtype 2012-08-13 11:37:34 +02:00
Quentin Glidic 210fc6dfed libi3: Rework predict_text_width
predict_text_width now takes an i3String as argument
2012-08-13 11:37:23 +02:00
Quentin Glidic 53365fa887 libi3: Rework draw_text
We now have two versions of draw_text
draw_text: Now takes an i3String
draw_text_ascii: Designed for static strings in plain ASCII
2012-08-13 11:37:21 +02:00
Fernando Tarlá Cardoso Lemos 7f22d4fe32 libi3: Implement i3String
New type designed to handle UCS-2/UTF-8 conversion nicely
2012-08-13 11:29:18 +02:00
Michael Stapelberg b8e782c983 root_atom_contents: handle CARDINAL atoms such as I3_PID 2012-08-12 14:30:24 +02:00
Quentin Glidic c7029a5e21 common.mk: Introduce I3_*FLAGS
CPPFLGES, CFLAGS and LDFLAGS should be user variables
We now provide default flags but use I3_*FLAGS flags for our own needed
flags

Also reoder lib flags a bit
2012-07-22 23:53:49 +02:00
Quentin Glidic 3b1b72ecbb *.mk: Support passing specific CFLAGS/LIBS 2012-07-22 23:53:13 +02:00
Quentin Glidic e452acb30e Add stub Makefiles to allow subdir make calls 2012-07-22 19:57:48 +02:00
Quentin Glidic e3b9ffe381 Move libi3 to the new Makefile layout 2012-07-22 19:57:21 +02:00
Michael Stapelberg f229570bbc remove unused variable 2012-05-09 19:58:50 +02:00
Michael Stapelberg eeb6ff9237 Move is_debug_build() to libi3/ 2012-05-09 19:12:20 +02:00
Michael Stapelberg 206b96202c Use (void) instead of () for functions without args (Thanks fernandotcl)
See also:
http://article.gmane.org/gmane.linux.kernel/1268792

The C compiler will handle (void) as "no arguments" and () as "variadic
function" (equivalent to (...)) which might lead to subtle errors, such
as the one which was fixed with commit 0ea64ae4.
2012-03-31 10:53:04 +02:00
Fernando Tarlá Cardoso Lemos 95f510e724 Don't multiply by sizeof(char) twice.
This is a no-op, since sizeof(char) is 1. But still, we shouldn't
multiply twice, it's misleading.
2012-03-26 16:47:44 +02:00
Fernando Tarlá Cardoso Lemos 484c2a697b Document text_len in the draw_text description. 2012-03-26 16:47:23 +02:00
Michael Stapelberg 58ecd14900 Implement support for chosing a 32 bit visual (necessary for pseudo-transparency) (Thanks darkraven)
You need to specify the --enable-32bit-visual flag when starting i3. This is
done because everything feels sluggish on my system when using a 32 bit visual
instead of a 24 bit visual. Fast > fancy.
2012-02-15 18:56:07 +00:00
Michael Stapelberg dee7c07ad2 shmlog: store meta information in the buffer itself, store path as X11 atom
This makes i3-dump-log completely independent of a running i3 instance.
2012-01-06 23:40:07 +00:00
Fernando Tarlá Cardoso Lemos 0e6d1909b8 Handle the case where there's no font char infos.
Fixes i3bar crash with some fonts (and possible i3 crash too).
Thanks to xeen for reporting the issue.
2011-11-27 19:58:06 +00:00
Fernando Tarlá Cardoso Lemos 340592a532 Invalidate cached pixmaps on reload and redraw.
After a reload, the drawing parameters for the decorations might
have changed, so we need to invalidate the cache and force a redraw
of the currently visible decorations. Also, don't leak the previous
font when reloading by freeing it before parsing the config.
2011-11-26 21:51:49 +00:00
Michael Stapelberg 561cf3719f little style fixes 2011-11-21 21:48:24 +00:00
Fernando Tarlá Cardoso Lemos 344c04af12 Implement set_font_colors.
This paves the way for other font rendering backends. Fonts and
colors shouldn't be specified manually from now on.
2011-11-21 20:52:32 +00:00
Fernando Tarlá Cardoso Lemos 5c2088c87e Enhance libi3 and use it in i3bar.
Abstracted draw_text and predict_text_width into libi3. Use
predict_text_width from libi3 in i3 too. This required tracking
xcb_connection in a xcb_connection_t *conn variable that libi3
expects to be available in i3bar.
2011-11-21 20:52:26 +00:00
Michael Stapelberg 70793d8bb9 libi3/ucs2_conversion: tiny style fixes 2011-11-16 21:41:55 +00:00
Fernando Tarlá Cardoso Lemos fb11cc2d14 Consolidate all convert_* functions into libi3.
Some minor fixes along the way as well. Very minor stuff, unlikely
to ever be visible to the user.
2011-11-16 20:54:30 +00:00
Michael Stapelberg 726f2a1e5a normalize file headers across **/*.{h,c} 2011-10-25 21:19:38 +01:00
Michael Stapelberg a58018cf66 Add libi3/load_font, use it everywhere
…except for i3bar, which needs slightly more information about the font
2011-10-23 22:37:11 +01:00
Michael Stapelberg 91134f75c0 Move get_mod_mask to libi3, use it in i3 and i3-config-wizard
Also, the API changed a bit. There are two functions now, both assume you
already got the keysyms (which is the case for i3 and i3-config-wizard),
one gets the modifier mapping for you (aio_get_mod_mask_for) while the other
assumes you also got that. No roundtrips are required for the latter.
2011-10-23 21:26:15 +01:00
Michael Stapelberg 9eda7fb6fb move strndup to libi3 2011-10-23 18:02:01 +01:00
Michael Stapelberg cb9bbcfccf Move get_colorpixel to libi3, use it everywhere else 2011-10-23 17:38:21 +01:00
Michael Stapelberg 4f57d49318 add libi3/ipc_connect, use it in i3-config-wizard, i3-input, i3bar 2011-10-23 17:18:14 +01:00
Michael Stapelberg 9d15a00ba8 introduce sasprintf() in libi3, use it everywhere 2011-10-23 13:16:56 +01:00
Michael Stapelberg 29c185dd0b Move fake_configure_notify to libi3 2011-10-09 13:40:15 +01:00
Michael Stapelberg 046cf99585 Move ipc_send_message and ipc_recv_message to libi3
Make i3-msg and src/ipc.c use it
2011-10-02 18:33:36 +01:00
Michael Stapelberg 501dc36b98 move sstrdup, scalloc, smalloc, srealloc to libi3, improve error messages 2011-10-02 18:09:30 +01:00
Michael Stapelberg 094c26556e Introduce libi3, an *internal* library to eliminate code duplication 2011-10-02 16:11:30 +01:00