mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
425b9886c9
Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
233 lines
7.2 KiB
C
233 lines
7.2 KiB
C
/* GDK - The GIMP Drawing Kit
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
/*
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
* files for a list of changes. These files are distributed with
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
*/
|
|
|
|
#include <X11/Xlib.h>
|
|
#include <X11/cursorfont.h>
|
|
|
|
#include "gdkprivate-x11.h"
|
|
#include "gdkcursor.h"
|
|
#include "gdkpixmap-x11.h"
|
|
#include "gdkx.h"
|
|
#include <gdk/gdkpixmap.h>
|
|
#include "gdkscreen-x11.h"
|
|
|
|
/**
|
|
* gdk_cursor_new_for_screen:
|
|
* @screen: the #GdkScreen where the cursor will be defined
|
|
* @cursor_type: cursor to create
|
|
*
|
|
* Creates a new cursor from the set of builtin cursors.
|
|
* Some useful ones are:
|
|
* <itemizedlist>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="right_ptr.png"></inlinegraphic> #GDK_RIGHT_PTR (right-facing arrow)
|
|
* </para></listitem>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="crosshair.png"></inlinegraphic> #GDK_CROSSHAIR (crosshair)
|
|
* </para></listitem>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="xterm.png"></inlinegraphic> #GDK_XTERM (I-beam)
|
|
* </para></listitem>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="watch.png"></inlinegraphic> #GDK_WATCH (busy)
|
|
* </para></listitem>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="fleur.png"></inlinegraphic> #GDK_FLEUR (for moving objects)
|
|
* </para></listitem>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="hand1.png"></inlinegraphic> #GDK_HAND1 (a right-pointing hand)
|
|
* </para></listitem>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="hand2.png"></inlinegraphic> #GDK_HAND2 (a left-pointing hand)
|
|
* </para></listitem>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="left_side.png"></inlinegraphic> #GDK_LEFT_SIDE (resize left side)
|
|
* </para></listitem>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="right_side.png"></inlinegraphic> #GDK_RIGHT_SIDE (resize right side)
|
|
* </para></listitem>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="top_left_corner.png"></inlinegraphic> #GDK_TOP_LEFT_CORNER (resize northwest corner)
|
|
* </para></listitem>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="top_right_corner.png"></inlinegraphic> #GDK_TOP_RIGHT_CORNER (resize northeast corner)
|
|
* </para></listitem>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="bottom_left_corner.png"></inlinegraphic> #GDK_BOTTOM_LEFT_CORNER (resize southwest corner)
|
|
* </para></listitem>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="bottom_right_corner.png"></inlinegraphic> #GDK_BOTTOM_RIGHT_CORNER (resize southeast corner)
|
|
* </para></listitem>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="top_side.png"></inlinegraphic> #GDK_TOP_SIDE (resize top side)
|
|
* </para></listitem>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="bottom_side.png"></inlinegraphic> #GDK_BOTTOM_SIDE (resize bottom side)
|
|
* </para></listitem>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="sb_h_double_arrow.png"></inlinegraphic> #GDK_SB_H_DOUBLE_ARROW (move vertical splitter)
|
|
* </para></listitem>
|
|
* <listitem><para>
|
|
* <inlinegraphic format="png" fileref="sb_v_double_arrow.png"></inlinegraphic> #GDK_SB_V_DOUBLE_ARROW (move horizontal splitter)
|
|
* </para></listitem>
|
|
* </itemizedlist>
|
|
*
|
|
* To make the cursor invisible, use gdk_cursor_new_from_pixmap() to create
|
|
* a cursor with no pixels in it.
|
|
*
|
|
* Return value: a new #GdkCursor
|
|
**/
|
|
GdkCursor*
|
|
gdk_cursor_new_for_screen (GdkScreen *screen,
|
|
GdkCursorType cursor_type)
|
|
{
|
|
GdkCursorPrivate *private;
|
|
GdkCursor *cursor;
|
|
Cursor xcursor;
|
|
|
|
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
|
|
|
|
xcursor = XCreateFontCursor (GDK_SCREEN_XDISPLAY (screen), cursor_type);
|
|
private = g_new (GdkCursorPrivate, 1);
|
|
private->screen = screen;
|
|
private->xcursor = xcursor;
|
|
cursor = (GdkCursor *) private;
|
|
cursor->type = cursor_type;
|
|
cursor->ref_count = 1;
|
|
|
|
return cursor;
|
|
}
|
|
|
|
/**
|
|
* gdk_cursor_new:
|
|
* @cursor_type: cursor to create
|
|
*
|
|
* Creates a new cursor from the set of builtin cursors for the default screen.
|
|
* See gdk_cursor_new_for_screen().
|
|
*
|
|
* To make the cursor invisible, use gdk_cursor_new_from_pixmap() to create
|
|
* a cursor with no pixels in it.
|
|
*
|
|
* Return value: a new #GdkCursor
|
|
**/
|
|
GdkCursor*
|
|
gdk_cursor_new (GdkCursorType cursor_type)
|
|
{
|
|
return gdk_cursor_new_for_screen (gdk_get_default_screen(), cursor_type);
|
|
}
|
|
|
|
GdkCursor*
|
|
gdk_cursor_new_from_pixmap (GdkPixmap *source,
|
|
GdkPixmap *mask,
|
|
GdkColor *fg,
|
|
GdkColor *bg,
|
|
gint x,
|
|
gint y)
|
|
{
|
|
GdkCursorPrivate *private;
|
|
GdkCursor *cursor;
|
|
Pixmap source_pixmap, mask_pixmap;
|
|
Cursor xcursor;
|
|
XColor xfg, xbg;
|
|
GdkScreen *screen;
|
|
|
|
g_return_val_if_fail (GDK_IS_PIXMAP (source), NULL);
|
|
g_return_val_if_fail (GDK_IS_PIXMAP (mask), NULL);
|
|
g_return_val_if_fail (fg != NULL, NULL);
|
|
g_return_val_if_fail (bg != NULL, NULL);
|
|
|
|
source_pixmap = GDK_PIXMAP_XID (source);
|
|
mask_pixmap = GDK_PIXMAP_XID (mask);
|
|
screen = GDK_PIXMAP_SCREEN (source);
|
|
|
|
xfg.pixel = fg->pixel;
|
|
xfg.red = fg->red;
|
|
xfg.blue = fg->blue;
|
|
xfg.green = fg->green;
|
|
xbg.pixel = bg->pixel;
|
|
xbg.red = bg->red;
|
|
xbg.blue = bg->blue;
|
|
xbg.green = bg->green;
|
|
|
|
xcursor = XCreatePixmapCursor (GDK_SCREEN_XDISPLAY (screen),
|
|
source_pixmap, mask_pixmap, &xfg, &xbg, x, y);
|
|
private = g_new (GdkCursorPrivate, 1);
|
|
private->screen = screen;
|
|
private->xcursor = xcursor;
|
|
cursor = (GdkCursor *) private;
|
|
cursor->type = GDK_CURSOR_IS_PIXMAP;
|
|
cursor->ref_count = 1;
|
|
|
|
return cursor;
|
|
}
|
|
|
|
void
|
|
_gdk_cursor_destroy (GdkCursor *cursor)
|
|
{
|
|
GdkCursorPrivate *private;
|
|
|
|
g_return_if_fail (cursor != NULL);
|
|
g_return_if_fail (cursor->ref_count == 0);
|
|
|
|
private = (GdkCursorPrivate *) cursor;
|
|
XFreeCursor (GDK_SCREEN_XDISPLAY (private->screen), private->xcursor);
|
|
|
|
g_free (private);
|
|
}
|
|
|
|
Display *
|
|
gdk_x11_cursor_get_xdisplay (GdkCursor *cursor)
|
|
{
|
|
g_return_val_if_fail (cursor != NULL, NULL);
|
|
|
|
return GDK_SCREEN_XDISPLAY(((GdkCursorPrivate *)cursor)->screen);
|
|
}
|
|
|
|
Cursor
|
|
gdk_x11_cursor_get_xcursor (GdkCursor *cursor)
|
|
{
|
|
g_return_val_if_fail (cursor != NULL, None);
|
|
|
|
return ((GdkCursorPrivate *)cursor)->xcursor;
|
|
}
|
|
|
|
/**
|
|
* gdk_cursor_get_screen:
|
|
* @cursor : a #GdkCursor.
|
|
*
|
|
* Returns the screen on which the GdkCursor is defined
|
|
*
|
|
* Returns : the #GdkScreen associated to @cursor
|
|
*/
|
|
|
|
GdkScreen *
|
|
gdk_cursor_get_screen (GdkCursor *cursor)
|
|
{
|
|
g_return_val_if_fail (cursor != NULL, NULL);
|
|
|
|
return ((GdkCursorPrivate *)cursor)->screen;
|
|
}
|