Blame gdk/directfb/gdkcursor-directfb.c

Packit 98cdb6
/* GDK - The GIMP Drawing Kit
Packit 98cdb6
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
Packit 98cdb6
 *
Packit 98cdb6
 * This library is free software; you can redistribute it and/or
Packit 98cdb6
 * modify it under the terms of the GNU Lesser General Public
Packit 98cdb6
 * License as published by the Free Software Foundation; either
Packit 98cdb6
 * version 2 of the License, or (at your option) any later version.
Packit 98cdb6
 *
Packit 98cdb6
 * This library is distributed in the hope that it will be useful,
Packit 98cdb6
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 98cdb6
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 98cdb6
 * Lesser General Public License for more details.
Packit 98cdb6
 *
Packit 98cdb6
 * You should have received a copy of the GNU Lesser General Public
Packit 98cdb6
 * License along with this library; if not, write to the
Packit 98cdb6
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Packit 98cdb6
 * Boston, MA 02111-1307, USA.
Packit 98cdb6
 */
Packit 98cdb6
Packit 98cdb6
/*
Packit 98cdb6
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
Packit 98cdb6
 * file for a list of people on the GTK+ Team.
Packit 98cdb6
 */
Packit 98cdb6
Packit 98cdb6
/*
Packit 98cdb6
 * GTK+ DirectFB backend
Packit 98cdb6
 * Copyright (C) 2001-2002  convergence integrated media GmbH
Packit 98cdb6
 * Copyright (C) 2002       convergence GmbH
Packit 98cdb6
 * Written by Denis Oliver Kropp <dok@convergence.de> and
Packit 98cdb6
 *            Sven Neumann <sven@convergence.de>
Packit 98cdb6
 */
Packit 98cdb6
#include "config.h"
Packit 98cdb6
#include "gdk.h"
Packit 98cdb6
Packit 98cdb6
#include "gdkdirectfb.h"
Packit 98cdb6
#include "gdkprivate-directfb.h"
Packit 98cdb6
#include "gdkcursor.h"
Packit 98cdb6
#include "gdkalias.h"
Packit 98cdb6
Packit 98cdb6
#include "x-cursors.xbm"
Packit 98cdb6
Packit 98cdb6
#include <directfb_version.h>
Packit 98cdb6
Packit 98cdb6
Packit 98cdb6
static struct {
Packit 98cdb6
  const guchar *bits;
Packit 98cdb6
  int width, height, hotx, hoty;
Packit 98cdb6
  GdkCursor *cursor;
Packit 98cdb6
} stock_cursors[] = {
Packit 98cdb6
  {X_cursor_bits, X_cursor_width, X_cursor_height, X_cursor_x_hot, X_cursor_y_hot},
Packit 98cdb6
  {X_cursor_mask_bits, X_cursor_mask_width, X_cursor_mask_height, X_cursor_mask_x_hot, X_cursor_mask_y_hot},
Packit 98cdb6
  {arrow_bits, arrow_width, arrow_height, arrow_x_hot, arrow_y_hot},
Packit 98cdb6
  {arrow_mask_bits, arrow_mask_width, arrow_mask_height, arrow_mask_x_hot, arrow_mask_y_hot},
Packit 98cdb6
  {based_arrow_down_bits, based_arrow_down_width, based_arrow_down_height, based_arrow_down_x_hot, based_arrow_down_y_hot},
Packit 98cdb6
  {based_arrow_down_mask_bits, based_arrow_down_mask_width, based_arrow_down_mask_height, based_arrow_down_mask_x_hot, based_arrow_down_mask_y_hot},
Packit 98cdb6
  {based_arrow_up_bits, based_arrow_up_width, based_arrow_up_height, based_arrow_up_x_hot, based_arrow_up_y_hot},
Packit 98cdb6
  {based_arrow_up_mask_bits, based_arrow_up_mask_width, based_arrow_up_mask_height, based_arrow_up_mask_x_hot, based_arrow_up_mask_y_hot},
Packit 98cdb6
  {boat_bits, boat_width, boat_height, boat_x_hot, boat_y_hot},
Packit 98cdb6
  {boat_mask_bits, boat_mask_width, boat_mask_height, boat_mask_x_hot, boat_mask_y_hot},
Packit 98cdb6
  {bogosity_bits, bogosity_width, bogosity_height, bogosity_x_hot, bogosity_y_hot},
Packit 98cdb6
  {bogosity_mask_bits, bogosity_mask_width, bogosity_mask_height, bogosity_mask_x_hot, bogosity_mask_y_hot},
Packit 98cdb6
  {bottom_left_corner_bits, bottom_left_corner_width, bottom_left_corner_height, bottom_left_corner_x_hot, bottom_left_corner_y_hot},
Packit 98cdb6
  {bottom_left_corner_mask_bits, bottom_left_corner_mask_width, bottom_left_corner_mask_height, bottom_left_corner_mask_x_hot, bottom_left_corner_mask_y_hot},
Packit 98cdb6
  {bottom_right_corner_bits, bottom_right_corner_width, bottom_right_corner_height, bottom_right_corner_x_hot, bottom_right_corner_y_hot},
Packit 98cdb6
  {bottom_right_corner_mask_bits, bottom_right_corner_mask_width, bottom_right_corner_mask_height, bottom_right_corner_mask_x_hot, bottom_right_corner_mask_y_hot},
Packit 98cdb6
  {bottom_side_bits, bottom_side_width, bottom_side_height, bottom_side_x_hot, bottom_side_y_hot},
Packit 98cdb6
  {bottom_side_mask_bits, bottom_side_mask_width, bottom_side_mask_height, bottom_side_mask_x_hot, bottom_side_mask_y_hot},
Packit 98cdb6
  {bottom_tee_bits, bottom_tee_width, bottom_tee_height, bottom_tee_x_hot, bottom_tee_y_hot},
Packit 98cdb6
  {bottom_tee_mask_bits, bottom_tee_mask_width, bottom_tee_mask_height, bottom_tee_mask_x_hot, bottom_tee_mask_y_hot},
Packit 98cdb6
  {box_spiral_bits, box_spiral_width, box_spiral_height, box_spiral_x_hot, box_spiral_y_hot},
Packit 98cdb6
  {box_spiral_mask_bits, box_spiral_mask_width, box_spiral_mask_height, box_spiral_mask_x_hot, box_spiral_mask_y_hot},
Packit 98cdb6
  {center_ptr_bits, center_ptr_width, center_ptr_height, center_ptr_x_hot, center_ptr_y_hot},
Packit 98cdb6
  {center_ptr_mask_bits, center_ptr_mask_width, center_ptr_mask_height, center_ptr_mask_x_hot, center_ptr_mask_y_hot},
Packit 98cdb6
  {circle_bits, circle_width, circle_height, circle_x_hot, circle_y_hot},
Packit 98cdb6
  {circle_mask_bits, circle_mask_width, circle_mask_height, circle_mask_x_hot, circle_mask_y_hot},
Packit 98cdb6
  {clock_bits, clock_width, clock_height, clock_x_hot, clock_y_hot},
Packit 98cdb6
  {clock_mask_bits, clock_mask_width, clock_mask_height, clock_mask_x_hot, clock_mask_y_hot},
Packit 98cdb6
  {coffee_mug_bits, coffee_mug_width, coffee_mug_height, coffee_mug_x_hot, coffee_mug_y_hot},
Packit 98cdb6
  {coffee_mug_mask_bits, coffee_mug_mask_width, coffee_mug_mask_height, coffee_mug_mask_x_hot, coffee_mug_mask_y_hot},
Packit 98cdb6
  {cross_bits, cross_width, cross_height, cross_x_hot, cross_y_hot},
Packit 98cdb6
  {cross_mask_bits, cross_mask_width, cross_mask_height, cross_mask_x_hot, cross_mask_y_hot},
Packit 98cdb6
  {cross_reverse_bits, cross_reverse_width, cross_reverse_height, cross_reverse_x_hot, cross_reverse_y_hot},
Packit 98cdb6
  {cross_reverse_mask_bits, cross_reverse_mask_width, cross_reverse_mask_height, cross_reverse_mask_x_hot, cross_reverse_mask_y_hot},
Packit 98cdb6
  {crosshair_bits, crosshair_width, crosshair_height, crosshair_x_hot, crosshair_y_hot},
Packit 98cdb6
  {crosshair_mask_bits, crosshair_mask_width, crosshair_mask_height, crosshair_mask_x_hot, crosshair_mask_y_hot},
Packit 98cdb6
  {diamond_cross_bits, diamond_cross_width, diamond_cross_height, diamond_cross_x_hot, diamond_cross_y_hot},
Packit 98cdb6
  {diamond_cross_mask_bits, diamond_cross_mask_width, diamond_cross_mask_height, diamond_cross_mask_x_hot, diamond_cross_mask_y_hot},
Packit 98cdb6
  {dot_bits, dot_width, dot_height, dot_x_hot, dot_y_hot},
Packit 98cdb6
  {dot_mask_bits, dot_mask_width, dot_mask_height, dot_mask_x_hot, dot_mask_y_hot},
Packit 98cdb6
  {dotbox_bits, dotbox_width, dotbox_height, dotbox_x_hot, dotbox_y_hot},
Packit 98cdb6
  {dotbox_mask_bits, dotbox_mask_width, dotbox_mask_height, dotbox_mask_x_hot, dotbox_mask_y_hot},
Packit 98cdb6
  {double_arrow_bits, double_arrow_width, double_arrow_height, double_arrow_x_hot, double_arrow_y_hot},
Packit 98cdb6
  {double_arrow_mask_bits, double_arrow_mask_width, double_arrow_mask_height, double_arrow_mask_x_hot, double_arrow_mask_y_hot},
Packit 98cdb6
  {draft_large_bits, draft_large_width, draft_large_height, draft_large_x_hot, draft_large_y_hot},
Packit 98cdb6
  {draft_large_mask_bits, draft_large_mask_width, draft_large_mask_height, draft_large_mask_x_hot, draft_large_mask_y_hot},
Packit 98cdb6
  {draft_small_bits, draft_small_width, draft_small_height, draft_small_x_hot, draft_small_y_hot},
Packit 98cdb6
  {draft_small_mask_bits, draft_small_mask_width, draft_small_mask_height, draft_small_mask_x_hot, draft_small_mask_y_hot},
Packit 98cdb6
  {draped_box_bits, draped_box_width, draped_box_height, draped_box_x_hot, draped_box_y_hot},
Packit 98cdb6
  {draped_box_mask_bits, draped_box_mask_width, draped_box_mask_height, draped_box_mask_x_hot, draped_box_mask_y_hot},
Packit 98cdb6
  {exchange_bits, exchange_width, exchange_height, exchange_x_hot, exchange_y_hot},
Packit 98cdb6
  {exchange_mask_bits, exchange_mask_width, exchange_mask_height, exchange_mask_x_hot, exchange_mask_y_hot},
Packit 98cdb6
  {fleur_bits, fleur_width, fleur_height, fleur_x_hot, fleur_y_hot},
Packit 98cdb6
  {fleur_mask_bits, fleur_mask_width, fleur_mask_height, fleur_mask_x_hot, fleur_mask_y_hot},
Packit 98cdb6
  {gobbler_bits, gobbler_width, gobbler_height, gobbler_x_hot, gobbler_y_hot},
Packit 98cdb6
  {gobbler_mask_bits, gobbler_mask_width, gobbler_mask_height, gobbler_mask_x_hot, gobbler_mask_y_hot},
Packit 98cdb6
  {gumby_bits, gumby_width, gumby_height, gumby_x_hot, gumby_y_hot},
Packit 98cdb6
  {gumby_mask_bits, gumby_mask_width, gumby_mask_height, gumby_mask_x_hot, gumby_mask_y_hot},
Packit 98cdb6
  {hand1_bits, hand1_width, hand1_height, hand1_x_hot, hand1_y_hot},
Packit 98cdb6
  {hand1_mask_bits, hand1_mask_width, hand1_mask_height, hand1_mask_x_hot, hand1_mask_y_hot},
Packit 98cdb6
  {hand2_bits, hand2_width, hand2_height, hand2_x_hot, hand2_y_hot},
Packit 98cdb6
  {hand2_mask_bits, hand2_mask_width, hand2_mask_height, hand2_mask_x_hot, hand2_mask_y_hot},
Packit 98cdb6
  {heart_bits, heart_width, heart_height, heart_x_hot, heart_y_hot},
Packit 98cdb6
  {heart_mask_bits, heart_mask_width, heart_mask_height, heart_mask_x_hot, heart_mask_y_hot},
Packit 98cdb6
  {icon_bits, icon_width, icon_height, icon_x_hot, icon_y_hot},
Packit 98cdb6
  {icon_mask_bits, icon_mask_width, icon_mask_height, icon_mask_x_hot, icon_mask_y_hot},
Packit 98cdb6
  {iron_cross_bits, iron_cross_width, iron_cross_height, iron_cross_x_hot, iron_cross_y_hot},
Packit 98cdb6
  {iron_cross_mask_bits, iron_cross_mask_width, iron_cross_mask_height, iron_cross_mask_x_hot, iron_cross_mask_y_hot},
Packit 98cdb6
  {left_ptr_bits, left_ptr_width, left_ptr_height, left_ptr_x_hot, left_ptr_y_hot},
Packit 98cdb6
  {left_ptr_mask_bits, left_ptr_mask_width, left_ptr_mask_height, left_ptr_mask_x_hot, left_ptr_mask_y_hot},
Packit 98cdb6
  {left_side_bits, left_side_width, left_side_height, left_side_x_hot, left_side_y_hot},
Packit 98cdb6
  {left_side_mask_bits, left_side_mask_width, left_side_mask_height, left_side_mask_x_hot, left_side_mask_y_hot},
Packit 98cdb6
  {left_tee_bits, left_tee_width, left_tee_height, left_tee_x_hot, left_tee_y_hot},
Packit 98cdb6
  {left_tee_mask_bits, left_tee_mask_width, left_tee_mask_height, left_tee_mask_x_hot, left_tee_mask_y_hot},
Packit 98cdb6
  {leftbutton_bits, leftbutton_width, leftbutton_height, leftbutton_x_hot, leftbutton_y_hot},
Packit 98cdb6
  {leftbutton_mask_bits, leftbutton_mask_width, leftbutton_mask_height, leftbutton_mask_x_hot, leftbutton_mask_y_hot},
Packit 98cdb6
  {ll_angle_bits, ll_angle_width, ll_angle_height, ll_angle_x_hot, ll_angle_y_hot},
Packit 98cdb6
  {ll_angle_mask_bits, ll_angle_mask_width, ll_angle_mask_height, ll_angle_mask_x_hot, ll_angle_mask_y_hot},
Packit 98cdb6
  {lr_angle_bits, lr_angle_width, lr_angle_height, lr_angle_x_hot, lr_angle_y_hot},
Packit 98cdb6
  {lr_angle_mask_bits, lr_angle_mask_width, lr_angle_mask_height, lr_angle_mask_x_hot, lr_angle_mask_y_hot},
Packit 98cdb6
  {man_bits, man_width, man_height, man_x_hot, man_y_hot},
Packit 98cdb6
  {man_mask_bits, man_mask_width, man_mask_height, man_mask_x_hot, man_mask_y_hot},
Packit 98cdb6
  {middlebutton_bits, middlebutton_width, middlebutton_height, middlebutton_x_hot, middlebutton_y_hot},
Packit 98cdb6
  {middlebutton_mask_bits, middlebutton_mask_width, middlebutton_mask_height, middlebutton_mask_x_hot, middlebutton_mask_y_hot},
Packit 98cdb6
  {mouse_bits, mouse_width, mouse_height, mouse_x_hot, mouse_y_hot},
Packit 98cdb6
  {mouse_mask_bits, mouse_mask_width, mouse_mask_height, mouse_mask_x_hot, mouse_mask_y_hot},
Packit 98cdb6
  {pencil_bits, pencil_width, pencil_height, pencil_x_hot, pencil_y_hot},
Packit 98cdb6
  {pencil_mask_bits, pencil_mask_width, pencil_mask_height, pencil_mask_x_hot, pencil_mask_y_hot},
Packit 98cdb6
  {pirate_bits, pirate_width, pirate_height, pirate_x_hot, pirate_y_hot},
Packit 98cdb6
  {pirate_mask_bits, pirate_mask_width, pirate_mask_height, pirate_mask_x_hot, pirate_mask_y_hot},
Packit 98cdb6
  {plus_bits, plus_width, plus_height, plus_x_hot, plus_y_hot},
Packit 98cdb6
  {plus_mask_bits, plus_mask_width, plus_mask_height, plus_mask_x_hot, plus_mask_y_hot},
Packit 98cdb6
  {question_arrow_bits, question_arrow_width, question_arrow_height, question_arrow_x_hot, question_arrow_y_hot},
Packit 98cdb6
  {question_arrow_mask_bits, question_arrow_mask_width, question_arrow_mask_height, question_arrow_mask_x_hot, question_arrow_mask_y_hot},
Packit 98cdb6
  {right_ptr_bits, right_ptr_width, right_ptr_height, right_ptr_x_hot, right_ptr_y_hot},
Packit 98cdb6
  {right_ptr_mask_bits, right_ptr_mask_width, right_ptr_mask_height, right_ptr_mask_x_hot, right_ptr_mask_y_hot},
Packit 98cdb6
  {right_side_bits, right_side_width, right_side_height, right_side_x_hot, right_side_y_hot},
Packit 98cdb6
  {right_side_mask_bits, right_side_mask_width, right_side_mask_height, right_side_mask_x_hot, right_side_mask_y_hot},
Packit 98cdb6
  {right_tee_bits, right_tee_width, right_tee_height, right_tee_x_hot, right_tee_y_hot},
Packit 98cdb6
  {right_tee_mask_bits, right_tee_mask_width, right_tee_mask_height, right_tee_mask_x_hot, right_tee_mask_y_hot},
Packit 98cdb6
  {rightbutton_bits, rightbutton_width, rightbutton_height, rightbutton_x_hot, rightbutton_y_hot},
Packit 98cdb6
  {rightbutton_mask_bits, rightbutton_mask_width, rightbutton_mask_height, rightbutton_mask_x_hot, rightbutton_mask_y_hot},
Packit 98cdb6
  {rtl_logo_bits, rtl_logo_width, rtl_logo_height, rtl_logo_x_hot, rtl_logo_y_hot},
Packit 98cdb6
  {rtl_logo_mask_bits, rtl_logo_mask_width, rtl_logo_mask_height, rtl_logo_mask_x_hot, rtl_logo_mask_y_hot},
Packit 98cdb6
  {sailboat_bits, sailboat_width, sailboat_height, sailboat_x_hot, sailboat_y_hot},
Packit 98cdb6
  {sailboat_mask_bits, sailboat_mask_width, sailboat_mask_height, sailboat_mask_x_hot, sailboat_mask_y_hot},
Packit 98cdb6
  {sb_down_arrow_bits, sb_down_arrow_width, sb_down_arrow_height, sb_down_arrow_x_hot, sb_down_arrow_y_hot},
Packit 98cdb6
  {sb_down_arrow_mask_bits, sb_down_arrow_mask_width, sb_down_arrow_mask_height, sb_down_arrow_mask_x_hot, sb_down_arrow_mask_y_hot},
Packit 98cdb6
  {sb_h_double_arrow_bits, sb_h_double_arrow_width, sb_h_double_arrow_height, sb_h_double_arrow_x_hot, sb_h_double_arrow_y_hot},
Packit 98cdb6
  {sb_h_double_arrow_mask_bits, sb_h_double_arrow_mask_width, sb_h_double_arrow_mask_height, sb_h_double_arrow_mask_x_hot, sb_h_double_arrow_mask_y_hot},
Packit 98cdb6
  {sb_left_arrow_bits, sb_left_arrow_width, sb_left_arrow_height, sb_left_arrow_x_hot, sb_left_arrow_y_hot},
Packit 98cdb6
  {sb_left_arrow_mask_bits, sb_left_arrow_mask_width, sb_left_arrow_mask_height, sb_left_arrow_mask_x_hot, sb_left_arrow_mask_y_hot},
Packit 98cdb6
  {sb_right_arrow_bits, sb_right_arrow_width, sb_right_arrow_height, sb_right_arrow_x_hot, sb_right_arrow_y_hot},
Packit 98cdb6
  {sb_right_arrow_mask_bits, sb_right_arrow_mask_width, sb_right_arrow_mask_height, sb_right_arrow_mask_x_hot, sb_right_arrow_mask_y_hot},
Packit 98cdb6
  {sb_up_arrow_bits, sb_up_arrow_width, sb_up_arrow_height, sb_up_arrow_x_hot, sb_up_arrow_y_hot},
Packit 98cdb6
  {sb_up_arrow_mask_bits, sb_up_arrow_mask_width, sb_up_arrow_mask_height, sb_up_arrow_mask_x_hot, sb_up_arrow_mask_y_hot},
Packit 98cdb6
  {sb_v_double_arrow_bits, sb_v_double_arrow_width, sb_v_double_arrow_height, sb_v_double_arrow_x_hot, sb_v_double_arrow_y_hot},
Packit 98cdb6
  {sb_v_double_arrow_mask_bits, sb_v_double_arrow_mask_width, sb_v_double_arrow_mask_height, sb_v_double_arrow_mask_x_hot, sb_v_double_arrow_mask_y_hot},
Packit 98cdb6
  {shuttle_bits, shuttle_width, shuttle_height, shuttle_x_hot, shuttle_y_hot},
Packit 98cdb6
  {shuttle_mask_bits, shuttle_mask_width, shuttle_mask_height, shuttle_mask_x_hot, shuttle_mask_y_hot},
Packit 98cdb6
  {sizing_bits, sizing_width, sizing_height, sizing_x_hot, sizing_y_hot},
Packit 98cdb6
  {sizing_mask_bits, sizing_mask_width, sizing_mask_height, sizing_mask_x_hot, sizing_mask_y_hot},
Packit 98cdb6
  {spider_bits, spider_width, spider_height, spider_x_hot, spider_y_hot},
Packit 98cdb6
  {spider_mask_bits, spider_mask_width, spider_mask_height, spider_mask_x_hot, spider_mask_y_hot},
Packit 98cdb6
  {spraycan_bits, spraycan_width, spraycan_height, spraycan_x_hot, spraycan_y_hot},
Packit 98cdb6
  {spraycan_mask_bits, spraycan_mask_width, spraycan_mask_height, spraycan_mask_x_hot, spraycan_mask_y_hot},
Packit 98cdb6
  {star_bits, star_width, star_height, star_x_hot, star_y_hot},
Packit 98cdb6
  {star_mask_bits, star_mask_width, star_mask_height, star_mask_x_hot, star_mask_y_hot},
Packit 98cdb6
  {target_bits, target_width, target_height, target_x_hot, target_y_hot},
Packit 98cdb6
  {target_mask_bits, target_mask_width, target_mask_height, target_mask_x_hot, target_mask_y_hot},
Packit 98cdb6
  {tcross_bits, tcross_width, tcross_height, tcross_x_hot, tcross_y_hot},
Packit 98cdb6
  {tcross_mask_bits, tcross_mask_width, tcross_mask_height, tcross_mask_x_hot, tcross_mask_y_hot},
Packit 98cdb6
  {top_left_arrow_bits, top_left_arrow_width, top_left_arrow_height, top_left_arrow_x_hot, top_left_arrow_y_hot},
Packit 98cdb6
  {top_left_arrow_mask_bits, top_left_arrow_mask_width, top_left_arrow_mask_height, top_left_arrow_mask_x_hot, top_left_arrow_mask_y_hot},
Packit 98cdb6
  {top_left_corner_bits, top_left_corner_width, top_left_corner_height, top_left_corner_x_hot, top_left_corner_y_hot},
Packit 98cdb6
  {top_left_corner_mask_bits, top_left_corner_mask_width, top_left_corner_mask_height, top_left_corner_mask_x_hot, top_left_corner_mask_y_hot},
Packit 98cdb6
  {top_right_corner_bits, top_right_corner_width, top_right_corner_height, top_right_corner_x_hot, top_right_corner_y_hot},
Packit 98cdb6
  {top_right_corner_mask_bits, top_right_corner_mask_width, top_right_corner_mask_height, top_right_corner_mask_x_hot, top_right_corner_mask_y_hot},
Packit 98cdb6
  {top_side_bits, top_side_width, top_side_height, top_side_x_hot, top_side_y_hot},
Packit 98cdb6
  {top_side_mask_bits, top_side_mask_width, top_side_mask_height, top_side_mask_x_hot, top_side_mask_y_hot},
Packit 98cdb6
  {top_tee_bits, top_tee_width, top_tee_height, top_tee_x_hot, top_tee_y_hot},
Packit 98cdb6
  {top_tee_mask_bits, top_tee_mask_width, top_tee_mask_height, top_tee_mask_x_hot, top_tee_mask_y_hot},
Packit 98cdb6
  {trek_bits, trek_width, trek_height, trek_x_hot, trek_y_hot},
Packit 98cdb6
  {trek_mask_bits, trek_mask_width, trek_mask_height, trek_mask_x_hot, trek_mask_y_hot},
Packit 98cdb6
  {ul_angle_bits, ul_angle_width, ul_angle_height, ul_angle_x_hot, ul_angle_y_hot},
Packit 98cdb6
  {ul_angle_mask_bits, ul_angle_mask_width, ul_angle_mask_height, ul_angle_mask_x_hot, ul_angle_mask_y_hot},
Packit 98cdb6
  {umbrella_bits, umbrella_width, umbrella_height, umbrella_x_hot, umbrella_y_hot},
Packit 98cdb6
  {umbrella_mask_bits, umbrella_mask_width, umbrella_mask_height, umbrella_mask_x_hot, umbrella_mask_y_hot},
Packit 98cdb6
  {ur_angle_bits, ur_angle_width, ur_angle_height, ur_angle_x_hot, ur_angle_y_hot},
Packit 98cdb6
  {ur_angle_mask_bits, ur_angle_mask_width, ur_angle_mask_height, ur_angle_mask_x_hot, ur_angle_mask_y_hot},
Packit 98cdb6
  {watch_bits, watch_width, watch_height, watch_x_hot, watch_y_hot},
Packit 98cdb6
  {watch_mask_bits, watch_mask_width, watch_mask_height, watch_mask_x_hot, watch_mask_y_hot},
Packit 98cdb6
  {xterm_bits, xterm_width, xterm_height, xterm_x_hot, xterm_y_hot},
Packit 98cdb6
  {xterm_mask_bits, xterm_mask_width, xterm_mask_height, xterm_mask_x_hot, xterm_mask_y_hot}
Packit 98cdb6
};
Packit 98cdb6
Packit 98cdb6
GdkCursor *
Packit 98cdb6
gdk_cursor_new_for_display (GdkDisplay *display, GdkCursorType cursor_type)
Packit 98cdb6
{
Packit 98cdb6
  GdkCursor *cursor;
Packit 98cdb6
  GdkDisplayDFB *dfb_display = GDK_DISPLAY_DFB (display);
Packit 98cdb6
Packit 98cdb6
  if (cursor_type >= sizeof (stock_cursors) / sizeof (stock_cursors[0]))
Packit 98cdb6
    return NULL;
Packit 98cdb6
Packit 98cdb6
  cursor = stock_cursors[cursor_type].cursor;
Packit 98cdb6
  if (!cursor)
Packit 98cdb6
    {
Packit 98cdb6
      GdkCursorDirectFB *private;
Packit 98cdb6
      DFBResult          ret;
Packit 98cdb6
      IDirectFBSurface  *temp;
Packit 98cdb6
      IDirectFBSurface  *shape;
Packit 98cdb6
Packit 98cdb6
      int width  = stock_cursors[cursor_type+1].width;
Packit 98cdb6
      int height = stock_cursors[cursor_type+1].height;
Packit 98cdb6
Packit 98cdb6
      temp = gdk_display_dfb_create_surface (dfb_display,
Packit 98cdb6
                                             DSPF_ARGB,
Packit 98cdb6
                                             width, height);
Packit 98cdb6
Packit 98cdb6
      if (!temp)
Packit 98cdb6
        {
Packit 98cdb6
          return NULL;
Packit 98cdb6
        }
Packit 98cdb6
      else
Packit 98cdb6
        {
Packit 98cdb6
          u32  *dst;
Packit 98cdb6
          int     pitch;
Packit 98cdb6
Packit 98cdb6
          ret = temp->Lock (temp, DSLF_WRITE, (void**)&dst, &pitch);
Packit 98cdb6
          if (ret)
Packit 98cdb6
            {
Packit 98cdb6
              DirectFBError ("gdkcursor-directfb.c (gdk_cursor_new): "
Packit 98cdb6
                             "temp->Lock", ret);
Packit 98cdb6
Packit 98cdb6
              temp->Release (temp);
Packit 98cdb6
Packit 98cdb6
              return NULL;
Packit 98cdb6
            }
Packit 98cdb6
          else
Packit 98cdb6
            {
Packit 98cdb6
              gint x, y;
Packit 98cdb6
              gint mx, my;
Packit 98cdb6
              gint  p = ((stock_cursors[cursor_type].width + 7) / 8) * 8;
Packit 98cdb6
              gint mp = ((stock_cursors[cursor_type + 1].width + 7) / 8) * 8;
Packit 98cdb6
Packit 98cdb6
              const guchar *src;
Packit 98cdb6
              const guchar *mask;
Packit 98cdb6
Packit 98cdb6
              pitch >>= 2;
Packit 98cdb6
Packit 98cdb6
              src  = stock_cursors[cursor_type].bits;
Packit 98cdb6
              mask = stock_cursors[cursor_type+1].bits;
Packit 98cdb6
Packit 98cdb6
              mx = stock_cursors[cursor_type+1].hotx - stock_cursors[cursor_type].hotx;
Packit 98cdb6
              my = stock_cursors[cursor_type+1].hoty - stock_cursors[cursor_type].hoty;
Packit 98cdb6
Packit 98cdb6
              for (y = 0; y < height; y++)
Packit 98cdb6
                {
Packit 98cdb6
                  for (x = 0; x < width; x++)
Packit 98cdb6
                    {
Packit 98cdb6
                      gint  bit = x-mx + (y-my) * p;
Packit 98cdb6
                      gint mbit =    x +     y  * mp;
Packit 98cdb6
Packit 98cdb6
                      u32 color = ((x - mx) < 0  || (y - my) < 0  ||
Packit 98cdb6
                                   (x - mx) >= stock_cursors[cursor_type].width  ||
Packit 98cdb6
                                   (y - my) >= stock_cursors[cursor_type].height)
Packit 98cdb6
                        ? 0x00FFFFFF : (src[bit/8] & (1 << bit%8) ? 0 : 0x00FFFFFF);
Packit 98cdb6
Packit 98cdb6
		      u8  a     = color ? 0xE0 : 0xFF;
Packit 98cdb6
                      u32 alpha = mask[mbit/8] & (1 << mbit%8) ? (a << 24) : 0;
Packit 98cdb6
Packit 98cdb6
                      dst[x + y*pitch] = alpha | color;
Packit 98cdb6
                    }
Packit 98cdb6
                }
Packit 98cdb6
Packit 98cdb6
              temp->Unlock (temp);
Packit 98cdb6
            }
Packit 98cdb6
        }
Packit 98cdb6
Packit 98cdb6
Packit 98cdb6
      width  += 2;
Packit 98cdb6
      height += 2;
Packit 98cdb6
Packit 98cdb6
      shape = gdk_display_dfb_create_surface (dfb_display,
Packit 98cdb6
                                              DSPF_ARGB,
Packit 98cdb6
                                              width, height);
Packit 98cdb6
Packit 98cdb6
      if (!shape) {
Packit 98cdb6
	temp->Release (temp);
Packit 98cdb6
	return NULL;
Packit 98cdb6
      }
Packit 98cdb6
Packit 98cdb6
      shape->Clear (shape, 0x80, 0x80, 0x80, 0);
Packit 98cdb6
Packit 98cdb6
      shape->SetBlittingFlags (shape, (DSBLIT_BLEND_COLORALPHA |
Packit 98cdb6
                                       DSBLIT_BLEND_ALPHACHANNEL));
Packit 98cdb6
Packit 98cdb6
      shape->SetColor (shape, 0, 0, 0, 0x30);
Packit 98cdb6
      shape->Blit (shape, temp, NULL, 0, 0);
Packit 98cdb6
      shape->Blit (shape, temp, NULL, 0, 2);
Packit 98cdb6
      shape->Blit (shape, temp, NULL, 2, 0);
Packit 98cdb6
      shape->Blit (shape, temp, NULL, 2, 2);
Packit 98cdb6
Packit 98cdb6
      shape->SetColor (shape, 0, 0, 0, 0xA0);
Packit 98cdb6
      shape->Blit (shape, temp, NULL, 1, 0);
Packit 98cdb6
      shape->Blit (shape, temp, NULL, 0, 1);
Packit 98cdb6
      shape->Blit (shape, temp, NULL, 2, 1);
Packit 98cdb6
      shape->Blit (shape, temp, NULL, 1, 2);
Packit 98cdb6
Packit 98cdb6
      shape->SetColor (shape, 0, 0, 0, 0xE0);
Packit 98cdb6
      shape->Blit (shape, temp, NULL, 1, 1);
Packit 98cdb6
Packit 98cdb6
      temp->Release (temp);
Packit 98cdb6
Packit 98cdb6
      private = g_new0 (GdkCursorDirectFB, 1);
Packit 98cdb6
      cursor = (GdkCursor *) private;
Packit 98cdb6
      cursor->type = GDK_CURSOR_IS_PIXMAP;
Packit 98cdb6
      cursor->ref_count = 1;
Packit 98cdb6
Packit 98cdb6
      private->shape = shape;
Packit 98cdb6
      private->hot_x = stock_cursors[cursor_type].hotx;
Packit 98cdb6
      private->hot_y = stock_cursors[cursor_type].hoty;
Packit 98cdb6
Packit 98cdb6
      stock_cursors[cursor_type].cursor = cursor;
Packit 98cdb6
    }
Packit 98cdb6
Packit 98cdb6
  return gdk_cursor_ref (cursor);
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
GdkCursor *
Packit 98cdb6
gdk_cursor_new_from_pixmap (GdkPixmap      *source,
Packit 98cdb6
                            GdkPixmap      *mask,
Packit 98cdb6
                            const GdkColor *fg,
Packit 98cdb6
                            const GdkColor *bg,
Packit 98cdb6
                            gint            x,
Packit 98cdb6
                            gint            y)
Packit 98cdb6
{
Packit 98cdb6
  GdkCursor               *cursor;
Packit 98cdb6
  GdkCursorDirectFB       *private;
Packit 98cdb6
  GdkDrawableImplDirectFB *impl;
Packit 98cdb6
  GdkDrawableImplDirectFB *mask_impl;
Packit 98cdb6
  IDirectFBSurface        *shape;
Packit 98cdb6
Packit 98cdb6
  g_return_val_if_fail (GDK_IS_PIXMAP (source), NULL);
Packit 98cdb6
  g_return_val_if_fail (GDK_IS_PIXMAP (mask), NULL);
Packit 98cdb6
Packit 98cdb6
  impl = GDK_DRAWABLE_IMPL_DIRECTFB (GDK_PIXMAP_OBJECT (source)->impl);
Packit 98cdb6
  mask_impl = GDK_DRAWABLE_IMPL_DIRECTFB (GDK_PIXMAP_OBJECT (mask)->impl);
Packit 98cdb6
Packit 98cdb6
  int width  = impl->width;
Packit 98cdb6
  int height = impl->height;
Packit 98cdb6
Packit 98cdb6
  shape = gdk_display_dfb_create_surface (_gdk_display,
Packit 98cdb6
                                          DSPF_ARGB,
Packit 98cdb6
                                          width, height);
Packit 98cdb6
Packit 98cdb6
  if (!shape)
Packit 98cdb6
    {
Packit 98cdb6
      return NULL;
Packit 98cdb6
    }
Packit 98cdb6
Packit 98cdb6
  /*
Packit 98cdb6
   *  The following code assumes that pixmap and mask are A8 surfaces
Packit 98cdb6
   *  that correspond to X11 bitmaps. This is the traditional usage of
Packit 98cdb6
   *  gdk_cursor_new_from_pixmap(). For GTK+-DirectFB it might make
Packit 98cdb6
   *  sense to allow arbitrary ARGB cursors.
Packit 98cdb6
   */
Packit 98cdb6
Packit 98cdb6
  shape->Clear (shape, bg->red >> 8, bg->green >> 8, bg->blue >> 8, 0xFF);
Packit 98cdb6
Packit 98cdb6
  shape->SetColor (shape, fg->red >> 8, fg->green >> 8, fg->blue >> 8, 0xFF);
Packit 98cdb6
  shape->SetBlittingFlags (shape,
Packit 98cdb6
                           DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_COLORIZE);
Packit 98cdb6
  shape->Blit (shape, impl->surface, NULL, 0, 0);
Packit 98cdb6
Packit 98cdb6
  shape->SetPorterDuff (shape, DSPD_DST_IN);
Packit 98cdb6
  shape->Blit (shape, mask_impl->surface, NULL, 0, 0);
Packit 98cdb6
Packit 98cdb6
  shape->SetBlittingFlags (shape, DSBLIT_NOFX);
Packit 98cdb6
  shape->SetPorterDuff (shape, DSPD_NONE);
Packit 98cdb6
Packit 98cdb6
  private = g_new (GdkCursorDirectFB, 1);
Packit 98cdb6
  cursor = (GdkCursor *) private;
Packit 98cdb6
  cursor->type = GDK_CURSOR_IS_PIXMAP;
Packit 98cdb6
  cursor->ref_count = 1;
Packit 98cdb6
Packit 98cdb6
  private->shape = shape;
Packit 98cdb6
  private->hot_x = x;
Packit 98cdb6
  private->hot_y = y;
Packit 98cdb6
Packit 98cdb6
  return cursor;
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
GdkCursor *
Packit 98cdb6
gdk_cursor_new_from_pixbuf (GdkDisplay *display,
Packit 98cdb6
                            GdkPixbuf  *pixbuf,
Packit 98cdb6
                            gint        x,
Packit 98cdb6
                            gint        y)
Packit 98cdb6
{
Packit 98cdb6
  GdkPixmap  *pixmap, *mask;
Packit 98cdb6
  GdkCursor  *cursor;
Packit 98cdb6
  gint        width, height, depth = 8;
Packit 98cdb6
  GdkVisual*  visual;
Packit 98cdb6
Packit 98cdb6
  /* FIXME: this is not the right way to set colours */
Packit 98cdb6
  GdkColor fg = { 0, 65535, 65535, 65535 };
Packit 98cdb6
  GdkColor bg = { 0, 65535, 65535, 65535 };
Packit 98cdb6
Packit 98cdb6
  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
Packit 98cdb6
  g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
Packit 98cdb6
  g_return_val_if_fail (0 <= x && x < gdk_pixbuf_get_width (pixbuf), NULL);
Packit 98cdb6
  g_return_val_if_fail (0 <= y && y < gdk_pixbuf_get_height (pixbuf), NULL);
Packit 98cdb6
Packit 98cdb6
  width = gdk_pixbuf_get_width (pixbuf);
Packit 98cdb6
  height = gdk_pixbuf_get_height (pixbuf);
Packit 98cdb6
Packit 98cdb6
  pixmap = gdk_pixmap_new (NULL, width, height, depth);
Packit 98cdb6
  mask = gdk_pixmap_new (NULL, width, height, 1);
Packit 98cdb6
  visual = gdk_rgb_get_visual ();
Packit 98cdb6
  depth = visual->depth;
Packit 98cdb6
Packit 98cdb6
  gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 0);
Packit 98cdb6
Packit 98cdb6
  g_return_val_if_fail (GDK_IS_PIXMAP (pixmap), NULL);
Packit 98cdb6
  g_return_val_if_fail (GDK_IS_PIXMAP (mask), NULL);
Packit 98cdb6
Packit 98cdb6
  cursor = gdk_cursor_new_from_pixmap (pixmap, mask, &fg, &bg, x, y) ;
Packit 98cdb6
Packit 98cdb6
  g_object_unref (pixmap);
Packit 98cdb6
  g_object_unref (mask);
Packit 98cdb6
Packit 98cdb6
  /* a cursor of type GDK_CURSOR_IS_PIXMAP is returned */
Packit 98cdb6
  return cursor;
Packit 98cdb6
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
GdkCursor*
Packit 98cdb6
gdk_cursor_new_from_name (GdkDisplay  *display,
Packit 98cdb6
                          const gchar *name)
Packit 98cdb6
{
Packit 98cdb6
  GdkCursor *cursor;
Packit 98cdb6
  GdkPixbuf *pixbuf;
Packit 98cdb6
Packit 98cdb6
  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
Packit 98cdb6
Packit 98cdb6
  pixbuf = gdk_pixbuf_new_from_file (name, NULL);
Packit 98cdb6
  /* Prevents attempts to load stock X cursors from generating error messages */
Packit 98cdb6
  if (pixbuf == NULL)
Packit 98cdb6
    return NULL;
Packit 98cdb6
  g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
Packit 98cdb6
  cursor = gdk_cursor_new_from_pixbuf (display, pixbuf, 1, 1);
Packit 98cdb6
  g_object_unref (pixbuf);
Packit 98cdb6
Packit 98cdb6
  return cursor;
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
Packit 98cdb6
GdkPixbuf*
Packit 98cdb6
gdk_cursor_get_image (GdkCursor *cursor)
Packit 98cdb6
{
Packit 98cdb6
  g_return_val_if_fail (cursor != NULL, NULL);
Packit 98cdb6
Packit 98cdb6
  return NULL;
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
Packit 98cdb6
Packit 98cdb6
void
Packit 98cdb6
_gdk_cursor_destroy (GdkCursor *cursor)
Packit 98cdb6
{
Packit 98cdb6
  GdkCursorDirectFB *private;
Packit 98cdb6
Packit 98cdb6
  g_return_if_fail (cursor != NULL);
Packit 98cdb6
  g_return_if_fail (cursor->ref_count == 0);
Packit 98cdb6
Packit 98cdb6
  private = (GdkCursorDirectFB *) cursor;
Packit 98cdb6
Packit 98cdb6
  private->shape->Release (private->shape);
Packit 98cdb6
Packit 98cdb6
  g_free (private);
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
GdkDisplay *
Packit 98cdb6
gdk_cursor_get_display (GdkCursor *cursor)
Packit 98cdb6
{
Packit 98cdb6
  return gdk_display_get_default ();
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
guint
Packit 98cdb6
gdk_display_get_default_cursor_size (GdkDisplay *display)
Packit 98cdb6
{
Packit 98cdb6
  g_return_val_if_fail (GDK_IS_DISPLAY (display), 0);
Packit 98cdb6
Packit 98cdb6
  return 16;
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
/**
Packit 98cdb6
 * gdk_display_get_maximal_cursor_size:
Packit 98cdb6
 * @display: a #GdkDisplay
Packit 98cdb6
 * @width: the return location for the maximal cursor width
Packit 98cdb6
 * @height: the return location for the maximal cursor height
Packit 98cdb6
 *
Packit 98cdb6
 * Gets the maximal size to use for cursors on @display.
Packit 98cdb6
 *
Packit 98cdb6
 * Since: 2.4
Packit 98cdb6
 */
Packit 98cdb6
void
Packit 98cdb6
gdk_display_get_maximal_cursor_size (GdkDisplay *display,
Packit 98cdb6
                                     guint       *width,
Packit 98cdb6
                                     guint       *height)
Packit 98cdb6
{
Packit 98cdb6
  g_return_if_fail (GDK_IS_DISPLAY (display));
Packit 98cdb6
Packit 98cdb6
  /* Cursor sizes in DirectFB can be large (4095x4095), but we limit this to
Packit 98cdb6
     128x128 for max compatibility with the x11 backend. */
Packit 98cdb6
  *width  = 128;
Packit 98cdb6
  *height = 128;
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
/**
Packit 98cdb6
 * gdk_display_supports_cursor_alpha:
Packit 98cdb6
 * @display: a #GdkDisplay
Packit 98cdb6
 *
Packit 98cdb6
 * Returns %TRUE if cursors can use an 8bit alpha channel
Packit 98cdb6
 * on @display. Otherwise, cursors are restricted to bilevel
Packit 98cdb6
 * alpha (i.e. a mask).
Packit 98cdb6
 *
Packit 98cdb6
 * Returns: whether cursors can have alpha channels.
Packit 98cdb6
 *
Packit 98cdb6
 * Since: 2.4
Packit 98cdb6
 */
Packit 98cdb6
gboolean
Packit 98cdb6
gdk_display_supports_cursor_alpha (GdkDisplay *display)
Packit 98cdb6
{
Packit 98cdb6
  g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
Packit 98cdb6
  return TRUE;
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
gboolean
Packit 98cdb6
gdk_display_supports_cursor_color (GdkDisplay *display)
Packit 98cdb6
{
Packit 98cdb6
  g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
Packit 98cdb6
  return TRUE;
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
#define __GDK_CURSOR_X11_C__
Packit 98cdb6
#include "gdkaliasdef.c"
Packit 98cdb6