Commit Graph

98 Commits

Author SHA1 Message Date
Michael Stapelberg 419b73be9e Merge pull request #1816 from tcreech/tcreech-for-illumos
Changes for compiling i3 on Illumos
2015-08-04 00:10:06 -07:00
shdown c85d16faa4 Use safe wrappers wherever possible 2015-08-03 12:50:50 +03:00
shdown bc52fae15c libi3: change scalloc() signature to match calloc() 2015-08-03 12:50:13 +03:00
Tim Creech f41018b33e Changes for compiling on Illumos
* common.mk: use -lsocket -liconv -lgen on Illumos/Solaris
* mkdirp: return int and accept a mode argument
* use i3's mkdirp on everything except Illumos
2015-07-30 07:44:10 -04:00
Ingo Bürk 5a8d66a1d5 Parse the title_format and display the customized window title if a format was set.
The format string set with "title_format" can contain the placeholder "%title" which will be replaced with the actual window title.

By not overwriting window->name itself, we make sure that assignment matching still works as expected.

fixes #1723
2015-06-29 09:13:31 +02:00
Theo Buehler ea6af13127 mkdirp: do not throw an error if directory exists
If I restart i3 4.10.2 twice, e.g. with

$ i3-msg restart; sleep 3; i3-msg restart

the second time I get the following two errors:

05/22/15 10:46:03 - ERROR: mkdir(/tmp/i3-theo.toAK7N) failed: File exists
05/22/15 10:46:03 - ERROR: Could not create "/tmp/i3-theo.toAK7N" for storing the restart layout, layout will be lost.

The first one is from mkdirp() in src/ipc.c and the second one is from
store_restart_layout() in src/util.c.

Notice that I do _not_ get the ``open()'' or ``Could not write restart layout to
...'' error messages, so the layout writing code after line 260 in
store_restart_layout() succeeded and the layout isn't actually lost.  Thus,
these error messages are a bit misleading, especially the second one (which is
triggered by the failure of mkdirp()).

POSIX says about `mkdir -p':

``Each dir operand that names an existing directory shall be ignored without
error.''

Therefore, I suggest the following simple patch that makes mkdirp() succeed if
the named file exists and actually is a directory.  This silences the second
error as well.
2015-05-23 13:12:18 +02:00
Michael Hofmann 0319bda1d4 Introduce sstrndup wrapper. 2015-05-06 16:33:15 +02:00
Deiz 884214f14f Update copyright notices and get rid of ranges
The script used to make these changes can be found at:

   https://gist.github.com/Deiz/32322020f76d23e2bf8f
2015-04-20 17:50:21 -04:00
Deiz e622c42ef0 Move mkdirp into libi3 2015-03-29 17:18:00 -04:00
Deiz 4daed31c3e Move resolve_tilde and get_config_path into libi3 2015-03-29 14:45:42 -04:00
Michael Stapelberg 6b04f28b48 fix remaining warnings 2015-03-29 17:12:20 +02:00
hwangcc 42515308e7 Add a safe wrapper for write and fix some warnings
1. Add a function writeall and make swrite wrap that function. Use either writeall or swrite, depending on whether we want to exit on errors or not.
2. Fix warnings when compiling with a higher optimisation level.
(CFLAGS ?= -pipe -O3 -march=native -mtune=native -freorder-blocks-and-partition)

Signed-off-by: hwangcc <hwangcc@csie.nctu.edu.tw>
2015-03-29 10:22:34 +08:00
Tony Crisci e681f34ec1 i3bar: set markup per block
Add `markup` to the i3bar protocol as a block member.

This is a string that determines how the block should be parsed as
markup. "pango" indicates the block should be parsed as Pango markup.
"none" indicates the block should not be parsed as markup.
2015-03-24 02:27:38 -04:00
Ingo Bürk c9019ada4e Add support for short_text
When the statusline is too long, try to use the short_text property of each status block before falling back to truncating it.
fixes #1092
2015-03-23 11:24:30 +01:00
Ingo Bürk 8272924117 Introduce a function to copy i3strings 2015-03-23 11:03:45 +01:00
Tony Crisci 6fb7fc9bc6 Bugfix: validation segfault
When `new_window` is given in the config, config validation with `i3 -C`
would segfault.

Add a NULL check in logical_px() to check for the case when the config
is being validated without an X server to prevent this.
2015-03-22 05:46:52 -04:00
Michael Stapelberg 5b80713233 Merge pull request #1549 from shdown/y-offset-fix
Fix incorrect y-offset for text in i3bar (2)
2015-03-21 16:32:19 +01:00
shdown 123de9a25f Fix incorrect y-offset for text in i3bar (2)
014aa7ff74 fixed incorrect align of small
symbols, but also introduced a problem with texts with mixed large and
normal symbols. Fix it by centering the text vertically only if its
height is smaller that the saved font height.
Fixes #1543.
2015-03-15 10:32:17 +03:00
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