Commit Graph

3048 Commits (c6cf0d32b99c5c63f191596dca616a0f791ddfbf)

Author SHA1 Message Date
Ingo Bürk dd13cae5c0 Merge pull request #2959 from orestisf1993/issue-2764
Allow assign to output
2017-09-22 16:24:26 +02:00
Vladimir Panteleev 760b2e1b4a
Do not canonicalize special output names
canonicalize_output_name allowed the "primary" special output name to
be canonicalized, thus converting it to the name of whatever output
was the primary output at the time. This caused settings
(specifically, i3bar output and tray_output settings) to be stored as
specific output names, instead of the intended special names whose
referred output may change as the system's configuration (i.e. current
primary output) changes.

Add a check to canonicalize_output_name to return the name as-is if it
is the special name "primary".
2017-09-19 14:57:08 +00:00
Vladimir Panteleev caae4db0bc
fake_outputs: Allow designating a fake output as primary
Allow appending 'P' to the fake output specification to set the
created output's "primary" flag, to allow writing test cases that
depend on the presence of a primary output.
2017-09-19 14:57:08 +00:00
Vladimir Panteleev 19b00346e5
fake_outputs: Don't read past the end of string
fake_outputs_init would unconditionally increase the string read
pointer variable (walk) by one character more than the number of
characters that have been read, to skip past the character delimiting
records (a comma). However, when the input string was not terminated
by a comma, it would cause the function to read past the null
terminator instead.

Avoid this by explicitly checking for the expected delimiter.
2017-09-19 14:57:08 +00:00
Vladimir Panteleev 755b223278
fake_outputs: Use %n format specifier instead of sprintf
fake_outputs_init used a sprintf invocation with a throw-away buffer
to estimate how many characters the sscanf invocation consumed. This
was unnecessary, and also potentially incorrect, as differences
between the read and formatted strings (such as leading zeros) could
lead to fake_outputs_init to lose its track.

Instead, use the %n format specifier which allows saving the number of
characters consumed by sscanf so far. %n is part of C99.
2017-09-19 14:57:03 +00:00
Michael Stapelberg e48441ecbd Bugfix: avert crash by fixing focus when creating output containers (#2966)
fixes #2854
2017-09-18 16:37:34 +02:00
Michael Stapelberg d1296cd1cf Bugfix: don’t invalidate layout upon invalid 'layout toggle' params (#2965)
fixes #2903
2017-09-18 16:36:57 +02:00
Michael Stapelberg 607e97e651 ipc: rename COMMAND to RUN_COMMAND for consistency (#2956)
All other message types are verbs, only our first-ever message COMMAND wasn’t.

While we’re here, also change the message type dictionary into a table with
clickable links to the corresponding reply type.

Authors of downstream IPC libraries are encouraged to keep the old name around
so as to not break existing code, but mark it as deprecated.
2017-09-17 15:25:00 +02:00
Orestis Floros a35854ddf4 Allow assign to output
Implements the "assign" part of issue #2764.
2017-09-17 15:37:17 +03:00
Orestis Floros e2bacc7df8 Add con_move_to_output_name function 2017-09-17 15:37:17 +03:00
Orestis Floros 91c8c00afc Fix use of err after it is freed 2017-09-17 01:14:47 +03:00
Orestis Floros f7a7c7778b Fix wrong call to free
To confirm, assign n to a constant value and try to use the
append_layout command.

Without the change i3 crashes.
2017-09-17 00:24:15 +03:00
Orestis Floros 205dd76096 Prevent freeing of uninitialized pointer
> variable 'buf' is used uninitialized whenever 'if' condition is true

Note: freeing a NULL pointer is fine.
2017-09-16 23:54:12 +03:00
Orestis Floros fa5d8a0209 Make swap work with fullscreen windows
Swap works like normal with fullscreen windows but swaps the fullscreen
mode of the 2 containers after it's done.

Fixes #2811
2017-09-16 13:49:20 +03:00
Ingo Bürk 8cad1c1fa6 Merge pull request #2887 from orestisf1993/next
Allow assign to workspace by number
2017-09-15 21:26:35 +02:00
Vladimir Panteleev 480f688b44
Fix erratic behavior with single container child jumping outputs
This fixes a regression introduced in commit
4e88c10564ca5366c2578908f62ec56625a26718: when attempting to move the
single child of a container in the direction of another output, i3
would move the window to the output, despite the window not being at
the edge of its output, instead of moving it to its parent container.

The bug occurred because the check for moving containers across
outputs with non-default workspace layouts (issue #1603) did not
actually verify that the moved window lies at the edge of the
workspace, despite what its comment said.

Fixes issue #2466.
2017-09-15 09:27:32 +00:00
Orestis Floros eaf7a49e28 Allow assign to workspace by number
Makes "assign [<criteria>] workspace number <number>" work in the same
manner as "move to workspace number <number>" instead of assigning the
window to a workspace named "number <number>".

config.spec is modified to expect a 'number' string and an extra
argument is used in cfg_assign.

For workspaces that don't exist yet, workspace_get is used as a
fallback. This also allows the user to assign to "<number> <workspace>"
eg "2: work" and the full name will be used if workspace number 2
doesn't exist yet.

Fixes #2590.
2017-09-15 03:38:13 +03:00
Vladimir Panteleev bfa76016de
Fix typo in con_parent_with_orientation description 2017-09-15 00:07:40 +00:00
Michael Stapelberg c45c002bad validate JSON before loading
This commit also introduces slurp() which reads a file in its entirety. Using
this function instead of doing IO in the functions in load_layout.c again and
again makes the code cleaner (fixing at least two memory leaks) and avoids
re-reading the same file 3 times.

related to #2755
2017-09-13 17:41:05 +02:00
Michael Stapelberg b23e1f644f Bugfix: free incomplete containers when JSON parsing fails
related to #2755
2017-09-13 16:39:13 +02:00
Orestis Floros 7b0f4abf4f scalloc parse_config input to make sure it terminates with '\0'
Otherwise strchr() can crash for files that don't end with '\n' because
it won't find a null char to terminate at.

Fixes #2934
2017-09-13 15:31:53 +03:00
Vladimir Panteleev 6de9cdd96f
ipc: Canonicalize output names in bar configuration
Convert the output names specified in the "output" and "tray_output"
fields in bar blocks in i3's configuration to the referred output's
primary name. This allows specifying names other than the primary
output's name in the given fields without changing the IPC protocol.
2017-09-13 08:23:26 +00:00
Vladimir Panteleev ae8f3c2679
randr: Look up alternative output names when searching outputs
Update get_output_by_name to look at all additional names added by the
change in the previous commit, not just the primary one.
2017-09-13 08:23:26 +00:00
Vladimir Panteleev 8d51780d13
randr: Register monitors' output names as additional i3 output names
In addition to the name of the monitor itself (which is still used as
the i3 output's primary name), register RandR output names associated
with the RandR monitor as alternative i3 output names.
2017-09-13 08:23:26 +00:00
Vladimir Panteleev d01a59b922
Store output names as a linked list
Currently, only one name is ever added, and only the first name is
ever accessed; actually using the capability to store and access
multiple names comes in the following commits.
2017-09-13 08:23:24 +00:00
Vladimir Panteleev 30b1ab38b3
Introduce output_primary_name function
Currently simply returns output->name, but this will make it easier to
change how output names are stored in the following commits.

Also replace reading output->name with invocations of
output_primary_name. Code which writes output->name is unchanged. Done
using a mostly mechanical replacement of output->name to
output_primary_name(output).
2017-09-13 08:22:57 +00:00
Orestis Floros 554775f694 Set marks to NULL after freeing
realloc() was being called on an already freed pointer.

Fixes #2900
2017-09-07 10:51:13 +03:00
Orestis 66f2148236 Check if con_id exists in cmd_swap (#2898)
Also adds some testcases for swap using con_id.

Fixes #2895
2017-09-06 07:34:14 +02:00
Ingo Bürk 85eb097677 Invert condition to log debug message in correct situation (#2896) 2017-09-05 09:01:53 +02:00
hwangcc23 92b8196192 Properly initialize sigaction struct
The code in handle_signal() wasn't clearing the struct sigaction before passing it to sigaction().
This meant that we would block a random set of signals while executing the default handler, or jump to the uninitialized __sa_sigaction__ (instead of sa_handler).
Initialize properly as we do in setup_signal_handler().
2017-08-31 22:48:33 +08:00
Michael Stapelberg 4dca8e6e0b Respect focus_on_window_activation for ConfigureRequests (#2889)
fixes #2873
2017-08-28 12:07:56 +02:00
Michael Stapelberg d7e6cba17e do leak check before exiting
related to #2541
2017-08-28 09:23:42 +02:00
Michael Stapelberg c4474adfd6 Fix memleak: free regex when parsing fails
fixes #2541
2017-08-28 09:22:56 +02:00
Michael Stapelberg 260bcf283f Respect dont_warp flag when moving containers (#2867)
fixes #2681
fixes #2592
2017-08-20 17:07:23 +02:00
Michael Stapelberg c70fa8078f Focus windows upon ConfigureWindow with stack-mode=Above (#2865)
fixes #2708
fixes #2745
2017-08-20 14:56:44 +02:00
Michael Stapelberg bb0aac6e39 start nagbar when encountering invalid set statements
related to #2564
2017-08-20 12:59:07 +02:00
Michael Stapelberg 8cc11dcb08 Skip lines consisting only of “set” 2017-08-20 12:59:03 +02:00
Michael Stapelberg dd019f59fa (Re-)initialize optional fields to empty strings 2017-08-20 12:55:55 +02:00
Michael Stapelberg c25bee0ffc Bugfix: check bounds before accessing memory
This fixes the following issue when having an error early in the config file:

==1562==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6220000180ff at pc 0x55c837edb1d3 bp 0x7ffee7534650 sp 0x7ffee7534648
READ of size 1 at 0x6220000180ff thread T0
    #0 0x55c837edb1d2 in start_of_line ../../i3/src/config_parser.c:238
    #1 0x55c837edc96f in parse_config ../../i3/src/config_parser.c:493
    #2 0x55c837edf527 in parse_file ../../i3/src/config_parser.c:1091
    #3 0x55c837ecf14b in parse_configuration ../../i3/src/config.c:65
    #4 0x55c837ed1ef4 in load_configuration ../../i3/src/config.c:230
    #5 0x55c837f0a8d0 in main ../../i3/src/main.c:539
    #6 0x7fb63ae042b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
    #7 0x55c837e95eb9 in _start (/home/michael/i3/build/i3+0x4beb9)

0x6220000180ff is located 1 bytes to the left of 5165-byte region [0x622000018100,0x62200001952d)
allocated by thread T0 here:
    #0 0x7fb63e590cf8 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1cf8)
    #1 0x55c837f59aa6 in smalloc ../../i3/libi3/safewrappers.c:24
    #2 0x55c837edef45 in parse_file ../../i3/src/config_parser.c:1029
    #3 0x55c837ecf14b in parse_configuration ../../i3/src/config.c:65
    #4 0x55c837ed1ef4 in load_configuration ../../i3/src/config.c:230
    #5 0x55c837f0a8d0 in main ../../i3/src/main.c:539
    #6 0x7fb63ae042b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
2017-08-20 12:54:49 +02:00
Michael Stapelberg 4d93d26484 Bugfix: consider inactive monitors when querying (#2862)
fixes #2815
fixes #2594
2017-08-20 00:19:45 +02:00
Michael Stapelberg a6d8ed9b1a Introduce the GET_CONFIG IPC request
This introduces memory usage by one copy of the config file, which is an
acceptable trade-off for being able to easily revert data loss.
The default config is 6KB, user configs will be in the same ballpark.

fixes #2856
2017-08-19 19:08:51 +02:00
akash akya ec3ffdd7a0 Fix 'Mouse binding don't work' 2017-07-07 01:03:36 +05:30
Michael Stapelberg a4f6387911 compare modifiers for equality, not subset (+test)
Subset comparison was introduced with the rather large commit
bf3cd41b5d, but I now think we should use
equality.

In other words, the following key binding:

    bindsym Mod4+x nop Mod4+x

previously would have been triggered when pressing Mod3+Mod4+x.

Strictly speaking, this is a change of behavior, but it breaks none of our
tests, and using equality instead of subset comparison enables more use-cases.

fixes #2002
2017-05-24 20:42:27 +02:00
Michael Stapelberg 26f5edb97f no-op change: store |button| in the correct data type 2017-05-24 20:41:55 +02:00
Michael Stapelberg 0acd11a8d7 no-op change: move bind->release check into loop
We don’t have to negate the check anymore, making it more readable.
2017-05-24 20:41:17 +02:00
Michael Stapelberg 6d9b165fb4 no-op change: don’t compare keycode for every modifier 2017-05-24 20:40:17 +02:00
Chih-Chyuan Hwang 13372d511a Fix the i3 crash caused by mark + restart commands (#2779)
This patch fixes the issue #2511(https://github.com/i3/i3/issues/2511).

1). Memorize the marks, but only call con_mark once the container has finished parsing. (Credit: This is @Airblader's patch.)

2). Add a test case 267-regress-mark-restart.t for regression test to check if mark and restart command crash i3.
2017-05-23 08:47:11 +02:00
Michael Stapelberg 2bd3639fbb Fix --release bindings broken by previous commit
fixes #2559
2017-05-23 08:28:56 +02:00
Michael Stapelberg 36f80f2de8 Apply numlock fallback to bindcode where necessary (#2781)
This was broken with commit d77d40173a

fixes #2559
2017-05-22 21:32:05 +02:00
Ingo Bürk 7b6f592b71 Merge pull request #2771 from hwangcc23/fix-2764
Support to get the primary output
2017-05-16 18:39:37 +02:00
hwangcc23 f99727b518 Support to get the primary output
This makes `primary` output available for assign or move commands.
Fix the issue #2764(https://github.com/i3/i3/issues/2764).
2017-05-16 23:06:12 +08:00
Michael Stapelberg 6dd4252cd5 Merge pull request #2496 from Airblader/feature-917
Implement 'swap' command.
2017-05-15 21:35:10 +02:00
Ingo Bürk 5f9a5e8d7d Implement 'swap' command.
This patch introduces a new command 'swap' that swaps two containers so
that they assume each other's position and geometry.

fixes #917
2017-05-15 21:06:38 +02:00
Ingo Bürk 9178c5b8ca Force container to be redrawn upon moving to another container. (#2769)
This is necessary as otherwise urgent containers can be broken
after moving them.
2017-05-12 19:26:35 +02:00
Nathan Schulte 9bc504ebdb add error check and log for xcb_create_window 2017-05-12 09:01:37 +02:00
Ingo Bürk d78fd8d91f Introduce --exclude-titlebar flag for mouse bindings. (#2703)
This introduces the flag --exclude-titlebar for mouse bindings which
allows bindings like

    bindsym --whole-window --border --exclude-titlebar button3 focus

fixes #2347
2017-05-02 09:08:42 +02:00
Mihai Coman 52ce8c803d Fix changing of root workspace layout from stacked/tabbed 2017-04-27 17:50:55 +03:00
Nathan Schulte 454578b331 add error check and log for xcb_create_window 2017-04-07 09:59:24 -05:00
Ingo Bürk c474ddd782 Merge pull request #2649 from s3rb31/next
layout toggle: take any combination of layouts as arguments (continuation of #2476)
2017-02-24 00:58:19 +01:00
s3rb31 37658bd6d7 layout toggle: take any combination of layouts as arguments (#2649)
With this PR the 'layout toggle' command can be passed any
combination of valid layout keywords as arguments. They will
be activated one after another each time you issue the command,
advancing from left to right always selecting the layout after
the currently active layout or the leftmost layout if the active
layout is not in the argument list.

This PR also incorporates the feature request from #2476.
2017-02-24 00:34:18 +01:00
s3rb31 3410cb256d Implement mapping from string to layout as extra function 2017-02-23 21:49:48 +01:00
Michael Stapelberg 4a2d5da044 Merge pull request #2680 from Airblader/feature-2677
[#2677] Allow using left/right scrolling like up/down scrolling.
2017-02-20 09:06:57 -08:00
Ingo Bürk 8158e4c415 Copy the entire window content on Expose events. (#2685)
With commit d58dbc3 we started ignoring Expose events in a sequence
except for the last one. Since we only copied the affected part of
the window in the Expose event handler, this caused incorrectly
rendered window decorations.

Instead of reverting to the old behavior, we now copy the entire window
content on this single, last event with the following rationale:
- It's cheaper to copy a larger chunk once than multiple smaller
  chunks doing one server roundtrip each.
- That's how we do it when rendering out decoration on decoration
  changes as well.

fixes #2683
2017-02-17 00:06:40 -08:00
Ingo Bürk 432c4211ea Allow using left/right scrolling like up/down scrolling.
This commit makes left/right scrolling synonyms for up/down scrolling for
* scrolling on window decoration
* scrolling on i3bar workspaces

fixes #2677
2017-02-14 22:28:01 +01:00
Ingo Bürk 7732971ad8 Introduce named aliases for mouse buttons.
This increases readability and allows us to cover up the fact that
XCB doesn't define constants for left/right scrolling.
2017-02-12 20:44:45 +01:00
Tony Crisci 04dcf42397 Add the ipc shutdown event (#2652)
This event is triggered when the connection to the ipc is about to
shutdown because of a user action such as with a `restart` or `exit`
command. The `change` field indicates why the ipc is shutting down. It
can be either "restart" or "exit".

fixes #2318
2017-01-22 14:08:32 -08:00
mihaicmn 564945bc14 migrate placeholder windows to draw_util (#2646) 2017-01-21 07:53:09 -08:00
Ingo Bürk 367811be2d Ensure that marks and the title are displayed even if the window title is empty. (#2639)
Previously rendering marks and the title were skipped if the title is empty. With marks
this is obviously wrong, with the title it is also wrong because title_format might be
set.
2017-01-16 14:00:01 -08:00
Ingo Bürk 7f84f49846 Don't exit() on redefined binding mode. (#2638)
Doing a hard exit() is a rather harsh action for something i3 can handle
perfectly fine and is only meant to be a check to make debugging easier
for users in certain situations.
2017-01-13 10:01:36 -08:00
Ingo Bürk d58dbc3a77 Only react on the last Expose event in a series of events. (#2636)
Thanks to @psychon for pointing this out during the review of PR #2624.
This commit extends this change to all other occurences of Expose events
within i3.
2017-01-13 09:34:58 -08:00
Ingo Bürk e0582aa5eb Remove unused function arguments. (#2635)
The connection is no longer necessary since the non-cairo paths have
been removed.
2017-01-13 09:34:09 -08:00
Ingo Bürk 33d6a4e829 Validate that a binding mode is not defined more than once. (#2633)
While defining the same mode usually wouldn't hurt and, in fact, the old behavior
allows to split the definition of a binding mode into several blocks, this
can lead to user errors where they accidentally define a mode twice and don't understand
why the mode behaves a certain way (this has been observed in real life :-)).

There's no good usecase for splitting a single binding mode into multiple blocks, thus
the new behavior is better.

fixes #2615
2017-01-13 09:33:29 -08:00
Ingo Bürk 14eea7fce5 Added support for _NET_MOVERESIZE_WINDOW. (#2634)
fixes #2603
2017-01-13 09:30:50 -08:00
Ingo Bürk abf8300792 Rewrite the signal handler dialogs.
This commit is a rewrite of the popup dialogs used when i3 crashes. We now
use our draw_util suite and both properly react to EXPOSE events and clean
up the windows when the handler exits.

As a side-effect, this fixes #2422
2017-01-10 20:13:25 +01:00
Jens-Wolfhard Schicke-Uffmann 584263b1b3 Report error during error log creation (#2625) 2017-01-10 09:29:06 +01:00
Zbyněk Moravec 05a2270eb7 Fix read of uninitialized memory (#2596)
Previous code was reading whole array, it was slower and it
read uninitialized memory
2016-12-02 18:53:59 +01:00
Ingo Bürk a301396997 Respect minimum size hints for floating windows. (#2508)
This commit introduces proper support for the minimum size on floating
windows by ensuring that it is respected during mapping, later changes as
well as resizes.

Furthermore, this commit fixes minor issues with how the hints are handled
during calculations.

fixes #2436
2016-11-28 22:09:39 +01:00
Michael Stapelberg 633a9f7b14 Implement RandR 1.5 support (#2580)
This comes with the intentionally undocumented --disable-randr15 command
line flag and disable-randr15 configuration directive. We will add
documentation before the release if and only if it turns out that users
actually need to use this flag in their setups. Ideally, nobody would
need to use the flag and everything would just keep working, but it’s
better to be safe than sorry.

fixes #1799
2016-11-28 18:20:46 +01:00
Michael Stapelberg 2f9bb7dd5a Fix memory leak: free marks when destroying containers (#2578) 2016-11-21 02:41:15 -08:00
Michael Stapelberg 90d68d7ea0 Remove some now-unused functions from xcb.[ch] (#2574)
xcb_draw_line is unused since commit
d7f9700ba4

xcb_draw_rect is unused since commit
a79d33fc7f

xcb_raise_window is unused since commit
7208d01048

xcb_warp_pointer is unused since commit
755c618cd4
2016-11-21 00:37:17 -08:00
Michael Stapelberg 70e7f0e39a Remove unused src/debug.c (#2575) 2016-11-21 00:37:10 -08:00
mihaicmn da5fe3b934 fix incorrect reply to ipc command (#2567) 2016-11-15 09:26:53 -08:00
Chih-Chyuan Hwang 9108f3214c Fix memory leaks (#2560)
Fix memory leaks when executing 'i3 --moreversion'.

=================================================================
==14852==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 159 byte(s) in 1 object(s) allocated from:
    #0 0x7fea40855602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x4c4c4a in smalloc ../../i3/libi3/safewrappers.c:24
    #2 0x4c3aee in ipc_recv_message ../../i3/libi3/ipc_recv_message.c:61
    #3 0x44dc2e in display_running_version ../../i3/src/display_version.c:94
    #4 0x472947 in main ../../i3/src/main.c:269
    #5 0x7fea3d0c982f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

Direct leak of 39 byte(s) in 2 object(s) allocated from:
    #0 0x7fea40855602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7fea3d11f7d7 in vasprintf (/lib/x86_64-linux-gnu/libc.so.6+0x767d7)

SUMMARY: AddressSanitizer: 198 byte(s) leaked in 3 allocation(s).
2016-11-13 10:45:39 -08:00
Michael Stapelberg fff3f79da9 switch to clang-format-3.8 (#2547)
https://llvm.org/bugs/show_bug.cgi?id=30353 was filed for the unintended
line break between in e.g. “TAILQ_ENTRY(foo)\nbar;”.

Until that’s fixed or a workaround is known, we’ll live with line
breaks. To make it a bit easier for readers to see what’s going on, I
added extra line breaks around each such struct member/variable
definition, so that they at least visually are a single unit.

fixes #2174
2016-11-08 13:46:43 -08:00
Chih-Chyuan Hwang faa9915abc Fix an use-after-free bug (#2522)
Fix the issue #2421 (https://github.com/i3/i3/issues/2421).

floating_enable() invokes tree_close_internal() to free con->parent.
After con->parent is freed in tree_close_internal() but before con->parent is reassigned by the caller, con->parent may be dereferenced and causes i3 crash.

The backtrace below is an example.
The already-freed pointer is dereferenced again through the pointer "focused" in x_push_changes().

Reassign con->parent before calling tree_close_internal() to fix this use-after-free bug.

0x0000000000416372 in con_get_workspace (con=0x7ab9c0) at ../i3/src/con.c:375
0x0000000000416103 in con_has_managed_window (con=0x7ab9c0) at ../i3/src/con.c:266
0x000000000042b413 in x_push_changes (con=0x78d190) at ../i3/src/x.c:1132
0x0000000l0004533e8 in tree_render () at ../i3/src/tree.c:504
0x0000000000452b4f in tree_close_internal (con=0x7b67c0, kill_window=DONT_KILL_WINDOW, dont_kill_parent=false, force_set_focus=false)
../i3/src/tree.c:314
0x00000000004196f0 in con_on_remove_child (con=0x7b67c0) at ../i3/src/con.c:1801
0x0000000000452eb7 in tree_close_internal (con=0x783840, kill_window=DONT_KILL_WINDOW, dont_kill_parent=false, force_set_focus=false)
../i3/src/tree.c:364
0x0000000000431516 in floating_enable (con=0x7ab9c0, automatic=false) at ../i3/src/floating.c:183
0x0000000000431eed in toggle_floating_mode (con=0x7ab9c0, automatic=false) at ../i3/src/floating.c:379
0x0000000000420d92 in cmd_floating (current_match=0x679a20 , cmd_output=0x679aa0 , floating_mode=0x7ab8c0 "toggle")
../i3/src/commands.c:1088
0x000000000043e5ae in GENERATED_call (call_identifier=60, result=0x679aa0 ) at include/GENERATED_command_call.h:486
0x000000000043ee19 in next_state (token=0x675d70 ) at ../i3/src/commands_parser.c:187
0x000000000043f2fb in parse_command (input=0x7b4fe0 "floating toggle", gen=0x0) at ../i3/src/commands_parser.c:308
0x00000000004125f8 in run_binding (bind=0x784260, con=0x0) at ../i3/src/bindings.c:792
0x000000000042bace in handle_key_press (event=0x7a01a0) at ../i3/src/key_press.c:33
0x000000000044e6aa in handle_event (type=2, event=0x7a01a0) at ../i3/src/handlers.c:1420
0x0000000000439533 in xcb_check_cb (loop=0x7ffff532f8e0, w=0x68c140, revents=32768) at ../i3/src/main.c:133
0x00007ffff5125d73 in ev_invoke_pending () from /usr/lib/x86_64-linux-gnu/libev.so.4
0x00007ffff51293de in ev_run () from /usr/lib/x86_64-linux-gnu/libev.so.4
0x0000000000439418 in ev_loop (loop=0x7ffff532f8e0, flags=0) at /usr/include/ev.h:835
0x000000000043d51d in main (argc=3, argv=0x7fffffffe0a8) at ../i3/src/main.c:913
2016-11-08 00:56:46 -08:00
Ingo Bürk fea0bc1a45 Fix memory leaks. (#2530)
fixes #2529
2016-11-03 00:18:18 -07:00
Michael Stapelberg f58dde2850 Merge pull request #2507 from stapelberg/autotools
Switch to autotools (GNU build system)
2016-10-25 08:56:12 +02:00
Michael Stapelberg f354f53435 Ensure all *.[ch] files include config.h
Including config.h is necessary to get e.g. the _GNU_SOURCE define and
any other definitions that autoconf declares. Hence, config.h needs to
be included as the first header in each file.

This is done either via:
1. Including "common.h" (i3bar)
2. Including "libi3.h"
3. Including "all.h" (i3)
4. Including <config.h> directly

Also remove now-unused I3__FILE__, add copyright/license statement
where missing and switch include/all.h to #pragma once.
2016-10-23 21:09:24 +02:00
Michael Stapelberg 4a52a7e9fb Switch to autotools (GNU build system)
This commit probably comes as a surprise to some, given that one of i3’s
explicitly stated goals used to be “Do not use programs such as
autoconf/automake for configuration and creating unreadable/broken makefiles”.

I phrased this goal over 7 years ago, based largely on a grudge that I
inherited, which — as I’ve realized in the meantime — was largely held against
FOSS in general, and not actually nuanced criticism of autotools.

In the meantime, I have come to realize that the knee-jerk reaction of “I could
do this better!” (i.e. writing our own build system in this particular case) is
usually misguided, and nowadays I strongly suggest trying hard to fix the
existing system for the benefit of all existing and future users.

Further, I recently got to experience the other side of the coin, as I packaged
a new version of FreeRADIUS for Debian, which at the time of writing used
autoconf in combination with boilermake, a custom make-based build system that
only FreeRADIUS uses. Understanding the build system enough to fix issues and
enable parallel compilation took me an entire day. That time is time which
potentially every downstream maintainer needs to invest, and the resulting
knowledge cannot be applied to any other project.

Hence, I believe it’s a good idea switch i3 to autotools. Yes, it might be that
particular features were easier to implement/understand in our custom
Makefiles, and there might be individuals who have an easier time reading
through our custom Makefiles than learning autotools. All of these
considerations are outweighed by the benefits we get from using the same build
system as literally thousands of other FOSS software packages.

Aside from these somewhat philosophical considerations, there’s also practical
improvements which this change brings us. See the “changes” section below.

┌──────────────────────────────────────────────────────────────────────────────┐
│ new workflow                                                                 │
└──────────────────────────────────────────────────────────────────────────────┘

You can now build i3 like you build any other software package which uses
autotools. Here’s a memory refresher:

    autoreconf -fi
    mkdir -p build && cd build
    ../configure
    make -j8

(The autoreconf -fi step is unnecessary if you are building from a release
 tarball, but shouldn’t hurt either.)

┌──────────────────────────────────────────────────────────────────────────────┐
│ recommended reading                                                          │
└──────────────────────────────────────────────────────────────────────────────┘

I very much recommend reading “A Practitioner's Guide to GNU Autoconf,
Automake, and Libtool” by John Calcote (https://www.nostarch.com/autotools.htm).
That book is from 2010 and, AFAICT, is the most up to date comprehensive
description of autotools. Do not read older documentation. In particular, if a
document you’re reading mentions configure.in (deprecated filename) or
recursive make (now considered harmful), it’s likely outdated.

┌──────────────────────────────────────────────────────────────────────────────┐
│ changes                                                                      │
└──────────────────────────────────────────────────────────────────────────────┘

This commit implements the following new functionality/changes in behavior:

• We use the AX_ENABLE_BUILDDIR macro to enforce builds happening in a separate
  directory. This is a prerequisite for the AX_EXTEND_SRCDIR macro and building
  in a separate directory is common practice anyway. In case this causes any
  trouble when packaging i3 for your distribution, please let me know.

• “make check” runs the i3 testsuite.
  You can still use ./testcases/complete-run.pl to get the interactive progress
  output.

• “make distcheck” (runs testsuite on “make dist” result, tiny bit quicker
  feedback cycle than waiting for the travis build to catch the issue).

• “make uninstall” (occasionally requested by users who compile from source)

• “make” will build manpages/docs by default if the tools are installed.
  Conversely, manpages/docs are not tried to be built for users who don’t want
  to install all these dependencies to get started hacking on i3.

• non-release builds will enable address sanitizer by default. Use the
  --disable-sanitizers configure option to turn off all sanitizers, and see
  --help for available sanitizers.

• Support for pre-compiled headers (PCH) has been dropped for now in the
  interest of simplicitly. Maybe we can re-add it later.

• coverage reports are now generated using “make check-code-coverage”, which
  requires specifying --enable-code-coverage when calling configure.

┌──────────────────────────────────────────────────────────────────────────────┐
│ build system feature parity/testing                                          │
└──────────────────────────────────────────────────────────────────────────────┘

In addition to what’s described above, I tested the following features:

• “make install” installs the same files (plus documentation and manpages)
  cd i3-old && make install PREFIX=/tmp/inst/old
  cd i3-new && ./configure --prefix=/tmp/inst/new
  cd /tmp/inst
  (cd old && for f in $(find); do [ -e "../new/$f" ] || echo "$f missing"; done)

• make dist generates a tarball which includes the same files
  cd i3-old && make dist
  cd i3-new/x86_64-pc-linux-gnu && make dist
  colordiff -u <(tar tf i3-old/i3-4.12.tar.bz2 | sort) \
               <(tar tf i3-new/x86_64-pc-linux-gnu/i3-4.12.tar.gz | sort)
  There are some expected differences:
  • Some files have been renamed (e.g. the new etc/ and share/ subdirectories)
  • Some files will now be generated at build-time, so only their corresponding
    .in file is shipped (e.g. testcases/complete-run.pl)
  • The generated parser files are shipped in the dist tarball (they only
    depend on the parser-specs/* files, not on the target system)
  • autotools infrastructure is shipped (e.g. “configure”, “missing”, etc.)

• DLOG and ELOG statements still produce the same file name in logfiles

• Listing source code in gdb still works.

• gdb backtraces contain the i3-<version> path component

• release.sh still works

• version embedding
  1. git checkout shows “4.12-136-gf720023 (2016-10-10, branch "autotools")”
  2. tarball of a git version shows “4.12-non-git”
  3. release tarball shows 4.13

• debug mode is enabled by default for non-release builds

• enabling verbose builds via V=1

┌──────────────────────────────────────────────────────────────────────────────┐
│ speed                                                                        │
└──────────────────────────────────────────────────────────────────────────────┘

There is no noticeable difference in compilation speed itself (of binaries,
documentation and manpages):

i3-old $ time make all docs mans -j8
make all docs mans -j8  28.92s user 2.15s system 640% cpu 4.852 total

i3-new $ time make -j8
make -j8  27.08s user 1.92s system 620% cpu 4.669 total

In terms of one-time costs:
configuring the build system (../configure) takes about 2.7s on my machine,
generating the build system (autoreconf -fi) takes about 3.1s on my machine.

┌──────────────────────────────────────────────────────────────────────────────┐
│ m4 macros                                                                    │
└──────────────────────────────────────────────────────────────────────────────┘

All files in m4/ have been copied from the autoconf-archive package in version
b6aeb1988f4b6c78bf39d97b6c4f6e1d594d59b9 and should be updated whenever they
change.

This commit has been tested with autoconf 2.69 and automake 1.15.
2016-10-23 21:09:21 +02:00
Peder Stray 6b89690a3f Add "output" to IPC events referencing a container (#2489)
Add the property "output" to all IPC events that has an output container
as a parent, making it easier to keep track of such things.

fixes #2478
2016-10-19 08:41:10 +02:00
Ingo Bürk e51a89e842 Implement new window::mark IPC event. (#2503)
This introduces a new type of 'window' event sent wit change:mark whenever
a mark on a window changes.

fixes #2501
2016-10-18 07:32:41 +01:00
Michael Stapelberg 3cba06f7b9 Fix _i3_version debugging symbol (#2492)
The idea was to ensure the symbol would always be present. For that, we need
__attribute__((used)), not __attribute__((unused)). Further, ensure the
variable has static storage, as the used attribute only applies to variables
with static storage. See also http://stackoverflow.com/a/29545417/712014
2016-10-05 09:46:33 -07:00
Michael Stapelberg 3a359a0243 Remove extraneous newline when printing core_pattern (#2490)
This was accidentally changed in commit 94a09b3cac
2016-10-03 23:53:49 -07:00
Ferdinand Bachmann 6b3d8b9e8b Bugfix: NULL dereference when stickying _NET_WM_DESKTOP_ALL windows (#2488)
In some cases, ws will be NULL here.

Originally tested with "lemonbar"
2016-10-03 05:53:56 -07:00
Ingo Bürk c71f6f8f7c Implement special value 'current' for output. (#2483)
This commit introduces the special 'current' value for outputs in both of

* move con to output current
* move workspace to output current

fixes #2357
2016-09-30 08:28:02 -07:00
Ingo Bürk 6a8fb69eff Added new criteria 'tiling' / 'floating'. (#2481)
These criteria allow selecting only windows in a specific mode, i.e.,
tiling and floating, respectively.

fixes #2406
2016-09-27 19:04:00 -07:00
Michael Stapelberg 0e73a6e9e7 Remove conditional compilation for cairo/pangocairo (#2480)
We strive to avoid conditional compilation in i3 as much as possible.
cairo and pangocairo have been around long enough in the versions that
we need that it’s time to unconditionally depend on them.

Also update DEPENDS with the last-known-good-versions while at it.
2016-09-27 12:57:00 -07:00
Ingo Bürk a15ce8cb8d Assign the sticky value for _NET_WM_DESKTOP on scratchpad windows. (#2457)
fixes #2456
2016-09-26 22:39:17 -07:00
Michael Stapelberg c93056b2d8 Unconditionally depend on libpcre >= 8.10 (#2472)
Even Debian oldstable has 8.30, so let’s get rid of conditional
compilation where we don’t actually need it.
2016-09-26 19:04:13 -07:00
Ingo Bürk f4f9b7102d Handle _NET_ACTIVE_WINDOW for scratchpad windows. (#2458)
We call scratchpad_show() on _NET_ACTIVE_WINDOW requests if the request
came from a pager. This is consistent with the i3 »focus« command because
we assume the user requested to see the window, so we do the only
sensible thing.

fixes #2455
2016-09-26 18:32:05 -07:00
Ingo Bürk b638ce2e4c Check output crossing on ENTER_NOTIFY to dockarea. (#2477)
When receiving an ENTER_NOTIFY event on a dock client we returned as to not
focus the dock client (cf. #321 and #323). However, we still need to check
for crossing output boundaries and if that happened focus the new output.

Otherwise it can happen that the cursor is on a different output than the
focused output. When opening a window, this would open it on the old output
and then warp the mouse there. This effect will be even worse if the window
is immediately moved with 'move position mouse' as the window will end up
in its correct position on the new output and the cursor warped to the old
output.

relates to #2081
2016-09-26 18:31:16 -07:00
Ingo Bürk cb1fcfed6a Use Xft.dpi for DPI if available.
fixes #2465
2016-09-26 20:29:53 +02:00
johannes karoff 1437271e65 do not match docks in config and command criteria (#2340) 2016-09-26 09:45:58 -07:00
Michael Stapelberg 9bf346c7a0 Remove compatibility definitions for xcb-util < 0.3.8 (#2473)
Even Debian oldstable has xcb-util 0.3.8.
2016-09-24 09:48:32 -07:00
Michael Stapelberg b850cfba4d Fix memleaks by avoiding _checked variants when discarding the result
Thanks psychon for pointing this out in
https://github.com/i3/i3/pull/2450#discussion_r78560433!
2016-09-14 09:22:45 +02:00
Michael Stapelberg 5594139676 Eliminate once-used check_error utility function 2016-09-14 09:19:25 +02:00
Ingo Bürk d48c9b1e33 Fix colormap handling for containers. (#2450)
This commit correctly handles colormaps by

* Using the static default colormap we determine on startup if the
  con has the corresponding depth. This avoids creating pointless
  colormaps.
* Not freeing the default colormap to not have stray colormaps on
  containers. This fixes an issue with certain programs such as xwd.
* Creating a custom colormap when necessary and freeing it when the
  container is killed.

fixes #2435
2016-09-14 09:13:17 +02:00
Michael Stapelberg 555f458d7a Bugfix: don’t apply shift+numlock fallback for keypad keys
fixes #2418
2016-09-12 22:24:23 +02:00
Nathan Schulte 41ce596a94 fix bindsyms with Shift, given NumLock tweaks 2016-09-12 22:22:59 +02:00
Nathan Schulte 02f206d816 fix typo in logging message 2016-09-12 22:22:59 +02:00
Michael Stapelberg 2244c843a8 Bugfix: don’t trigger unrelated key bindings for --release bindings
fixes #2442
2016-09-12 12:57:13 +02:00
Michael Stapelberg 0469716fd6 Bugfix: compare all resolved modifier masks
Before this commit, i3 only compared the user-specified modifiers and
incorrectly ignored the resolved modifiers (such as the numlock
fallback).

While at it, also fix the testcase which treated numlock as a momentary
modifier, whereas it really is a latched modifier.

fixes #2418
2016-09-12 12:05:38 +02:00
Michael Stapelberg 5ca7d4b222 expose binding pointer in debug messages
This makes it a bit easier to match up the different messages to the
configured binding.
2016-09-12 12:03:30 +02:00
Michael Stapelberg fac57699b4 Bugfix: avoid setting urgency hint on content container and above
fixes #2098 (I _think_)
2016-09-04 21:08:21 +02:00
Benedikt Heine e35aff5cb9 fix transition from named to numbered workspace 2016-08-24 11:11:50 +02:00
Benedikt Heine 5d6d974c66 remove goto statement
remove goto statement to similarize workspace_next and workspace_prev
2016-08-24 11:11:50 +02:00
Benedikt Heine d979748853 traverse numbered workspaces in correct order 2016-08-24 11:11:50 +02:00
Michael Stapelberg d77d40173a Only add NumLock fallback where necessary.
Previously, we always discarded the NumLock bit when looking up key
bindings for key press events, and we always grabbed every keycode with
and without the NumLock modifier.

With this commit, the NumLock bit is no longer discarded: since the
previous commit 3bd5e6e5c8 we can
correctly look up key bindings with/without the NumLock bit, as both
variants are stored in |keycodes_head|.

Further, before adding the NumLock fallback (resulting in grabbing the
keycode with the NumLock modifier), we now check whether the key has the
same meaning when NumLock is enabled. This correctly distinguishes the
KP_End vs. KP_1 case, i.e. one can now use the following key bindings:

    # No longer accidentally triggered when pressing KP_1.
    bindsym KP_End nop KP_End

    # Properly distinguished now:
    bindsym KP_End nop KP_End
    bindsym Mod2+KP_1 nop KP_1

fixes #2346
2016-08-02 20:34:20 +02:00
Michael Stapelberg 3bd5e6e5c8 refactoring: store modifiers alongside translated keycodes
This is a no-op refactoring in terms of functionality.

related to #2346
2016-08-02 20:10:49 +02:00
Michael Stapelberg 0239c4b6da move xkb_current_group check into own function
This is a no-op refactoring.
2016-08-02 19:33:26 +02:00
Michael Stapelberg afb90a0f97 remove superfluous check for input_type
This condition is already enforced in grab_all_keys().
2016-08-02 19:31:23 +02:00
yshui 3ffa88e54a Don't change border style if BS_NORMAL is requested in motif hints (#2386)
Fixes #2385
2016-06-25 21:35:36 +02:00
yshui 45012189bc Handle _MOTIF_WM_HINTS changes (#2384) 2016-06-22 08:39:25 +02:00
Ingo Bürk b1d70f25b3 Introduced a new GET_BINDING_MODES message type and reply. (#2376)
This type dumps all currently configured binding modes.

fixes #2375
2016-06-15 22:25:22 +02:00
Christopher Zimmermann 1322af1e4f Don't use pthread on OpenBSD
since OpenBSD pthread does not support pthread_condattr_setpshared().
This patch could also stay in the OpenBSD ports tree or depend on a
configure test macro rather than defined __OpenBSD__.
2016-06-11 14:47:26 +02:00
Christopher Zimmermann 87e90229bc Always use socket activation
it neither depends on systemd nor on any linuxism.
2016-06-11 14:47:23 +02:00
Christopher Zimmermann 7e2483edf7 Use 64 bit time_t 2016-06-11 12:58:16 +02:00
Ingo Bürk 18d6a1bc76 Explicitly terminate fallback in set_from_resource. (#2366) 2016-05-31 22:58:23 +02:00
Ingo Bürk 9409c2b2e5 Don't trigger binding on window border click unless --border is given. (#2349)
Prior to this commit a binding specifying only --whole-window would
trigger even when clicking on the window border. However, this should
only happen if --border is specified.

fixes #2348
2016-05-11 20:11:35 +02:00
Julien Lequertier 4bec3b9d24 Smart option added to hide_edge_borders config param (#2191) (#2191)
Use case:

* When managing multiple terminals in a workspace, the borders makes it easier
to know where the focus is, but when there is only one it's obvious where the
focus is.

* When there's only a web browser for example, the borders are actually counter-
productive since it makes clicking a side scrollbar or a tab a bit harder (if I
smash my cursor to the side or the top of the workspace, I have to move it in
the other direction by just a few pixels to be able to grab it)

Behaviour:

* No borders when there's a single window in a workspace
* Borders when there are multiple windows in a workspace

fixes #2188
2016-05-10 20:27:20 +02:00
Ingo Bürk 47562b4143 Introduce support for specifying variables from X resources. (#2286)
This patch introduces a new 'set_from_resource' config directive which
allows defining a variable by retrieving its value from the X resource
database. This avoids having to configure a color scheme in multiple
files. The directive takes an additional fallback value which is used
in case the resource cannot be found or during config validation where
no X connection is available.

Furthermore, this patch includes the following changes:
- If the same variable is defined twice, we now properly overwrite the
  value of the assignment rather than inserting two variable definitions
  with the same key.
- We now depend on xcb-util-xrm to query the resource.
- Increase the buffer size for variable / resource assignments.

fixes #2130
2016-05-08 12:55:27 +02:00
Ingo Bürk dbafb3cf23 Properly close disabled outputs restored during a restart. (#2337)
If an output is disabled during a restart, for example because a binding
such as

    bindsym $mod+Shift+r exec "xrandr --auto", restart

is used, it can happen that we first write the layout to disk and only
then receive the RandR change events. This leads to a situation where
the restored tree will contain these outputs, but the restarted i3
process will not receive the RandR events, thus the internal output in i3
is marked disabled.

This patch finds these cases after a restart and force-disables the
affected outputs.

fixes #2326
2016-05-08 12:49:24 +02:00
Johannes Lange a8757625c3 Do not count '\' in comment as line continuation (#2181)
fixes #2176
2016-05-08 00:20:08 +02:00
Ingo Bürk 6746aa4b5f Use the last known timestamp when calling xcb_set_input_focus(). (#2332)
In most cases this won't make a difference, but consider the following
scenario:

* Some application acquires input focus on its own (which the window manager
  is not involved in, so it will "always" work).
* Before the FocusIn / FocusOut events are processed by i3, the
  workflow to push X changes is run, resulting in xcb_set_input_focus()
  being called.

Using XCB_CURRENT_TIME, this means i3 will "win" and override the focus,
even though it simply wasn't aware (yet) that focus had already been taken
over by someone else. When processing the FocusIn / FocusOut events, i3
assumes that the focus is already set which results in a broken focus
state as i3 assumes some container has the input focus when it doesn't.

With the new behavior, i3's attempt to set the input focus will fail if
the FocusIn / FocusOut events have not yet processed. Once they are processed,
the focus state will be automatically corrected.

fixes #2322
2016-05-05 20:46:33 +02:00
Ingo Bürk b2397c9f01 Remove redundant depth argument from x_con_init(). (#2323) 2016-05-05 14:18:27 +02:00
Ingo Bürk 152318bccf Remove dead code guarded with "#if 0 … #endif" (#2338)
This code has been neutralized for many years now and served no purpose
other than cluttering up the code. We obviously don't need it and it's
out of date anyway.

If there's ever any reason to restore (parts of) it, we have git for
that. But we don't need to keep commented out code around.
2016-05-05 14:18:04 +02:00
Ingo Bürk 3b089d0771 Remove title indentation in nested containers. (#2330)
This commit removes the title indentation in certain nested container
situations. The behavior was considered broken as it didn't seem to
make sense and it was unclear why this was introduced.

Given that nobody on i3-discuss@ complained about removing this logic
within two weeks, we are now removing it to make the title rendering
code a little less complex.

fixes #2247
2016-05-01 18:59:50 +02:00
Kyle Kneitinger 2123888d4d Ensure config variables match on longest-length (#2306)
fixes #2235
2016-04-26 08:20:42 +01:00
Ingo Bürk 23beac46b7 Focus a newly managed container only if it doesn't use the globally active input model. (#2317)
fixes #1784
2016-04-26 08:09:07 +01:00
Ingo Bürk e9798b7e3e Use logical_px() and fix indentation.
relates to #2247
2016-04-15 18:51:20 +02:00
Ingo Bürk 057517b809 Redraw right-hand side border correctly.
Since we don't actually stop drawing a title (or marks) with the
distance of the border width on the right side, but instead with
a hard-coded two pixel distance, we can only redraw that much of
the border without potentiall cutting off text.

relates to #2247
2016-04-15 18:51:20 +02:00
Ingo Bürk c3db74a1f8 Only redraw right-hand side border if a non-pango font is used.
relates to #2247
2016-04-15 18:51:20 +02:00
Tony Crisci e690e3d483 Cast con id as uintptr_t (#2298)
Use `uintptr_t` to cast the con id to int instead of `long int`. This
type is guaranteed to hold the pointer as an int regardless of platform.

fixes #2283
2016-04-15 00:27:43 -07:00
Ingo Bürk 80dddd9961 Correctly count the number of windows for no_focus. (#2296)
Previously we counted the number of (direct) children of the workspace to
decide whether no_focus should be applied or not. However, this doesn't
work correctly if there's a single container with multiple windows on the
workspace.

This patch correctly counts all windows on the workspace.

fixes #2292
2016-04-15 00:26:42 -07:00
Ingo Bürk 83c8740bf1 Only grab the mouse buttons that need to be grabbed. (#2290)
This is a followup to #2049. While we had fixed that bug by only grabbing
buttons 4 and 5 if there is a whole-window binding for that button, this
did not consider buttons higher than 5 as found on many mice.

Therefore, we now ditch the special handling for scrollwheel buttons and
instead do the same for all buttons higher than 3.

fixes #2271
2016-04-13 10:45:57 -07:00
Guillaume Maudoux b52482705e Avoid hazardous casting. 2016-04-11 15:00:47 +02:00
Guillaume Maudoux 8dc7691a6f Remove "dereferencing type-punned pointer" warning
Fix the remaining warning discussed in #1538.
This is obviously a false positive from gcc.
2016-04-11 14:50:01 +02:00
wentasah fec1a9511e Make fullscreen windows open on the output which is indicated by their geometry
With this change, multi-monitor presentations (e.g. as implemented by
LibreOffice Impress) work out of the box. Previously, one had to move
the presentation windows to the right outputs oneself.
2016-04-06 21:19:10 +02:00
Eric Engeström 66d9c983e4 Fix spelling mistakes 2016-04-04 09:33:59 +02:00
Kacper Kowalik (Xarthisius) 301320585e Add missing MAX macros, ensure that i3 can be compiled without pango 2016-03-23 10:58:10 -05:00
Marcin Szewczyk ad36e32764 window_update_motif_hints(): uint32_t for fields, fixes #2238
xcb_get_property_value() returns 32-bit property fields
2016-03-02 23:31:08 +01:00
Michael Stapelberg 6fe8d30d65 Merge pull request #2233 from Airblader/bug-2228
Revert to default binding mode before reloading the config.
2016-02-25 21:19:14 +01:00
Michael Stapelberg 70cc9af69b Merge pull request #2232 from Airblader/bug-2229
Determine focused workspace correctly when moving workspace to output.
2016-02-25 21:18:55 +01:00
Ingo Bürk ad702dff13 Revert to default binding mode before reloading the config.
If a user reloads the config while in some binding mode, the binding mode
will revert to the default, but no event will ever be fired, causing a
broken i3bar mode display.

This patch explicitly reverts to the default binding mode before reloading
the config. We reload rather than switch to the binding mode after having
reloaded the config because there's no guarantee that mode will even still
exist.

fixes #2228
2016-02-25 19:28:48 +01:00
Ingo Bürk a9d8184c73 Determine focused workspace correctly when moving workspace to output.
This patch correctly determines the previously focused workspace on the
target output when moving a workspace to another output. Before, we used
nodes_head for this, which will not actually return the previously focused
workspace, but just the first workspace on that output. Hence, we now use
focus_head instead.

This bug was introduced all the way back in 1e143fea when the feature of
moving workspaces to another output was first implemented.

fixes #2229
2016-02-25 19:12:09 +01:00
Ingo Bürk 712c6d65ff Introduce I3_FLOATING_WINDOW
This patch introduces a proprietary atom I3_FLOATING_WINDOW which will be
set and maintained for floating windows and removed on tiling containers.

This allows users to select on this atom, e.g., in their compositor
configuration or in utility scripts (without using the IPC).

fixes #2223
2016-02-25 18:36:22 +01:00
Michael Stapelberg fdbbae56b2 split atoms.xmacro into 2 files to obtain _NET_SUPPORTED count
Manually updating a magic number doesn’t work in the long run.
With this change, the number of atoms contained in
include/atoms_NET_SUPPORTED.xmacro is used.

fixes #2230
2016-02-23 21:48:18 +01:00
Michael Stapelberg f63701ed09 Allow workspace renames which change case
fixes #2211
2016-02-15 08:34:03 +01:00
Michael Stapelberg e91fa09569 Merge pull request #2210 from Airblader/bug-2166
Don't allow floating workspaces anymore.
2016-02-15 08:15:23 +01:00
Ingo Bürk 9431ef16f6 Don't allow floating workspaces anymore.
This is essentially a revert of daf00a9 which introduced a mechanism
to float workspace containers by wrapping all children into a new
container and floating it.

This caused a bug and there's no good reason (anymore) to allow doing
this in the first place as we don't support floating nested containers.

fixes #2166
2016-02-11 21:25:50 +01:00
Ingo Bürk 018922dcc4 Allow "modifier none" in i3bar to disable the modifier.
This allows "modifier none" (and "modifier off") for the bar config
in order to disable the modifier key altogether. This is useful
for users who use a different approach to hiding / showing the bar,
e.g., a custom keybind that involved multiple keys or scripts.

fixes #2208
2016-02-11 20:51:05 +01:00
Ingo Bürk 6cbff6bfd4 Ensure that the "border" command uses logical pixels.
Until now, only the config directive for borders (new_window,
new_float) respected the DPI setting (using logical_px). This
patch makes sure we also do so for runtime "border" commands.

fixes #2202
2016-02-09 21:03:44 +01:00
Ingo Bürk ad95038c5e Remove _NET_WM_STATE on withdrawn windows.
According to the spec, _NET_WM_STATE must be removed when the window is
withdrawn, much like _NET_WM_DESKTOP.

fixes #2165
2016-02-07 12:08:50 +01:00
Michael Stapelberg fbfbdb8e12 travis: check spelling of binaries and manpages, use docker
We now build a docker base container based on debian sid (where the very
latest packages are available). That base container is updated once a
month, or whenever travis-build.Dockerfile or debian/control change, but
re-used for subsequent travis runs. While the initial build might take
up to 15 minutes, subsequent builds typically run in a minute or two.

All the different steps that we run on travis are now factored into
separate scripts in the travis/ directory.

Switching to docker should also help with issue #2174.
2016-02-06 10:36:43 +01:00
David Coppa 1041572769 Remove commented-out code. 2016-01-26 09:55:24 +01:00
Ingo Bürk 3c0ba081df Don't ignore focus on _NET_WM_DESKTOP client messages.
Ignoring the focus leads to a broken focus if the pointer is, e.g.,
over i3bar at the point in time the window is moved by the client
message. It also causes i3bar's workspace display to break.

Thanks to GermainZ for reporting.
2016-01-22 20:32:51 +01:00
Ingo Bürk 95b60b170e Don't grab the buttons on the root window.
We don't actually need to grab the buttons to fix #2097, but doing so
will cause a freeze due to unreleased events.

We partially revert 6f12f02 which avoids the freeze, but doesn't break
functionality.

relates to #2097
fixes #2168
2016-01-20 22:28:20 +01:00
Michael Stapelberg cfd07ab0e6 Merge pull request #2162 from Airblader/feature-2153
Handle the EWMH atom _NET_WM_DESKTOP.
2016-01-18 13:31:03 -08:00
Ingo Bürk 328035fb7e Handle the EWMH atom _NET_WM_DESKTOP.
We already claim _NET_WM_DESKTOP support in _NET_SUPPORTED since around 2009,
but haven't actually done anything with it. However, especially pagers like
gnome-panel rely on this property to be updated and many tools, like GTK, want
to use the corresponding client messages to make a window sticky, move it
around etc.

This patch implements full support according to the EWMH spec. This means:

* We set the property on all windows when managing it.
* We keep the property updated on all windows at all times.
* We read and respect the property upon managing a window if it was set before
  mapping the window.
* We react to client messages for it.
* We remove the property on withdrawn windows.

Note that the special value 0xFFFFFFFF, according to the spec, means that the
window shall be shown on all workspaces. We do this by making it sticky and
float it. This shows it on all workspaces at least on the output it is on.

Furthermore, the spec gives us the freedom to ignore _NET_WM_DESKTOP when
managing a window if we have good reason to. In our case, we give window
swallowing a higher priority since the user would likely expect that and we
want to keep placeholder windows only around for as long as we have to.
However, we do prioritize this property over, for example, startup
notifications.

fixes #2153
fixes #1507
fixes #938
2016-01-18 12:13:36 +01:00
Theo Buehler a1d1f456a1 Add pledge(2) support for OpenBSD
pledges for i3:
"stdio rpath unix" for talking to the i3 socket usually in /tmp
"proc exec" for executing programs
"wpath cpath" are needed for the restart-in-place functionality

To make this work, @semarie pointed out that it is sufficient to ensure
that we get physical_mem_bytes only once, namely in init_logging().

pledges for i3-msg:
"stdio rpath unix" are needed for talking to the i3-socket

pledges for i3-nagbar
"rpath getpw" to find the home directory
"wpath cpath" to write the script
"proc exec" to execute the script
2016-01-17 18:49:00 +01:00
Ingo Bürk 811ff07b8e Rename decoration_border to child_border.
fixes #2154
2016-01-09 16:47:33 -05:00
Michael Stapelberg cb3cdb602a ASAN: trigger leak before exiting
This disables the default leak-check-on-exit behavior which reports a
bunch of leaks that are only leaks while exiting, at which point they
don’t matter, because the operating system will clean up the memory our
process used.
2016-01-09 17:18:05 +01:00
Michael Stapelberg 17c55792c6 fix memory leak: use xcb_disconnect() instead of free() 2016-01-09 17:06:58 +01:00
Michael Stapelberg f511cc61c1 fix memory leak when swallowing windows 2016-01-09 17:06:58 +01:00
Michael Stapelberg 8d917497c2 manage.c: fix memory leak 2016-01-09 17:06:58 +01:00
Michael Stapelberg 8d4bf6c577 free dynamically allocated matches 2016-01-09 17:06:58 +01:00
Michael Stapelberg 436e4c17b3 free container matches when destroying containers 2016-01-09 17:06:58 +01:00
Michael Stapelberg 414be6290d tree_append_json: fix memory leaks 2016-01-09 17:06:58 +01:00
Michael Stapelberg f904511b7e con_get_tree_representation: fix memory leak 2016-01-09 17:06:58 +01:00
Michael Stapelberg feef3ea78a window.c: fix memory leak 2016-01-09 17:06:58 +01:00
Michael Stapelberg e7f1476180 reload: fix memory leak 2016-01-09 17:06:54 +01:00
Michael Stapelberg 79594398e2 commands.c: fix memory leak 2016-01-09 13:39:00 +01:00
Michael Stapelberg ada71471c1 x.c: fix memory leak 2016-01-09 13:13:57 +01:00
Michael Stapelberg 71476b03e3 log.c: fix memory leak 2016-01-09 13:11:03 +01:00
Michael Stapelberg 6f53dc01ef tree_restore(): fix memory leak 2016-01-09 12:50:38 +01:00
Michael Stapelberg 9eba061ed3 fix memory leak: free(pointerreply); 2016-01-09 12:07:47 +01:00
Michael Stapelberg de035cab6d ipc: fix memory leak when clients with subscriptions disconnect 2016-01-08 21:24:21 +01:00
Michael Stapelberg 287ebcc206 ipc: fix cosmetic memory leak when shutting down 2016-01-08 21:24:12 +01:00
Michael Stapelberg 08976f7a2a con_mark: fix heap-use-after-free 2016-01-08 20:41:09 +01:00
Michael Stapelberg 0d1aad0af4 rename workspace: fix heap-use-after-free 2016-01-08 20:21:54 +01:00
Ingo Bürk bcee585e17 Use correct fallback color for decoration_border.
The newly introduced decoration_border color incorrectly uses the default value
for "background" as a fallback when not specified. Instead, it should use the
user-specified "background" as a fallback.

fixes #2149
2016-01-06 09:19:42 -05:00
Michael Stapelberg 3853d1866b Merge pull request #2143 from Airblader/feature-2120
Allow title_format for all containers
2016-01-05 22:32:15 +01:00
Ingo Bürk 1f660a4cc4 Move title_format from window to container.
This patch moves the title_format information from windows to containers.
Furthermore, it allows correctly setting it on window-less containers and
displays the title accordingly for split containers.

We now also dump and read title_format in GET_TREE / during restarts.

fixes #2120
2016-01-05 12:22:27 -05:00
Lauri Tirkkonen 034a12acad add decoration_border color for the actual client borders
see https://github.com/i3/i3/pull/2136
2016-01-05 12:17:48 +02:00
Ingo Bürk 6fefe836d4 Fix memory leaks in title_format.
This fixes three memory leaks that were found during the implementation of #2120
so that they can be fixed in a bugfix release.

relates to #2143
2016-01-04 18:48:01 -05:00
Johannes Lange 8bfd06c3dd added "toggle" option to "split" command
as requested in #1814
2016-01-04 17:31:47 +01:00
Alex Auvolat c6a4e4519f Correct color management for pango fonts
Corrects the cases where the colorpixel is not 0xRRGGBB : we have to
use the full color_t struct to describe font colors, as Pango expects
RGB values and not an XCB colorpixel value.
2015-12-29 14:26:21 +01:00
Alex Auvolat 19fd6817af Refactor extern definition of conn and root_screen 2015-12-29 12:47:12 +01:00
Michael Stapelberg bc126aaeaf Merge pull request #2134 from Airblader/bug-1761
Properly validate containers when killing via criteria
2015-12-29 11:50:58 +01:00
Ingo Bürk 19c273a2ad Validate matched containers for "kill" command correctly.
We now execute the validations when "kill" is executed even if match
criteria are used. This prevents users from killing workspace containers,
which instead kills all clients (as before when not using criteria).

fixes #1761
2015-12-28 02:35:25 -05:00
Ingo Bürk 0dd71674de Rename tree_close() to tree_close_internal().
It should be clear for callers of this function that this is an internal
function that skips certain validations which might be important. Therefore
we make it clear that this is an internal function by renaming it.

relates to #1761
2015-12-27 20:58:35 -05:00
Ingo Bürk 61a8bc81ec Move urgent flag before killing the parent.
We need to move the urgent flag when moving a container across
workspaces before calling on_remove_child on the parent in order
to avoid a crash.

fixes #2128
2015-12-27 18:08:30 -05:00
Michael Stapelberg dc463077d6 Merge pull request #2113 from Airblader/bug-2111
Match on all criteria even if con_id or con_mark are given.
2015-12-25 17:14:29 +01:00
Michael Stapelberg 0ebb4b2005 make: should be XCB_CURSOR, not XCURSOR
After all, we’re not using libXcursor, but libxcb-cursor :).
2015-12-25 16:37:44 +01:00
Michael Stapelberg 019ae6d06c Bugfix: don’t remove SubstructureRedirect event mask temporarily
This fixes race conditions, for example when i3bar gets reconfigured
after the available outputs change. In that specific case, i3bar sends a
ConfigureWindow request (see
b5693d6fb3/i3bar/src/xcb.c (L376))
which normally is turned into a ConfigureRequest that i3 largely
ignores, only the dock client’s height is considered (see
b5693d6fb3/src/handlers.c (L390)).

Turning ConfigureWindow into ConfigureRequest is only done when the
SubstructureRedirect event mask is set, and because we temporarily
removed _all_ events from our mask, the ConfigureWindow request went
through unmodified.

This in turn lead to the i3bar client window (not its decoration frame)
being positioned at e.g. y=1304, whereas dock client windows should
always end up at x=0 y=0 within their decoration frame. The result of
the i3bar client window being out of the visible space was either a
black i3bar or graphics corruption.

This also fixes issue #1904, I think. I couldn’t reproduce issue #1904
specifically, but when i3bar is in the misconfigured state, it will
receive a VisibilityNotify event, telling i3bar that it is obscured.
This would explain why i3bar sent a SIGSTOP in issue #1904.

fixes #1904
2015-12-22 22:33:37 +01:00
Ingo Bürk 68e3cb8ab7 Don't force base 10 for parsing id. 2015-12-17 09:43:34 -05:00
Ingo Bürk bba18453af Match on all criteria even if con_id or con_mark are given.
Previously, if a match specification contained the con_id or con_mark criterion,
all other criteria were ignored. However, a user may want to specify one of
those two unique identifiers and still specify others as well, for example to
match the currently focused window, but only if it has a certain WM_CLASS:

    [con_id=__focused__ class=special] kill

We now check all specified criteria.

fixes #2111
2015-12-17 08:56:05 -05:00
Michael Stapelberg af49a8cd0d Merge pull request #2102 from ccryx/next
Add support for _NET_WM_WINDOW_TYPE_NOTIFICATION
2015-12-16 08:58:59 +01:00
Florian Merkel 33f017daa9 Support matching _NET_WM_WINDOW_TYPE_NOTIFICATION
This commit fixes #1969 by adding support for matching a window's type
against _NET_WM_WINDOW_TYPE_NOTIFICATION. The userguide and tests were
updated to reflect this change.
2015-12-15 21:55:33 +01:00
Ingo Bürk 905bca3531 Avoid rendering the tree twice in a row
The callee already renders the tree if necessary, so despite the documentation
of the function, doing it again on the caller side is unnecessary.
2015-12-15 13:59:50 -05:00
Ingo Bürk 6f12f029f4 Allow mouse bindings to run on the root window.
Previously, mouse bindings could only be run when a window was present,
by using --whole-window. Such bindings would not work on empty
workspaces. However, this is a valid usecase for bindings like

    bindsym $mod+button4 workspace prev
    bindsym $mod+button5 workspace next

Hence, we need to grab the root window as well and run bindings on it.

fixes #2097
2015-12-14 16:26:36 -05:00
Michael Stapelberg 8e081d7fff Merge pull request #2105 from Airblader/bug-2099
Reject empty swallow definitions
2015-12-14 20:48:49 +01:00
Ingo Bürk e3a5c004d3 Reject empty swallow definitions
Empty swallow definitions don't make sense and can lead to crashes,
for that reason we reject them.

fixes #2099
2015-12-11 20:28:13 +01:00
Ingo Bürk 8d36f78b8e Reject invalid match criteria with an error.
Previously, using a command like

  [con_id=foo] kill

would kill the currently focused window because while an error for
not being able to parse the con_id was logged, no further action
was taken, which caused the criterion to be ignored. In this case,
the fallback behavior of using the focused window took over.

For con_id, id and window_type we now reject incorrect values with
an error and abort the command.

fixes #2091
2015-12-09 14:00:53 +01:00
Michael Stapelberg 04be42f7cd Merge pull request #2095 from Airblader/bug-2090
Allow "move position center" to operate on matched windows
2015-12-04 09:02:51 +01:00
Ingo Bürk 256007442f Cast unsigned to signed before comparison
The values of a Rect are unsigned, but can contain signed values.
Using MAX when the value is negative causes incorrect behavior and
makes the result stay negative, which is what we wanted to avoid here
in the first place.

Fix by properly casting the value for the comparison.

fixes #2094
2015-12-03 18:57:02 +01:00
Ingo Bürk caeb193a6c Allow "move position center" to operate on matched windows
Moving windows to the center previously did not consider command criteria.
We now operate on matched windows as for other commands.

fixes #2090
2015-12-03 13:24:39 +01:00
Ingo Bürk 780cb8d15d Use 32-bit visual by default if available.
With this patch, we use 32-bit visuals per default whenever it is
available. Otherwise, we fall back to the actual root window's
depth, which will typically be 24-bit.

Before this patch, we already used 32-bit depth for containers with
a window that uses 32-bit. However, this means that we didn't use
32-bit for split parent containers on which decoration is drawn.
For 32-bit windows using transparency, this caused a graphical glitch
because the decoration pixmap behind it would show through. This
behavior is fixed with this change.

relates to #1278
2015-11-23 22:18:02 +01:00
Ingo Bürk d2126027ce Don't create a pixmap for CT_ROOT and CT_OUTPUT containers.
Such containers never require a pixmap anyway. In particular for the __i3
output (used for the scratchpad workspace), this would cause an allocation
error anyway because it can be very big -- so big, in fact, that X cannot
allocate the pixmap for it.

Until now, this error was silently ignored due to the fact that we did not
create the pixmap checked (and asserted its success), but with cairo this
would cause a crash because we'd try to create a surface for a pixmap
which doesn't exist.

relates to #1278
2015-11-23 22:18:02 +01:00
Ingo Bürk a4afd1b642 Parse colors as color_t instead of colorpixel.
With this patch we remove the temporary draw_util_colorpixel_to_color
function we introduced previously by parsing the colors as color_t to
begin with.

relates to #1278
2015-11-23 22:18:02 +01:00
Ingo Bürk fdeb4e0c36 Skip drawing for uninitialized surfaces.
We return early from drawing functions if the surface to draw to is not
initialized properly. There is no immediate need to do so, at least no
crashes have been observed, but it mirrors the previous behavior a bit
more closely. Furthermore, i3 should not crash due to not being able to
make some rendering call, so this provides some stability.

relates to #1278
2015-11-23 22:18:02 +01:00
Ingo Bürk b665049883 Migrate i3 rendering to cairo.
This patch migrates all decoration rendering of i3 to cairo. Using the
compile switch CAIRO_SUPPORT, rendering can be switched back to the
previous XCB behavior, just like with the previous migration to cairo
in i3bar.

This patch also fixes a bug in draw_util.c where copying one surface
to another would use incorrect coordinates if the source coordinates
are not 0, 0.

Furthermore, this patch implicitly fixes some minor issues in the
decoration rendering which would be ignored previously due to the fact
that errors would only show up in the event queue, but not cause the
rendering code path to crash. One example is zero-height pixmaps which
are not allowed. Using cairo, these would cause i3 to instantly segfault,
so this patch avoids this.

Lastly, this patch annotates other issues found but not fixed in this patch
using TODO comments, e.g., the zero-height check not working correctly
and the comment that it should probably work the same way for zero-width
pixmaps.

relates to #1278
2015-11-23 22:18:02 +01:00
Tony Crisci 8f90b8448b Bug: parse con_id base 16
Mouse bindings that target the window that was clicked send the command
to the parser with `con_id` of the clicked window serialized base 16
for compatability with FreeBSD. See 7c2842e for explaination.

Set base to 0 for strtol to handle base 16 numbers for that reason.

This allows mouse bindings that target specific windows to work
correctly. Without this change, the focused window is always targetted
rather than the window that was actually clicked.

Regression introduced in b744c5e.
2015-11-22 13:32:21 -05:00
Ingo Bürk 00881bb156 Support _NET_WM_USER_TIME.
With this patch, we support the special value "0" for _NET_WM_USER_TIME
on a window upon managing it, which indicates that the window shall not
be focused.

fixes #2064
2015-11-21 22:48:48 +01:00
Michael Stapelberg b255d140be Merge pull request #2061 from Airblader/bug-2049
Only grab scrollwheel buttons if necessary
2015-11-16 00:49:27 -08:00
Michael Stapelberg e48c4cd257 Revert "Bugfix: set group mask 1 by default, correctly compare modifiers"
This reverts commit 9692c1498b.

That commit accidentally defaulted to group mask 1, but the default
should be to match any group mask, so that having multiple layouts
loaded at the same time works.

fixes #2062
2015-11-16 09:00:27 +01:00
Ingo Bürk 029d78c0bf Only grab scrollwheel buttons if necessary.
With this patch, we only grab the scrollwheel buttons (4 and 5) when
managing a window if a whole window key binding exists for these buttons.

This allows both of these usecases:
  - Bindings to scrollwheel buttons using --whole-window (see #1701).
  - Scrolling in a window without focusing it if no such binding
    exists (see #2049).

Furthermore, we drop all button grabs and regrab them after a config
reload in order to reevaluate the new bindings correctly.

fixes #2049
2015-11-15 22:08:47 +01:00
Ingo Bürk 66882bf445 Extract function to grab buttons when managing a window.
We refactor the button grabbing into a function to allow the next patch
both to
  - conditionally grab different sets of buttons
  - grab the buttons again when reloading the config.

relates to #2049
2015-11-11 20:21:26 +01:00
Michael Stapelberg 31121f1334 Merge pull request #2054 from hwangcc23/fix-2051
Fix config validation fail when no new line from end of file
2015-11-02 20:13:20 +01:00
Ingo Bürk f2209a873c Remove autostart commands after they have been executed.
As there is no need to keep autostart commands in memory, we can safely
remove them as soon as they have been executed. As we previously didn't
clear them at all during config reloads, this also fixes a memory leak.

Note that neither autostarts nor autostarts_always is executed during
config reloads, so removing them from memory is fine as an i3 restart
will cause them to be parsed again.

fixes #2044
2015-11-02 09:21:43 -05:00
hwangcc23 18b3f09970 Fix config validation fail when no new line from end of file
1. i3 config validation failed when the new line is missing from the end of file.
   The error was: "ERROR: Your line continuation is too long, it exceeds 4096 bytes".
   It is wrong to assume that there is always a '\n' at the end of each line in the config file.
   (Not for the last line.)
   Fix it via adding a end-of-file check.

2. See the issue #2051. (https://github.com/i3/i3/issues/2051)
2015-11-02 22:12:44 +08:00
Ingo Bürk 5b9fb51b37 Fix memory leaks in modes and bar bindings. 2015-11-01 16:35:17 -05:00
Ingo Bürk bc250b26a0 Allow multiple tray_output directives.
This patch introduces the possibility to specify the tray_output directive
multiple times. All values will be used by i3bar, in the order they are
given.

This way, a single bar configuration can be used for several machines with
internal output names "eDP1" and "LVDS-0" by specifying tray_output for both.
Any external output (e.g., "DP-0") will still not receive the tray. The same
effect can be achieved by using "primary", but forces the user to couple the
tray display to the primary output which may not be desirable behavior.

relates to #555
2015-11-01 16:35:17 -05:00
Michael Stapelberg beb89e64b4 Bugfix: ignore XKB group bits in floating_modifier
fixes #2046
2015-10-30 08:38:53 +01:00
Michael Stapelberg 9692c1498b Bugfix: set group mask 1 by default, correctly compare modifiers
fixes #2002
2015-10-29 08:47:36 +01:00
Michael Stapelberg 0e5180cae9 Bugfix: correctly compare modifier mask when identifying keybindings
fixes #2002
2015-10-28 21:42:37 +01:00
Ingo Bürk 27db61f504 Fix multiple memory leaks with regular expressions. 2015-10-28 14:40:10 +01:00
David Simon dc05d905c1 Optionally change i3bar color on focused output, implements #2020 2015-10-27 09:12:57 -04:00
Michael Stapelberg 2451551f63 Merge pull request #2040 from Airblader/bug-2034
Fix crash when trying to split and float a dock container.
2015-10-27 10:07:25 +01:00
Ingo Bürk 57a7ff301f Add --no-auto-back-and-forth for moving windows.
This patch extends the previously introduced flag --no-auto-back-and-forth
to also apply to

    move window to workspace <name>
    move window to workspace number <number>

relates to #2028
2015-10-26 22:40:06 +01:00
Ingo Bürk 3d6c76eb93 Fix crash when trying to split and float a dock container.
Since splitting a docking container was allowed and successful, the check
to prevent floating it fails to work. This causes a crash because the
workspace of the container cannot be determined as the dockarea is higher
up in the tree than the workspace it belongs to.

This patch extends to sanity check to nested dock containers when trying to
float a container and also disallows manually splitting a docked container
or changing its layout.

fixes #2034
2015-10-26 22:14:14 +01:00
Michael Stapelberg 30c3729a24 Merge pull request #2036 from Airblader/bug-2015
Make resize grow|shrink width|height work for a nested split in the s…
2015-10-26 09:14:28 +01:00
Michael Stapelberg d35ee4501b Merge pull request #2031 from Airblader/feature-2028
Added --no-auto-back-and-forth to workspace commands.
2015-10-25 16:51:32 +01:00
Ingo Bürk ad10a366d6 Mark assignment as run before executing it.
We need to store the information that an assignment was run for a window
before actually executing the command. Otherwise, if the command causes
a change that causes assignments to be run again, the window might be
matched again, causing an infinite loop and hence i3 to freeze or crash.
2015-10-25 14:27:08 +01:00
Ingo Bürk ac4ac94181 Fixed logging statement.
Assignments don't necessarily represent workspace assignments, but could
also be used, e.g., for no_focus. Hence, there's no point in logging
dest.workspace for all assignments.
2015-10-25 14:25:55 +01:00
Ingo Bürk 10b1b39478 Make resize grow|shrink width|height work for a nested split in the same direction.
Suppose a horizontally oriented workspace has two windows open. Issuing "split h" on
the right window creates a nested horizontal container. If we now resize in "width"
direction, the resize doesn't work because it will only operate on the current parent,
which is a container with only one child, so the resize command exits.

This is unexpected behavior from a user point of view. Hence, with this patch, we
ensure that we don't just go up the tree until we find a parent with the correct
orientation, but also keep going if that parent has only a single child.

fixes #2015
2015-10-25 13:03:56 +01:00
Ingo Bürk 7270206e24 Added --no-auto-back-and-forth to workspace commands.
This patch introduces the --no-auto-back-and-forth flag to both of

    workspace --no-auto-back-and-forth <name>
    workspace --no-auto-back-and-forth number <number>

This flag will only have an effect if the back_and_forth feature is
enabled. If passed, the feature will be ignored for this particular
call only.

fixes #2028
2015-10-24 00:12:03 +02:00
Ingo Bürk f676781576 Remove broken and unused debug borders. 2015-10-23 00:38:11 +02:00
Ingo Bürk 60158d31a2 Introduce special value __focused__ for criterion con_id.
This allows matching with

    [con_id=__focused__] unmark

for commands that do not default to operating on the focused window
if no criteria have been specified (such as unmark).

relates to #2014
2015-10-22 15:46:55 +02:00
Ingo Bürk 9537ada5ad Make 'unmark' aware of matched windows.
This patch allows using 'unmark' on matched windows. The old behavior
of applying it to all windows if no criteria were specified is kept.

relates to #2014
2015-10-22 15:32:18 +02:00
Ingo Bürk 7a77c5f0bb Introduce "--add" for marking windows.
In order to keep compatibility to before allowing multiple marks on a window,
we introduce a flag "--add" that must be set to put more than one mark on a
window. The default, which is also available as "--replace", keeps the old
behavior of overwriting a mark when setting a new one.

fixes #2014
2015-10-22 15:32:15 +02:00
Ingo Bürk 9bb2f038ab Allow multiple marks on windows.
This patch allows multiple marks to be set on a single window. The restriction that a mark may
only be on one window at a time is still upheld as this is necessary for commands like
"move window to mark" to make sense.

relates to #2014
2015-10-22 15:29:42 +02:00
Ingo Bürk 41db909522 Activate root output if RandR request fails.
fixes #2011
2015-10-21 19:09:47 +02:00
Michael Stapelberg 8125b54e09 fix a memory leak in handle_get_bar_config 2015-10-19 19:13:15 +02:00
Michael Stapelberg 7b502cf44c Fix memleak in translate_keysyms 2015-10-19 18:53:59 +02:00
Michael Stapelberg fccf83294a Merge pull request #2004 from Airblader/bug-2003
Fix moving windows to a marked workspace by mark.
2015-10-18 12:26:37 +02:00
Ingo Bürk a172168e61 Fix moving windows to a marked workspace by mark.
When a window is moved to a mark and the marked container is a workspace,
we can skip any other logic and just call con_move_to_workspace directly.

fixes #2003
2015-10-16 21:07:16 +02:00
hwangcc23 dd400ff74b Revise workspace next/prev
See the issue #1798 (http://github.com/i3/i3/issues/1798).

+workspace_next+ as-is cycles through either numbered or named workspaces,
but when it reaches the last numbered/named workspace, it only looks for
named workspaces. This commit changes it: look for named workspaces after
exhausting numbered ones, but also for numbered ones after exhausting
named ones.

Also add a test case 528-workspace-next-prev.t (numbered workspaces and named
workspaces on 2 outputs) for testing this.
2015-10-16 23:25:12 +08:00
Michael Stapelberg 7275174510 Merge pull request #1994 from Airblader/bug-1992
Make pango markup in mode names optional with a flag.
2015-10-13 12:08:42 -07:00
Ingo Bürk fec61791e1 Rename is_markup to pango_markup. 2015-10-13 09:59:26 +02:00
Ingo Bürk 82dc747396 Make pango markup in mode names optional with a flag.
This introduces the flag "--pango" on the mode config directive to
explicitly enable pango markup for mode names. Not setting this will
cause the mode name to be rendered as is.
This fixes a regression in 4.11 where mode names containing characters
such as '<' would break user's configs as they didn't escape these
characters.

fixes #1992
2015-10-13 09:23:30 +02:00
Ingo Bürk f7907c11d7 Suppress no_focus for first window on a workspace.
With this patch, the no_focus directive will be ignored if the
to-be-opened window is the first on its workspace as there's no
reason the user would not want to focus it in this case.
This improves usability when, for example, using a tabbed
workspace_layout.

fixes #1987
2015-10-12 12:59:01 +02:00
Michael Stapelberg d24964ff6a Use sasprintf() 2015-10-11 20:42:52 +02:00
Michael Stapelberg 321bba224a Bugfix: add keymap fall back (_XKB_RULES_NAMES, then defaults)
fixes #1983
2015-10-11 20:24:16 +02:00
Ingo Bürk 1c4100ce5d Use 32-bit visuals for i3bar when possible and allow RGBA colors.
This patch creates all necessary windows for i3bar with 32-bit visuals if available.
It also introduces the possibility to define RGBA colors (next to RGB colors), which
allows the user to set the opacity of any color. This requires running a compositor.

With this patch we also start supporting _NET_SYSTEM_TRAY_VISUAL, which is necessary
for the tray icons so they create the tray window with the correct depth and visual.
2015-10-06 23:01:57 +02:00
Ingo Bürk b744c5e6c6 Refactor parsing of matches to avoid code duplication. 2015-10-04 17:40:25 +02:00
Michael Stapelberg 2248085c5c Merge pull request #1909 from Airblader/feature-refactor-1
Refactor rendering noodles a bit
2015-10-04 17:15:42 +02:00
Michael Stapelberg 77a7d625e1 Merge pull request #1965 from Airblader/feature-typed-commands-parser
Make the command parser stack typed
2015-10-04 17:05:27 +02:00
Michael Stapelberg 039494165a Merge pull request #1959 from hwangcc23/fix-1926
Check duplicated bindings after translating keysym
2015-10-02 19:51:42 +02:00
hwangcc23 fc48a297ed Check duplicated bindings after translating keysym
1). See the issue #1926. For example, the second keybinding is not detected as a duplicate:
        bindcode Mod4+24 sticky toggle
        bindsym Mod4+q focus parent
2). To fix it, check duplicated bindings when translating the keysym to keycodes.
2015-10-02 22:09:53 +08:00
Ingo Bürk 6cd6f43d09 Turn "char *" into "const char *" for all command parser functions. 2015-09-28 14:24:08 +02:00
Ingo Bürk c7ca6e1b41 Migrate the move command to use typed numbers. 2015-09-28 14:21:44 +02:00
Ingo Bürk 0ae9cddc98 Migrate the resize command to use typed numbers. 2015-09-28 14:21:44 +02:00
Ingo Bürk 23d5d704ed Allow the commands parser to use "number" arguments by making the stack typed. 2015-09-28 14:21:44 +02:00
Michael Stapelberg 71afed725a Merge pull request #1962 from Airblader/bug-move-to-output-criteria
Correctly handle command criteria for "move window to output".
2015-09-28 08:22:09 +02:00
Michael Stapelberg 2f9ed9c4c3 Merge pull request #1961 from Airblader/bug-1957
Avoid freeze when moving container
2015-09-28 08:19:23 +02:00
Michael Stapelberg 3830aa891e Merge pull request #1960 from Airblader/bug-restore-mark
Fix duplicated marks on append_layout
2015-09-28 08:19:04 +02:00
Ingo Bürk 852a2853e3 Correctly handle command criteria for "move window to output". 2015-09-26 21:31:28 +02:00
Ingo Bürk 594cd473b7 When moving a container to a mark, also check whether the container is being moved to its own descendant and
reject the request if this is the case.

fixes #1957
2015-09-25 19:43:43 +02:00
Ingo Bürk dd7a532160 When appending a layout containing a marked container, make sure that any other containers with the same mark
are unmarked during insertion of the new container.

fixes #1956
2015-09-25 19:26:41 +02:00
Michael Stapelberg c82e6a87dc Merge pull request #1931 from Airblader/bug-1924
Improvements for sticky windows
2015-09-24 22:34:29 +02:00
Ingo Bürk 922afe1919 Keep a sticky window focused if it was the focused window on the source workspace.
fixes #1924
2015-09-24 22:10:17 +02:00
hwangcc23 94e7d13e17 Not toggle floating on a CT_FLOATING_CON
See the issue #1875.
Forbid the command to toggle floating on a CT_FLOATING_CON to avoid the crash.
2015-09-23 00:16:25 +08:00
Ingo Bürk 2d4f8ce90b Set a proper WM_CLASS on frame windows. 2015-09-22 08:57:05 +02:00
Michael Stapelberg ee5db875c2 Merge pull request #1944 from tcatm/fix-vlog
log: avoid buffer overflow in vlog
2015-09-21 14:48:30 +02:00
Nils Schneider 717422c12c log: avoid buffer overflow in vlog
`vlog()` can not handle log messages longer than 4096 bytes. However, the
message generated in `store_restart_layout()` is likely to exceed this
as it contains a long JSON string.

This has caused a few SEGFAULTS during restarts for me when running with
`-d all`.

Fix this by truncating the message to 4096 bytes and punching in a newline at
the end.
2015-09-21 14:27:22 +02:00
Michael Stapelberg 5775147d37 Merge pull request #1943 from tcatm/fix-no-randr-output
Don't create empty workspaces on restart
2015-09-21 13:56:43 +02:00
Nils Schneider f14efe85d1 Don't create empty workspaces on restart
This fixes a bug I introduced in #1921. When restarting i3 in place a
stray workspace was created on the root_output during restart. On first
start, this workspace would have been moved to the first real and empty
output.

However, this does not produce the desired result during restarts when
workspaces are alread present on all real outputs. The stray workspace would
still be added to the first real output which already contains some
workspaces. Thus, adding a new empty workspace to it.

Fix this by delaying creation of the root output's workspace until it is
known whether the output is active or not.

Fixes #1940
2015-09-21 13:26:58 +02:00
Michael Stapelberg f3d898be4b Merge pull request #1937 from Airblader/bug-1910
Correctly restore floating windows
2015-09-21 10:18:25 +02:00
Michael Stapelberg 72b9909942 Merge pull request #1921 from tcatm/fix-no-randr-output
randr: use root window in case of no randr outputs
2015-09-21 10:17:21 +02:00
Michael Stapelberg 77d962f520 Merge branch 'debuglog-on-persist' of git://github.com/hwangcc23/i3 into hwangcc23-debuglog-on-persist 2015-09-21 10:05:14 +02:00
Ingo Bürk 55edbfe734 If no output is available, use the root screen geometry to determine the maximum size when checking the size of floating windows.
This is necessary during a restart of i3 when restoring floating windows. In this situation, we restore the layout before setting up the RandR outputs which would set the window's size to 0, making it invisible.

Thanks to hwangcc23 and spudowiar for reporting.

fixes #1910
fixes #1934
2015-09-20 12:31:29 +02:00
hwangcc23 b2bbd2c064 Make “debuglog on” command persist via restarts
1. Reference: issue #1929
2. When restarting, add the argument "-d all" if debuglog is on.
3. Add add_argument() for adding/replacing the given argument.
2015-09-20 07:48:02 +08:00
Nils Schneider 78decb565a randr: use root window in case of no randr outputs
This patch introduces a root output covering the root window. It is used
in two cases:

1. RandR is not available. In this case, the previous behaviour of
   creating a single output covering the root window is preserved.

2. RandR is available, but there is no active output. In this case,
   the root output is enabled and will be the only active output.
   If any RandR output becomes available, the root output will be
   disabled again. Existing mechanisms for migrating workspaces will
   just work without modification.

I've carefully slipped in a global variable `Output root_output` representing
that output.

Fixes #926 and #1489
2015-09-18 23:18:03 +02:00
Michael Stapelberg eb4a174788 Bugfix: load new keymap _before_ translating keysyms (Thanks Airblader)
fixes #1919
2015-09-17 22:34:59 +02:00
Michael Stapelberg d4fb17546c Merge pull request #1920 from Airblader/feature-1873
Set and unset individual atoms in _NET_WM_STATE
2015-09-17 10:08:27 +02:00
Ingo Bürk 034815b8fd Set and unset individual atoms in _NET_WM_STATE instead of overwriting the entire list everytime. This allows independent management of multiple states.
fixes #1873
2015-09-17 09:13:12 +02:00
Ingo Bürk b490f67925 Use the focused container to determine the target window_mode when using floating mode_toggle.
This fixes mode_toggle in case the workspace is focused and only a floating sticky window is open.

fixes #1927
2015-09-16 19:52:08 +02:00
Nils Schneider c87b256200 Revert "Add a timeout: delay_exit_on_zero_displays"
This reverts commit 2c77d7ceed.
2015-09-14 22:34:05 +02:00
Michael Stapelberg 7de15b3815 clang-format
(When will I learn? I need to integrate clang-format into my editor.)
2015-09-14 10:22:43 +02:00
Michael Stapelberg 840ce51bfd Extract workspace names from bindings before reordering.
fixes #1889
2015-09-14 09:28:42 +02:00
Ingo Bürk 1c4c3f06fa Make sure sticky windows pop to the front if they get sticky while not being on a visible workspace.
This commit also reworks the way focusing sticky windows is prevented by not focusing them temporarily at all, but preventing the focus in the first place.
2015-09-13 20:40:20 +02:00
Ingo Bürk 9866b00802 Implement new 'sticky' command to manually set, remove or toggle the sticky state on a window. 2015-09-13 20:40:20 +02:00
Ingo Bürk 2c338b6ae2 Handle _NET_WM_STATE_STICKY, but only for floating containers. If this atom is set, the floating window will always be automatically moved to the currently active workspace of the output that it is on. This is the equivalent of a sticky note stuck to the monitor.
We will respect this atom upon managing a window as well as when we receive a request that changes the sticky state.

fixes #1455
2015-09-13 20:40:20 +02:00
Ingo Bürk 5dbfb05c85 Use the EWMH support window rather than the root window as an input focus fallback.
If no other window is available on the active workspace, we now select the EWMH support window (used to indicate that an EWMH-compliant window manager is preent) as the focus window rather than the root window. The NET_WM_ACTIVE window will still be set to XCB_WINDOW_NONE to pretend that no window is actually focused.
This fixes the issue that when using the root window, a fallback mechanism in X11 takes effect which routes keyboard input to the window under the cursor, independent of whether that window has the input focus. Using the EWMH window instead, we can avoid this behavior. We cannot simply set it to XCB_WINDOW_NONE as this would discard all keyboard events, breaking keybindings.

fixes #1378
2015-09-13 20:29:02 +02:00
Michael Stapelberg ef6f2f4365 Merge pull request #1893 from rr-/resize
Added cmd_size
2015-09-11 14:31:33 -07:00
rr- 23d16e1332 Support "resize set W H" 2015-09-11 23:12:07 +02:00
Ingo Bürk f31e476b28 Let "focus" report success depending on whether a window was matched.
fixes #1809
2015-09-11 08:26:33 +02:00
Ingo Bürk bb5be480e7 Move rendering the root node into a separate function. 2015-09-10 20:57:04 +02:00
Ingo Bürk a194cab523 Move precalculating the container sizes into a separate function 2015-09-10 20:43:33 +02:00
Ingo Bürk dd989fa87b Refactor out some individual functions in render_con() to make the code more readable. 2015-09-09 18:37:07 +02:00
Michael Stapelberg cc98f465f2 Merge pull request #1895 from Airblader/bug-1883
Support moving dock clients to another output.
2015-09-06 13:26:53 +02:00
Ingo Bürk 053020f2db Support moving dock clients to another output.
This fixes #1883 where a race condition between i3 and i3bar caused two i3bar clients to be put onto the same output.
2015-09-05 21:30:55 +02:00
Ingo Bürk 1f79c44cde If a title contains a percent sign, make sure it is not swallowed by parsing the title_format (if one is set on the window). 2015-09-05 16:29:47 +02:00
Michael Stapelberg bbefa2a16c Fix “precisely 1 group” error message
fixes #1897
2015-09-05 14:32:58 +02:00
Michael Stapelberg eacf20278b Merge pull request #1891 from Airblader/bug-1890
Handle absent window title
2015-09-05 12:54:47 +02:00
Ingo Bürk d657c9c7a5 Make sure borders are never counted as adjacent to the edge for floating containers.
fixes #1215
relates to #998
2015-09-05 01:44:37 +02:00
Ingo Bürk f61b5c6cb7 Correctly handle an absent window title to avoid a crash for applications that only set it after opening the window.
fixes #1890
2015-09-05 01:18:35 +02:00
Michael Stapelberg ee2983c791 Merge pull request #1880 from Airblader/feature-665
Move data from Con to Window
2015-09-03 20:35:43 +02:00
Ingo Bürk 344514bca5 Move aspect_ratio from Con to Window.
relates to #665
2015-08-31 21:27:13 +02:00
Ingo Bürk f43a15acde Move width_increment and height_increment from Con to Window.
relates to #665
2015-08-31 21:27:10 +02:00
Michael Stapelberg 394161c479 Merge pull request #1877 from Airblader/feature-1872
Support _NET_WM_VISIBLE_NAME
2015-08-31 09:00:57 +02:00
Ingo Bürk 80ce13e44e Move base_width and base_height from Con to Window
relates to #665
2015-08-30 22:48:37 +02:00
Ingo Bürk f44c87685b Support _NET_WM_VISIBLE_NAME. As per specification this is necessary since we can display custom titles with title_format.
fixes #1872
2015-08-30 22:42:14 +02:00
Ingo Bürk 54d270e359 Support a special value "__focused__" as a command criterion pattern for class, instance, title, window_role and workspace.
This special value will match if the window's property equals that of the currently focused window.

relates to #1770
2015-08-28 10:07:12 +02:00
Michael Stapelberg b68a400abf Bugfix: sort bindings, re-ordering once is not enough.
Reordering once (as we did it before this commit) would only sort the
bindings by the _first_ bit of their event_state_mask, but we need to
sort them by _all_ bits of their event_state_mask.

fixes #1870
2015-08-28 09:30:28 +02:00
Michael Stapelberg cbdf1ac8b6 bindings: invert shift bit, don’t just remove it
Before this commit, we only made the transformation of C → c, with this
commit we’re considering both c → C and C → c.

fixes #1870
2015-08-28 09:09:31 +02:00
Michael Stapelberg ea514eb3d4 fix missing clang-format of amended commit 2015-08-26 10:01:14 +02:00
Michael Stapelberg bf3cd41b5d Use libxkbcommon for translating keysyms, support all XKB groups.
fixes #1835

This commit improves the translation of keysyms to keycodes by loading
keymaps using libxkbcommon-x11 and using libxkbcommon for figuring out
the keymap, depending on each keybinding’s modifiers. This way, the
upper layers of complex layouts are now usable with i3’s bindsym
directive, such as de_neo’s layer 3 and higher.

Furthermore, the commit generalizes the handling of different XKB
groups. We formerly had support only for two separate groups, the
default group 1, and group 2. While Mode_switch is only one way to
switch to group 2, we called the binding option Mode_switch. With this
commit, the new names Group1, Group2 (an alias for Mode_switch), Group3
and Group4 are introduced for configuring bindings. This is only useful
for advanced keyboard layouts, such as people loading two keyboard
layouts and switching between them (us, ru seems to be a popular
combination).

When grabbing keys, one can only specify the modifier mask, but not an
XKB state mask (or value), so we still dynamically unbind and re-bind
keys whenever the XKB group changes.

The commit was manually tested using the following i3 config:

    bindsym Group4+n nop heya from group 4
    bindsym Group3+n nop heya from group 3
    bindsym Group2+n nop heya from group 2
    bindsym n nop heya
    bindsym shift+N nop explicit shift binding
    bindsym shift+r nop implicit shift binding
    bindcode Group2+38 nop fallback overwritten in group 2 only
    bindcode 38 nop fallback

…with the following layout:

    setxkbmap -layout "us,ua,ru,de" -variant ",winkeys,,neo" \
      -option "grp:shift_caps_toggle,grp_led:scroll" \
      -model pc104 -rules evdev

By default (xkb group 1, us layout), pressing “n” will result in the
“heya” message appearing. Pressing “a” will result in the “fallback”
message appearing. “j” is not triggered.

By pressing Shift+CapsLock you switch to the next group (xkb group 2, ua
layout). Pressing “a” will result in the “fallback overwritten in group
2 only” message, pressing “n” will still result in “heya”. “j” is not
triggered.

In the next group (xkb group 3, ru layout), pressing “a” will result in
the “fallback” message again, pressing “n” will result in “heya”,
“j” is not triggered.

In the last group (xkb group 4, de_neo layout), pressing “a” will still
result in “fallback”, pressing “n” will result in “heya”, pressing “j”
will result in “heya from group 4”.

Pressing shift+n results in “explicit shift binding”, pressing shift+r
results in “implicit shift binding”. This ensures that keysym
translation falls back to looking at non-shift keys (“r” can be used
instead of ”R”) and that the order of keybindings doesn’t play a role
(“bindsym n” does not override “bindsym shift+n”, even though it’s
specified earlier in the config).

The fallback behavior ensures use-cases such as ticket #1775 are still
covered.

Only binding keys when the X server is in the corresponding XKB group
ensures use-cases such as ticket #585 are still covered.
2015-08-26 09:56:42 +02:00
Michael Stapelberg 1a9a9cc68d Revert "Check if output is disabled in handle_output()"
This reverts commit e71c304444.

It turns out that several users have workflows in which they turn off
their monitors without using e.g. `xrandr --output DP-1 --off`. The
result is that the monitors are disconnected, but not disabled.

With commit e71c304444, i3 started to see
these two states as one and the same state, but that causes more harm
than it does good. For example, for some users with only one monitor, i3
would just exit when these users turned off their monitor.

related to #1858, #1839

fixes #1845
2015-08-25 20:09:56 +02:00
Ingo Bürk 2938fc0ab1 Added '%class' and '%instance' as placeholders for the title_format directive.
relates to #1861
2015-08-25 19:22:05 +02:00
Felix C. Stegerman 12d35cc2bc remove useless get_first_output() call 2015-08-10 17:51:09 +02:00
Michael Stapelberg f76a2fdf68 layout restore: remove remaining criteria when swallowing window
fixes #1817
2015-08-06 21:35:34 +02:00
Michael Stapelberg 0fb784f5cb Translate bindsym bindings upon ISO_Next_Group
With commit c738b2e454 we changed i3 so
that the default keybindings can be used when ISO_Next_Group is enabled,
but bindings which explicitly use Mode_switch have precedence. This
behavior required the use of bindcode instead of bindsym.

With this commit, when switching from group 1 to group 2 using
ISO_Next_Group, i3 will re-translate all keybindings (looking at column
2/3, regardless of whether the keybinding itself specifies Mode_switch)
and re-grab them.

That way, the keybinding “bindsym $mod+x nop foo” will work when
pressing $mod+x without Mode_switch and when pressing the corresponding
$mod+x (different key) with Mode_switch. A binding such as “bindsym
Mode_switch+$mod+x nop bar” will still have precedence.

The intention here is to make bindsym keybindings work well with dual
keyboard layouts (such as {dvorak, us} or {us, ru}), so that users can
switch between groups and still have their (logical) keybindings behave
the same way.

fixes #1775
2015-08-06 09:32:22 +02:00
Michael Stapelberg fed05ef876 clang-format src/load_layout.c 2015-08-05 22:55:07 +02:00
Michael Stapelberg 57438d270d append_layout: load floating containers correctly
fixes #1739
fixes #1271
2015-08-05 22:40:58 +02:00
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 ad9ecd52fa Use safe wrappers inside "#if 0" too 2015-08-03 12:51:55 +03:00
shdown fa4f1c5b0f config_parser: don't use sizeof(char) 2015-08-03 12:51:20 +03: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
Michael Stapelberg 05fb909636 Merge pull request #1712 from Airblader/feature-next-wm-size-hints-adopted
[Adopted] Use WM_SIZE_HINTS when available to set the geometry of floating windows
2015-08-02 23:52:10 -07:00
Michael Stapelberg 21d4b2319f Properly clear the urgency hint when set by i3.
fixes #1825
2015-08-02 20:50:14 +02:00
Tony Crisci 0107d35508 Don't log motion notify
Do not log an XCB_MOTION_NOTIFY event in handlers.c because this
clutters the log.

Only log in the motion notify handler if something important happens.
2015-07-30 22:40:38 -04: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
Michael Stapelberg 86cc7d9a21 Improve error message for clarity. 2015-07-27 22:32:55 +02:00
hwangcc23 fc1477dfb5 Support config file line continuation
1. Allow to use the line continuation, which is indicated by \ before the new line character, in config files.
2. Add a new testcase "247-config-line-continuation.t" for
    a). testing line continuation
    b). making sure string escaping still works
    c). testing line continuations within a string
    b). testing line continuations with too many lines
2015-07-26 07:54:06 +08:00
hwangcc23 44367572c9 Display which config is used in --more_version
In the output of i3 --moreversion,
display the path of the used config and its last modified time.
2015-07-10 22:54:25 +08:00
Ingo Bürk c073de8d26 Remove asserts and return non-match instead if the container or its workspace cannot be found.
This can cause an issue if used in combination with for_window and i3bar during startup of i3 otherwise.

fixes #1774
2015-07-01 11:47:55 +02:00
Michael Stapelberg 6be1b28813 Merge pull request #1771 from Airblader/feature-1769
Implement new criterion 'workspace'.
2015-06-30 13:52:54 -07:00
Michael Stapelberg 7c1abc9ab0 Merge pull request #1772 from Airblader/feature-fix-newline
Added missing newlines in log statements.
2015-06-30 13:52:48 -07:00
Ingo Bürk be406d036d Implement new criterion 'workspace'.
If the match expression is a plain number (e.g., '99'), the number of a workspace will be compared strictly. Otherwise, the match expression is taken as a regular expression and compared against the workspace's name.
This allows all of the following:

for_window [workspace=5] ...
for_window [workspace="5:foo"] ...
for_window [workspace="foo"] ...

fixes #1769
2015-06-30 20:53:52 +02:00
Michael Stapelberg f76838794d Merge pull request #1768 from hwangcc23/atoi2strtol
Fix TODO in src/bindings.c
2015-06-30 11:50:28 -07:00
Ingo Bürk 94a09b3cac Added missing newlines in log statements. 2015-06-30 20:48:35 +02:00
hwangcc23 478dc5dc38 Fix TODO by replacing atoi by strtol
Fix TODO in bindings.c.
There is no problem to use atoi here since either keycode 0 or button0 is invalid.
But strtol is more flexible and is recommanded for conversion.
2015-06-30 22:22:56 +08:00
Michael Stapelberg 8df7e4ecb9 Merge pull request #1747 from Airblader/feature-1723
Implement "title_format"
2015-06-29 00:24:59 -07: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
Ingo Bürk 55e8d06ee4 Added command directive 'title_format'.
This directive will be used to customize the window title.
2015-06-29 09:13:31 +02:00
Michael Hofmann bad4203755 Configurable tray padding. 2015-06-28 00:14:37 +02:00
Michael Stapelberg 696d844ffa Merge pull request #1697 from Airblader/feature-1695
Extend mouse commands on i3bar
2015-06-18 20:50:56 +02:00
Ingo Bürk 9eb255d5fa Ensure format of dumped bindings for i3bar is compatible with i3 bindings.
fixes #1695
2015-06-18 19:28:24 +02:00
Michael Stapelberg 34183b97fd Merge pull request #1744 from Airblader/feature-docs-7
Documentation Improvements
2015-06-13 12:39:59 +02:00
Ingo Bürk 9940571069 Fix documentation for border styles. 2015-06-12 17:54:54 +02:00
Ingo Bürk 52c72e9007 Remove redundant and broken check for '\0'.
fixes #1742
2015-06-09 22:14:56 +02:00
Ingo Bürk 2b6f76852c Implement i3's logic for maintaining a list of 'bindsym' directives and passing it to i3bar through the IPC. 2015-06-05 12:30:53 +02:00
Ingo Bürk ab12d3fc74 Add new command skeleton 'bindsym <button> <command>' for 'bar' block. 2015-06-05 12:30:53 +02:00
Michael Stapelberg 6b505d8aca Merge pull request #1733 from Airblader/feature-1732
Added a separate color directive for the binding mode indicator
2015-06-02 08:35:14 +02:00
Ingo Bürk dd2e10868c Fix warning about potentially uninitialized variable. 2015-06-01 17:10:10 +02:00
Ingo Bürk 9b691bcca2 Introduce a config directive 'binding_mode' in the 'bar' config, pass it through the IPC and parse it in i3bar. 2015-05-31 16:49:09 +02:00
Ingo Bürk 27e50b827c Use XCB_NONE instead of hard-coded 0. 2015-05-29 23:49:42 +02:00
Ingo Bürk 3c11f27201 Allow hovering over the window decoration to change the focus if the parent container is split horizontally or vertically.
fixes #1056
2015-05-29 23:49:37 +02:00
Ingo Bürk b22a9ce617 Improve logging of button events. 2015-05-26 16:57:25 +02:00
Ingo Bürk 00c2fe4b69 Grab all buttons when managing a window to also allow 'bindsym --whole-window button4 …' to work correctly.
fixes #1701
2015-05-26 16:56:00 +02:00
Andrzej Pronobis d1262f2b6a Use WM_SIZE_HINTS whenever it's provided to set the geometry of floating windows. 2015-05-19 13:44:48 -04:00
Michael Stapelberg da064cc08f Merge pull request #1698 from Airblader/feature-1696
Added 'move position mouse'
2015-05-17 15:02:50 +02:00
Ingo Bürk 8801de2399 Protect "move position mouse" against a NULL access.
This could happen if two outputs are set up to have a gap in between them and the mouse cursor
being in said gap when the command is triggered.
2015-05-14 13:07:56 -04:00
Ingo Bürk 4a585748a4 Implemented new command 'move [window|container] [to] position mouse|cursor|pointer
fixes #1696
2015-05-12 17:46:06 -04:00
Tony Crisci a74662052a Detect base 16 in cmd criteria
Try to detect base 16 numbers given to `con_id` and `id` for command criteria
by setting the base of strtol to 0. This should also detect octal.

This is necessary because mouse bindings now may be serialized as hex as of
5c32de4.
2015-05-12 17:04:01 -04:00
Michael Stapelberg be2634c91f Merge pull request #1693 from mh21/wm-class-garbage-no-copy
Don't duplicate property value on class change.
2015-05-06 23:55:47 -07:00
Michael Hofmann f2542fc413 No memcpy on class change. 2015-05-06 16:33:15 +02:00
Michael Stapelberg 66a1fa7d46 Merge pull request #1638 from hwangcc23/fix-1489
Add a timeout: delay_exit_on_zero_displays
2015-05-05 00:43:43 -07:00
Michael Stapelberg 1aa42794ed Merge pull request #1685 from Deiz/fix-new-workspace-float
Initialize workspace rect to the output's upon creation
2015-05-02 08:24:54 -07:00
Deiz f0f906a52e Initialize workspace rect to the output's upon creation
The comment immediately following implied that this was the intended
behaviour. Not doing so means that compound commands that both move a
window to a new workspace as well as do something that depends on the
workspace's geometry (e.g. 'move position center' or 'floating enable'
on a tiled window) would use the workspace's calloc'd 0x0+0x0 geometry.
2015-04-28 15:09:58 -04:00
Michael Stapelberg 37bee99538 Merge pull request #1680 from acrisci/bug/randr-disabled-outputs
Check if output is disabled in handle_output()
2015-04-26 23:44:03 +02:00
Michael Stapelberg a4f0ed62e5 Merge pull request #1684 from acrisci/bug/focus-without-input-hint
Ignore InputHint when not in WM_HINTS
2015-04-26 12:15:38 +02:00
Tony Crisci 6cbe349774 Ignore InputHint when not in WM_HINTS
When InputHint is not in WM_HINTS (i.e., the flag is not set), treat the window
as if the InputHint was set (the default behavior). This means that i3 will
focus the window when it becomes managed.

fixes #1676
2015-04-25 22:43:46 -04:00
Tony Crisci 5c32de43c0 Bugfix: serialize con_id with %p in run_binding()
%p is equivalent to either %x or %lx, depending on the pointer size of the
platform. Before this commit, we always used %d, which has the same behavior
on Linux, but is not automatically expanded to %ld on e.g. FreeBSD.

fixes #1661
2015-04-25 20:05:55 -04:00
Tony Crisci 14e95e765e Check if output is disabled in handle_output()
Check if the `connection` of the randr output is
XCB_RANDR_CONNECTION_DISONNECTED and disable the output if it is.

This fixes an issue where the output would not be disabled if the output was
physically unplugged from the machine.
2015-04-23 18:21:15 -04:00
Ingo Bürk ffe25d9e43 Set the _NET_WM_STATE_HIDDEN atom on windows that are currently not visible due to being in the non-focused tab of a stacked or tabbed container.
fixes #1648
2015-04-21 09:14:22 +02:00
Ingo Bürk d12482e5fd Added 'con_is_hidden' to check whether a given container is visible to the user assuming its workspace is visible.
This is useful for determining whether we want to set the _NET_WM_STATE_HIDDEN atom on the window.
2015-04-21 09:13:48 +02:00
Michael Stapelberg 67ec2333ee Merge pull request #1665 from Airblader/feature-1658
Added criterion 'window_type'
2015-04-21 08:42:16 +02:00
Michael Stapelberg b1974a469f Merge pull request #1636 from Deiz/update-notices
Update copyright notices and get rid of ranges
2015-04-21 08:31:40 +02:00
Kacper Kowalik (Xarthisius) 30b6584de1 Fix ‘FALSE’ undeclared (first use in this function) when i3 is built without PANGO support 2015-04-20 16:51:58 -05: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
Ingo Bürk 1f472b454c Handle changes to _NET_WM_WINDOW_TYPE after the window has been managed. 2015-04-20 19:27:43 +02:00
Ingo Bürk 550c0ec318 Implement new criterion 'window_type = normal|dialog|utility|toolbar|splash|menu|dropdown_menu|popup_menu|tooltip'
fixes #1658
2015-04-20 19:27:39 +02:00
Ingo Bürk a59fe0d3d2 Added test case for transfer of urgency flag when moving a window to a mark. 2015-04-19 20:57:49 +02:00
Ingo Bürk 283b231290 Disallow moving a container to itself since this would crash i3. 2015-04-19 20:57:49 +02:00
Ingo Bürk 94bbdc9159 Implement the command 'move container to mark <mark>' using 'con_move_to_mark'. 2015-04-19 20:57:49 +02:00
Ingo Bürk 475671ae2a Added 'con_move_to_mark' to move a container to the container holding a certain mark. 2015-04-19 20:57:49 +02:00
Ingo Bürk 9ab4216787 Extract a function from con_move_to_workpsace that deals with moving a container to some other container rather than being restricted to moving to a specific workspace. 2015-04-19 20:57:49 +02:00
Ingo Bürk c4a84385d6 added function 'con_by_mark' to look up a con holding the given mark 2015-04-19 20:57:49 +02:00
Ingo Bürk 9613a0744d Added configuration directive for 'move [container|window] [to] mark <str>' 2015-04-19 20:57:44 +02:00
Michael Stapelberg 8a608ee63a Merge pull request #1632 from Deiz/binding-border
Add a --border flag to enable mouse binds to trigger on border click
2015-04-19 09:28:08 -07:00
Michael Stapelberg 7b68577901 Merge pull request #1651 from tanderson92/pkgconfig
Respect EXEC_PREFIX and a users' choice of PKG_CONFIG.
2015-04-16 00:34:01 -07:00
Thomas Anderson 196e1d0971 Respect EXEC_PREFIX and a users' choice of PKG_CONFIG.
The Makefiles should put binaries in $(EXEC_PREFIX) and
architecture-independent files in $(PREFIX). Also a user may have a
prefixed- pkg-config, as in the case of cross compiling on Exherbo
Linux, so respect the well-accepted $(PKG_CONFIG) variable for this
purpose.
2015-04-12 17:59:30 -07:00
Michael Stapelberg 5e7339d8f0 Merge pull request #1641 from Deiz/fix-1640
Store Git commit identifier in its own object
2015-04-12 10:08:43 -07:00
Deiz 5a987cfd6b Rebuild version.o when version.c or LAST_VERSION change
$(TOPDIR)/LAST_VERSION is a cached copy of common.mk's I3_VERSION var,
updated only if the two differ.
2015-04-12 12:31:58 -04:00
hwangcc 2c77d7ceed Add a timeout: delay_exit_on_zero_displays
Outputs may disappear momentarily and come back later.
To prevent i3 from exit when no output is available momentarily, add a timeout delay_exit_on_zero_displays.
2015-04-11 22:13:10 +08:00
Ingo Bürk edda9306ed Removed comment on removal of legacy "default" layout.
closes #1649
2015-04-11 10:27:42 +02:00
Deiz cd4bc2adf5 Store Git commit identifier in its own object
Fixes #1640
2015-04-06 18:28:40 -04:00
Michael Stapelberg 1546891e6a Bugfix: Remove windows from the save set when unmapping.
fixes #1617
2015-04-06 15:40:12 +02:00
Deiz ce48d5c5d7 Add a --border flag to enable mouse binds to trigger on border click 2015-04-02 16:24:05 -04:00
Michael Stapelberg 92ffc78e19 Merge pull request #1630 from Deiz/consistent-mouse-actions
Make floating window mouse handling consistent with tiled windows
2015-04-02 00:09:13 -07:00
Deiz bb95571516 Make floating window mouse handling consistent with tiled windows
It seems that this was the intended behaviour all along, according to
the comments.
2015-04-02 02:44:37 -04:00
Ingo Bürk b5f7c132fc Added config directive 'no_focus <criteria>' (#1416) 2015-04-01 20:46:56 +02:00
Ingo Bürk e155447932 Added assignment type 'A_NO_FOCUS' (#1416)
Any assignment with type 'A_NO_FOCUS' will cause the matched window to not be focused by i3 when it is managed.
2015-04-01 20:46:55 +02:00
Ingo Bürk 2e4fac61d2 Only mark a window if only one window is matched
We only support unique marks, so looping over all matched windows must be prevented.
If more than one window is matched, we reject it with an error message.

fixes #1614
2015-04-01 13:51:48 +02:00
Michael Stapelberg 3b81e40096 Merge pull request #1618 from Deiz/fix-1603
Allow single-child non-default layout cons to be moved between outputs
2015-04-01 09:08:22 +02:00
Deiz 4e88c10564 Allow single-child non-default layout cons to be moved between outputs
Includes a test case to verify the behaviour of 'move <direction>'.
Fixes #1603.
2015-03-31 13:58:29 -04:00
Ingo Bürk 6036d4e506 Changed the default for show_marks from "no" to "yes" 2015-03-30 23:11:50 +02:00
Ingo Bürk 245a29e233 Make show_marks configurable
Introduce a config directive "show_marks [yes|no]" to en- or disable drawing marks on window decorations.
To not change the look & feel of existing configurations, the default is "no".
2015-03-30 23:11:50 +02:00
Ingo Bürk 2af1a80028 Introduce a cached boolean for changes to the mark of a window.
This is necessary to correctly redraw window decorations when the mark of
a window is added or removed.
2015-03-30 23:08:25 +02:00
Ingo Bürk 1e89a301d5 Draw marks in window decoration
If a window has a mark set, e.g., "example", it will be printed on the right side of the window decorations.
The format is "[example]" and the name of the window is truncated if necessary.

Marks starting with an underscore ("_") will be ignored.
2015-03-30 23:08:25 +02:00
Michael Stapelberg 0ad097ee67 Merge pull request #1613 from Airblader/feature-1426
Added focus_on_window_activation directive
2015-03-30 22:58:16 +02:00
Ingo Bürk 9bf161710b Added 'focus_on_window_activation' directive
When a window receives a _NET_ACTIVE_WINDOW message, it can steal the focus. This may not be preferable to all users.
With this directive, the user can choose from one of the following:
1) 'smart' - focus the container if its workspace is visible, otherwise set the urgency flag (default)
2) 'urgent' - always set the urgency flag, do not steal focus
3) 'focus' - always switch focus, never set the urgency hint
4) 'none' - ignore the request entirely (do not switch focus, nor set the urgency hint)

fixes #1426
2015-03-30 22:09:36 +02:00
Deiz c6581a5fd6 Handle floating centering in one function and test for consistency 2015-03-30 16:03:35 -04:00
Michael Stapelberg 2759a308a2 Merge pull request #1608 from mh21/renaming-empty-ws-startup
Update old_name when renaming current workspace
2015-03-30 22:01:18 +02:00
Michael Hofmann eb84281f8c Cope with non-null-terminated x class properties.
- fixes #1605
2015-03-30 08:56:46 +02:00
Michael Stapelberg 9718640622 Merge pull request #1589 from Deiz/fix-center
Make center coordinates relative to current workspace
2015-03-30 08:47:04 +02:00
Michael Hofmann f76e6c2bb1 Get workspace name when renaming current workspace.
- fixes #1607
2015-03-30 08:28:36 +02:00
Deiz e622c42ef0 Move mkdirp into libi3 2015-03-29 17:18:00 -04:00
Michael Stapelberg b338e25317 Merge pull request #1595 from Deiz/fix-1484
Fix percents when attaching a window to a ws creates a new split con
2015-03-29 23:14:37 +02:00
Ingo Bürk 7a75cb7e0b Added test cases for 'mark --toggle' (#1463) 2015-03-29 21:21:50 +02:00
Ingo Bürk d51d6d730e Added a --toggle switch to "mark [--toggle] <mark>"
This option allows toggling marks on a window without knowing whether the mark is already set or not.
It behaves as follows:
1) If the matched window has no mark, the new mark is set.
2) If the matched window has another mark, the old mark is removed and the new mark is set.
3) If the matched window already has the mark, the mark is removed.

The behavior that all non-matched windows have this mark removed is kept.

fixes #1463
2015-03-29 21:21:50 +02:00
Michael Stapelberg 3191be366d Merge pull request #1600 from Deiz/libi3
Move resolve_tilde and get_config_path into libi3
2015-03-29 20:56:07 +02:00
Deiz 4daed31c3e Move resolve_tilde and get_config_path into libi3 2015-03-29 14:45:42 -04:00
Michael Stapelberg 700dc4bfde Merge pull request #1597 from Airblader/bug-1187
Move urgency hint when moving container to another workspace
2015-03-29 19:50:03 +02:00
Michael Stapelberg 6b04f28b48 fix remaining warnings 2015-03-29 17:12:20 +02:00
Michael Stapelberg 93adcf8bdc Merge pull request #1575 from hwangcc23/next
Fix warnings
2015-03-29 16:53:14 +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
Ingo Bürk 6a5d561235 Move urgency hint when moving container
When an urgent container is moved to another workspace, the urgency hint
1) is unset on the source workspace and
2) set on the target workspace

fixes #1187
2015-03-28 18:29:34 +01:00
Deiz 48d2acd8f6 Fix percents when attaching a window to a ws creates a new split con
Fixes #1484 and includes a test case.
2015-03-27 22:20:28 -04:00
Michael Stapelberg fb0573e183 Merge pull request #1582 from shdown/allow-escaping-backslashes
Allow escaping backslashes
2015-03-27 09:40:09 +01:00
Deiz 24f0ea2f24 Make center coordinates relative to current workspace
Fixes #1211
2015-03-25 22:40:59 -04:00
Tony Crisci 49510427b9 Handle strut partial changes for dock clients
Handle changes to the property _NET_WM_STRUT_PARTIAL by reallocating
screen space in the dock area when the dock client requests a new
position.

This will allow changes to the bar config directive `position` to be
effective on the `reload` command.

fixes #1294
2015-03-25 19:45:42 -04:00
Michael Stapelberg 037cb317cb Merge pull request #1578 from Airblader/feature-custom-separator
Add support for a custom separator symbol
2015-03-25 22:49:09 +01:00
Michael Stapelberg fa93f275bb Don’t focus placeholder windows. 2015-03-25 22:47:23 +01:00
Ingo Bürk 80da100ac8 Add support for a custom separator symbol
This introduces a "separator_symbol" property for the i3bar configuration.
If set, the specified string will be used as a separator instead of a vertical line. Since it is an optional configuration, complete backwards compatibility is given.

fixes #1472
2015-03-25 21:38:55 +01:00
Michael Stapelberg 26237508ea Bugfix: skip restart_mode swallow specifications
Otherwise, placeholder windows would accumulate these over restarts. The
worst part is that they don’t get dumped properly, meaning an empty
swallows specification ends up in the state, which matches any window,
so other random windows would be matched into the placeholder (e.g.
i3bar).

fixes #1502
2015-03-25 20:50:25 +01:00