Compare commits

..

21 Commits

Author SHA1 Message Date
Chris Lee
c1a3cc7977 add refresh-execp message 2021-12-04 10:49:03 +01:00
Chris Lee
f8f9c18cef Release 17.0.2 2021-12-04 10:46:45 +01:00
Chris Lee
56bccf2b4f Update changelog 2021-12-04 10:45:36 +01:00
Chris Lee
ec4eccd769 Add tint2-send to cmake 2021-11-21 01:23:39 +01:00
Chris Lee
2ed026ba32 Attempt to fix get window monitor 2021-11-14 10:24:14 +01:00
Chris
a4996c84bd Update .gitlab-ci.yml file 2021-06-27 23:47:21 +00:00
Chris Lee
7b42055a20 add ci pipeline 2021-06-28 01:25:46 +02:00
Chris Lee
f628cba966 Release 17.0.1 2021-05-29 11:24:56 +02:00
Chris Lee
a922884485 update changelog 2021-05-01 19:16:51 +02:00
Chris Lee
66a6238014 fix crash in single-monitor execp 2021-05-01 19:15:38 +02:00
Chris Lee
5e8c65b87e remove useless fsync 2021-05-01 19:12:28 +02:00
Chris Lee
7737edff47 Release 17.0 2021-04-18 19:43:11 -07:00
Chris Lee
b7e7743b21 update changelog 2021-04-18 19:42:58 -07:00
Chris Lee
7232feee5a fix incorrect timeout microsecond computation 2021-04-14 23:38:36 +02:00
Chris
6b127f9661 Merge branch 'imlib-leak' into 'master'
Fix imlib image leak

Closes #704

See merge request o9000/tint2!39
2021-03-23 23:00:58 +00:00
Adam M. Trofa
e2641092b8 Fix imlib image leak
Double-adding the image caused imlib's reference count to increment
twice, requiring us to free it twice to actually release the cached
image, but we only ever free it once.

Fixes #704, likely #721 (leak is not present with -DENABLE_RSVG=OFF),
possibly #650 based on connection to execp, maybe others since this was
introduced nearly 6 years ago in 1d02b858 in launcher-specific code.
2021-03-19 19:44:25 -04:00
Chris Lee
49e7f54d2f preserve item order when skipping executors #799 2021-02-25 00:01:39 +01:00
Chris Lee
0f00212c58 add execp_monitor config #799 2021-02-24 22:08:20 +01:00
Chris Lee
dba0e66646 add scrollbars to fix issue #796 2021-01-26 23:15:51 +01:00
Chris Lee
2ed7ecb08d revert change to cmakefile 2021-01-04 22:21:50 +01:00
Chris Lee
f9cb16a0f0 attempt to port to gtk3 2021-01-04 22:06:31 +01:00
26 changed files with 246 additions and 72 deletions

34
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,34 @@
stages:
- build
- test
- release
variables:
DEBIAN_FRONTEND: 'noninteractive'
job-build:
stage: build
image: ubuntu:rolling
script:
- sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
- apt-get update
- apt-get build-dep -y tint2
- apt-get install -y libgtk-3-dev git
- git clean -ffdx
- mkdir build
- cd build
- cmake ..
- make -j
job-release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG =~ /^v.*/
script:
- echo 'running release_job'
release:
name: 'Release $CI_COMMIT_TAG'
description: 'Release $CI_COMMIT_TAG / $CI_COMMIT_SHA'
tag_name: '$CI_COMMIT_TAG'
ref: '$CI_COMMIT_SHA'

View File

@@ -286,6 +286,9 @@ add_dependencies( tint2 version )
set_target_properties( tint2 PROPERTIES COMPILE_FLAGS "-Wall -Wpointer-arith -fno-strict-aliasing -pthread -std=${CSTD} ${ASAN_C_FLAGS} ${TRACING_C_FLAGS}" )
set_target_properties( tint2 PROPERTIES LINK_FLAGS "-pthread -fno-strict-aliasing ${ASAN_L_FLAGS} ${BACKTRACE_L_FLAGS} ${TRACING_L_FLAGS}" )
add_executable(tint2-send src/tint2-send/tint2-send.c)
target_link_libraries(tint2-send ${X11_LIBRARIES})
install( TARGETS tint2 DESTINATION bin )
install( FILES tint2.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps )
install( FILES tint2.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications )

View File

@@ -1,3 +1,21 @@
2021-12-04 17.0.2
- Fixes:
- On dual monitor, when minimizing Chrome window it minimizes on the wrong monitor panel (issue #818)
2021-05-29 17.0.1
- Fixes:
- Crash on panel cleanup in single-monitor execp (issue #801)
2021-04-18 17.0
- Fixes:
- Crash when a window icon is large (issue #786) (santouits)
- Minute clock doesn't update (issue #786)
- Scrollbars in tint2conf (issue #796)
- Preserve item order when skipping executors (issue #799)
- Image memory leak (issues #704, #721) (Adam M. Trofa)
- Incorrect timeout microsecond computation leading to high CPU usage (issue #800)
- Enhancements:
- Port tint2conf to gtk3 (issue #380)
- execp_monitor config (issue #799)
- Improved executor examples (Nikita Zlobin)
2019-07-14 16.7
- Fixes:
- Fix spacing around icons in executor without text in vertical panels (issue #716)
@@ -1031,3 +1049,4 @@ released tint-0.2
.
.
.
.

View File

@@ -1,5 +1,5 @@
# Latest stable release: 16.7
Changes: https://gitlab.com/o9000/tint2/blob/16.7/ChangeLog
# Latest stable release: 17.0.2
Changes: https://gitlab.com/o9000/tint2/blob/17.0.2/ChangeLog
Documentation: [doc/tint2.md](doc/tint2.md)
@@ -8,7 +8,7 @@ Compile it with (after you install the [dependencies](https://gitlab.com/o9000/t
```
git clone https://gitlab.com/o9000/tint2.git
cd tint2
git checkout 16.7
git checkout 17.0.2
mkdir build
cd build
cmake ..

View File

@@ -609,6 +609,7 @@ panel_size = 94% 30
<li><p><code>execp_background_id = integer</code> : Which background to use. <em>(since 0.12.4)</em></p></li>
<li><p><code>execp_centered = boolean (0 or 1)</code> : Whether to center the text. <em>(since 0.12.4)</em></p></li>
<li><p><code>execp_padding = horizontal_padding vertical_padding spacing_between_icon_and_text</code> <em>(since 0.12.4)</em></p></li>
<li><p><code>execp_monitor = integer (1, 2, ...), primary or all</code> : On which monitor to draw the executor. The first monitor is <code>1</code>. <em>(since 17.0)</em></p></li>
<li><p><code>execp_lclick_command = text</code> : Command to execute on left click. If not defined, <code>execp_command</code> is executed immediately, unless it is currently running. <em>(since 0.12.4)</em></p></li>
<li><p><code>execp_mclick_command = text</code> : Command to execute on right click. If not defined, <code>execp_command</code> is executed immediately, unless it is currently running. <em>(since 0.12.4)</em></p></li>
<li><p><code>execp_rclick_command = text</code> : Command to execute on middle click. If not defined, <code>execp_command</code> is executed immediately, unless it is currently running. <em>(since 0.12.4)</em></p></li>
@@ -647,13 +648,13 @@ execp_command = ping -i 1 -c 1 -W 1 -O -D -n $(ip route | grep default | grep vi
execp_continuous = 0
execp_interval = 1
execp_markup = 1
</code></pre></div><h5 id="memory-usage">Memory usage<a name="memory-usage" href="#memory-usage" class="md2man-permalink" title="permalink"></a></h5><div class="highlight"><pre class="highlight plaintext"><code>execp = new
execp_command = free | awk '/^-/ { printf "Mem: '$(free -h | awk '/^Mem:/ { print $2 }')' %.0f%%\n", 100*$3/($3+$4); fflush(stdout) }'
execp_interval = 5
execp_continuous = 0
</code></pre></div><h5 id="network-load">Network load<a name="network-load" href="#network-load" class="md2man-permalink" title="permalink"></a></h5><div class="highlight"><pre class="highlight plaintext"><code># Note the use of "stdbuf -oL" to force the program to flush the output line by line.
</code></pre></div><h5 id="memory-usage">Memory usage<a name="memory-usage" href="#memory-usage" class="md2man-permalink" title="permalink"></a></h5><div class="highlight"><pre class="highlight plaintext"><code># Note the use of "stdbuf -oL" to force the program to flush the output line by line.
execp = new
execp_command = stdbuf -oL bwm-ng -o csv -t 1000 | awk -F ';' '/total/ { printf "Net: %.0f Mb/s\n", ($5*8/1.0e6) }; fflush(stdout)'
execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { printf "Mem: %s %.0f%%\n", $2, 100 * ($2 - $7) / $2 }' | stdbuf -oL numfmt --to=iec-i --field=2 -d' '
execp_interval = 1
execp_continuous = 1
</code></pre></div><h5 id="network-load">Network load<a name="network-load" href="#network-load" class="md2man-permalink" title="permalink"></a></h5><div class="highlight"><pre class="highlight plaintext"><code>execp = new
execp_command = stdbuf -oL bwm-ng -o csv -t 1000 | stdbuf -oL awk -F ';' '/total/ { printf "Net: %.0f Mb/s\n", ($5*8/1.0e6) }'
execp_continuous = 1
execp_interval = 1
</code></pre></div><h3 id="button">Button<a name="button" href="#button" class="md2man-permalink" title="permalink"></a></h3>

View File

@@ -199,9 +199,9 @@ pre {
</style>
</head>
<body>
<h1 id="latest-stable-release-16-7"><span class="md2man-title">Latest</span> <span class="md2man-section">stable</span> <span class="md2man-date">release:</span> <span class="md2man-source">16.7</span><a name="latest-stable-release-16-7" href="#latest-stable-release-16-7" class="md2man-permalink" title="permalink"></a></h1><p>Changes: <a href="https://gitlab.com/o9000/tint2/blob/16.7/ChangeLog">https://gitlab.com/o9000/tint2/blob/16.7/ChangeLog</a></p><p>Documentation: <a href="manual.html">manual.html</a></p><p>Compile it with (after you install the <a href="https://gitlab.com/o9000/tint2/wikis/Install#dependencies">dependencies</a>):</p><div class="highlight"><pre class="highlight plaintext"><code>git clone https://gitlab.com/o9000/tint2.git
<h1 id="latest-stable-release-17-0-2"><span class="md2man-title">Latest</span> <span class="md2man-section">stable</span> <span class="md2man-date">release:</span> <span class="md2man-source">17.0.2</span><a name="latest-stable-release-17-0-2" href="#latest-stable-release-17-0-2" class="md2man-permalink" title="permalink"></a></h1><p>Changes: <a href="https://gitlab.com/o9000/tint2/blob/17.0.2/ChangeLog">https://gitlab.com/o9000/tint2/blob/17.0.2/ChangeLog</a></p><p>Documentation: <a href="manual.html">manual.html</a></p><p>Compile it with (after you install the <a href="https://gitlab.com/o9000/tint2/wikis/Install#dependencies">dependencies</a>):</p><div class="highlight"><pre class="highlight plaintext"><code>git clone https://gitlab.com/o9000/tint2.git
cd tint2
git checkout 16.7
git checkout 17.0.2
mkdir build
cd build
cmake ..

View File

@@ -1,4 +1,4 @@
.TH TINT2 1 "2019\-07\-14" 16.7
.TH TINT2 1 "2021\-12\-04" 17.0.2
.SH NAME
.PP
tint2 \- lightweight panel/taskbar
@@ -748,6 +748,8 @@ To hide the clock, comment \fB\fCtime1_format\fR and \fB\fCtime2_format\fR\&.
.IP \(bu 2
\fB\fCexecp_padding = horizontal_padding vertical_padding spacing_between_icon_and_text\fR \fI(since 0.12.4)\fP
.IP \(bu 2
\fB\fCexecp_monitor = integer (1, 2, ...), primary or all\fR : On which monitor to draw the executor. The first monitor is \fB\fC1\fR\&. \fI(since 17.0)\fP
.IP \(bu 2
\fB\fCexecp_lclick_command = text\fR : Command to execute on left click. If not defined, \fB\fCexecp_command\fR is executed immediately, unless it is currently running. \fI(since 0.12.4)\fP
.IP \(bu 2
\fB\fCexecp_mclick_command = text\fR : Command to execute on right click. If not defined, \fB\fCexecp_command\fR is executed immediately, unless it is currently running. \fI(since 0.12.4)\fP
@@ -833,7 +835,7 @@ execp_markup = 1
.nf
# Note the use of "stdbuf \-oL" to force the program to flush the output line by line.
execp = new
execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { printf "Mem: %s %.0f%%\n", $2, 100 * ($2 - $7) / $2 }' | stdbuf -oL numfmt --to=iec-i --field=2 -d' '
execp_command = free \-b \-s1 | stdbuf \-oL awk '/^Mem:/ { printf "Mem: %s %.0f%%\\n", $2, 100 * ($2 \- $7) / $2 }' | stdbuf \-oL numfmt \-\-to=iec\-i \-\-field=2 \-d' '
execp_interval = 1
execp_continuous = 1
.fi
@@ -843,7 +845,7 @@ execp_continuous = 1
.RS
.nf
execp = new
execp_command = stdbuf \-oL bwm\-ng \-o csv \-t 1000 | stdbuf -oL awk \-F ';' '/total/ { printf "Net: %.0f Mb/s\\n", ($5*8/1.0e6) }'
execp_command = stdbuf \-oL bwm\-ng \-o csv \-t 1000 | stdbuf \-oL awk \-F ';' '/total/ { printf "Net: %.0f Mb/s\\n", ($5*8/1.0e6) }'
execp_continuous = 1
execp_interval = 1
.fi

View File

@@ -1,4 +1,4 @@
# TINT2 1 "2019-07-14" 16.7
# TINT2 1 "2021-12-04" 17.0.2
## NAME
tint2 - lightweight panel/taskbar
@@ -621,6 +621,8 @@ The action semantics:
* `execp_padding = horizontal_padding vertical_padding spacing_between_icon_and_text` *(since 0.12.4)*
* `execp_monitor = integer (1, 2, ...), primary or all` : On which monitor to draw the executor. The first monitor is `1`. *(since 17.0)*
* `execp_lclick_command = text` : Command to execute on left click. If not defined, `execp_command` is executed immediately, unless it is currently running. *(since 0.12.4)*
* `execp_mclick_command = text` : Command to execute on right click. If not defined, `execp_command` is executed immediately, unless it is currently running. *(since 0.12.4)*
* `execp_rclick_command = text` : Command to execute on middle click. If not defined, `execp_command` is executed immediately, unless it is currently running. *(since 0.12.4)*

View File

@@ -6,7 +6,7 @@ Build-Depends: cmake,
debhelper (>= 9),
libcairo2-dev,
libglib2.0-dev,
libgtk2.0-dev,
libgtk-3-dev,
libimlib2-dev,
libpango1.0-dev,
librsvg2-dev,

View File

@@ -697,6 +697,9 @@ void add_entry(char *key, char *value)
} else {
execp->backend->interval = v;
}
} else if (strcmp(key, "execp_monitor") == 0) {
Execp *execp = get_or_create_last_execp();
execp->backend->monitor = config_get_monitor(value);
} else if (strcmp(key, "execp_has_icon") == 0) {
Execp *execp = get_or_create_last_execp();
execp->backend->has_icon = atoi(value);

View File

@@ -43,13 +43,36 @@ Execp *create_execp()
execp->backend->cache_icon = TRUE;
execp->backend->centered = TRUE;
execp->backend->font_color.alpha = 0.5;
execp->backend->monitor = -1;
INIT_TIMER(execp->backend->timer);
execp->backend->bg = &g_array_index(backgrounds, Background, 0);
execp->backend->buf_stdout_capacity = 1024;
execp->backend->buf_stdout = calloc(execp->backend->buf_stdout_capacity, 1);
execp->backend->buf_stderr_capacity = 1024;
execp->backend->buf_stderr = calloc(execp->backend->buf_stderr_capacity, 1);
execp->backend->text = strdup("");
execp->backend->icon_path = NULL;
return execp;
}
gpointer create_execp_frontend(gconstpointer arg, gpointer data)
{
Execp *execp_backend = (Execp *)arg;
Panel *panel = data;
if (execp_backend->backend->monitor >= 0 &&
panel->monitor != execp_backend->backend->monitor) {
printf("Skipping executor '%s' with monitor %d for panel on monitor %d\n",
execp_backend->backend->command,
execp_backend->backend->monitor, panel->monitor);
Execp *dummy = create_execp();
dummy->frontend = (ExecpFrontend *)calloc(1, sizeof(ExecpFrontend));
dummy->backend->instances = g_list_append(dummy->backend->instances, dummy);
dummy->dummy = true;
return dummy;
}
printf("Creating executor '%s' with monitor %d for panel on monitor %d\n",
execp_backend->backend->command,
execp_backend->backend->monitor, panel->monitor);
Execp *execp_frontend = (Execp *)calloc(1, sizeof(Execp));
execp_frontend->backend = execp_backend->backend;
@@ -67,7 +90,11 @@ void destroy_execp(void *obj)
free_and_null(execp->frontend);
remove_area(&execp->area);
free_area(&execp->area);
free_and_null(execp);
if (execp->dummy) {
destroy_execp(execp);
} else {
free_and_null(execp);
}
} else {
// This is a backend element
destroy_timer(&execp->backend->timer);
@@ -144,12 +171,6 @@ void init_execp()
// Set missing config options
if (!execp->backend->bg)
execp->backend->bg = &g_array_index(backgrounds, Background, 0);
execp->backend->buf_stdout_capacity = 1024;
execp->backend->buf_stdout = calloc(execp->backend->buf_stdout_capacity, 1);
execp->backend->buf_stderr_capacity = 1024;
execp->backend->buf_stderr = calloc(execp->backend->buf_stderr_capacity, 1);
execp->backend->text = strdup("");
execp->backend->icon_path = NULL;
}
}
@@ -163,7 +184,7 @@ void init_execp_panel(void *p)
// panel->execp_list is now a copy of the pointer panel_config.execp_list
// We make it a deep copy
panel->execp_list = g_list_copy_deep(panel_config.execp_list, create_execp_frontend, NULL);
panel->execp_list = g_list_copy_deep(panel_config.execp_list, create_execp_frontend, panel);
for (GList *l = panel->execp_list; l; l = l->next) {
Execp *execp = l->data;

View File

@@ -24,6 +24,7 @@ typedef struct ExecpBackend {
char *command;
// Interval in seconds
int interval;
int monitor;
// 1 if first line of output is an icon path
gboolean has_icon;
gboolean cache_icon;
@@ -96,6 +97,7 @@ typedef struct Execp {
ExecpBackend *backend;
// Set only for frontend Execp items.
ExecpFrontend *frontend;
bool dummy;
} Execp;
// Called before the config is read and panel_config/panels are created.

View File

@@ -545,6 +545,11 @@ void handle_x_event(XEvent *e)
handle_dnd_position(&e->xclient);
} else if (e->xclient.message_type == server.atom.XdndDrop) {
handle_dnd_drop(&e->xclient);
} else if (e->xclient.message_type == server.atom.TINT2_REFRESH_EXECP &&
e->xclient.format == 8) {
char name[sizeof(e->xclient.data.b) + 1] = {};
memcpy(name, e->xclient.data.b, sizeof(e->xclient.data.b));
printf("TODO: refresh execp: %s\n", name);
}
break;
}

View File

@@ -269,8 +269,9 @@ void init_panel()
init_freespace_panel(p);
if (panel_items_order[k] == ':')
init_separator_panel(p);
if (panel_items_order[k] == 'E')
if (panel_items_order[k] == 'E') {
init_execp_panel(p);
}
if (panel_items_order[k] == 'P')
init_button_panel(p);
}

View File

@@ -1,12 +0,0 @@
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
tint2-send: tint2-send.c
$(CC) tint2-send.c -lX11 -o tint2-send
install: tint2-send
install -m 755 tint2-send $(DESTDIR)/$(PREFIX)/bin/
clean:
rm -f tint2-send

View File

@@ -60,11 +60,10 @@ int is_tint2(Window window)
return class_match;
}
void handle_tint2_window(Window window, void *arg)
void handle_tint2_window(Window window, char *action, char **args)
{
if (!is_tint2(window))
return;
char *action = (char *)arg;
if (strcmp(action, "show") == 0) {
fprintf(stderr, "Showing tint2 window: %lx\n", window);
XEvent event = {};
@@ -85,16 +84,40 @@ void handle_tint2_window(Window window, void *arg)
event.xcrossing.same_screen = True;
XSendEvent(display, window, False, 0, &event);
XFlush(display);
} else if (strcmp(action, "refresh-execp") == 0) {
XEvent event = {};
char *name = args[0];
if (!name) {
fprintf(stderr, "Error: missing execp name\n");
return;
}
if (!name[0]) {
fprintf(stderr, "Error: empty execp name\n");
return;
}
if (strlen(name) > sizeof(event.xclient.data.b)) {
fprintf(stderr, "Error: execp name too long\n");
return;
}
fprintf(stderr, "Refreshing execp '%s' for window: %lx\n", name, window);
event.xclient.type = ClientMessage;
event.xclient.window = window;
event.xclient.send_event = True;
event.xclient.message_type = XInternAtom(display, "_TINT2_REFRESH_EXECP", False);
event.xclient.format = 8;
strncpy(event.xclient.data.b, name, sizeof(event.xclient.data.b));
XSendEvent(display, window, False, 0, &event);
XFlush(display);
} else {
fprintf(stderr, "Error: unknown action %s\n", action);
}
}
typedef void window_callback_t(Window window, void *arg);
typedef void window_callback_t(Window window, char *action, char **args);
void walk_windows(Window node, window_callback_t *callback, void *arg)
void walk_windows(Window node, window_callback_t *callback, char *action, char **args)
{
callback(node, arg);
callback(node, action, args);
Window root = 0;
Window parent = 0;
Window *children = 0;
@@ -104,7 +127,7 @@ void walk_windows(Window node, window_callback_t *callback, void *arg)
return;
}
for (unsigned int i = 0; i < nchildren; i++) {
walk_windows(children[i], callback, arg);
walk_windows(children[i], callback, action, args);
}
}
@@ -118,11 +141,12 @@ int main(int argc, char **argv)
argc--, argv++;
if (!argc) {
fprintf(stderr, "Usage: tint2-show [show|hide]\n");
fprintf(stderr, "Usage: tint2-show [show|hide|refresh-execp]\n");
exit(1);
}
char *action = argv[0];
walk_windows(DefaultRootWindow(display), handle_tint2_window, action);
char **args = argv + 1;
walk_windows(DefaultRootWindow(display), handle_tint2_window, action, args);
return 0;
}

View File

@@ -70,7 +70,7 @@ add_definitions( -DINSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\" )
add_definitions( -DLOCALEDIR=\"${CMAKE_INSTALL_FULL_LOCALEDIR}\" )
add_definitions( -DGETTEXT_PACKAGE=\"tint2conf\" )
add_definitions( -DDGLIB_DISABLE_DEPRECATION_WARNINGS=1 )
set_target_properties( tint2conf PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wpointer-arith -fno-strict-aliasing -pthread -std=c99 -Werror-implicit-function-declaration -Wno-deprecated -Wno-deprecated-declarations" )
set_target_properties( tint2conf PROPERTIES COMPILE_FLAGS "-Wall -Wpointer-arith -fno-strict-aliasing -pthread -std=c99 -Werror-implicit-function-declaration -Wno-deprecated -Wno-deprecated-declarations" )
set_target_properties( tint2conf PROPERTIES LINK_FLAGS "-pthread" )
add_subdirectory(po)

View File

@@ -234,10 +234,17 @@ GtkWidget *create_properties()
dialog_vbox3 = gtk_dialog_get_content_area(GTK_DIALOG(view));
gtk_widget_show(dialog_vbox3);
GtkWidget *scroll = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_box_pack_start(GTK_BOX(dialog_vbox3), scroll, TRUE, TRUE, 1);
gtk_widget_show(scroll);
notebook = gtk_notebook_new();
gtk_widget_show(notebook);
gtk_container_set_border_width(GTK_CONTAINER(notebook), 5);
gtk_box_pack_start(GTK_BOX(dialog_vbox3), notebook, TRUE, TRUE, 6);
gtk_container_add(GTK_CONTAINER(scroll), notebook);
gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_LEFT);
button = gtk_button_new_from_stock("gtk-apply");
@@ -4367,6 +4374,31 @@ void create_execp(GtkWidget *notebook, int i)
"that print data downloaded from the Internet is a potential security risk."),
NULL);
row++, col = 2;
label = gtk_label_new(_("Monitor"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_widget_show(label);
gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
col++;
executor->execp_monitor = gtk_combo_box_text_new();
gtk_widget_show(executor->execp_monitor);
gtk_table_attach(GTK_TABLE(table), executor->execp_monitor, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
col++;
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(executor->execp_monitor), _("All"));
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(executor->execp_monitor), _("Primary"));
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(executor->execp_monitor), _("1"));
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(executor->execp_monitor), _("2"));
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(executor->execp_monitor), _("3"));
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(executor->execp_monitor), _("4"));
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(executor->execp_monitor), _("5"));
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(executor->execp_monitor), _("6"));
gtk_combo_box_set_active(GTK_COMBO_BOX(executor->execp_monitor), 0);
gtk_tooltips_set_tip(tooltips,
executor->execp_monitor,
_("Specifies the monitor on which to place the executor."),
NULL);
change_paragraph(parent);
label = gtk_label_new(_("<b>Mouse events</b>"));

View File

@@ -133,7 +133,7 @@ typedef struct Executor {
GtkWidget *page_execp;
GtkWidget *page_label;
GtkWidget *execp_command, *execp_interval, *execp_has_icon, *execp_cache_icon, *execp_show_tooltip;
GtkWidget *execp_continuous, *execp_markup, *execp_tooltip;
GtkWidget *execp_continuous, *execp_markup, *execp_tooltip, *execp_monitor;
GtkWidget *execp_left_command, *execp_right_command;
GtkWidget *execp_mclick_command, *execp_rclick_command, *execp_uwheel_command, *execp_dwheel_command;
GtkWidget *execp_font, *execp_font_set, *execp_font_color, *execp_padding_x, *execp_padding_y, *execp_centered;

View File

@@ -871,6 +871,16 @@ void config_write_execp(FILE *fp)
fprintf(fp,
"execp_markup = %d\n",
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_markup)) ? 1 : 0);
fprintf(fp, "execp_monitor = ");
if (gtk_combo_box_get_active(GTK_COMBO_BOX(executor->execp_monitor)) <= 0) {
fprintf(fp, "all");
} else if (gtk_combo_box_get_active(GTK_COMBO_BOX(executor->execp_monitor)) == 1) {
fprintf(fp, "primary");
} else {
fprintf(fp, "%d", MAX(1, gtk_combo_box_get_active(GTK_COMBO_BOX(executor->execp_monitor)) - 1));
}
fprintf(fp, "\n");
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_show_tooltip))) {
fprintf(fp, "execp_tooltip = \n");
} else {
@@ -1964,6 +1974,23 @@ void add_entry(char *key, char *value)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_continuous), atoi(value));
} else if (strcmp(key, "execp_markup") == 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_markup), atoi(value));
} else if (strcmp(key, "execp_monitor") == 0) {
if (strcmp(value, "all") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_monitor), 0);
else if (strcmp(value, "primary") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_monitor), 1);
else if (strcmp(value, "1") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_monitor), 2);
else if (strcmp(value, "2") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_monitor), 3);
else if (strcmp(value, "3") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_monitor), 4);
else if (strcmp(value, "4") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_monitor), 5);
else if (strcmp(value, "5") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_monitor), 6);
else if (strcmp(value, "6") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_monitor), 7);
} else if (strcmp(key, "execp_tooltip") == 0) {
if (strlen(value) > 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_show_tooltip), 1);

View File

@@ -794,8 +794,8 @@ Imlib_Image load_image(const char *path, int cached)
static unsigned long counter = 0;
if (debug_icons)
fprintf(stderr, "tint2: loading icon %s\n", path);
#ifdef HAVE_RSVG
image = imlib_load_image(path);
#ifdef HAVE_RSVG
if (!image && g_str_has_suffix(path, ".svg")) {
char tmp_filename[128];
snprintf(tmp_filename, sizeof(tmp_filename), "/tmp/tint2-%d-%lu.png", (int)getpid(), counter);
@@ -825,11 +825,8 @@ Imlib_Image load_image(const char *path, int cached)
unlink(tmp_filename);
}
}
} else
#endif
{
image = imlib_load_image(path);
}
#endif
imlib_context_set_image(image);
imlib_image_set_changes_on_disk();
return image;

View File

@@ -122,6 +122,9 @@ void server_init_atoms()
server.atom.XdndActionCopy = XInternAtom(server.display, "XdndActionCopy", False);
server.atom.XdndFinished = XInternAtom(server.display, "XdndFinished", False);
server.atom.TARGETS = XInternAtom(server.display, "TARGETS", False);
// tint2 atoms
server.atom.TINT2_REFRESH_EXECP = XInternAtom(server.display, "_TINT2_REFRESH_EXECP", False);
}
const char *GetAtomName(Display *disp, Atom a)

View File

@@ -91,6 +91,7 @@ typedef struct Global_atom {
Atom XdndActionCopy;
Atom XdndFinished;
Atom TARGETS;
Atom TINT2_REFRESH_EXECP;
} Global_atom;
typedef struct Property {

View File

@@ -85,7 +85,6 @@ static void sigchld_handler(int sig)
int savedErrno = errno;
ssize_t unused = write(sigchild_pipe[1], "x", 1);
(void)unused;
fsync(sigchild_pipe[1]);
errno = savedErrno;
}

View File

@@ -131,7 +131,8 @@ struct timeval *get_duration_to_next_timer_expiration()
next_timer->expiration_time_ms_,
next_timer->period_ms_);
result.tv_sec = duration / 1000;
result.tv_usec = 1000 * (duration - result.tv_sec);
duration -= result.tv_sec * 1000;
result.tv_usec = 1000 * duration;
return &result;
}

View File

@@ -169,31 +169,40 @@ int get_window_desktop(Window win)
return best_match;
}
#define swap(a, b) do { __typeof__(a) _tmp = (a); (a) = (b); (b) = _tmp; } while(0)
int get_interval_overlap(int a1, int a2, int b1, int b2)
{
if (a1 > b1) {
swap(a1, b1);
swap(a2, b2);
}
if (b1 <= a2)
return a2 - b1;
return 0;
}
int get_window_monitor(Window win)
{
int x, y, w, h;
get_window_coordinates(win, &x, &y, &w, &h);
int best_match = -1;
int match_right = 0;
int match_bottom = 0;
// There is an ambiguity when a window is right on the edge between screens.
// In that case, prefer the monitor which is on the right and bottom of the window's top-left corner.
int best_match = 0;
int best_area = -1;
for (int i = 0; i < server.num_monitors; i++) {
if (x >= server.monitors[i].x && x <= (server.monitors[i].x + server.monitors[i].width) &&
y >= server.monitors[i].y && y <= (server.monitors[i].y + server.monitors[i].height)) {
int current_right = x < (server.monitors[i].x + server.monitors[i].width);
int current_bottom = y < (server.monitors[i].y + server.monitors[i].height);
if (best_match < 0 || (!match_right && current_right) || (!match_bottom && current_bottom)) {
best_match = i;
}
int commonx = get_interval_overlap(x, x + w, server.monitors[i].x, server.monitors[i].x + server.monitors[i].width);
int commony = get_interval_overlap(y, y + h, server.monitors[i].y, server.monitors[i].y + server.monitors[i].height);
int area = commonx * commony;
if (0)
printf("Monitor %d (%dx%d+%dx%d): win (%dx%d+%dx%d) area %dx%d=%d\n",
i, server.monitors[i].x, server.monitors[i].y, server.monitors[i].width, server.monitors[i].height,
x, y, w, h,
commonx, commony, area);
if (area > best_area) {
best_area = area;
best_match = i;
}
}
if (best_match < 0)
best_match = 0;
// fprintf(stderr, "tint2: desktop %d, window %lx %s : monitor %d, (%d, %d)\n", 1 + get_current_desktop(), win,
// get_task(win) ? get_task(win)->title : "??", best_match+1, x, y);
return best_match;
}