81 Commits

Author SHA1 Message Date
Benedikt Heine
a6abfdf7c5 Include all local files relatively 2018-11-15 15:17:48 +01:00
Benedikt Heine
08019dc268 Move context_menu into right header 2018-10-31 15:19:24 +01:00
Benedikt Heine
c0e2a2a7e3 Move all strcmp operations to STR*EQ macros 2018-10-09 10:08:17 +02:00
Benedikt Heine
516161e765 Typo 2018-10-08 17:38:00 +02:00
Nikos Tsipinakis
740ebdd5a3
Merge pull request #545 from tsipinakis/bugfix/x11-opt
Draw event optimizations
2018-09-24 20:25:17 +03:00
Nikos Tsipinakis
7ac054b3cc Simplify window showing and hiding
As suggested by @bebehei make x_win_{show,hide} callable at any time and
avoid double checking the queue length.
2018-09-20 10:49:40 +03:00
Nikos Tsipinakis
69100790a1 Do not wake up on focus events
Focus events do not mark any change in state of the notifications so
calling wake_up as a response is a wake of CPU cycles. Instead treat
them like PropertyNotify and only redraw if we need to change monitors.
2018-09-20 10:40:05 +03:00
Benedikt Heine
bbbddad3a7 Use structs for notifications 2018-09-16 02:58:31 +02:00
Benedikt Heine
c944949e36 Pack types from x.c into structs 2018-09-16 02:58:13 +02:00
Benedikt Heine
f14b0b2b4a Show xmore layout only when needed
For the case, that there is a single notification waiting in queue, the
xmore layout is an annoying setting.
2018-09-13 12:08:41 +02:00
Zijung Chueh
7a22fa0e5f Fix code style
* Move mouse_left/middle/right_click to global section
  * Match the enum value style
  * Ignore unknow mouse event
  * Split copy-paste code into a function
  * Fix typo
2018-07-13 14:45:38 +08:00
Zijung Chueh
fbcc26b5e1 Add options to specify mouse event 2018-07-13 01:40:20 +08:00
Benedikt Heine
368182f4d7 Log XEvents by their written names
All XEvents only got logged with their IDs. It makes more sense to write
out the XEvent's name. Also, writing that we received an XEvent and then
logging again, that we ignored it, makes no sense.
2018-07-10 13:35:51 +02:00
Benedikt Heine
f4fb95c827 Do not make explicit NULL checks on elements
Most of the NULL checks are actually doubly false logic. Turning the
logic around and removing the NULL check makes the program easier to
read.
2018-07-10 13:23:12 +02:00
Nikos Tsipinakis
8b2d5c49ba
Merge pull request #523 from bebehei/xfreegc
Fix X11 memoryleak for round corners
2018-06-23 16:51:11 +03:00
Benedikt Heine
0e5034b02a Fix X11 memoryleak for round corners
When using round corners, the shape_gc in x_win_round_corners never got
freed. This created a memory leak in x11 itself and let the X process
create more load while becoming sluggish in some situations.

From the docs, XFreeGC actually could return an int and could throw a
BadGC error. Neither of them are important to catch in our situation:

- Having a look into the Xlib sourcecode, XFreeGC returns always 1.
- As we don't overwrite the shape_gc or do any other destoying calls,
  the BadGC can't happen in this code.
2018-06-22 11:55:34 +02:00
Benedikt Heine
0a057450fe Fix typos 2018-06-11 14:10:07 +02:00
Nikos Tsipinakis
a0f21f5c26 Stop trying to setup round corners with 0 radius
If corner_radius is 0 we do not need to do the entire process of setting
up the shaped window.
2018-05-29 11:36:51 +03:00
Benedikt Heine
aab9fef78c Simplify corner arcs in X11 code 2018-05-28 13:41:31 +03:00
dj95
a3034d5f62 Implement support for round corners 2018-05-28 13:36:45 +03:00
Nikos Tsipinakis
4891710af3 Refactor window_x11 struct to be opaque
This removes window accesses from outside the x.c file which will allow
us to abstract the window struct to implement multiple outputs in the
future.
2018-05-14 10:39:46 +03:00
Benedikt Heine
119340c07d Remove unused and superfluous macro definitions 2018-05-14 09:31:53 +03:00
Nikos Tsipinakis
1fe80a5db8 Refactor x event to use g_source_add_unix_fd
According to the glib docs we should use g_source_add_unix_fd rather
than g_source_add_poll. Additionally, this helps us with memory
management since we don't have to handle the allocation of dpy_pollfd.
2018-05-14 09:31:53 +03:00
Nikos Tsipinakis
adc075bf2c Cleanup x.h prototypes 2018-05-14 09:31:53 +03:00
Nikos Tsipinakis
90dd111970 Refactor x11 event source to handle multiple windows
Move the code to register the x11 event source under x_win_create so
multiple windows can be created and be properly registered as the event
source.

One more missing piece is that the callback functions are still using
the global win variable and not getting the window from the source.
2018-05-14 09:31:53 +03:00
Nikos Tsipinakis
c29b1a39fb Refactor window positioning and surface rendering into x.c
Move the double-buffering implementation and the x_win_call move into
x.c so we only need to call x_display_surface for each draw.

This isolates all uses of the cairo context and root surface outside of
x.c which will help to add support for other display servers.
2018-05-14 09:31:53 +03:00
Nikos Tsipinakis
72aab3daf4 Refactor window creation and destruction
Move the main window reference from xctx to draw.c and at the same time
make each X11 function that modifies the window require the pointer as a
parameter. This makes it easier to implement features that require
multiple windows.
2018-05-14 09:31:53 +03:00
Nikos Tsipinakis
bec02ef6a0 Fix wrong return value in x11 event dispatch
According to glib docs the dispatch function should be G_SOURCE_REMOVE
or G_SOURCE_CONTINUE. Since this was worked properly until now I assume
we were lucky enough that true == G_SOURCE_CONTINUE but it may not
always be the case.
2018-05-14 09:31:53 +03:00
Nikos Tsipinakis
dffe1e1a5a Fix dunst losing on-top status on WM restart
Subscribe to receive window creation events on the root window and raise
the window when that happens to ensure dunst is on top.
We do not raise the window when another override redirect window is
created to avoid being on top of things like screen lockers.

Fixes #160
2018-05-14 09:31:53 +03:00
Nikos Tsipinakis
f513d8417f Move positioning logic out of x_win_move 2018-05-14 09:30:42 +03:00
Nikos Tsipinakis
a2863d5312 Move window-related fields to dedicated struct
The first step in allowing dunst to have multiple windows.
2018-05-14 09:30:42 +03:00
Nikos Tsipinakis
ce5c49f0e8 Remove dead code from XEvent handler
According to the X11 docs XSelectionNotify event is generated from a
response to the ConvertSelection protocol which we don't use.
2018-05-14 09:30:42 +03:00
Nikos Tsipinakis
651be8eee9 Avoid using dimensions struct for unrelated uses
The `dimension_t` struct was used in many different places and even held
on the geometry info at some point which is counter-intuitive as it's
best to have each struct serve a single purpose.
2018-05-14 09:11:25 +03:00
Nikos Tsipinakis
a7fd3cb0ec Move geometry handling to settings
Change the value of geometry in settings from an unparsed string to a
struct containing the properly parsed geometry info. Since we depend on
X11 for geometry parsing this (unfortunately) introduces an X11
dependency on the settings module, this can only be resolved if we
implement our own parsing.
2018-05-14 09:11:25 +03:00
Nikos Tsipinakis
5895593d0b Remove leftover cairo variables in x.c
Clean-up x.c from cairo items that were left over after the move to
draw.c.
2018-05-06 13:47:24 +03:00
Nikos Tsipinakis
466f95eb91 Move drawing functions to draw.c
Copy-paste all the drawing functions from x.c to draw.c. In the spirit
of making changes easily traceable the minimal amount of changes
required to make the functions work was made. Further improvement (like
removing the cairo-xlib dependency) will be done in later commits.
2018-05-06 13:47:24 +03:00
Nikos Tsipinakis
045ec98c0e Setup initial file for draw.c
Setup the initial template for draw.c to be between X11 calls and the
rest of the codebase. This prepares the file to move all the drawing
related function here in the next commit.
2018-05-06 13:47:24 +03:00
Nikos Tsipinakis
52055f12c7 Move icon related methods to icon.c
The first step to cleaning out x.c.
2018-05-06 13:47:20 +03:00
Nikos Tsipinakis
7a9187728c Merge branch 'maint' 2018-05-06 13:36:07 +03:00
Nikos Tsipinakis
6ebe7ca413 Fix crash when loading an invalid or corrupted icon
GError values should be freed with g_error_free rather than g_free it
otherwise causes a crash.

Credit to @bebehei for discovering this.
2018-05-06 13:21:47 +03:00
Benedikt Heine
0cf4753a68 Wake up for fullscreen change events
The PropertyNotify handling has been changed in the dropgtk branch to
ignore XEvents, when redrawing was unnecessary. But when the fullscreen
state of a window changes, we can't ignore the event, because it didn't
change the screen.

Additionally, there had been a mistake in the handling of the cur_screen:
The xctx.cur_screen field will only get updated, when the application is
visible and gets redrawn. Therefore, when a PropertyNotify event arrived
while the application had been hidden and the screens do not match
anymore, wake_up() will be called albeit being unnecessary.

Calling x_win_draw() when the screens change is also the preferable
solution over wake_up(), as there is nothing subject to change in the
queues when the displays change.
2018-02-25 20:44:31 +01:00
Benedikt Heine
c12873184c Debug processed XEvents 2018-02-25 20:44:23 +01:00
Benedikt Heine
3b6c5299be Use void as argument for parameterless functions 2018-02-20 16:24:00 +01:00
Benedikt Heine
6402218205 Remove negative NULL-check warning
According to the docs in the GSourceFuncs, the timeout_ parameter can be
NULL. But when it's NULL, it would be equivalent to an invocation to
return -1 as timeout_ and FALSE as return value. This is exactly the
same, what we're doing if timeout_ is not NULL.
2018-02-02 17:29:05 +01:00
Benedikt Heine
38dced7591 Translate last unusual logging calls 2018-02-02 17:29:04 +01:00
Benedikt Heine
19b364d67c Translate fprintf statements into log messages 2018-02-02 17:29:04 +01:00
Benedikt Heine
020a90e521 Replace die method with appropriate critical log 2018-02-02 17:29:04 +01:00
Benedikt Heine
8f5afaafb6 Do not redraw window on PropertyChange
When receiving a PropertyChange XEvent, it's mostly because the focus of
another window changed to another window. This isn't actually neccessary
for dunst. We need the event only, to know, when the screens have
switched.

As redrawing the screen became more expensive with the drop of GTK3, we
have to ignore this event and only really redraw the window, when the
focus has moved to another screen.
2017-12-25 15:53:20 +01:00
Benedikt Heine
d7ec8bf165 Explain counterintuitive gdk pixbuf conversion 2017-12-22 22:27:08 +01:00
Benedikt Heine
a6dea0cc35 Use GByteArray for bytebuffer in pixbuf conversion 2017-12-22 22:27:08 +01:00