Example #1
0
void
_gdk_windowing_set_default_display (GdkDisplay *display)
{
  _gdk_display = GDK_DISPLAY_DFB (display);
}
Example #2
0
GdkCursor *
gdk_cursor_new_for_display (GdkDisplay *display, GdkCursorType cursor_type)
{
  GdkCursor *cursor;
  GdkDisplayDFB *dfb_display = GDK_DISPLAY_DFB (display);

  if (cursor_type >= sizeof (stock_cursors) / sizeof (stock_cursors[0]))
    return NULL;

  cursor = stock_cursors[cursor_type].cursor;
  if (!cursor)
    {
      GdkCursorDirectFB *private;
      DFBResult          ret;
      IDirectFBSurface  *temp;
      IDirectFBSurface  *temp2;
      IDirectFBSurface  *shape;

      int width  = stock_cursors[cursor_type+1].width;
      int height = stock_cursors[cursor_type+1].height;

      temp = gdk_display_dfb_create_surface (dfb_display,
                                             DSPF_ARGB,
                                             width, height);

      if (!temp)
        {
          return NULL;
        }
      else
        {
          u32  *dst;
          int     pitch;

          ret = temp->Lock (temp, DSLF_WRITE, (void**)&dst, &pitch);
          if (ret)
            {
              DirectFBError ("gdkcursor-directfb.c (gdk_cursor_new): "
                             "temp->Lock", ret);

              temp->Release (temp);

              return NULL;
            }
          else
            {
              gint x, y;
              gint mx, my;
              gint  p = ((stock_cursors[cursor_type].width + 7) / 8) * 8;
              gint mp = ((stock_cursors[cursor_type + 1].width + 7) / 8) * 8;

              const guchar *src;
              const guchar *mask;

              pitch >>= 2;

              src  = stock_cursors[cursor_type].bits;
              mask = stock_cursors[cursor_type+1].bits;

              mx = stock_cursors[cursor_type+1].hotx - stock_cursors[cursor_type].hotx;
              my = stock_cursors[cursor_type+1].hoty - stock_cursors[cursor_type].hoty;

              for (y = 0; y < height; y++)
                {
                  for (x = 0; x < width; x++)
                    {
                      gint  bit = x-mx + (y-my) * p;
                      gint mbit =    x +     y  * mp;

                      u32 color = ((x - mx) < 0  || (y - my) < 0  ||
                                   (x - mx) >= stock_cursors[cursor_type].width  ||
                                   (y - my) >= stock_cursors[cursor_type].height)
                        ? 0x00FFFFFF : (src[bit/8] & (1 << bit%8) ? 0 : 0x00FFFFFF);

		      u8  a     = color ? 0xE0 : 0xFF;
                      u32 alpha = mask[mbit/8] & (1 << mbit%8) ? (a << 24) : 0;

                      dst[x + y*pitch] = alpha | color;
                    }
                }

              temp->Unlock (temp);
            }
        }


      width  += 2;
      height += 2;

      temp2 = gdk_display_dfb_create_surface (dfb_display,
                                              DSPF_ARGB,
                                              width, height);

      if (!temp2) {
	temp->Release (temp);
	return NULL;
      }

      temp2->Clear (temp2, 0x80, 0x80, 0x80, 0);

      temp2->SetBlittingFlags (temp2, (DSBLIT_BLEND_COLORALPHA |
                                       DSBLIT_BLEND_ALPHACHANNEL));

      temp2->SetColor (temp2, 0, 0, 0, 0x30);
      temp2->Blit (temp2, temp, NULL, 0, 0);
      temp2->Blit (temp2, temp, NULL, 0, 2);
      temp2->Blit (temp2, temp, NULL, 2, 0);
      temp2->Blit (temp2, temp, NULL, 2, 2);

      temp2->SetColor (temp2, 0, 0, 0, 0xA0);
      temp2->Blit (temp2, temp, NULL, 1, 0);
      temp2->Blit (temp2, temp, NULL, 0, 1);
      temp2->Blit (temp2, temp, NULL, 2, 1);
      temp2->Blit (temp2, temp, NULL, 1, 2);

      temp2->SetColor (temp2, 0, 0, 0, 0xE0);
      temp2->Blit (temp2, temp, NULL, 1, 1);

      temp->Release (temp);

      // creating stretch
      width = width * 2;
      height = height * 2;
      shape = gdk_display_dfb_create_surface (dfb_display,
                                           	DSPF_ARGB,
                                              width, height);
      if (!shape)
      {
      	temp2->Release (temp2);
         return NULL;
      }
      shape->StretchBlit(shape, temp2, NULL, NULL);
      temp2->Release (temp2);

      private = g_new0 (GdkCursorDirectFB, 1);