changeset 26521:c67d43408daa

Update hardware cursor correctly.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 05 Apr 2009 08:22:22 +0000
parents fd97c0de433d
children 8df78c06d10e
files ChangeLog finch/libgnt/gntbox.c finch/libgnt/gntcheckbox.c finch/libgnt/gntcombobox.c finch/libgnt/gntentry.c finch/libgnt/gnttextview.c finch/libgnt/gnttree.c finch/libgnt/gntwm.c
diffstat 8 files changed, 42 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Apr 05 04:34:48 2009 +0000
+++ b/ChangeLog	Sun Apr 05 08:22:22 2009 +0000
@@ -35,6 +35,10 @@
 	* The New Account dialog is now broken into three tabs.  Proxy
 	  configuration has been moved from the Advanced tab to the new tab.
 
+	Finch:
+	* The hardware cursor is updated correctly. This will be useful
+	  especially for users of braille terminals, screen readers etc.
+
 version 2.5.5 (03/01/2009):
 	libpurple:
 	* Fix a crash when removing an account with an unknown protocol id.
--- a/finch/libgnt/gntbox.c	Sun Apr 05 04:34:48 2009 +0000
+++ b/finch/libgnt/gntbox.c	Sun Apr 05 08:22:22 2009 +0000
@@ -78,13 +78,11 @@
 
 	g_list_foreach(box->list, (GFunc)gnt_widget_draw, NULL);
 
-	gnt_box_sync_children(box);
-
 	if (box->title && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER))
 	{
 		int pos, right;
 		char *title = g_strdup(box->title);
-		
+
 		get_title_thingies(box, title, &pos, &right);
 
 		if (gnt_widget_has_focus(widget))
@@ -96,8 +94,8 @@
 		mvwaddch(widget->window, 0, right, ACS_LTEE | gnt_color_pair(GNT_COLOR_NORMAL));
 		g_free(title);
 	}
-	
-	GNTDEBUG;
+
+	gnt_box_sync_children(box);
 }
 
 static void
@@ -723,6 +721,9 @@
 	if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER))
 		pos = 0;
 
+	if (!box->active)
+		find_focusable_widget(box);
+
 	for (iter = box->list; iter; iter = iter->next)
 	{
 		GntWidget *w = GNT_WIDGET(iter->data);
@@ -764,6 +765,9 @@
 		copywin(w->window, widget->window, 0, 0,
 				y, x, y + height - 1, x + width - 1, FALSE);
 		gnt_widget_set_position(w, x + widget->priv.x, y + widget->priv.y);
+		if (w == box->active) {
+			wmove(widget->window, y + getcury(w->window), x + getcurx(w->window));
+		}
 	}
 }
 
--- a/finch/libgnt/gntcheckbox.c	Sun Apr 05 04:34:48 2009 +0000
+++ b/finch/libgnt/gntcheckbox.c	Sun Apr 05 08:22:22 2009 +0000
@@ -42,7 +42,7 @@
 		type = GNT_COLOR_HIGHLIGHT;
 	else
 		type = GNT_COLOR_NORMAL;
-	
+
 	wbkgdset(widget->window, '\0' | gnt_color_pair(type));
 
 	text = g_strdup_printf("[%c]", cb->checked ? 'X' : ' ');
@@ -51,7 +51,8 @@
 
 	wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_NORMAL));
 	mvwaddstr(widget->window, 0, 4, GNT_BUTTON(cb)->priv->text);
-	
+	wmove(widget->window, 0, 1);
+
 	GNTDEBUG;
 }
 
--- a/finch/libgnt/gntcombobox.c	Sun Apr 05 04:34:48 2009 +0000
+++ b/finch/libgnt/gntcombobox.c	Sun Apr 05 08:22:22 2009 +0000
@@ -73,7 +73,7 @@
 	char *text = NULL, *s;
 	GntColorType type;
 	int len;
-	
+
 	if (box->dropdown && box->selected)
 		text = gnt_tree_get_selection_text(GNT_TREE(box->dropdown));
 
@@ -94,6 +94,7 @@
 	whline(widget->window, ' ' | gnt_color_pair(type), widget->priv.width - 4 - len);
 	mvwaddch(widget->window, 1, widget->priv.width - 3, ACS_VLINE | gnt_color_pair(GNT_COLOR_NORMAL));
 	mvwaddch(widget->window, 1, widget->priv.width - 2, ACS_DARROW | gnt_color_pair(GNT_COLOR_NORMAL));
+	wmove(widget->window, 1, 1);
 
 	g_free(text);
 	GNTDEBUG;
--- a/finch/libgnt/gntentry.c	Sun Apr 05 04:34:48 2009 +0000
+++ b/finch/libgnt/gntentry.c	Sun Apr 05 08:22:22 2009 +0000
@@ -271,6 +271,7 @@
 	GntEntry *entry = GNT_ENTRY(widget);
 	int stop;
 	gboolean focus;
+	int curpos;
 
 	if ((focus = gnt_widget_has_focus(widget)))
 		wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_TEXT_NORMAL));
@@ -289,9 +290,10 @@
 	if (stop < widget->priv.width)
 		mvwhline(widget->window, 0, stop, ENTRY_CHAR, widget->priv.width - stop);
 
+	curpos = gnt_util_onscreen_width(entry->scroll, entry->cursor);
 	if (focus)
-		mvwchgat(widget->window, 0, gnt_util_onscreen_width(entry->scroll, entry->cursor),
-				1, A_REVERSE, GNT_COLOR_TEXT_NORMAL, NULL);
+		mvwchgat(widget->window, 0, curpos, 1, A_REVERSE, GNT_COLOR_TEXT_NORMAL, NULL);
+	wmove(widget->window, 0, curpos);
 
 	GNTDEBUG;
 }
--- a/finch/libgnt/gnttextview.c	Sun Apr 05 04:34:48 2009 +0000
+++ b/finch/libgnt/gnttextview.c	Sun Apr 05 08:22:22 2009 +0000
@@ -177,7 +177,7 @@
 					gnt_color_pair(GNT_COLOR_HIGHLIGHT_D));
 	}
 
-	GNTDEBUG;
+	wmove(widget->window, 0, 0);
 }
 
 static void
--- a/finch/libgnt/gnttree.c	Sun Apr 05 04:34:48 2009 +0000
+++ b/finch/libgnt/gnttree.c	Sun Apr 05 08:22:22 2009 +0000
@@ -420,6 +420,7 @@
 	GntTreeRow *row;
 	int pos, up, down = 0;
 	int rows, scrcol;
+	int current = 0;
 
 	if (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_MAPPED))
 		return;
@@ -518,6 +519,7 @@
 
 		if (row == tree->current)
 		{
+			current = i;
 			attr |= A_BOLD;
 			if (gnt_widget_has_focus(widget))
 				attr |= gnt_color_pair(GNT_COLOR_HIGHLIGHT);
@@ -606,6 +608,7 @@
 		mvwaddnstr(widget->window, widget->priv.height - pos - 1, pos,
 				tree->priv->search->str, str - tree->priv->search->str);
 	}
+	wmove(widget->window, current, pos);
 
 	gnt_widget_queue_update(widget);
 }
--- a/finch/libgnt/gntwm.c	Sun Apr 05 04:34:48 2009 +0000
+++ b/finch/libgnt/gntwm.c	Sun Apr 05 08:22:22 2009 +0000
@@ -135,6 +135,17 @@
 	src = widget->window;
 	dst = node->window;
 	copywin(src, dst, node->scroll, 0, 0, 0, getmaxy(dst) - 1, getmaxx(dst) - 1, 0);
+
+	/* Update the hardware cursor */
+	if (GNT_IS_WINDOW(widget) || GNT_IS_BOX(widget)) {
+		GntWidget *active = GNT_BOX(widget)->active;
+		if (active) {
+			int curx = active->priv.x + getcurx(active->window);
+			int cury = active->priv.y + getcury(active->window);
+			if (wmove(node->window, cury - widget->priv.y, curx - widget->priv.x) != OK)
+				wmove(node->window, 0, 0);
+		}
+	}
 }
 
 /**
@@ -1101,8 +1112,8 @@
 
 	g_hash_table_foreach(wm->nodes, (GHFunc)refresh_node, GINT_TO_POINTER(TRUE));
 	g_signal_emit(wm, signals[SIG_TERMINAL_REFRESH], 0);
+	gnt_ws_draw_taskbar(wm->cws, TRUE);
 	update_screen(wm);
-	gnt_ws_draw_taskbar(wm->cws, TRUE);
 	curs_set(0);   /* endwin resets the cursor to normal */
 
 	return TRUE;
@@ -1872,8 +1883,8 @@
 		}
 	}
 
+	gnt_ws_draw_taskbar(wm->cws, FALSE);
 	update_screen(wm);
-	gnt_ws_draw_taskbar(wm->cws, FALSE);
 }
 
 void gnt_wm_window_decorate(GntWM *wm, GntWidget *widget)
@@ -1910,8 +1921,8 @@
 		}
 	}
 
+	gnt_ws_draw_taskbar(wm->cws, FALSE);
 	update_screen(wm);
-	gnt_ws_draw_taskbar(wm->cws, FALSE);
 }
 
 time_t gnt_wm_get_idle_time()
@@ -2181,8 +2192,8 @@
 		GntNode *nd = g_hash_table_lookup(wm->nodes, wm->_list.window);
 		top_panel(nd->panel);
 	}
+	gnt_ws_draw_taskbar(wm->cws, FALSE);
 	update_screen(wm);
-	gnt_ws_draw_taskbar(wm->cws, FALSE);
 }
 
 void gnt_wm_update_window(GntWM *wm, GntWidget *widget)
@@ -2207,8 +2218,8 @@
 
 	if (ws == wm->cws || GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) {
 		gnt_wm_copy_win(widget, node);
+		gnt_ws_draw_taskbar(wm->cws, FALSE);
 		update_screen(wm);
-		gnt_ws_draw_taskbar(wm->cws, FALSE);
 	} else if (ws && ws != wm->cws && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_URGENT)) {
 		if (!act || (act && !g_list_find(act, ws)))
 			act = g_list_prepend(act, ws);