summaryrefslogtreecommitdiffstats
path: root/src/qt_theme_draw.c
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-12-22 16:44:58 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-12-22 16:44:58 -0600
commit6e6dbb068e03a8bb818a76ba774d6f94ade7389f (patch)
tree731dbbe8b8cd5b1dea593fbf252247ae3cfc0428 /src/qt_theme_draw.c
parent690b6e163ba9b4da03fcd2b4f133bb5631be437b (diff)
downloadgtk-qt-engine-6e6dbb068e03a8bb818a76ba774d6f94ade7389f.tar.gz
gtk-qt-engine-6e6dbb068e03a8bb818a76ba774d6f94ade7389f.zip
Fix numerous drawing glitches in Firefox
Diffstat (limited to 'src/qt_theme_draw.c')
-rw-r--r--src/qt_theme_draw.c225
1 files changed, 144 insertions, 81 deletions
diff --git a/src/qt_theme_draw.c b/src/qt_theme_draw.c
index 20d8c87..e84c4f7 100644
--- a/src/qt_theme_draw.c
+++ b/src/qt_theme_draw.c
@@ -676,8 +676,9 @@ draw_box(GtkStyle * style,
int nbpages;
sanitize_size(window, &width, &height);
- if (gtkQtDebug)
+ if (gtkQtDebug) {
printf("Box (%d,%d,%d,%d) Widget: %s Detail: %s\n",x,y,width,height,gtk_widget_get_name(widget),detail);
+ }
if (GTK_IS_SCROLLBAR(widget))
{
@@ -685,38 +686,54 @@ draw_box(GtkStyle * style,
{
GtkAdjustment* adj = (GtkAdjustment*)gtk_range_get_adjustment(GTK_RANGE(widget));
int orientation = ((width>height) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
-
+
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawScrollBar(window, style, state_type, orientation, adj, x, y, width, height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
}
return;
}
if (DETAIL("menuitem"))
{
/* Crude way of checking if it's a menu item, or a menubar item */
- if (x != 0)
+ if (x != 0) {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawMenuBarItem(window,style,state_type,x,y,width,height);
- else
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
+ }
+ else {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawMenuItem(window,style,state_type,x,y,width,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
+ }
return;
}
if (DETAIL("menubar"))
{
- if (openOfficeFix == 1)
+ if (openOfficeFix == 1) {
parent_class->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
- else if (mozillaFix == 1)
+ }
+ else if (mozillaFix == 1) {
parent_class->draw_box (style, window, state_type, GTK_SHADOW_NONE, area, widget, detail, x, y, width, height);
- else
+ }
+ else {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawMenubar(window,style,state_type,x,y,width,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
+ }
return;
}
if (DETAIL("menu"))
{
- if (openOfficeFix == 1)
+ if (openOfficeFix == 1) {
parent_class->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
- else
- {
- if ((x >= 0) && (y >= 0)) /* Work around weirdness in firefox */
+ }
+ else {
+ if ((x >= 0) && (y >= 0)) { /* Work around weirdness in firefox */
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawMenu(window,style,state_type,x,y,width,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
+ }
}
return;
}
@@ -724,16 +741,15 @@ draw_box(GtkStyle * style,
{
double fraction = gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(widget));
GtkProgressBarOrientation orientation = gtk_progress_bar_get_orientation(GTK_PROGRESS_BAR(widget));
-
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawProgressBar(window,style,state_type,orientation,fraction,x,y,width,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
return;
}
if (GTK_IS_PROGRESS(widget) && DETAIL("bar"))
{
if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
-
drawProgressChunk(window,style,state_type,x,y,width,height);
-
if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
return;
}
@@ -742,8 +758,7 @@ draw_box(GtkStyle * style,
GtkAdjustment* adj;
int inverted;
GValue *val = (GValue*)g_malloc( sizeof(GValue) );
- if (gdk_window_is_viewable(gtk_widget_get_parent_window(widget)))
- {
+ if (gdk_window_is_viewable(gtk_widget_get_parent_window(widget))) {
GdkPixbuf *gpix;
gpix = gdk_pixbuf_get_from_drawable(NULL, gtk_widget_get_parent_window(widget),NULL, x, y, 0, 0, width, height);
setFillPixmap(gpix);
@@ -758,7 +773,9 @@ draw_box(GtkStyle * style,
g_free(val);
adj = gtk_range_get_adjustment((GtkRange *) widget);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawSlider(window,style,state_type,adj,x,y,width,height, (GTK_RANGE(widget))->orientation, inverted);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
return;
}
if (DETAIL("button"))
@@ -767,18 +784,15 @@ draw_box(GtkStyle * style,
int toolbutton = 0;
parent = gtk_widget_get_parent(widget);
- if (parent && (GTK_IS_CLIST(parent) || GTK_IS_LIST(parent) || GTK_IS_TREE_VIEW(parent)))
- {
+ if (parent && (GTK_IS_CLIST(parent) || GTK_IS_LIST(parent) || GTK_IS_TREE_VIEW(parent))) {
drawListHeader(window,style,state_type,x,y,width,height);
return;
}
/* this is a very very bad hack but there seems to be no way to find if a button is on a
* toolbar in gtk */
- while (1)
- {
- if (GTK_IS_WIDGET(parent))
- {
+ while (1) {
+ if (GTK_IS_WIDGET(parent)) {
#ifdef HAVE_BONOBO
if (GTK_IS_TOOLBAR(parent) || BONOBO_IS_UI_TOOLBAR(parent))
#else
@@ -789,17 +803,20 @@ draw_box(GtkStyle * style,
break;
}
}
- else
+ else {
break;
+ }
parent = gtk_widget_get_parent(parent);
}
parent = gtk_widget_get_parent(widget);
- if (toolbutton)
+ if (toolbutton) {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawToolButton(window,style,state_type,x,y,width,height);
- else
- {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
+ }
+ else {
/* Baghira hack -- rounded buttons really ugly when they are small like
on a dropdown entry box -- eg. search/replace in gedit */
/* Draw square buttons only if number of children in the hbox is 2 and
@@ -807,31 +824,35 @@ draw_box(GtkStyle * style,
int defaultButton = gtk_widget_has_focus(widget);
GtkWindow* toplevel;
- if (isBaghira && GTK_IS_BOX(parent) && (g_list_length(GTK_BOX(parent)->children) == 2))
- {
+ if (isBaghira && GTK_IS_BOX(parent) && (g_list_length(GTK_BOX(parent)->children) == 2)) {
child_list = g_list_first((GTK_BOX(parent)->children));
child = (GtkWidget *)child_list->data;
- if (GTK_IS_ENTRY(child))
- {
+ if (GTK_IS_ENTRY(child)) {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawSquareButton(window,style,state_type,x,y,width,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
return;
}
child_list = g_list_last((GTK_BOX(parent)->children));
child = ((GtkBoxChild *)child_list->data)->widget;
- if (GTK_IS_ENTRY(child))
- {
+ if (GTK_IS_ENTRY(child)) {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawSquareButton(window,style,state_type,x,y,width,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
return;
}
}
toplevel = GTK_WINDOW(gtk_widget_get_toplevel(widget));
- if (toplevel && toplevel->default_widget == widget)
+ if (toplevel && toplevel->default_widget == widget) {
defaultButton = 1;
-
+ }
+
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawButton(window,style,state_type,defaultButton,x,y,width,height,GTK_BUTTON(widget));
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
}
return;
}
@@ -860,43 +881,55 @@ draw_box(GtkStyle * style,
/* Now draw the tab -- tab position is also calculated in this function
checkout drawTabFrame() for drawing tabbarbase. */
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawTabNG(window,style,state_type,x, y, width/*-2*/, height, nb );
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
}
else {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawTab(window,style,state_type,x,y,width/*-2*/,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
}
return;
}
- if (DETAIL("optionmenu"))
- {
+ if (DETAIL("optionmenu")) {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawComboBox(window,style,state_type,x,y,width,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
return;
}
- if (DETAIL("toolbar"))
- {
+ if (DETAIL("toolbar")) {
if (openOfficeFix == 1)
parent_class->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
else
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawToolbar(window,style,state_type,x,y,width,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
return;
}
- if (DETAIL("spinbutton_up"))
- {
+ if (DETAIL("spinbutton_up")) {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawSpinButton(window, style, state_type, 0, x, y, width, height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
return;
}
- if (DETAIL("spinbutton_down"))
- {
+ if (DETAIL("spinbutton_down")) {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawSpinButton(window, style, state_type, 1, x, y, width, height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
return;
}
- if (DETAIL("spinbutton"))
+ if (DETAIL("spinbutton")) {
return;
+ }
- if (DETAIL("optionmenutab") || DETAIL("buttondefault"))
+ if (DETAIL("optionmenutab") || DETAIL("buttondefault")) {
return;
-
+ }
+
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawFrame(window,style,state_type,shadow_type,x,y,width,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
}
@@ -916,11 +949,11 @@ draw_flat_box(GtkStyle * style,
{
sanitize_size(window, &width, &height);
- if (gtkQtDebug)
+ if (gtkQtDebug) {
printf("Flat Box (%d,%d,%d,%d) Widget: %s Detail: %s %d %d\n",x,y,width,height,gtk_widget_get_name(widget),detail, state_type, GTK_STATE_SELECTED);
+ }
- if (DETAIL("tooltip"))
- {
+ if (DETAIL("tooltip")) {
GdkColor tooltipColor;
GdkGCValues gc_values;
GdkGCValuesMask gc_values_mask;
@@ -940,21 +973,25 @@ draw_flat_box(GtkStyle * style,
gtk_gc_release(tooltipGc);
}
- if ((DETAILHAS("cell_even") || DETAILHAS("cell_odd")) && (state_type == GTK_STATE_SELECTED))
- {
+ if ((DETAILHAS("cell_even") || DETAILHAS("cell_odd")) && (state_type == GTK_STATE_SELECTED)) {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawListViewItem(window,style,state_type,x,y,width,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
}
- else if (DETAIL("listitem"))
- {
+ else if (DETAIL("listitem")) {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawListViewItem(window,style,state_type,x,y,width,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
}
- else if (DETAILHAS("cell_even"))
- {
+ else if (DETAILHAS("cell_even")) {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
gdk_draw_rectangle(window, style->base_gc[GTK_STATE_NORMAL], TRUE, x, y, width, height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
}
- else if (DETAILHAS("cell_odd"))
- {
+ else if (DETAILHAS("cell_odd")) {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
gdk_draw_rectangle(window, alternateBackgroundGc(style), TRUE, x, y, width, height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
}
}
@@ -972,26 +1009,28 @@ draw_check(GtkStyle * style,
gint width,
gint height)
{
- if (gtkQtDebug)
+ if (gtkQtDebug) {
printf("Check (%d,%d,%d,%d) Widget: %s Detail: %s\n", x, y, width, height,gtk_widget_get_name(widget),detail);
+ }
- if (GTK_IS_MENU_ITEM(widget))
- {
- if (shadow_type == GTK_SHADOW_IN)
- {
- if (gdk_window_is_viewable(gtk_widget_get_parent_window(widget)))
- {
+ if (GTK_IS_MENU_ITEM(widget)) {
+ if (shadow_type == GTK_SHADOW_IN) {
+ if (gdk_window_is_viewable(gtk_widget_get_parent_window(widget))) {
GdkPixbuf *gpix;
gpix = gdk_pixbuf_get_from_drawable(NULL, gtk_widget_get_parent_window(widget), NULL, x, y, 0, 0, width, height);
setFillPixmap(gpix);
g_object_unref(gpix);
}
-
+
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawMenuCheck(window,style,state_type,x,y,width,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
}
return;
}
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawCheckBox(window,style,state_type,(shadow_type==GTK_SHADOW_IN),x,y,width,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
}
@@ -1009,11 +1048,11 @@ draw_option(GtkStyle * style,
gint width,
gint height)
{
- if (gtkQtDebug)
+ if (gtkQtDebug) {
printf("Option (%d,%d,%d,%d) Widget: %s Detail: %s\n", x, y, width, height,gtk_widget_get_name(widget),detail);
+ }
- if (gdk_window_is_viewable(gtk_widget_get_parent_window(widget)))
- {
+ if (gdk_window_is_viewable(gtk_widget_get_parent_window(widget))) {
GdkPixbuf *gpix;
gpix = gdk_pixbuf_get_from_drawable(NULL, gtk_widget_get_parent_window(widget),NULL, x, y, 0, 0, width, height);
setFillPixmap(gpix);
@@ -1022,11 +1061,16 @@ draw_option(GtkStyle * style,
if (GTK_IS_MENU_ITEM(widget))
{
- if (shadow_type == GTK_SHADOW_IN)
+ if (shadow_type == GTK_SHADOW_IN) {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawMenuCheck(window,style,state_type,x,y,width,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
+ }
return;
}
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawRadioButton(window,style,state_type,(shadow_type==GTK_SHADOW_IN),x,y,width,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
}
@@ -1043,8 +1087,9 @@ draw_tab(GtkStyle * style,
gint width,
gint height)
{
- if (gtkQtDebug)
+ if (gtkQtDebug) {
printf("Tab (%d,%d,%d,%d) Widget: %s Detail: %s\n", x, y, width, height,gtk_widget_get_name(widget),detail);
+ }
gtk_paint_box(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
}
@@ -1218,11 +1263,15 @@ draw_box_gap(GtkStyle* style,
if (width<0 || height<0) return; /* Eclipse really can be this stupid! */
- if (gtkQtDebug)
+ if (gtkQtDebug) {
printf("Box_gap (%d,%d,%d,%d) Widget: %s Detail: %s\n", x, y, width, height,gtk_widget_get_name(widget),detail);
+ }
- if (DETAIL("notebook"))
+ if (DETAIL("notebook")) {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawTabFrame(window,style,state_type,x,y-2,width,height+2, gtk_notebook_get_tab_pos((GtkNotebook *)widget));
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
+ }
}
@@ -1245,8 +1294,9 @@ draw_extension(GtkStyle * style,
sanitize_size (window, &width, &height);
- if (gtkQtDebug)
+ if (gtkQtDebug) {
printf("Extension (%d,%d,%d,%d) Widget: %s Detail: %s\n", x, y, width, height,gtk_widget_get_name(widget),detail);
+ }
gtk_paint_box(style, window, state_type, shadow_type, area, widget, detail,
x, y, width, height);
@@ -1265,8 +1315,9 @@ draw_focus (GtkStyle *style,
gint width,
gint height)
{
- if (gtkQtDebug)
+ if (gtkQtDebug) {
printf("Focus Rect (%d,%d,%d,%d) Widget: %s Detail: %s\n", x, y, width, height,gtk_widget_get_name(widget),detail);
+ }
GtkWidget* parent = gtk_widget_get_parent(widget);
@@ -1274,7 +1325,9 @@ draw_focus (GtkStyle *style,
GTK_IS_RADIO_BUTTON(widget) ||
(parent && (GTK_IS_CLIST(parent) || GTK_IS_LIST(parent) || GTK_IS_TREE_VIEW(parent))))
{
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawFocusRect(window, style, x, y, width, height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
}
return;
}
@@ -1293,24 +1346,31 @@ draw_slider(GtkStyle * style,
gint height,
GtkOrientation orientation)
{
- if (gtkQtDebug)
+ if (gtkQtDebug) {
printf("Slider (%d,%d,%d,%d) Widget: %s Detail: %s\n", x, y, width, height,gtk_widget_get_name(widget),detail);
+ }
- if (DETAIL("slider"))
- {
+ if (DETAIL("slider")) {
GtkAdjustment* adj = gtk_range_get_adjustment(GTK_RANGE(widget));
int widgetX, widgetY;
GtkWidget* parent = widget;
- while (gtk_widget_get_parent(parent) != NULL)
+ while (gtk_widget_get_parent(parent) != NULL) {
parent = gtk_widget_get_parent(parent);
+ }
gtk_widget_translate_coordinates(widget, parent, 0, 0, &widgetX, &widgetY);
- if (orientation == GTK_ORIENTATION_VERTICAL)
+ if (orientation == GTK_ORIENTATION_VERTICAL) {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawScrollBarSlider(window, style, state_type, orientation, adj, x-1, y, width+2, height, y-widgetY, widget->allocation.height);
- else
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
+ }
+ else {
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawScrollBarSlider(window, style, state_type, orientation, adj, x, y-1, width, height+2, x-widgetX, widget->allocation.width);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
+ }
return;
}
}
@@ -1334,10 +1394,13 @@ draw_handle(GtkStyle * style,
sanitize_size(window, &width, &height);
- if (gtkQtDebug)
+ if (gtkQtDebug) {
printf("Handle (%d,%d,%d,%d) Widget: %s Detail: %s State Type: %d\n",x,y,width,height,gtk_widget_get_name(widget),detail, state_type);
-
+ }
+
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
drawSplitter(window,style,state_type,orientation,x,y,width,height);
+ if (area) gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
return;
}