*change* make tooltip more generous, and preparation for setting a tooltip on the clock
git-svn-id: http://tint2.googlecode.com/svn/trunk@271 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
char *time1_format=0;
|
char *time1_format=0;
|
||||||
char *time2_format=0;
|
char *time2_format=0;
|
||||||
|
char *time_tooltip_format=0;
|
||||||
char *clock_lclick_command=0;
|
char *clock_lclick_command=0;
|
||||||
char *clock_rclick_command=0;
|
char *clock_rclick_command=0;
|
||||||
struct timeval time_clock;
|
struct timeval time_clock;
|
||||||
@@ -42,6 +43,7 @@ PangoFontDescription *time1_font_desc=0;
|
|||||||
PangoFontDescription *time2_font_desc=0;
|
PangoFontDescription *time2_font_desc=0;
|
||||||
static char buf_time[40];
|
static char buf_time[40];
|
||||||
static char buf_date[40];
|
static char buf_date[40];
|
||||||
|
static char buf_tooltip[40];
|
||||||
int clock_enabled;
|
int clock_enabled;
|
||||||
|
|
||||||
|
|
||||||
@@ -57,6 +59,12 @@ void update_clocks()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* clock_get_tooltip(void* obj)
|
||||||
|
{
|
||||||
|
return buf_tooltip;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void init_clock()
|
void init_clock()
|
||||||
{
|
{
|
||||||
if(time1_format) {
|
if(time1_format) {
|
||||||
@@ -109,6 +117,11 @@ void init_clock_panel(void *p)
|
|||||||
clock->time1_posy -= ((date_height_ink + 2) / 2);
|
clock->time1_posy -= ((date_height_ink + 2) / 2);
|
||||||
clock->time2_posy = clock->time1_posy + time_height + 2 - (time_height - time_height_ink)/2 - (date_height - date_height_ink)/2;
|
clock->time2_posy = clock->time1_posy + time_height + 2 - (time_height - time_height_ink)/2 - (date_height - date_height_ink)/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (time_tooltip_format) {
|
||||||
|
clock->area._get_tooltip_text = clock_get_tooltip;
|
||||||
|
strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, localtime(&time_clock.tv_sec));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -123,6 +136,8 @@ void cleanup_clock()
|
|||||||
g_free(time1_format);
|
g_free(time1_format);
|
||||||
if (time2_format)
|
if (time2_format)
|
||||||
g_free(time2_format);
|
g_free(time2_format);
|
||||||
|
if (time_tooltip_format)
|
||||||
|
g_free(time_tooltip_format);
|
||||||
if (clock_lclick_command)
|
if (clock_lclick_command)
|
||||||
g_free(clock_lclick_command);
|
g_free(clock_lclick_command);
|
||||||
if (clock_rclick_command)
|
if (clock_rclick_command)
|
||||||
|
|||||||
106
src/panel.c
106
src/panel.c
@@ -512,3 +512,109 @@ Panel *get_panel(Window win)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Taskbar *click_taskbar (Panel *panel, int x, int y)
|
||||||
|
{
|
||||||
|
Taskbar *tskbar;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (panel_horizontal) {
|
||||||
|
for (i=0; i < panel->nb_desktop ; i++) {
|
||||||
|
tskbar = &panel->taskbar[i];
|
||||||
|
if (tskbar->area.on_screen && x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
|
||||||
|
return tskbar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (i=0; i < panel->nb_desktop ; i++) {
|
||||||
|
tskbar = &panel->taskbar[i];
|
||||||
|
if (tskbar->area.on_screen && y >= tskbar->area.posy && y <= (tskbar->area.posy + tskbar->area.height))
|
||||||
|
return tskbar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Task *click_task (Panel *panel, int x, int y)
|
||||||
|
{
|
||||||
|
GSList *l0;
|
||||||
|
Taskbar *tskbar;
|
||||||
|
|
||||||
|
if ( (tskbar = click_taskbar(panel, x, y)) ) {
|
||||||
|
if (panel_horizontal) {
|
||||||
|
Task *tsk;
|
||||||
|
for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
|
||||||
|
tsk = l0->data;
|
||||||
|
if (tsk->area.on_screen && x >= tsk->area.posx && x <= (tsk->area.posx + tsk->area.width)) {
|
||||||
|
return tsk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Task *tsk;
|
||||||
|
for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
|
||||||
|
tsk = l0->data;
|
||||||
|
if (tsk->area.on_screen && y >= tsk->area.posy && y <= (tsk->area.posy + tsk->area.height)) {
|
||||||
|
return tsk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int click_padding(Panel *panel, int x, int y)
|
||||||
|
{
|
||||||
|
if (panel_horizontal) {
|
||||||
|
if (x < panel->area.paddingxlr || x > panel->area.width-panel->area.paddingxlr)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (y < panel->area.paddingxlr || y > panel->area.height-panel->area.paddingxlr)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int click_clock(Panel *panel, int x, int y)
|
||||||
|
{
|
||||||
|
Clock clk = panel->clock;
|
||||||
|
if (panel_horizontal) {
|
||||||
|
if (clk.area.on_screen && x >= clk.area.posx && x <= (clk.area.posx + clk.area.width))
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
if (clk.area.on_screen && y >= clk.area.posy && y <= (clk.area.posy + clk.area.height))
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Area* click_area(Panel *panel, int x, int y)
|
||||||
|
{
|
||||||
|
Area* result = &panel->area;
|
||||||
|
Area* new_result = result;
|
||||||
|
do {
|
||||||
|
result = new_result;
|
||||||
|
GSList* it = result->list;
|
||||||
|
while (it) {
|
||||||
|
Area* a = it->data;
|
||||||
|
if (panel_horizontal) {
|
||||||
|
if (a->on_screen && x >= a->posx && x <= (a->posx + a->width)) {
|
||||||
|
new_result = a;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (a->on_screen && y >= a->posy && y <= (a->posy + a->height)) {
|
||||||
|
new_result = a;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it = it->next;
|
||||||
|
}
|
||||||
|
} while (new_result != result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|||||||
@@ -120,5 +120,10 @@ void set_panel_background(Panel *p);
|
|||||||
// detect witch panel
|
// detect witch panel
|
||||||
Panel *get_panel(Window win);
|
Panel *get_panel(Window win);
|
||||||
|
|
||||||
#endif
|
Taskbar *click_taskbar (Panel *panel, int x, int y);
|
||||||
|
Task *click_task (Panel *panel, int x, int y);
|
||||||
|
int click_padding(Panel *panel, int x, int y);
|
||||||
|
int click_clock(Panel *panel, int x, int y);
|
||||||
|
Area* click_area(Panel *panel, int x, int y);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -36,6 +36,13 @@
|
|||||||
|
|
||||||
static int urgent_timer = 0;
|
static int urgent_timer = 0;
|
||||||
|
|
||||||
|
const char* task_get_tooltip(void* obj)
|
||||||
|
{
|
||||||
|
Task* t = obj;
|
||||||
|
return t->title;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Task *add_task (Window win)
|
Task *add_task (Window win)
|
||||||
{
|
{
|
||||||
if (!win) return 0;
|
if (!win) return 0;
|
||||||
@@ -82,6 +89,7 @@ Task *add_task (Window win)
|
|||||||
new_tsk2->area.on_screen = 0;
|
new_tsk2->area.on_screen = 0;
|
||||||
}
|
}
|
||||||
new_tsk2->title = new_tsk.title;
|
new_tsk2->title = new_tsk.title;
|
||||||
|
new_tsk2->area._get_tooltip_text = task_get_tooltip;
|
||||||
new_tsk2->icon = new_tsk.icon;
|
new_tsk2->icon = new_tsk.icon;
|
||||||
new_tsk2->icon_active = new_tsk.icon_active;
|
new_tsk2->icon_active = new_tsk.icon_active;
|
||||||
new_tsk2->icon_width = new_tsk.icon_width;
|
new_tsk2->icon_width = new_tsk.icon_width;
|
||||||
@@ -102,12 +110,6 @@ void remove_task (Task *tsk)
|
|||||||
Window win = tsk->win;
|
Window win = tsk->win;
|
||||||
int desktop = tsk->desktop;
|
int desktop = tsk->desktop;
|
||||||
|
|
||||||
if (g_tooltip.task == tsk) {
|
|
||||||
tooltip_hide();
|
|
||||||
alarm(0);
|
|
||||||
g_tooltip.task = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// free title and icon just for the first task
|
// free title and icon just for the first task
|
||||||
// even with task_on_all_desktop and with task_on_all_panel
|
// even with task_on_all_desktop and with task_on_all_panel
|
||||||
//printf("remove_task %s %d\n", tsk->title, tsk->desktop);
|
//printf("remove_task %s %d\n", tsk->title, tsk->desktop);
|
||||||
@@ -159,12 +161,6 @@ void get_title(Task *tsk)
|
|||||||
|
|
||||||
if (!panel->g_task.text && !g_tooltip.enabled) return;
|
if (!panel->g_task.text && !g_tooltip.enabled) return;
|
||||||
|
|
||||||
if (g_tooltip.task == tsk) {
|
|
||||||
tooltip_hide();
|
|
||||||
alarm(0);
|
|
||||||
g_tooltip.task = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
name = server_get_property (tsk->win, server.atom._NET_WM_VISIBLE_NAME, server.atom.UTF8_STRING, 0);
|
name = server_get_property (tsk->win, server.atom._NET_WM_VISIBLE_NAME, server.atom.UTF8_STRING, 0);
|
||||||
if (!name || !strlen(name)) {
|
if (!name || !strlen(name)) {
|
||||||
name = server_get_property (tsk->win, server.atom._NET_WM_NAME, server.atom.UTF8_STRING, 0);
|
name = server_get_property (tsk->win, server.atom._NET_WM_NAME, server.atom.UTF8_STRING, 0);
|
||||||
|
|||||||
88
src/tint.c
88
src/tint.c
@@ -178,86 +178,6 @@ void get_snapshot(const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Taskbar *click_taskbar (Panel *panel, int x, int y)
|
|
||||||
{
|
|
||||||
Taskbar *tskbar;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (panel_horizontal) {
|
|
||||||
for (i=0; i < panel->nb_desktop ; i++) {
|
|
||||||
tskbar = &panel->taskbar[i];
|
|
||||||
if (tskbar->area.on_screen && x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
|
|
||||||
return tskbar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (i=0; i < panel->nb_desktop ; i++) {
|
|
||||||
tskbar = &panel->taskbar[i];
|
|
||||||
if (tskbar->area.on_screen && y >= tskbar->area.posy && y <= (tskbar->area.posy + tskbar->area.height))
|
|
||||||
return tskbar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Task *click_task (Panel *panel, int x, int y)
|
|
||||||
{
|
|
||||||
GSList *l0;
|
|
||||||
Taskbar *tskbar;
|
|
||||||
|
|
||||||
if ( (tskbar = click_taskbar(panel, x, y)) ) {
|
|
||||||
if (panel_horizontal) {
|
|
||||||
Task *tsk;
|
|
||||||
for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
|
|
||||||
tsk = l0->data;
|
|
||||||
if (tsk->area.on_screen && x >= tsk->area.posx && x <= (tsk->area.posx + tsk->area.width)) {
|
|
||||||
return tsk;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Task *tsk;
|
|
||||||
for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
|
|
||||||
tsk = l0->data;
|
|
||||||
if (tsk->area.on_screen && y >= tsk->area.posy && y <= (tsk->area.posy + tsk->area.height)) {
|
|
||||||
return tsk;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int click_padding(Panel *panel, int x, int y)
|
|
||||||
{
|
|
||||||
if (panel_horizontal) {
|
|
||||||
if (x < panel->area.paddingxlr || x > panel->area.width-panel->area.paddingxlr)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (y < panel->area.paddingxlr || y > panel->area.height-panel->area.paddingxlr)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int click_clock(Panel *panel, int x, int y)
|
|
||||||
{
|
|
||||||
Clock clk = panel->clock;
|
|
||||||
if (panel_horizontal) {
|
|
||||||
if (clk.area.on_screen && x >= clk.area.posx && x <= (clk.area.posx + clk.area.width))
|
|
||||||
return TRUE;
|
|
||||||
} else {
|
|
||||||
if (clk.area.on_screen && y >= clk.area.posy && y <= (clk.area.posy + clk.area.height))
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void window_action (Task *tsk, int action)
|
void window_action (Task *tsk, int action)
|
||||||
{
|
{
|
||||||
if (!tsk) return;
|
if (!tsk) return;
|
||||||
@@ -789,9 +709,10 @@ int main (int argc, char *argv[])
|
|||||||
case MotionNotify: {
|
case MotionNotify: {
|
||||||
if (!g_tooltip.enabled) break;
|
if (!g_tooltip.enabled) break;
|
||||||
Panel* panel = get_panel(e.xmotion.window);
|
Panel* panel = get_panel(e.xmotion.window);
|
||||||
Task* task = click_task(panel, e.xmotion.x, e.xmotion.y);
|
Area* area = click_area(panel, e.xmotion.x, e.xmotion.y);
|
||||||
if (task)
|
if (area->_get_tooltip_text) {
|
||||||
tooltip_trigger_show(task, e.xmotion.x_root, e.xmotion.y_root);
|
tooltip_trigger_show(area, panel, e.xmotion.x_root, e.xmotion.y_root);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
tooltip_trigger_hide();
|
tooltip_trigger_hide();
|
||||||
break;
|
break;
|
||||||
@@ -810,7 +731,6 @@ int main (int argc, char *argv[])
|
|||||||
tooltip_update();
|
tooltip_update();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case PropertyNotify:
|
case PropertyNotify:
|
||||||
event_property_notify(&e);
|
event_property_notify(&e);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ void stop_timeouts();
|
|||||||
|
|
||||||
// give the tooltip some reasonable default values
|
// give the tooltip some reasonable default values
|
||||||
Tooltip g_tooltip = {
|
Tooltip g_tooltip = {
|
||||||
.task = 0,
|
.area = 0,
|
||||||
|
.panel = 0,
|
||||||
.window = 0,
|
.window = 0,
|
||||||
.show_timeout = { 0, 0 },
|
.show_timeout = { 0, 0 },
|
||||||
.hide_timeout = { 0, 0 },
|
.hide_timeout = { 0, 0 },
|
||||||
@@ -73,9 +74,7 @@ void cleanup_tooltip()
|
|||||||
stop_timeouts();
|
stop_timeouts();
|
||||||
tooltip_hide();
|
tooltip_hide();
|
||||||
g_tooltip.enabled = False;
|
g_tooltip.enabled = False;
|
||||||
if (g_tooltip.task) {
|
g_tooltip.area = 0;
|
||||||
g_tooltip.task = 0;
|
|
||||||
}
|
|
||||||
if (g_tooltip.window) {
|
if (g_tooltip.window) {
|
||||||
XDestroyWindow(server.dsp, g_tooltip.window);
|
XDestroyWindow(server.dsp, g_tooltip.window);
|
||||||
g_tooltip.window = 0;
|
g_tooltip.window = 0;
|
||||||
@@ -87,18 +86,17 @@ void cleanup_tooltip()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void tooltip_trigger_show(Task* task, int x_root, int y_root)
|
void tooltip_trigger_show(Area* area, Panel* p, int x_root, int y_root)
|
||||||
{
|
{
|
||||||
x = x_root;
|
x = x_root;
|
||||||
y = y_root;
|
y = y_root;
|
||||||
|
g_tooltip.panel = p;
|
||||||
if (g_tooltip.mapped && g_tooltip.task != task) {
|
if (g_tooltip.mapped && g_tooltip.area != area) {
|
||||||
g_tooltip.task = task;
|
g_tooltip.area = area;
|
||||||
tooltip_update();
|
tooltip_update();
|
||||||
stop_timeouts();
|
stop_timeouts();
|
||||||
}
|
}
|
||||||
else if (!g_tooltip.mapped) {
|
else if (!g_tooltip.mapped) {
|
||||||
g_tooltip.task = task;
|
|
||||||
start_show_timeout();
|
start_show_timeout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,8 +104,10 @@ void tooltip_trigger_show(Task* task, int x_root, int y_root)
|
|||||||
|
|
||||||
void tooltip_show()
|
void tooltip_show()
|
||||||
{
|
{
|
||||||
|
Area* area = click_area(g_tooltip.panel, x, y);
|
||||||
stop_timeouts();
|
stop_timeouts();
|
||||||
if (!g_tooltip.mapped) {
|
if (!g_tooltip.mapped && area->_get_tooltip_text) {
|
||||||
|
g_tooltip.area = area;
|
||||||
g_tooltip.mapped = True;
|
g_tooltip.mapped = True;
|
||||||
XMapWindow(server.dsp, g_tooltip.window);
|
XMapWindow(server.dsp, g_tooltip.window);
|
||||||
XFlush(server.dsp);
|
XFlush(server.dsp);
|
||||||
@@ -124,13 +124,13 @@ void tooltip_update_geometry()
|
|||||||
c = cairo_create(cs);
|
c = cairo_create(cs);
|
||||||
layout = pango_cairo_create_layout(c);
|
layout = pango_cairo_create_layout(c);
|
||||||
pango_layout_set_font_description(layout, g_tooltip.font_desc);
|
pango_layout_set_font_description(layout, g_tooltip.font_desc);
|
||||||
pango_layout_set_text(layout, g_tooltip.task->title, -1);
|
pango_layout_set_text(layout, g_tooltip.area->_get_tooltip_text(g_tooltip.area), -1);
|
||||||
PangoRectangle r1, r2;
|
PangoRectangle r1, r2;
|
||||||
pango_layout_get_pixel_extents(layout, &r1, &r2);
|
pango_layout_get_pixel_extents(layout, &r1, &r2);
|
||||||
width = 2*g_tooltip.border.width + 2*g_tooltip.paddingx + r2.width;
|
width = 2*g_tooltip.border.width + 2*g_tooltip.paddingx + r2.width;
|
||||||
height = 2*g_tooltip.border.width + 2*g_tooltip.paddingy + r2.height;
|
height = 2*g_tooltip.border.width + 2*g_tooltip.paddingy + r2.height;
|
||||||
|
|
||||||
Panel* panel = g_tooltip.task->area.panel;
|
Panel* panel = g_tooltip.panel;
|
||||||
if (panel_horizontal && panel_position & BOTTOM)
|
if (panel_horizontal && panel_position & BOTTOM)
|
||||||
y = panel->posy-height;
|
y = panel->posy-height;
|
||||||
else if (panel_horizontal && panel_position & TOP)
|
else if (panel_horizontal && panel_position & TOP)
|
||||||
@@ -152,7 +152,7 @@ void tooltip_adjust_geometry()
|
|||||||
// it seems quite impossible that the height needs to be adjusted, but we do it anyway.
|
// it seems quite impossible that the height needs to be adjusted, but we do it anyway.
|
||||||
|
|
||||||
int min_x, min_y, max_width, max_height;
|
int min_x, min_y, max_width, max_height;
|
||||||
Panel* panel = g_tooltip.task->area.panel;
|
Panel* panel = g_tooltip.panel;
|
||||||
int screen_width = server.monitor[panel->monitor].x + server.monitor[panel->monitor].width;
|
int screen_width = server.monitor[panel->monitor].x + server.monitor[panel->monitor].width;
|
||||||
int screen_height = server.monitor[panel->monitor].y + server.monitor[panel->monitor].height;
|
int screen_height = server.monitor[panel->monitor].y + server.monitor[panel->monitor].height;
|
||||||
if ( x+width <= screen_width && y+height <= screen_height && x>=0 && y>=0)
|
if ( x+width <= screen_width && y+height <= screen_height && x>=0 && y>=0)
|
||||||
@@ -194,7 +194,7 @@ void tooltip_adjust_geometry()
|
|||||||
|
|
||||||
void tooltip_update()
|
void tooltip_update()
|
||||||
{
|
{
|
||||||
if (!g_tooltip.task) {
|
if (!g_tooltip.area->_get_tooltip_text) {
|
||||||
tooltip_hide();
|
tooltip_hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -224,7 +224,7 @@ void tooltip_update()
|
|||||||
cairo_set_source_rgba(c, fc.color[0], fc.color[1], fc.color[2], fc.alpha);
|
cairo_set_source_rgba(c, fc.color[0], fc.color[1], fc.color[2], fc.alpha);
|
||||||
layout = pango_cairo_create_layout(c);
|
layout = pango_cairo_create_layout(c);
|
||||||
pango_layout_set_font_description(layout, g_tooltip.font_desc);
|
pango_layout_set_font_description(layout, g_tooltip.font_desc);
|
||||||
pango_layout_set_text(layout, g_tooltip.task->title, -1);
|
pango_layout_set_text(layout, g_tooltip.area->_get_tooltip_text(g_tooltip.area), -1);
|
||||||
PangoRectangle r1, r2;
|
PangoRectangle r1, r2;
|
||||||
pango_layout_get_pixel_extents(layout, &r1, &r2);
|
pango_layout_get_pixel_extents(layout, &r1, &r2);
|
||||||
pango_layout_set_width(layout, width*PANGO_SCALE);
|
pango_layout_set_width(layout, width*PANGO_SCALE);
|
||||||
@@ -243,7 +243,7 @@ void tooltip_update()
|
|||||||
void tooltip_trigger_hide(Tooltip* tooltip)
|
void tooltip_trigger_hide(Tooltip* tooltip)
|
||||||
{
|
{
|
||||||
if (g_tooltip.mapped) {
|
if (g_tooltip.mapped) {
|
||||||
g_tooltip.task = 0;
|
g_tooltip.area = 0;
|
||||||
start_hide_timeout();
|
start_hide_timeout();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -21,10 +21,12 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
#include "panel.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Task* task;
|
Area* area;
|
||||||
|
Panel* panel;
|
||||||
Window window;
|
Window window;
|
||||||
struct timespec show_timeout;
|
struct timespec show_timeout;
|
||||||
struct timespec hide_timeout;
|
struct timespec hide_timeout;
|
||||||
@@ -44,7 +46,7 @@ extern Tooltip g_tooltip;
|
|||||||
|
|
||||||
void init_tooltip();
|
void init_tooltip();
|
||||||
void cleanup_tooltip();
|
void cleanup_tooltip();
|
||||||
void tooltip_trigger_show(Task* task, int x, int y);
|
void tooltip_trigger_show(Area* area, Panel* p, int x, int y);
|
||||||
void tooltip_show();
|
void tooltip_show();
|
||||||
void tooltip_update();
|
void tooltip_update();
|
||||||
void tooltip_trigger_hide();
|
void tooltip_trigger_hide();
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ typedef struct {
|
|||||||
void (*_resize)(void *obj);
|
void (*_resize)(void *obj);
|
||||||
void (*_add_child)(void *obj);
|
void (*_add_child)(void *obj);
|
||||||
int (*_remove_child)(void *obj);
|
int (*_remove_child)(void *obj);
|
||||||
|
const char* (*_get_tooltip_text)(void *obj);
|
||||||
} Area;
|
} Area;
|
||||||
|
|
||||||
|
|
||||||
@@ -101,6 +102,5 @@ void free_area (Area *a);
|
|||||||
|
|
||||||
// draw rounded rectangle
|
// draw rounded rectangle
|
||||||
void draw_rect(cairo_t *c, double x, double y, double w, double h, double r);
|
void draw_rect(cairo_t *c, double x, double y, double w, double h, double r);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user