~ballogy/notify-osd/make-tests-optional

« back to all changes in this revision

Viewing changes to src/bubble.c

  • Committer: Mirco Müller
  • Date: 2010-04-01 14:37:44 UTC
  • mfrom: (420.1.3 notify-osd_lucid)
  • Revision ID: mirco.mueller@ubuntu.com-20100401143744-fvl2uj4xpirvpnmx
Merged my fix-546650 branch after review and approval from Cody. This
fixes LP: #546650.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1591
1591
 
1592
1592
static
1593
1593
void
1594
 
update_input_shape (GtkWidget* window,
1595
 
                    gint       width,
1596
 
                    gint       height)
 
1594
update_input_shape (GtkWidget* window)
1597
1595
{
1598
 
        GdkBitmap* mask = NULL;
1599
 
        cairo_t*   cr   = NULL;
1600
 
 
1601
 
        mask = (GdkBitmap*) gdk_pixmap_new (NULL, width, height, 1);
1602
 
        if (mask)
1603
 
        {
1604
 
                cr = gdk_cairo_create (mask);
1605
 
                if (cairo_status (cr) == CAIRO_STATUS_SUCCESS)
1606
 
                {
1607
 
                        cairo_scale (cr, 1.0f, 1.0f);
1608
 
                        cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
1609
 
                        cairo_paint (cr);
1610
 
                        cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1611
 
                        cairo_set_source_rgb (cr, 1.0f, 1.0f, 1.0f);
1612
 
 
1613
 
                        // just draw something
1614
 
                        draw_round_rect (cr,
1615
 
                                         1.0f,
1616
 
                                         0.0f, 0.0f,
1617
 
                                         10.0f,
1618
 
                                         10.0f, 10.0f);
1619
 
 
1620
 
                        cairo_fill (cr);
1621
 
 
1622
 
                        cairo_destroy (cr);
1623
 
 
1624
 
                        gtk_widget_input_shape_combine_mask (window,
1625
 
                                                             NULL,
1626
 
                                                             0,
1627
 
                                                             0);
1628
 
                        gtk_widget_input_shape_combine_mask (window,
1629
 
                                                             mask,
1630
 
                                                             0,
1631
 
                                                             0);
1632
 
                }
1633
 
 
1634
 
                g_object_unref ((gpointer) mask);
1635
 
        }
 
1596
        GdkRegion*   region = NULL;
 
1597
 
 
1598
        // sanity check
 
1599
        if (!window)
 
1600
                return;
 
1601
 
 
1602
        // set an empty input-mask to allow click-through 
 
1603
        region = gdk_region_new ();
 
1604
        gdk_window_input_shape_combine_region (window->window, region, 0, 0);
 
1605
        gdk_region_destroy (region);
1636
1606
}
1637
1607
 
1638
1608
static void
1659
1629
                return;
1660
1630
        }
1661
1631
 
1662
 
        // guess we need one
1663
 
        gtk_widget_get_size_request (priv->widget, &width, &height);
1664
 
        mask = (GdkBitmap*) gdk_pixmap_new (NULL, width, height, 1);
1665
 
        if (mask)
1666
 
        {
1667
 
                // create context from mask/pixmap
1668
 
                cr = gdk_cairo_create (mask);
1669
 
                if (cairo_status (cr) == CAIRO_STATUS_SUCCESS)
 
1632
        // we're not-composited, so deal with mouse-over differently
 
1633
        if (bubble_is_mouse_over (self))
 
1634
        {
 
1635
                gtk_widget_hide (priv->widget);
 
1636
        }
 
1637
        else
 
1638
        {
 
1639
                gtk_widget_show (priv->widget);
 
1640
                gtk_widget_get_size_request (priv->widget, &width, &height);
 
1641
                mask = (GdkBitmap*) gdk_pixmap_new (NULL, width, height, 1);
 
1642
                if (mask)
1670
1643
                {
1671
 
                        // clear mask/context
1672
 
                        cairo_scale (cr, 1.0f, 1.0f);
1673
 
                        cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
1674
 
                        cairo_paint (cr);
1675
 
 
1676
 
                        width  -= 2 * EM2PIXELS (defaults_get_bubble_shadow_size (d), d);
1677
 
                        height -= 2 * EM2PIXELS (defaults_get_bubble_shadow_size (d), d);
1678
 
 
1679
 
                        // draw rounded rectangle shape/mask
1680
 
                        if (bubble_is_mouse_over (self))
 
1644
                        // create context from mask/pixmap
 
1645
                        cr = gdk_cairo_create (mask);
 
1646
                        if (cairo_status (cr) == CAIRO_STATUS_SUCCESS)
 
1647
                        {
 
1648
                                // clear mask/context
 
1649
                                cairo_scale (cr, 1.0f, 1.0f);
1681
1650
                                cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
1682
 
                        else
 
1651
                                cairo_paint (cr);
 
1652
 
 
1653
                                width  -= 2 * EM2PIXELS (defaults_get_bubble_shadow_size (d), d);
 
1654
                                height -= 2 * EM2PIXELS (defaults_get_bubble_shadow_size (d), d);
 
1655
 
 
1656
                                // draw rounded rectangle shape/mask
1683
1657
                                cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1684
 
                        cairo_set_source_rgb (cr, 1.0f, 1.0f, 1.0f);
1685
 
                        draw_round_rect (cr,
 
1658
                                cairo_set_source_rgb (cr, 1.0f, 1.0f, 1.0f);
 
1659
                                draw_round_rect (cr,
1686
1660
                                         1.0f,
1687
1661
                                         EM2PIXELS (defaults_get_bubble_shadow_size (d), d),
1688
1662
                                         EM2PIXELS (defaults_get_bubble_shadow_size (d), d),
1689
1663
                                         EM2PIXELS (defaults_get_bubble_corner_radius (d), d),
1690
1664
                                         width,
1691
1665
                                         height);
1692
 
                        cairo_fill (cr);
1693
 
                        /*if (bubble_is_mouse_over (self))
1694
 
                        {
1695
 
                                cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
1696
 
                                draw_round_rect (
1697
 
                                        cr,
1698
 
                                        1.0f,
1699
 
                                        2 + EM2PIXELS (defaults_get_bubble_shadow_size (d), d),
1700
 
                                        2 + EM2PIXELS (defaults_get_bubble_shadow_size (d), d),
1701
 
                                        EM2PIXELS (defaults_get_bubble_corner_radius (d), d),
1702
 
                                        width - 4,
1703
 
                                        height - 4);
1704
1666
                                cairo_fill (cr);
1705
 
                        }*/
1706
 
 
1707
 
                        cairo_destroy (cr);
1708
 
 
1709
 
                        // remove any current shape-mask
1710
 
                        gtk_widget_shape_combine_mask (priv->widget,NULL, 0, 0);
1711
 
 
1712
 
                        // set new shape-mask
1713
 
                        gtk_widget_shape_combine_mask (priv->widget,mask, 0, 0);
 
1667
                                cairo_destroy (cr);
 
1668
 
 
1669
                                // remove any current shape-mask
 
1670
                                gtk_widget_shape_combine_mask (priv->widget,
 
1671
                                                               NULL,
 
1672
                                                               0,
 
1673
                                                               0);
 
1674
 
 
1675
                                // set new shape-mask
 
1676
                                gtk_widget_shape_combine_mask (priv->widget,
 
1677
                                                               mask,
 
1678
                                                               0,
 
1679
                                                               0);
 
1680
                        }
 
1681
                        g_object_unref ((gpointer) mask);
1714
1682
                }
1715
 
 
1716
 
                g_object_unref ((gpointer) mask);
1717
1683
        }
1718
1684
}
1719
1685
 
2307
2273
        this->priv->prevent_fade               = FALSE;
2308
2274
        this->priv->old_icon_filename          = g_string_new ("");
2309
2275
 
2310
 
        update_input_shape (window, 1, 1);
 
2276
        update_input_shape (window);
2311
2277
 
2312
2278
        return this;
2313
2279
}