Commit Graph

220 Commits (0b621292246f2736eeed82ef106f64749c058f68)

Author SHA1 Message Date
Orestis Floros 0b62129224
Remove unused headers
With help from
https://github.com/include-what-you-use/include-what-you-use/
2020-04-20 04:25:06 +02:00
Orestis Floros 3c522d9f2f
Sort includes in *.c files
Not enabling in .clang-format because it breaks headers files.

Used:
    IncludeCategories:
      - Regex:           '^<config'
        Priority:        0
      - Regex:           '^".*"'
        Priority:        1
      - Regex:           '^<(xcb|xkb|yajl|X11)'
        Priority:        3
      - Regex:           '.*'
        Priority:        2
2020-04-19 09:58:25 +02:00
Orestis Floros ae757c6848
Extend tiling/floating criteria with optional auto/user values (#4006)
The default `tiling` and `floating` behavior is preserved and matches
both cases.

Adds a new handler to `remanage_window` on A_I3_FLOATING_WINDOW change.

Mainly in order to `run_assignments`, this makes `for_window [floating]`
directives to work for windows which where initially opened as tiling.
Now, when floating is enabled, `for_window` will trigger correctly. Same
applies to `for_window [tiling]`.

The obvious solution of `run_assignments` after
`floating_{enable,disable}` doesn't work because `run_assignments`
modifies the parser state in src/assignments.c:51.

Fixes #3588

Co-Authored-By: Michael Stapelberg <michael@stapelberg.de>
2020-04-12 13:49:08 +02:00
Albert Safin d3976fee8c Code style: fix misaligned and trailing whitespaces 2020-02-21 02:06:48 +00:00
xzfc 1f0c628cde
clang-format: bring back ForeachMacros (#3948)
* clang-format: bring back ForeachMacros

ForeachMacros was disabled in 4211274fcd
due to the breakage of include/queue.h. The currently used version,
clang-format-6.0 doesn't break it.

* Add curly braces

Co-authored-by: Orestis Floros <orestisflo@gmail.com>
2020-02-19 11:31:09 +01:00
Orestis Floros 812507c4a1
remanage_window: avoid crash when nc->window == NULL
Temporary solution until we find the root cause. Not that it is a bad
idea to check for NULL either way.

Related to #3731
2019-10-18 11:58:08 +03:00
izzel 0845d7b264 Remanage window after property updates (like titles) (#3759) 2019-08-13 08:50:48 +02:00
Orestis Floros cc9b227978
Make small DLOG improvements
- manage_window: log the window in the start of the function so that the
reader knows what the rest of the messages refer to, even if the
function exits prematurely.
- con_is_floating: Message is spammy
2019-04-03 18:51:34 +03:00
Albert Safin 1a85619498 Add input and bounding shapes support (#2742)
Basic idea: if the window has a shape, set the parent container shape as
the union of the window shape and the shape of the frame borders.

Co-authored-by: Uli Schlachter <psychon@znc.in>
2018-12-01 11:52:41 +07:00
Orestis Floros 100d05a2a6
render_con: Get rid of render_fullscreen argument
Only true for the fullscreen container and doesn't affect any of its
children. Thus, we can get the same result by checking
->fullscreen_mode.
2018-11-12 19:05:50 +02:00
Orestis Floros 29f2510fa9
Fix aspect ratio bugs
- ICCCM says: > If a base size is not provided, the minimum size is to
be used in its place and vice versa.
i3 didn't obey the "vice versa" part. Min size and base size are both
saved without replacements in window_update_normal_hints,
floating_check_size makes the needed replacements if either was not
provided.
- Aspect ratio is now saved correctly in manage_window because
window_update_normal_hints is called.
- i3 didn't save the aspect ratio if the window conformed the given
aspect ratio range when handle_normal_hints was called. If the window
was resized to a size outside of the given bounds, i3 didn't correct it.
- Aspect ratio now affects only tiling windows, like the rest of the
normal size hints
- The aspect ratio calculation is now done without a loop

A real life example of how these changes affect the workflow:
An mpv window, when playing a video, sets its min == max aspect ratio
during mapping. i3 ignored these hints. When resized, the window's
aspect ratio was not preserved. With this commit, resizing floating mpv
windows will always preserve the aspect ratio.
2018-11-12 18:45:00 +02:00
Orestis Floros 8c17e4e38d
manage_window: cleaner variable declarations 2018-10-13 21:10:10 +03:00
Thomas Fischer 690e6d1f0e
Respect max size in WM_NORMAL_HINTS 2018-09-20 11:31:19 +03:00
Orestis Floros efc78de4ee
Introduce con_get_fullscreen_covering_ws
This commit will also fix the following bugs:
1. click.c: Users could drag global fullscreen floating containers.
2. render.c: Floating containers would get rendered with a global fullscreen container in another
workspace.
2018-08-22 14:05:50 +03:00
Dan Elkouby 7ac37d8ae4 Reframe swallowed windows if depth doesn't match
X will not allow a window with ParentRelative background to be created
or reparented under a window with mismatching color depth.
Deal with this by destroying the container frame and creating a new one
with the right depth upon swallowing.
Defer destruction of the frame window until after the updated tree has
been rendered to avoid some distracting flickering.

Fixes #3297
2018-06-02 14:32:47 +03:00
Orestis Floros aca7790217
Fix redundant return statements
… at the end of a function with a void return type.

Found using clang-tidy's readability-redundant-control-flow.
2018-04-27 00:09:42 +03:00
Orestis Floros 0b5799412a
Introduce get_existing_workspace_by_num 2018-03-28 15:18:43 +03:00
Orestis Floros 0c2fbeedc2 Don't raise floating windows when focused because of focus_follows_mouse
Fixes #2990.
2018-01-14 15:45:33 +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
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
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 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
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 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
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 a15ce8cb8d Assign the sticky value for _NET_WM_DESKTOP on scratchpad windows. (#2457)
fixes #2456
2016-09-26 22:39:17 -07: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 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
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
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
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
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
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
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
Ingo Bürk 27db61f504 Fix multiple memory leaks with regular expressions. 2015-10-28 14:40:10 +01: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
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
Michael Stapelberg f76a2fdf68 layout restore: remove remaining criteria when swallowing window
fixes #1817
2015-08-06 21:35:34 +02: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
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 67ec2333ee Merge pull request #1665 from Airblader/feature-1658
Added criterion 'window_type'
2015-04-21 08:42:16 +02:00
Deiz 884214f14f Update copyright notices and get rid of ranges
The script used to make these changes can be found at:

   https://gist.github.com/Deiz/32322020f76d23e2bf8f
2015-04-20 17:50:21 -04:00
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