fixed bug with "task on all desktop" (issue 39), fixed memory corruption
git-svn-id: http://tint2.googlecode.com/svn/trunk@26 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
parent
067f07625e
commit
d818e66097
15 changed files with 177 additions and 74 deletions
|
@ -1,4 +1,9 @@
|
||||||
|
|
||||||
|
2009-01-18
|
||||||
|
- update documentation for new config format
|
||||||
|
- fixed memory corruption
|
||||||
|
- fixed bug with "task on all desktop" (issue 39)
|
||||||
|
|
||||||
2009-01-17
|
2009-01-17
|
||||||
- fixed drawing of active task (with new layout)
|
- fixed drawing of active task (with new layout)
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ void init_clock(Clock *clock, int panel_height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void draw_foreground_clock (void *obj, cairo_t *c)
|
void draw_foreground_clock (void *obj, cairo_t *c, int active)
|
||||||
{
|
{
|
||||||
Clock *clock = obj;
|
Clock *clock = obj;
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
|
|
|
@ -32,7 +32,7 @@ typedef struct Clock {
|
||||||
// initialize clock : y position, precision, ...
|
// initialize clock : y position, precision, ...
|
||||||
void init_clock(Clock *clock, int panel_height);
|
void init_clock(Clock *clock, int panel_height);
|
||||||
|
|
||||||
void draw_foreground_clock (void *obj, cairo_t *c);
|
void draw_foreground_clock (void *obj, cairo_t *c, int active);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,7 +35,8 @@ void visual_refresh ()
|
||||||
set_panel_background();
|
set_panel_background();
|
||||||
|
|
||||||
if (server.pmap) XFreePixmap (server.dsp, server.pmap);
|
if (server.pmap) XFreePixmap (server.dsp, server.pmap);
|
||||||
server.pmap = server_create_pixmap (panel.area.width, panel.area.height);
|
server.pmap = XCreatePixmap (server.dsp, server.root_win, panel.area.width, panel.area.height, server.depth);
|
||||||
|
|
||||||
XCopyArea (server.dsp, panel.area.pix.pmap, server.pmap, server.gc, 0, 0, panel.area.width, panel.area.height, 0, 0);
|
XCopyArea (server.dsp, panel.area.pix.pmap, server.pmap, server.gc, 0, 0, panel.area.width, panel.area.height, 0, 0);
|
||||||
|
|
||||||
// draw child object
|
// draw child object
|
||||||
|
@ -176,7 +177,8 @@ void set_panel_background()
|
||||||
{
|
{
|
||||||
Pixmap wall = get_root_pixmap();
|
Pixmap wall = get_root_pixmap();
|
||||||
|
|
||||||
panel.area.pix.pmap = server_create_pixmap (panel.area.width, panel.area.height);
|
if (panel.area.pix.pmap) XFreePixmap (server.dsp, panel.area.pix.pmap);
|
||||||
|
panel.area.pix.pmap = XCreatePixmap (server.dsp, server.root_win, panel.area.width, panel.area.height, server.depth);
|
||||||
|
|
||||||
// add layer of root pixmap
|
// add layer of root pixmap
|
||||||
XCopyArea (server.dsp, wall, panel.area.pix.pmap, server.gc, server.posx, server.posy, panel.area.width, panel.area.height, 0, 0);
|
XCopyArea (server.dsp, wall, panel.area.pix.pmap, server.gc, server.posx, server.posy, panel.area.width, panel.area.height, 0, 0);
|
||||||
|
|
|
@ -135,12 +135,6 @@ void *server_get_property (Window win, Atom at, Atom type, int *num_results)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Pixmap server_create_pixmap (int width, int height)
|
|
||||||
{
|
|
||||||
return XCreatePixmap (server.dsp, server.root_win, width, height, server.depth);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Pixmap get_root_pixmap ()
|
Pixmap get_root_pixmap ()
|
||||||
{
|
{
|
||||||
Pixmap ret;
|
Pixmap ret;
|
||||||
|
|
|
@ -97,7 +97,6 @@ void server_refresh_root_pixmap ();
|
||||||
void server_refresh_main_pixmap ();
|
void server_refresh_main_pixmap ();
|
||||||
void server_catch_error (Display *d, XErrorEvent *ev);
|
void server_catch_error (Display *d, XErrorEvent *ev);
|
||||||
void server_init_atoms ();
|
void server_init_atoms ();
|
||||||
Pixmap server_create_pixmap (int width, int height);
|
|
||||||
void get_monitors();
|
void get_monitors();
|
||||||
Pixmap get_root_pixmap();
|
Pixmap get_root_pixmap();
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,8 @@ void add_task (Window win)
|
||||||
Task *new_tsk;
|
Task *new_tsk;
|
||||||
int desktop, monitor;
|
int desktop, monitor;
|
||||||
|
|
||||||
if (!win || window_is_hidden (win) || win == window.main_win) return;
|
if (!win) return;
|
||||||
|
if (window_is_hidden (win) || win == window.main_win) return;
|
||||||
|
|
||||||
new_tsk = malloc(sizeof(Task));
|
new_tsk = malloc(sizeof(Task));
|
||||||
new_tsk->win = win;
|
new_tsk->win = win;
|
||||||
|
@ -55,31 +56,46 @@ void add_task (Window win)
|
||||||
//if (panel.mode == MULTI_MONITOR) monitor = window_get_monitor (new_tsk->win);
|
//if (panel.mode == MULTI_MONITOR) monitor = window_get_monitor (new_tsk->win);
|
||||||
//else monitor = 0;
|
//else monitor = 0;
|
||||||
//printf("task %s : desktop %d, monitor %d\n", new_tsk->title, desktop, monitor);
|
//printf("task %s : desktop %d, monitor %d\n", new_tsk->title, desktop, monitor);
|
||||||
|
|
||||||
XSelectInput (server.dsp, new_tsk->win, PropertyChangeMask|StructureNotifyMask);
|
XSelectInput (server.dsp, new_tsk->win, PropertyChangeMask|StructureNotifyMask);
|
||||||
|
|
||||||
|
Taskbar *tskbar;
|
||||||
if (desktop == 0xFFFFFFFF) {
|
if (desktop == 0xFFFFFFFF) {
|
||||||
if (new_tsk->title) {
|
tskbar = &panel.taskbar[index(0, monitor)];
|
||||||
free (new_tsk->title);
|
new_tsk->all_desktop = 1;
|
||||||
new_tsk->title = 0;
|
}
|
||||||
}
|
else {
|
||||||
if (new_tsk->icon_data) {
|
tskbar = &panel.taskbar[index(desktop, monitor)];
|
||||||
free (new_tsk->icon_data);
|
new_tsk->all_desktop = 0;
|
||||||
new_tsk->icon_data = 0;
|
|
||||||
}
|
|
||||||
free(new_tsk);
|
|
||||||
fprintf(stderr, "task on all desktop : ignored\n");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("add_task %d %s\n", index(desktop, monitor), new_tsk->title);
|
//printf("add_task %d %s\n", index(desktop, monitor), new_tsk->title);
|
||||||
Taskbar *tskbar;
|
|
||||||
tskbar = &panel.taskbar[index(desktop, monitor)];
|
|
||||||
new_tsk->area.parent = tskbar;
|
new_tsk->area.parent = tskbar;
|
||||||
tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk);
|
tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk);
|
||||||
|
|
||||||
if (resize_tasks (tskbar))
|
if (resize_tasks (tskbar))
|
||||||
set_redraw (&tskbar->area);
|
set_redraw (&tskbar->area);
|
||||||
|
|
||||||
|
if (desktop == 0xFFFFFFFF) {
|
||||||
|
// task on all desktop
|
||||||
|
int i;
|
||||||
|
Task *new_tsk2;
|
||||||
|
for (i = 1 ; i < server.nb_desktop ; i++) {
|
||||||
|
new_tsk2 = malloc(sizeof(Task));
|
||||||
|
memcpy(new_tsk2, new_tsk, sizeof(Task));
|
||||||
|
|
||||||
|
new_tsk2->title = 0;
|
||||||
|
new_tsk2->icon_data = 0;
|
||||||
|
get_icon(new_tsk2);
|
||||||
|
get_title(new_tsk2);
|
||||||
|
|
||||||
|
tskbar = &panel.taskbar[index(i, monitor)];
|
||||||
|
new_tsk2->area.parent = tskbar;
|
||||||
|
tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk2);
|
||||||
|
|
||||||
|
if (resize_tasks (tskbar))
|
||||||
|
set_redraw (&tskbar->area);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,6 +110,11 @@ void remove_task (Task *tsk)
|
||||||
set_redraw (&tskbar->area);
|
set_redraw (&tskbar->area);
|
||||||
//printf("remove_task %d %s\n", index(tskbar->desktop, tskbar->monitor), tsk->title);
|
//printf("remove_task %d %s\n", index(tskbar->desktop, tskbar->monitor), tsk->title);
|
||||||
|
|
||||||
|
if (tsk == panel.task_active)
|
||||||
|
panel.task_active = 0;
|
||||||
|
if (tsk == panel.task_drag)
|
||||||
|
panel.task_drag = 0;
|
||||||
|
|
||||||
if (tsk->title) {
|
if (tsk->title) {
|
||||||
free (tsk->title);
|
free (tsk->title);
|
||||||
tsk->title = 0;
|
tsk->title = 0;
|
||||||
|
@ -102,6 +123,7 @@ void remove_task (Task *tsk)
|
||||||
free (tsk->icon_data);
|
free (tsk->icon_data);
|
||||||
tsk->icon_data = 0;
|
tsk->icon_data = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
XFreePixmap (server.dsp, tsk->area.pix.pmap);
|
XFreePixmap (server.dsp, tsk->area.pix.pmap);
|
||||||
XFreePixmap (server.dsp, tsk->area.pix_active.pmap);
|
XFreePixmap (server.dsp, tsk->area.pix_active.pmap);
|
||||||
free(tsk);
|
free(tsk);
|
||||||
|
|
|
@ -46,6 +46,7 @@ typedef struct {
|
||||||
int icon_width;
|
int icon_width;
|
||||||
int icon_height;
|
int icon_height;
|
||||||
char *title;
|
char *title;
|
||||||
|
int all_desktop;
|
||||||
} Task;
|
} Task;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,8 @@ Task *task_get_task (Window win)
|
||||||
for (i=0 ; i < nb ; i++) {
|
for (i=0 ; i < nb ; i++) {
|
||||||
for (l0 = panel.taskbar[i].area.list; l0 ; l0 = l0->next) {
|
for (l0 = panel.taskbar[i].area.list; l0 ; l0 = l0->next) {
|
||||||
tsk = l0->data;
|
tsk = l0->data;
|
||||||
if (win == tsk->win) return tsk;
|
if (win == tsk->win)
|
||||||
|
return tsk;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
105
src/tint.c
105
src/tint.c
|
@ -190,10 +190,12 @@ suite:
|
||||||
// drag and drop task
|
// drag and drop task
|
||||||
if (panel.task_drag) {
|
if (panel.task_drag) {
|
||||||
if (tskbar != panel.task_drag->area.parent && action == TOGGLE_ICONIFY) {
|
if (tskbar != panel.task_drag->area.parent && action == TOGGLE_ICONIFY) {
|
||||||
windows_set_desktop(panel.task_drag->win, tskbar->desktop);
|
if (!panel.task_drag->all_desktop && panel.mode == MULTI_DESKTOP) {
|
||||||
if (tskbar->desktop == server.desktop)
|
windows_set_desktop(panel.task_drag->win, tskbar->desktop);
|
||||||
set_active(panel.task_drag->win);
|
if (tskbar->desktop == server.desktop)
|
||||||
panel.task_drag = 0;
|
set_active(panel.task_drag->win);
|
||||||
|
panel.task_drag = 0;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else panel.task_drag = 0;
|
else panel.task_drag = 0;
|
||||||
|
@ -249,7 +251,20 @@ void event_property_notify (Window win, Atom at)
|
||||||
/* Change active */
|
/* Change active */
|
||||||
else if (at == server.atom._NET_ACTIVE_WINDOW) {
|
else if (at == server.atom._NET_ACTIVE_WINDOW) {
|
||||||
if (panel.task_active) {
|
if (panel.task_active) {
|
||||||
panel.task_active->area.is_active = 0;
|
if (panel.task_active->all_desktop) {
|
||||||
|
Task *tsk;
|
||||||
|
GSList *l0;
|
||||||
|
int i, nb;
|
||||||
|
nb = server.nb_desktop * server.nb_monitor;
|
||||||
|
for (i=0 ; i < nb ; i++) {
|
||||||
|
for (l0 = panel.taskbar[i].area.list; l0 ; l0 = l0->next) {
|
||||||
|
tsk = l0->data;
|
||||||
|
tsk->area.is_active = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
panel.task_active->area.is_active = 0;
|
||||||
panel.task_active = 0;
|
panel.task_active = 0;
|
||||||
}
|
}
|
||||||
Window w1 = window_get_active ();
|
Window w1 = window_get_active ();
|
||||||
|
@ -260,7 +275,21 @@ void event_property_notify (Window win, Atom at)
|
||||||
if (w2) t = task_get_task(w2);
|
if (w2) t = task_get_task(w2);
|
||||||
}
|
}
|
||||||
if (t) {
|
if (t) {
|
||||||
t->area.is_active = 1;
|
if (t->all_desktop) {
|
||||||
|
Task *tsk;
|
||||||
|
GSList *l0;
|
||||||
|
int i, nb;
|
||||||
|
nb = server.nb_desktop * server.nb_monitor;
|
||||||
|
for (i=0 ; i < nb ; i++) {
|
||||||
|
for (l0 = panel.taskbar[i].area.list; l0 ; l0 = l0->next) {
|
||||||
|
tsk = l0->data;
|
||||||
|
if (tsk->win == t->win)
|
||||||
|
tsk->area.is_active = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
t->area.is_active = 1;
|
||||||
panel.task_active = t;
|
panel.task_active = t;
|
||||||
}
|
}
|
||||||
panel.refresh = 1;
|
panel.refresh = 1;
|
||||||
|
@ -280,17 +309,49 @@ void event_property_notify (Window win, Atom at)
|
||||||
|
|
||||||
/* Window title changed */
|
/* Window title changed */
|
||||||
if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) {
|
if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) {
|
||||||
get_title(tsk);
|
if (tsk->all_desktop) {
|
||||||
tsk->area.redraw = 1;
|
Task *tsk2;
|
||||||
|
GSList *l0;
|
||||||
|
int i, nb;
|
||||||
|
nb = server.nb_desktop * server.nb_monitor;
|
||||||
|
for (i=0 ; i < nb ; i++) {
|
||||||
|
for (l0 = panel.taskbar[i].area.list; l0 ; l0 = l0->next) {
|
||||||
|
tsk2 = l0->data;
|
||||||
|
if (tsk->win == tsk2->win) {
|
||||||
|
get_title(tsk2);
|
||||||
|
tsk2->area.redraw = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
get_title(tsk);
|
||||||
|
tsk->area.redraw = 1;
|
||||||
|
}
|
||||||
panel.refresh = 1;
|
panel.refresh = 1;
|
||||||
}
|
}
|
||||||
/* Iconic state */
|
/* Iconic state */
|
||||||
else if (at == server.atom.WM_STATE) {
|
else if (at == server.atom.WM_STATE) {
|
||||||
if (window_is_iconified (win))
|
if (window_is_iconified (win))
|
||||||
if (panel.task_active == tsk) {
|
if (panel.task_active) {
|
||||||
tsk->area.is_active = 0;
|
if (panel.task_active->win == tsk->win) {
|
||||||
panel.task_active = 0;
|
if (tsk->all_desktop) {
|
||||||
}
|
Task *tsk2;
|
||||||
|
GSList *l0;
|
||||||
|
int i, nb;
|
||||||
|
nb = server.nb_desktop * server.nb_monitor;
|
||||||
|
for (i=0 ; i < nb ; i++) {
|
||||||
|
for (l0 = panel.taskbar[i].area.list; l0 ; l0 = l0->next) {
|
||||||
|
tsk2 = l0->data;
|
||||||
|
tsk2->area.is_active = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
panel.task_active->area.is_active = 0;
|
||||||
|
panel.task_active = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Window icon changed */
|
/* Window icon changed */
|
||||||
else if (at == server.atom._NET_WM_ICON) {
|
else if (at == server.atom._NET_WM_ICON) {
|
||||||
|
@ -303,8 +364,24 @@ void event_property_notify (Window win, Atom at)
|
||||||
}
|
}
|
||||||
/* Window desktop changed */
|
/* Window desktop changed */
|
||||||
else if (at == server.atom._NET_WM_DESKTOP) {
|
else if (at == server.atom._NET_WM_DESKTOP) {
|
||||||
add_task (tsk->win);
|
Window win2 = tsk->win;
|
||||||
remove_task (tsk);
|
if (tsk->all_desktop) {
|
||||||
|
Task *tsk2;
|
||||||
|
GSList *l0;
|
||||||
|
int i, nb;
|
||||||
|
nb = server.nb_desktop * server.nb_monitor;
|
||||||
|
for (i=0 ; i < nb ; i++) {
|
||||||
|
for (l0 = panel.taskbar[i].area.list; l0 ; ) {
|
||||||
|
tsk2 = l0->data;
|
||||||
|
l0 = l0->next;
|
||||||
|
if (win2 == tsk2->win)
|
||||||
|
remove_task (tsk2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
remove_task (tsk);
|
||||||
|
add_task (win);
|
||||||
panel.refresh = 1;
|
panel.refresh = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
BIN
src/tint2
BIN
src/tint2
Binary file not shown.
|
@ -23,11 +23,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib.h>
|
#include <pango/pangocairo.h>
|
||||||
|
|
||||||
#include "window.h"
|
|
||||||
#include "server.h"
|
|
||||||
#include "area.h"
|
#include "area.h"
|
||||||
|
#include "server.h"
|
||||||
|
|
||||||
|
|
||||||
void refresh (Area *a)
|
void refresh (Area *a)
|
||||||
|
@ -69,7 +68,7 @@ void draw (Area *a, int active)
|
||||||
|
|
||||||
//printf("begin draw area\n");
|
//printf("begin draw area\n");
|
||||||
if (*pmap) XFreePixmap (server.dsp, *pmap);
|
if (*pmap) XFreePixmap (server.dsp, *pmap);
|
||||||
*pmap = server_create_pixmap (a->width, a->height);
|
*pmap = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth);
|
||||||
|
|
||||||
// add layer of root pixmap
|
// add layer of root pixmap
|
||||||
XCopyArea (server.dsp, server.pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);
|
XCopyArea (server.dsp, server.pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);
|
||||||
|
@ -186,3 +185,24 @@ void free_area (Area *a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void draw_rect(cairo_t *c, double x, double y, double w, double h, double r)
|
||||||
|
{
|
||||||
|
if (r > 0.0) {
|
||||||
|
double c1 = 0.55228475 * r;
|
||||||
|
|
||||||
|
cairo_move_to(c, x+r, y);
|
||||||
|
cairo_rel_line_to(c, w-2*r, 0);
|
||||||
|
cairo_rel_curve_to(c, c1, 0.0, r, c1, r, r);
|
||||||
|
cairo_rel_line_to(c, 0, h-2*r);
|
||||||
|
cairo_rel_curve_to(c, 0.0, c1, c1-r, r, -r, r);
|
||||||
|
cairo_rel_line_to (c, -w +2*r, 0);
|
||||||
|
cairo_rel_curve_to (c, -c1, 0, -r, -c1, -r, -r);
|
||||||
|
cairo_rel_line_to (c, 0, -h + 2 * r);
|
||||||
|
cairo_rel_curve_to (c, 0, -c1, r - c1, -r, r, -r);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cairo_rectangle(c, x, y, w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,10 @@
|
||||||
#ifndef AREA_H
|
#ifndef AREA_H
|
||||||
#define AREA_H
|
#define AREA_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <pango/pangocairo.h>
|
#include <cairo.h>
|
||||||
|
#include <cairo-xlib.h>
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -101,5 +101,8 @@ void remove_area (Area *a);
|
||||||
void add_area (Area *a);
|
void add_area (Area *a);
|
||||||
void free_area (Area *a);
|
void free_area (Area *a);
|
||||||
|
|
||||||
|
// draw rounded rectangle
|
||||||
|
void draw_rect(cairo_t *c, double x, double y, double w, double h, double r);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <Imlib2.h>
|
#include <Imlib2.h>
|
||||||
|
#include <cairo.h>
|
||||||
|
#include <cairo-xlib.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
@ -217,31 +220,12 @@ long *get_best_icon (long *data, int icon_count, int num, int *iw, int *ih, int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void draw_rect(cairo_t *c, double x, double y, double w, double h, double r)
|
|
||||||
{
|
|
||||||
if (r > 0.0) {
|
|
||||||
double c1 = 0.55228475 * r;
|
|
||||||
|
|
||||||
cairo_move_to(c, x+r, y);
|
|
||||||
cairo_rel_line_to(c, w-2*r, 0);
|
|
||||||
cairo_rel_curve_to(c, c1, 0.0, r, c1, r, r);
|
|
||||||
cairo_rel_line_to(c, 0, h-2*r);
|
|
||||||
cairo_rel_curve_to(c, 0.0, c1, c1-r, r, -r, r);
|
|
||||||
cairo_rel_line_to (c, -w +2*r, 0);
|
|
||||||
cairo_rel_curve_to (c, -c1, 0, -r, -c1, -r, -r);
|
|
||||||
cairo_rel_line_to (c, 0, -h + 2 * r);
|
|
||||||
cairo_rel_curve_to (c, 0, -c1, r - c1, -r, r, -r);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
cairo_rectangle(c, x, y, w, h);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void get_text_size(PangoFontDescription *font, int *height_ink, int *height, int panel_height, char *text, int len)
|
void get_text_size(PangoFontDescription *font, int *height_ink, int *height, int panel_height, char *text, int len)
|
||||||
{
|
{
|
||||||
PangoRectangle rect_ink, rect;
|
PangoRectangle rect_ink, rect;
|
||||||
|
|
||||||
Pixmap pmap = server_create_pixmap (panel_height, panel_height);
|
Pixmap pmap = XCreatePixmap (server.dsp, server.root_win, panel_height, panel_height, server.depth);
|
||||||
|
|
||||||
cairo_surface_t *cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, panel_height, panel_height);
|
cairo_surface_t *cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, panel_height, panel_height);
|
||||||
cairo_t *c = cairo_create (cs);
|
cairo_t *c = cairo_create (cs);
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
#ifndef WINDOW_H
|
#ifndef WINDOW_H
|
||||||
#define WINDOW_H
|
#define WINDOW_H
|
||||||
|
|
||||||
#include <cairo.h>
|
|
||||||
#include <cairo-xlib.h>
|
|
||||||
#include <pango/pangocairo.h>
|
#include <pango/pangocairo.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,9 +35,6 @@ void windows_set_desktop (Window win, int desktop);
|
||||||
int window_get_monitor (Window win);
|
int window_get_monitor (Window win);
|
||||||
Window window_get_active ();
|
Window window_get_active ();
|
||||||
|
|
||||||
// draw rounded rectangle
|
|
||||||
void draw_rect(cairo_t *c, double x, double y, double w, double h, double r);
|
|
||||||
|
|
||||||
void get_text_size(PangoFontDescription *font, int *height_ink, int *height, int panel_height, char *text, int len);
|
void get_text_size(PangoFontDescription *font, int *height_ink, int *height, int panel_height, char *text, int len);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue