466 Commits

Author SHA1 Message Date
Nikos Tsipinakis
1bc3237a35 Subscribe to PropertyChangeMask regardless of follow_mode
PropertyNotify events are used primarily to detect active screen changes
when follow mode is used but now we also need them to receive resource
manager events in order to update the dpi value.
2019-03-23 20:01:27 +02:00
Benedikt Heine
812d5a3b84 Replace the xresources DB on PropertyNotify
When changing values with xrdb on the command line, an XEvent is
triggered on the "RESOURCE_MANAGER" atom.

But xlib just doesn't care. XResourceManagerString() will still report
the old values. Also XrmGetDatabase() won't help out.

So, when we receive a PropertyNotify for the resource manager atom, we
have to manually query its contents, convert it to a DB and replace it
in the display object.

This allows, that any method just can call XrmGetDatabase() and get the
latest values.
2019-03-23 20:01:27 +02:00
Benedikt Heine
4b06d67605 Initialize xrm during init
Initializing xrm is required only once. Everything else would be
overhead.
2019-03-23 20:01:27 +02:00
Benedikt Heine
9961efd10c Copy the database from the display connection
This allows to update the DB on the xctx.dpy object. Crawling the string
from xctx.dpy will always return the xdefaults string, which represents
the defaults from the initialisation, but not with any other updates.
2019-03-23 20:01:27 +02:00
Benedikt Heine
e9e199c4ec Pass pointer to check_screen_event 2019-03-23 20:01:27 +02:00
Benedikt Heine
ca7234b1c8 Cache the Xft.dpi value outside
The Xft.dpi value is one way to set the dpi of the X11 display. Querying
this value requires much overhead. Therefore we have to cache this.

Previously we did just query it at the beginning and ignored further
changes.

As there is no native signal to catch a change in its xrdb value, we
have to rely on the root window's PropertyNotify event and filter there
the RESOURCE_MANAGER atom.

This will get hooked up later.
2019-03-23 20:01:27 +02:00
Benedikt Heine
37e580e857 (style) swap conditional blocks 2019-03-23 20:01:27 +02:00
Benedikt Heine
4f510e1703 Query the X11 screen's DPI instead of monitor
When changing the DPI via xrandr --dpi <DPI>, xrandr will send a
RRScreenChangeEvent and the DPI value should get adjusted.

Falsely, we thought randr_update() would catch up and query the right
monitor values. But nothing changes, because we query the
XRRMonitorInfo. The monitor info contains the real physical width and
height of the monitor's screen.

But xrandr --dpi only changes the - let's say - virtual screen size of
the virtual overall screen (and therefore changing the DPI to the
matching value).

Important commands to understand:

- Changes dpi of the virtual screen

    xrandr --dpi

- Gives info about the "virtual" screen size (used by DisplayWidth)

    xdpyinfo | grep -B1 resolution

- Gives info about the "physical" screen size (used by XRRMonitorInfo)

    xrandr -q

I know, that I'm probably not right and might not understand the topic
in its full size yet[0]. But I'm 100% sure, that the terms "monitor",
"screen", "screens", "output" and "display" do not have a consistent
naming scheme.
[0] https://twitter.com/dechampsgu/status/857924498280124416

Fixes #382
2019-03-23 20:01:27 +02:00
Benedikt Heine
121ddd2b94 Always throw out the whole screen array
If n < screens_len, screens_len did not get updated. So boundary
checks wouldn't catch, if screens between n and screens_len are
accessed. This will prevent such an error type in the future.
2019-03-23 20:01:27 +02:00
Benedikt Heine
9bcb27f2e8 Pass the RRScreenChangeNotify event to libxrandr
From Xrandr(3):

> Clients must call back into Xlib using XRRUpdateConfiguration when
> screen configuration change notify events are generated [...].
2019-03-23 20:01:27 +02:00
Nikos Tsipinakis
59a87e4e99
Merge pull request #610 from bebehei/docs-retval
Use @retval in codedocs
2019-03-07 22:29:18 +02:00
Benedikt Heine
16fcbc9db9 Use @retval in codedocs 2019-03-06 21:14:52 +01:00
Sascha kruse
c99f715391 Limit icon size when we have a fixed width
Fix #540
2019-02-13 12:01:35 +02:00
Michael Sloan
802b1abb09 Use queues_notification_close for skip_display instead of queues_history_push
https://github.com/dunst-project/dunst/pull/590
2019-02-05 13:36:56 -08:00
Michael Sloan
977a7a7ea4 New rule option: skip_display 2019-01-30 23:50:33 -08:00
Nikos Tsipinakis
dd6320a0a9
Merge pull request #592 from bebehei/desktop-entry
Desktop entry filters.
2019-01-25 14:09:13 +02:00
Benedikt Heine
1e82c761c9 Add support for desktop-entry hints 2019-01-25 07:59:01 +01:00
Benedikt Heine
19c9a8e296 Harden against undefined X Atoms
Fixes #589
2019-01-23 17:56:59 +01:00
Benedikt Heine
3828cca699 Introduce rule_new 2019-01-23 16:20:21 +01:00
Benedikt Heine
53ad430b48 Compose rule matching function more readable 2019-01-23 16:11:22 +01:00
Nikos Tsipinakis
c8c7d2e675
Merge pull request #587 from mgsloan/fix-notification-decode-error-handling
Fix handling of case where notification decode failure occurs
2019-01-13 17:48:02 +02:00
Nikos Tsipinakis
b0db27eed4
Merge pull request #586 from bebehei/checksummed-icons
Checksummed icons
2019-01-13 17:34:11 +02:00
Michael Sloan
dd54709b9e Fix handling of case where notification decode failure occurs
I'm not sure whether this case can happen in the wild, but if
artifically exercising the condition, I noticed it behaves
poorly. Specifically:

* The error_name parameter must be a valid D-Bus error name. It seems
  conventional to set this to "org.freedesktop.Notifications.Error".
  Without this change, the following error is thrown:

  CRITICAL: g_dbus_method_invocation_return_dbus_error: assertion 'error_name != NULL && g_dbus_is_name (error_name)' failed

* Previously execution would continue even though the notification did
  not decode, causing essentially a null pointer exception later.
  Adds a return for this case.

* With those two things fixed, this case seems relatively silent -
  "notify-send" invocations succeed even if the condition for the if
  is "true". So, I added a warning log to indicate that this case is
  occurring
2019-01-13 01:15:19 -08:00
Benedikt Heine
6f8b53c4e8 Compare raw icons by their checksums
Currently, we just skipped the notification comparison, if the
notification had a raw icon attached. This is a bit counterintuitive.

Calculating a checksum of the raw icon's data is the solution.

For that we cache the pixel buffer and introduce a field, which saves
the current icon's id. The icon_id may be a path or a hash.
So you can compare two notifications by their icon_id field regardless
of their icon type by their icon_id field.
2019-01-11 13:10:37 +01:00
Benedikt Heine
5627d06070 Pass NULL instead of empty string to option parser
A bug, introduced in #576. If alignment isn't set in the config, the
settings would print a warning about an invalid value. But actually it's
just the default string, which can't get parsed.

The fallback value should get handled by a false return value and not by
the option_get_string's default value.
2019-01-09 13:12:46 +01:00
Benedikt Heine
8a46b88da9 Use g_strcmp0 for string comparisons
g_strcmp0 handles NULL values correctly. This allows to omit NULL
pointer checks, which would be otherwise crucial.
2019-01-07 17:56:00 +01:00
Benedikt Heine
f9f5804b08 Remove notification_icon_get wrapper 2019-01-07 17:56:00 +01:00
Benedikt Heine
cd09d5a88e Cache GdkPixbuf in notification structure 2019-01-07 17:56:00 +01:00
Benedikt Heine
088907488c Rename icon field to iconname 2019-01-07 17:56:00 +01:00
Benedikt Heine
4043e1a18e Refactor pixbuf scaling into seperate method 2019-01-07 17:56:00 +01:00
Benedikt Heine
6a8f1c52c3
Merge pull request #576 from bebehei/settings-p1
Settings (part 1/x)
2019-01-07 17:17:16 +01:00
Benedikt Heine
41ce7cce4a Add string_parse_* functions
Changes all string parsers to have a the almost same interface while
also having a proper return value, which indicates success of the
parsing process.
2019-01-07 15:32:28 +01:00
Benedikt Heine
8579b3ed6b Add assertion macro to return values
Just recently, I started using g_return_val_if_fail as a brief assertion
checker. It'll also exit the function with a specified return value.

But actually this introduces some weird behavior. It's configurable by
environment variables and it'll print out a log message, if the
expression didn't validate properly. But some of these assertions are
actually ment to be silent.

Using a simple macro makes it simple to structure the assertions and its
return values in a block at the start of a function or anywhere else.
2019-01-07 15:30:42 +01:00
Benedikt Heine
56f2adb106 Manually convert GdkPixbuf to cairo surfaces
As already noted in the code comment, we all knew that the in memory
conversion to a PNG stream is a cumbersome technique. But it was worth
to remove the GTK dependency.

After finding out, that gdk_pixbuf_new_from_data can actually use a
GVariant and share its memory without allocating new memory, I poked
the cairo docs for a similar technique.

There is cairo_image_surface_create_for_data, which would achieve the
same, but cairo uses another color byte order. So we have to manually
copy and reassemble the bytes.

It may look like a big rise in complexity, but actually, it's straight
forward copying pixel by pixel and changing the byte's order.

And the gdk_pixbuf_to_cairo_surface is 33x faster.
2019-01-07 00:45:34 +01:00
Benedikt Heine
5ebedab78b Fix maybe uninitialized variable 2018-12-29 14:38:59 +01:00
Benedikt Heine
63f455276f Print correct ID for foreign DBus service
By providing an additional layer of pointers, the printed PID was
actually the value at the PID's memory position. 🙈
2018-12-29 14:38:59 +01:00
Benedikt Heine
57a6baae85 Test FDN Daemon info 2018-12-29 14:38:59 +01:00
Benedikt Heine
ae58207f9b Use binary search for functions 2018-12-29 14:38:58 +01:00
Benedikt Heine
c35801b3ab Use a macro for method callbacks 2018-12-29 14:36:50 +01:00
Benedikt Heine
4fbb8fa75b Prefix dbus callbacks with dbus_cb_ 2018-12-29 14:31:31 +01:00
Benedikt Heine
b10bb292c6 Simplify DBus notification assembly 2018-12-29 14:31:31 +01:00
Benedikt Heine
52885ca6ad Use a hashtable for notification actions
As g_strv_contains is only available in GLib >= 2.44, we have to bump
the GLib requirements and the CI distros, too.
2018-12-29 14:30:55 +01:00
Benedikt Heine
db350883cc Improve extract_urls 2018-12-27 20:59:47 +01:00
Benedikt Heine
ecfe64c4bd Cleanup unused macros 2018-11-26 19:54:21 +01:00
Benedikt Heine
7e81506226 Remove colors field from xctx
The xctx color field is a full duplicate of the settings logic.
Only logic included in xctx color fields, are the frame colors, which
fall back to the global frame setting. So, this required to handle it
directly in settings.c
2018-11-26 19:54:07 +01:00
Benedikt Heine
3e205ff159 Use notification_colors struct in settings 2018-11-26 18:17:00 +01:00
Benedikt Heine
c3cd623f41 Use notification_colors struct for notification colors 2018-11-26 17:31:46 +01:00
Benedikt Heine
7ba6ca910f
Merge pull request #551 from bebehei/queues-tests
Queues tests
2018-11-26 10:50:58 +01:00
Benedikt Heine
93f6eb58a3 Remove n->start tests
These aren't used anymore. Any notification which gets moved from
waiting to displayed, will have set the start field with the current
monotonic time.

So testing start == 0 won't ever succeed in
queues_notification_is_finished, as the tested notification is contained
in the displayed queue. So the start field never will be 0.

Also there's no semantics for start being 0 in dunst actually
implemented.
2018-11-24 15:22:18 +01:00
Benedikt Heine
d96a29fed5 Move field definition on top of function (readability) 2018-11-24 15:22:18 +01:00