Commit 0c754aff authored by o9000's avatar o9000

Refactoring

parent 1e45abe9
......@@ -988,3 +988,17 @@ void execp_update_post_read(Execp *execp)
schedule_panel_redraw();
}
}
void handle_execp_events()
{
for (GList *l = panel_config.execp_list; l; l = l->next) {
Execp *execp = (Execp *)l->data;
if (read_execp(execp)) {
GList *l_instance;
for (l_instance = execp->backend->instances; l_instance; l_instance = l_instance->next) {
Execp *instance = (Execp *)l_instance->data;
execp_update_post_read(instance);
}
}
}
}
......@@ -148,4 +148,6 @@ void execp_update_post_read(Execp *execp);
void execp_default_font_changed();
void handle_execp_events();
#endif // EXECPLUGIN_H
......@@ -166,6 +166,8 @@ void init_post_config()
RED "Could not load default_icon.png. Please check that tint2 has been installed correctly!" RESET
"\n");
}
XSync(server.display, False);
}
void init_X11_pre_config()
......
This diff is collapsed.
......@@ -1149,3 +1149,60 @@ void _schedule_panel_redraw(const char *file, const char *function, const int li
fprintf(stderr, YELLOW "%s %s %d: triggering panel redraw" RESET "\n", file, function, line);
}
}
void save_panel_screenshot(const Panel *panel, const char *path)
{
imlib_context_set_drawable(panel->temp_pmap);
Imlib_Image img = imlib_create_image_from_drawable(0, 0, 0, panel->area.width, panel->area.height, 1);
if (!img) {
XImage *ximg =
XGetImage(server.display, panel->temp_pmap, 0, 0, panel->area.width, panel->area.height, AllPlanes, ZPixmap);
if (ximg) {
DATA32 *pixels = (DATA32 *)calloc(panel->area.width * panel->area.height, sizeof(DATA32));
for (int x = 0; x < panel->area.width; x++) {
for (int y = 0; y < panel->area.height; y++) {
DATA32 xpixel = XGetPixel(ximg, x, y);
DATA32 r = (xpixel >> 16) & 0xff;
DATA32 g = (xpixel >> 8) & 0xff;
DATA32 b = (xpixel >> 0) & 0xff;
DATA32 a = 0x0;
DATA32 argb = (a << 24) | (r << 16) | (g << 8) | b;
pixels[y * panel->area.width + x] = argb;
}
}
XDestroyImage(ximg);
img = imlib_create_image_using_data(panel->area.width, panel->area.height, pixels);
}
}
if (img) {
imlib_context_set_image(img);
if (!panel_horizontal) {
// rotate 90° vertical panel
imlib_image_flip_horizontal();
imlib_image_flip_diagonal();
}
imlib_save_image(path);
imlib_free_image();
}
}
void save_screenshot(const char *path)
{
Panel *panel = &panels[0];
if (panel->area.width > server.monitors[0].width)
panel->area.width = server.monitors[0].width;
panel->temp_pmap =
XCreatePixmap(server.display, server.root_win, panel->area.width, panel->area.height, server.depth);
render_panel(panel);
XSync(server.display, False);
save_panel_screenshot(panel, path);
}
......@@ -206,4 +206,7 @@ void default_font_changed();
void free_icon(Imlib_Image icon);
Imlib_Image scale_icon(Imlib_Image original, int icon_size);
void save_screenshot(const char *path);
void save_panel_screenshot(const Panel *panel, const char *path);
#endif
......@@ -98,6 +98,16 @@ void sigchld_handler_async()
}
}
void handle_sigchld_events()
{
if (sigchild_pipe_valid) {
char buffer[1];
while (read(sigchild_pipe[0], buffer, sizeof(buffer)) > 0) {
sigchld_handler_async();
}
}
}
void init_signals_postconfig()
{
gboolean need_sigchld = FALSE;
......
......@@ -6,7 +6,7 @@ void init_signals_postconfig();
void emit_self_restart(const char *reason);
int get_signal_pending();
void sigchld_handler_async();
void handle_sigchld_events();
extern int sigchild_pipe_valid;
extern int sigchild_pipe[2];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment