Compare commits
119 Commits
gtk3-remov
...
gtk-1-0
Author | SHA1 | Date | |
---|---|---|---|
|
a650699a94 | ||
|
16d5a3563f | ||
|
e0af616538 | ||
|
545d803f80 | ||
|
fafa639f7b | ||
|
0bbd333f29 | ||
|
f04ccd3146 | ||
|
0a1be824fd | ||
|
41e220c75d | ||
|
a48ad6be3e | ||
|
56ce3d070b | ||
|
358d0c4e13 | ||
|
be7ac5fc4a | ||
|
397a0daaaa | ||
|
b840c209fe | ||
|
488cb58d8d | ||
|
bbaadfc586 | ||
|
38c3cf2961 | ||
|
7977bf7bc4 | ||
|
52a9e5cae8 | ||
|
92b28247ed | ||
|
ea15a83623 | ||
|
0b345bfa9c | ||
|
2ca0b3898b | ||
|
403212acab | ||
|
1a236b3c44 | ||
|
2bc0f1c83d | ||
|
780f6c48f5 | ||
|
0a4017b054 | ||
|
39a1087c7c | ||
|
7f8bb36f06 | ||
|
7e893194cd | ||
|
3b4e7ea423 | ||
|
7c1e35b4c6 | ||
|
559a3b4435 | ||
|
d367a71915 | ||
|
e43a752e2b | ||
|
4ae5397e86 | ||
|
fcf1813ac6 | ||
|
320c0f5b4a | ||
|
4992f18f25 | ||
|
7f44192c6f | ||
|
15e5518841 | ||
|
e8358c9845 | ||
|
b975c992ba | ||
|
a66b9ecba3 | ||
|
fe487d27d3 | ||
|
ffefc931cb | ||
|
936a9bb82f | ||
|
2cf9cfc70e | ||
|
8e1f6f269d | ||
|
4a666956be | ||
|
ed9c2e8b44 | ||
|
d5e1327f9e | ||
|
f25b333e33 | ||
|
510541dd5b | ||
|
7c9cc2cf39 | ||
|
b252a7fffd | ||
|
b26728291a | ||
|
b62fc60de7 | ||
|
7defce053a | ||
|
f322097971 | ||
|
8d312b1d4f | ||
|
3b0e9baee5 | ||
|
0b1b179e45 | ||
|
6c6b244015 | ||
|
725300f5f2 | ||
|
7d56ba7b0c | ||
|
832e096207 | ||
|
063c490570 | ||
|
8d55a9d665 | ||
|
6c21fc646d | ||
|
0847bed69f | ||
|
f3f8304436 | ||
|
7e6c3c0df7 | ||
|
25f9fd2958 | ||
|
b3e0707899 | ||
|
aa505f0ff4 | ||
|
66dd08d2e8 | ||
|
8555c23889 | ||
|
98d997b105 | ||
|
5cb538d805 | ||
|
7d6aff77e5 | ||
|
668c7604a9 | ||
|
e8cf1d552b | ||
|
5266d6322a | ||
|
52d2e1b6a1 | ||
|
4aa965149c | ||
|
ab40e71ec9 | ||
|
d8e88af7d0 | ||
|
1a7acfef50 | ||
|
f8116014c1 | ||
|
eedaab9236 | ||
|
2117f4ac7e | ||
|
6349f7cb2c | ||
|
8435d34838 | ||
|
0f0ede22ad | ||
|
43ef2e2394 | ||
|
b94559a288 | ||
|
a3cfbc84cf | ||
|
4143e106cc | ||
|
d0a29b40d6 | ||
|
1b7fc490af | ||
|
8c66060a8e | ||
|
e94d12f926 | ||
|
cde57dc1d2 | ||
|
42a7da51fc | ||
|
2bec3fad18 | ||
|
2f6ee99191 | ||
|
9a1db40746 | ||
|
37bedcc07a | ||
|
302aaa2802 | ||
|
9829d1ee03 | ||
|
aa6097e255 | ||
|
1d8aed6816 | ||
|
49680fed32 | ||
|
4a7d355898 | ||
|
0982f71b98 | ||
|
7363897409 |
4
AUTHORS
4
AUTHORS
@@ -10,9 +10,9 @@ The GTK+ Team (in alphabetical order)
|
||||
Shawn T. Amundson <amundson@gtk.org>
|
||||
Jerome Bolliet <bolliet@in2p3.fr>
|
||||
Tony Gale <gale@gtk.org>
|
||||
Lars Hamann <hamann@braunschweig.netsurf.de>
|
||||
Lars Hamann <lars@gtk.org>
|
||||
Tim Janik <timj@gtk.org>
|
||||
Stefan Jeske <jeske@braunschweig.netsurf.de>
|
||||
Stefan Jeske <stefan@gtk.org>
|
||||
Elliot Lee <sopwith@gtk.org>
|
||||
Ian Main <imain@gtk.org>
|
||||
Fedrerico Mena <quartic@gtk.org>
|
||||
|
1011
ChangeLog.pre-2-0
1011
ChangeLog.pre-2-0
File diff suppressed because it is too large
Load Diff
1011
ChangeLog.pre-2-10
1011
ChangeLog.pre-2-10
File diff suppressed because it is too large
Load Diff
1011
ChangeLog.pre-2-2
1011
ChangeLog.pre-2-2
File diff suppressed because it is too large
Load Diff
1011
ChangeLog.pre-2-4
1011
ChangeLog.pre-2-4
File diff suppressed because it is too large
Load Diff
1011
ChangeLog.pre-2-6
1011
ChangeLog.pre-2-6
File diff suppressed because it is too large
Load Diff
1011
ChangeLog.pre-2-8
1011
ChangeLog.pre-2-8
File diff suppressed because it is too large
Load Diff
4
INSTALL
4
INSTALL
@@ -1,8 +1,8 @@
|
||||
Simple install procedure
|
||||
========================
|
||||
|
||||
% gzip -cd gtk+-1.0.0.tar.gz | tar xvf - # unpack the sources
|
||||
% cd gtk+-1.0.0 # change to the toplevel directory
|
||||
% gzip -cd gtk+-1.0.6.tar.gz | tar xvf - # unpack the sources
|
||||
% cd gtk+-1.0.6 # change to the toplevel directory
|
||||
% ./configure # run the `configure' script
|
||||
% make # build GTK
|
||||
[ Become root if necessary ]
|
||||
|
@@ -6,10 +6,11 @@ SUBDIRS = $(SRC_SUBDIRS) docs
|
||||
bin_SCRIPTS = gtk-config
|
||||
|
||||
EXTRA_DIST = \
|
||||
gtk+.prj \
|
||||
gtk+.spec \
|
||||
gtk.m4 \
|
||||
makecopyright \
|
||||
TODO \
|
||||
examples/README.1ST \
|
||||
examples/aspectframe/Makefile \
|
||||
examples/aspectframe/aspectframe.c \
|
||||
examples/buttons/Makefile \
|
||||
|
353
Makefile.in
353
Makefile.in
@@ -1,353 +0,0 @@
|
||||
# Makefile.in generated automatically by automake 1.2c from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = .
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = true
|
||||
PRE_INSTALL = true
|
||||
POST_INSTALL = true
|
||||
NORMAL_UNINSTALL = true
|
||||
PRE_UNINSTALL = true
|
||||
POST_UNINSTALL = true
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
CC = @CC@
|
||||
CPP = @CPP@
|
||||
LD = @LD@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
NM = @NM@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
VERSION = @VERSION@
|
||||
x_cflags = @x_cflags@
|
||||
x_includes = @x_includes@
|
||||
x_ldflags = @x_ldflags@
|
||||
x_libs = @x_libs@
|
||||
xinput_progs = @xinput_progs@
|
||||
|
||||
SRC_SUBDIRS = glib gdk gtk
|
||||
SUBDIRS = $(SRC_SUBDIRS) docs
|
||||
|
||||
EXTRA_DIST = gtk+.prj makecopyright TODO REFCOUNTING BUGS
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = config.h
|
||||
CONFIG_CLEAN_FILES = gtk+.xconfig
|
||||
DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \
|
||||
Makefile.in NEWS TODO acconfig.h aclocal.m4 config.guess config.h.in \
|
||||
config.sub configure configure.in gtk+.xconfig.in install-sh ltconfig \
|
||||
ltmain.sh missing mkinstalldirs stamp-h.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP = --best
|
||||
default: all
|
||||
|
||||
.SUFFIXES:
|
||||
$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
$(ACLOCAL_M4): @MAINT@ configure.in
|
||||
cd $(srcdir) && $(ACLOCAL)
|
||||
|
||||
config.status: $(srcdir)/configure
|
||||
$(SHELL) ./config.status --recheck
|
||||
$(srcdir)/configure: @MAINT@$(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
|
||||
cd $(srcdir) && $(AUTOCONF)
|
||||
|
||||
config.h: stamp-h
|
||||
@:
|
||||
stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES= CONFIG_HEADERS=config.h \
|
||||
$(SHELL) ./config.status
|
||||
@echo timestamp > stamp-h
|
||||
$(srcdir)/config.h.in: @MAINT@$(srcdir)/stamp-h.in
|
||||
$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h
|
||||
cd $(top_srcdir) && $(AUTOHEADER)
|
||||
@echo timestamp > $(srcdir)/stamp-h.in
|
||||
|
||||
mostlyclean-hdr:
|
||||
|
||||
clean-hdr:
|
||||
|
||||
distclean-hdr:
|
||||
-rm -f config.h
|
||||
|
||||
maintainer-clean-hdr:
|
||||
gtk+.xconfig: $(top_builddir)/config.status gtk+.xconfig.in
|
||||
cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= ./config.status
|
||||
|
||||
# This directory's subdirectories are mostly independent; you can cd
|
||||
# into them and run `make' without going through this Makefile.
|
||||
# To change the values of `make' variables: instead of editing Makefiles,
|
||||
# (1) if the variable is set in `config.status', edit `config.status'
|
||||
# (which will cause the Makefiles to be regenerated when you run `make');
|
||||
# (2) otherwise, pass the desired values on the `make' command line.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
all-recursive install-data-recursive install-exec-recursive \
|
||||
installdirs-recursive install-recursive uninstall-recursive \
|
||||
check-recursive installcheck-recursive info-recursive dvi-recursive:
|
||||
@set fnord $(MAKEFLAGS); amf=$$2; \
|
||||
for subdir in $(SUBDIRS); do \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
(cd $$subdir && $(MAKE) $$target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done && test -z "$$fail"
|
||||
|
||||
mostlyclean-recursive clean-recursive distclean-recursive \
|
||||
maintainer-clean-recursive:
|
||||
@set fnord $(MAKEFLAGS); amf=$$2; \
|
||||
rev=''; for subdir in $(SUBDIRS); do rev="$$subdir $$rev"; done; \
|
||||
for subdir in $$rev; do \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
(cd $$subdir && $(MAKE) $$target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done && test -z "$$fail"
|
||||
tags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
(cd $$subdir && $(MAKE) tags); \
|
||||
done
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES)
|
||||
here=`pwd` && cd $(srcdir) && mkid -f$$here/ID $(SOURCES) $(HEADERS)
|
||||
|
||||
TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
|
||||
done; \
|
||||
test -z "$(ETAGS_ARGS)config.h.in$(SOURCES)$(HEADERS)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $(SOURCES) $(HEADERS) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(PACKAGE)-$(VERSION)
|
||||
top_distdir = $(distdir)
|
||||
|
||||
# This target untars the dist file and tries a VPATH configuration. Then
|
||||
# it guarantees that the distribution is self-contained by making another
|
||||
# tarfile.
|
||||
distcheck: dist
|
||||
-rm -rf $(distdir)
|
||||
GZIP=$(GZIP) $(TAR) zxf $(distdir).tar.gz
|
||||
mkdir $(distdir)/=build
|
||||
mkdir $(distdir)/=inst
|
||||
dc_install_base=`cd $(distdir)/=inst && pwd`; \
|
||||
cd $(distdir)/=build \
|
||||
&& ../configure --srcdir=.. --prefix=$$dc_install_base \
|
||||
&& $(MAKE) \
|
||||
&& $(MAKE) dvi \
|
||||
&& $(MAKE) check \
|
||||
&& $(MAKE) install \
|
||||
&& $(MAKE) installcheck \
|
||||
&& $(MAKE) dist
|
||||
-rm -rf $(distdir)
|
||||
@echo "========================"; \
|
||||
echo "$(distdir).tar.gz is ready for distribution"; \
|
||||
echo "========================"
|
||||
dist: distdir
|
||||
-chmod -R a+r $(distdir)
|
||||
GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir)
|
||||
-rm -rf $(distdir)
|
||||
dist-all: distdir
|
||||
-chmod -R a+r $(distdir)
|
||||
GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir)
|
||||
-rm -rf $(distdir)
|
||||
distdir: $(DISTFILES)
|
||||
-rm -rf $(distdir)
|
||||
mkdir $(distdir)
|
||||
-chmod 777 $(distdir)
|
||||
here=`cd $(top_builddir) && pwd`; \
|
||||
top_distdir=`cd $(distdir) && pwd`; \
|
||||
distdir=`cd $(distdir) && pwd`; \
|
||||
cd $(top_srcdir) \
|
||||
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Makefile
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file; \
|
||||
done
|
||||
for subdir in $(SUBDIRS); do \
|
||||
test -d $(distdir)/$$subdir \
|
||||
|| mkdir $(distdir)/$$subdir \
|
||||
|| exit 1; \
|
||||
chmod 777 $(distdir)/$$subdir; \
|
||||
(cd $$subdir && $(MAKE) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \
|
||||
|| exit 1; \
|
||||
done
|
||||
info: info-recursive
|
||||
dvi: dvi-recursive
|
||||
check: all-am
|
||||
$(MAKE) check-recursive
|
||||
installcheck: installcheck-recursive
|
||||
all-recursive-am: config.h
|
||||
$(MAKE) all-recursive
|
||||
|
||||
all-am: Makefile config.h
|
||||
|
||||
install-exec: install-exec-recursive
|
||||
@$(NORMAL_INSTALL)
|
||||
|
||||
install-data: install-data-recursive
|
||||
@$(NORMAL_INSTALL)
|
||||
|
||||
install: install-recursive
|
||||
@:
|
||||
|
||||
uninstall: uninstall-recursive
|
||||
|
||||
all: all-recursive-am all-am
|
||||
|
||||
install-strip:
|
||||
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
|
||||
installdirs: installdirs-recursive
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
|
||||
|
||||
clean-generic:
|
||||
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(DISTCLEANFILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
|
||||
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
|
||||
mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic
|
||||
|
||||
clean-am: clean-hdr clean-tags clean-generic mostlyclean-am
|
||||
|
||||
distclean-am: distclean-hdr distclean-tags distclean-generic clean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \
|
||||
maintainer-clean-generic distclean-am
|
||||
|
||||
mostlyclean: mostlyclean-recursive mostlyclean-am
|
||||
|
||||
clean: clean-recursive clean-am
|
||||
|
||||
distclean: distclean-recursive distclean-am
|
||||
-rm -f config.status
|
||||
-rm -f libtool
|
||||
|
||||
maintainer-clean: maintainer-clean-recursive maintainer-clean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
-rm -f config.status
|
||||
|
||||
.PHONY: default mostlyclean-hdr distclean-hdr clean-hdr \
|
||||
maintainer-clean-hdr install-data-recursive uninstall-data-recursive \
|
||||
install-exec-recursive uninstall-exec-recursive installdirs-recursive \
|
||||
uninstalldirs-recursive all-recursive check-recursive \
|
||||
installcheck-recursive info-recursive dvi-recursive \
|
||||
mostlyclean-recursive distclean-recursive clean-recursive \
|
||||
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
|
||||
distclean-tags clean-tags maintainer-clean-tags distdir info dvi \
|
||||
installcheck all-recursive-am all-am install-exec install-data install \
|
||||
uninstall all installdirs mostlyclean-generic distclean-generic \
|
||||
clean-generic maintainer-clean-generic clean mostlyclean distclean \
|
||||
maintainer-clean
|
||||
|
||||
|
||||
.PHONY: files populate checkin release
|
||||
|
||||
files:
|
||||
@files=`ls $(DISTFILES) 2> /dev/null `; for p in $$files; do \
|
||||
echo $$p; \
|
||||
done
|
||||
@for subdir in $(SUBDIRS); do \
|
||||
files=`cd $$subdir; $(MAKE) files | grep -v "make\[[1-9]\]"`; \
|
||||
for file in $$files; do \
|
||||
echo $$subdir/$$file; \
|
||||
done; \
|
||||
done
|
||||
|
||||
populate:
|
||||
@echo "populating project"
|
||||
@files=`$(MAKE) files | grep -v "make\[[1-9]\]"`; prcs populate -d gtk+.prj $$files
|
||||
|
||||
checkin: populate
|
||||
@echo "checking in project"
|
||||
@prcs checkin
|
||||
|
||||
release:
|
||||
$(MAKE) dist distdir=$(PACKAGE)`date +"%y%m%d"`
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
54
NEWS
54
NEWS
@@ -1,3 +1,57 @@
|
||||
Overview of Changes in GTK+ 1.0.6:
|
||||
|
||||
* Minor documentation fixups.
|
||||
* Miscellaneous fixes for Entry, Paned, Table and CList widgets.
|
||||
* More fixes for GtkText, should behave much more stable now.
|
||||
* GtkFileSelection should behave much more nicely in combination with AFS now.
|
||||
* Configuration fixes on various platforms.
|
||||
* Miscellaneous fixes to XInput support.
|
||||
* Build with shared library dependencies on Linux
|
||||
* Fix for a major bug in the type systems memory allocation code that could
|
||||
cause random crashes.
|
||||
|
||||
Overview of Changes in GTK+ 1.0.5:
|
||||
|
||||
* Minor documentation fixups.
|
||||
* Fixes for clist (pixmap clipping), notebook, optionmenu, spinbutton
|
||||
and text widgets.
|
||||
* Minor ficup about base class initializations in the type system.
|
||||
* Fix for a major bug in the signal code that would cause random crashes.
|
||||
|
||||
|
||||
Overview of Changes in GTK+ 1.0.4:
|
||||
|
||||
* Documentation changes (Thanks to Tony Gale!)
|
||||
* autoconf fix for x_lib variable
|
||||
* fixed pixmap clipping in gtkclist
|
||||
|
||||
|
||||
Overview of Changes in GTK+ 1.0.3:
|
||||
|
||||
* Bug fixes, including fix for visuals on SGI machines
|
||||
|
||||
|
||||
Overview of Changes in GTK+ 1.0.2:
|
||||
|
||||
* Speedups for type creation and especially gtk_type_is_a() checks.
|
||||
* Speedups in signal lookup, creation and emissions and connection handling.
|
||||
* Additions to the signal handling API (e.g. *_emitv).
|
||||
* Minor speedups with object data allocation and destruction.
|
||||
* Newly included file gtkfeatures.h which defines compatibility macros to
|
||||
test for certain API features upon program compilation.
|
||||
* Cleanups to give less warnings on 64-bit platforms.
|
||||
* Many bugs fixed, including:
|
||||
- A segfault with selections on Solaris and IRIX.
|
||||
- A segfault that occured for all keypresses on Linux/Alpha.
|
||||
|
||||
|
||||
Overview of Changes in GTK+ 1.0.1:
|
||||
|
||||
* Significant speedups to widget creation and destruction
|
||||
* Upgrade to libtool-1.2
|
||||
* Lots of bug fixes, including one that fixed a major memory leak
|
||||
in 1.0.0.
|
||||
|
||||
|
||||
Overview of Changes in GTK+ 1.0.0:
|
||||
|
||||
|
2
README
2
README
@@ -1,7 +1,7 @@
|
||||
General Information
|
||||
===================
|
||||
|
||||
This is GTK+ version 1.0.0. GTK+, which stands for the Gimp ToolKit,
|
||||
This is GTK+ version 1.0.6. GTK+, which stands for the Gimp ToolKit,
|
||||
is a library for creating graphical user interfaces for the X Window
|
||||
System. It is designed to be small, efficient, and flexible. GTK+ is
|
||||
written in C with a very object-oriented approach.
|
||||
|
11
acconfig.h
11
acconfig.h
@@ -17,10 +17,14 @@
|
||||
/* Other stuff */
|
||||
#undef HAVE_IPC_H
|
||||
#undef HAVE_SHM_H
|
||||
#undef HAVE_XPM
|
||||
#undef HAVE_XSHM_H
|
||||
#undef HAVE_SHAPE_EXT
|
||||
#undef HAVE_SYS_SELECT_H
|
||||
|
||||
/* some systems do not allow to ipcrm pages prior to
|
||||
* actual usage, namely: OSF1 V3.2, SunOS 4.1.1, 5.5, 5.5.1, 5.6,
|
||||
* IRIX 5.2 and 6.2.
|
||||
*/
|
||||
#undef IPC_RMID_DEFERRED_RELEASE
|
||||
|
||||
#undef NO_FD_SET
|
||||
@@ -31,11 +35,6 @@
|
||||
#undef XINPUT_GXI
|
||||
#undef XINPUT_XFREE
|
||||
|
||||
#undef GTK_MAJOR_VERSION
|
||||
#undef GTK_MINOR_VERSION
|
||||
#undef GTK_MICRO_VERSION
|
||||
#undef GTK_VERSION
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
|
11
config.h.in
11
config.h.in
@@ -18,10 +18,14 @@
|
||||
/* Other stuff */
|
||||
#undef HAVE_IPC_H
|
||||
#undef HAVE_SHM_H
|
||||
#undef HAVE_XPM
|
||||
#undef HAVE_XSHM_H
|
||||
#undef HAVE_SHAPE_EXT
|
||||
#undef HAVE_SYS_SELECT_H
|
||||
|
||||
/* some systems do not allow to ipcrm pages prior to
|
||||
* actual usage, namely: OSF1 V3.2, SunOS 4.1.1, 5.5, 5.5.1, 5.6,
|
||||
* IRIX 5.2 and 6.2.
|
||||
*/
|
||||
#undef IPC_RMID_DEFERRED_RELEASE
|
||||
|
||||
#undef NO_FD_SET
|
||||
@@ -32,11 +36,6 @@
|
||||
#undef XINPUT_GXI
|
||||
#undef XINPUT_XFREE
|
||||
|
||||
#undef GTK_MAJOR_VERSION
|
||||
#undef GTK_MINOR_VERSION
|
||||
#undef GTK_MICRO_VERSION
|
||||
#undef GTK_VERSION
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
|
86
configure.in
86
configure.in
@@ -6,7 +6,7 @@ cflags_set=${CFLAGS+set}
|
||||
|
||||
GTK_MAJOR_VERSION=1
|
||||
GTK_MINOR_VERSION=0
|
||||
GTK_MICRO_VERSION=0
|
||||
GTK_MICRO_VERSION=6
|
||||
GTK_VERSION=$GTK_MAJOR_VERSION.$GTK_MINOR_VERSION.$GTK_MICRO_VERSION
|
||||
|
||||
# For automake.
|
||||
@@ -16,12 +16,17 @@ PACKAGE=gtk+
|
||||
# Configure glib
|
||||
AC_CONFIG_SUBDIRS(glib)
|
||||
|
||||
# Save this value here, since automake will set cflags later
|
||||
cflags_set=${CFLAGS+set}
|
||||
|
||||
dnl Initialize automake stuff
|
||||
AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
|
||||
|
||||
AC_SUBST(GTK_MAJOR_VERSION)
|
||||
AC_SUBST(GTK_MINOR_VERSION)
|
||||
AC_SUBST(GTK_MICRO_VERSION)
|
||||
AC_SUBST(GTK_VERSION)
|
||||
|
||||
# Save this value here, since automake will set cflags later
|
||||
cflags_set=${CFLAGS+set}
|
||||
|
||||
# Specify a configuration file
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
|
||||
@@ -45,7 +50,7 @@ AC_ARG_WITH(locale, [ --with-locale=LOCALE locale name you want to use ])
|
||||
AC_ARG_WITH(xinput, [ --with-xinput=[no/gxi/xfree] support XInput ])
|
||||
|
||||
if test "x$enable_debug" = "xyes"; then
|
||||
test "$cflags_set" = set || CFLAGS="-g"
|
||||
test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
|
||||
CFLAGS="$CFLAGS -DG_ENABLE_DEBUG"
|
||||
else
|
||||
if test "x$enable_debug" = "xno"; then
|
||||
@@ -80,19 +85,52 @@ if test "x$GCC" = "xyes"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl DU4 native cc currently needs -std1 for ANSI mode (instead of K&R)
|
||||
AC_MSG_CHECKING([for extra flags to get ANSI library prototypes])
|
||||
gtk_save_LIBS=$LIBS
|
||||
LIBS="$LIBS -lm"
|
||||
AC_TRY_RUN([#include <math.h>
|
||||
int main (void) { return (log(1) != log(1.)); }],
|
||||
AC_MSG_RESULT(none needed),
|
||||
gtk_save_CFLAGS=$CFLAGS
|
||||
CFLAGS="$CFLAGS -std1"
|
||||
AC_TRY_RUN([#include <math.h>
|
||||
int main (void) { return (log(1) != log(1.)); }],
|
||||
AC_MSG_RESULT(-std1),
|
||||
AC_MSG_RESULT()
|
||||
CFLAGS=$gtk_save_CFLAGS
|
||||
AC_MSG_WARN(
|
||||
[No ANSI prototypes found in library. (-std1 didn't work.)])
|
||||
)
|
||||
)
|
||||
LIBS=$gtk_save_LIBS
|
||||
|
||||
dnl NeXTStep cc seems to need this
|
||||
AC_MSG_CHECKING([for extra flags for POSIX compliance])
|
||||
AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
|
||||
AC_MSG_RESULT(none needed),
|
||||
gtk_save_CFLAGS=$CFLAGS
|
||||
CFLAGS="$CFLAGS -posix"
|
||||
AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
|
||||
AC_MSG_RESULT(-posix),
|
||||
AC_MSG_RESULT()
|
||||
CFLAGS=$gtk_save_CFLAGS
|
||||
AC_MSG_WARN([Could not determine POSIX flag. (-posix didn't work.)])))
|
||||
|
||||
if test "x$enable_xim" = "xyes"; then
|
||||
CFLAGS="$CFLAGS -DUSE_XIM"
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED(GTK_MAJOR_VERSION, $GTK_MAJOR_VERSION)
|
||||
AC_DEFINE_UNQUOTED(GTK_MINOR_VERSION, $GTK_MINOR_VERSION)
|
||||
AC_DEFINE_UNQUOTED(GTK_MICRO_VERSION, $GTK_MICRO_VERSION)
|
||||
AC_DEFINE_UNQUOTED(GTK_VERSION, "$GTK_VERSION")
|
||||
|
||||
# Find the X11 include and library directories
|
||||
AC_PATH_X
|
||||
AC_PATH_XTRA
|
||||
|
||||
if test "x$no_x" = "xyes"; then
|
||||
AC_MSG_ERROR([
|
||||
*** X libraries or include files not found. Check 'config.log' for
|
||||
*** more details.])
|
||||
fi
|
||||
|
||||
if test "x$x_includes" = "x"; then
|
||||
x_includes="/usr/include"
|
||||
fi
|
||||
@@ -100,12 +138,14 @@ fi
|
||||
saved_cflags="$CFLAGS"
|
||||
saved_ldflags="$LDFLAGS"
|
||||
|
||||
CFLAGS="$X_CFLAGS"
|
||||
LDFLAGS="$X_LDFLAGS $X_LIBS"
|
||||
CFLAGS="$CFLAGS $X_CFLAGS"
|
||||
LDFLAGS="$LDFLAGS $X_LDFLAGS $X_LIBS"
|
||||
|
||||
# Checks for libraries.
|
||||
# Check for the X11 library
|
||||
AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", no_x11_lib=yes, $X_EXTRA_LIBS)
|
||||
AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS",
|
||||
AC_MSG_ERROR([*** libX11 not found. Check 'config.log' for more details.]),
|
||||
$X_EXTRA_LIBS)
|
||||
|
||||
if test "x$enable_shm" = "xyes"; then
|
||||
# Check for the Xext library (needed for XShm extention)
|
||||
@@ -118,6 +158,14 @@ if test "x$enable_shm" = "xyes"; then
|
||||
$x_libs)
|
||||
fi
|
||||
|
||||
# Check for shaped window extension
|
||||
|
||||
AC_CHECK_LIB(Xext, XShapeCombineMask,
|
||||
if test -z "`echo $x_libs | grep "\-lXext" 2> /dev/null`"; then
|
||||
x_libs="-lXext $x_libs"
|
||||
fi
|
||||
AC_DEFINE(HAVE_SHAPE_EXT),, $x_libs)
|
||||
|
||||
x_cflags="$X_CFLAGS"
|
||||
x_ldflags="$X_LDFLAGS $X_LIBS"
|
||||
|
||||
@@ -139,7 +187,6 @@ AC_SUBST(x_includes)
|
||||
AC_SUBST(x_ldflags)
|
||||
AC_SUBST(x_libs)
|
||||
AC_SUBST(xinput_progs)
|
||||
AC_SUBST(GTK_VERSION)
|
||||
|
||||
CFLAGS="$saved_cflags"
|
||||
LDFLAGS="$saved_ldflags"
|
||||
@@ -265,5 +312,12 @@ if test $gtk_ok = no; then
|
||||
AC_DEFINE(NO_FD_SET)
|
||||
fi
|
||||
|
||||
AC_OUTPUT([Makefile gtk-config docs/Makefile gdk/Makefile gtk/Makefile],
|
||||
[chmod +x gtk-config])
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
gtk-config
|
||||
docs/Makefile
|
||||
gdk/Makefile
|
||||
gtk/Makefile
|
||||
gtk/gtkfeatures.h
|
||||
],
|
||||
[chmod +x gtk-config])
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
info_TEXINFOS = gdk.texi gtk.texi glib.texi
|
||||
|
||||
man_MANS = gtk-config.1
|
||||
|
||||
EXTRA_DIST = \
|
||||
texinfo.tex \
|
||||
macros.texi \
|
||||
@@ -19,7 +21,8 @@ EXTRA_DIST = \
|
||||
widget_system.txt \
|
||||
gtk_tut_packbox1.gif \
|
||||
gtk_tut_packbox2.gif \
|
||||
gtk_tut_table.gif
|
||||
gtk_tut_table.gif \
|
||||
gtk-config.1
|
||||
|
||||
|
||||
|
||||
|
294
docs/Makefile.in
294
docs/Makefile.in
@@ -1,294 +0,0 @@
|
||||
# Makefile.in generated automatically by automake 1.2c from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = true
|
||||
PRE_INSTALL = true
|
||||
POST_INSTALL = true
|
||||
NORMAL_UNINSTALL = true
|
||||
PRE_UNINSTALL = true
|
||||
POST_UNINSTALL = true
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
CC = @CC@
|
||||
CPP = @CPP@
|
||||
LD = @LD@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
NM = @NM@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
VERSION = @VERSION@
|
||||
x_cflags = @x_cflags@
|
||||
x_includes = @x_includes@
|
||||
x_ldflags = @x_ldflags@
|
||||
x_libs = @x_libs@
|
||||
xinput_progs = @xinput_progs@
|
||||
|
||||
info_TEXINFOS = gdk.texi gtk.texi
|
||||
|
||||
EXTRA_DIST = texinfo.tex macros.texi Makefile.gtkfaq gtkfaq.sgml gtkfaq_fix
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
TEXI2DVI = texi2dvi
|
||||
TEXINFO_TEX = $(srcdir)/texinfo.tex
|
||||
INFO_DEPS = gdk.info gtk.info
|
||||
DVIS = gdk.dvi gtk.dvi
|
||||
TEXINFOS = gdk.texi gtk.texi
|
||||
DIST_COMMON = Makefile.am Makefile.in texinfo.tex
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP = --best
|
||||
default: all
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .dvi .info .ps .texi .texinfo
|
||||
$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu docs/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
gdk.info: gdk.texi
|
||||
gdk.dvi: gdk.texi
|
||||
|
||||
|
||||
gtk.info: gtk.texi
|
||||
gtk.dvi: gtk.texi
|
||||
|
||||
|
||||
DVIPS = dvips
|
||||
|
||||
.texi.info:
|
||||
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
|
||||
cd $(srcdir) \
|
||||
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
|
||||
|
||||
.texi.dvi:
|
||||
TEXINPUTS=$(srcdir):$$TEXINPUTS \
|
||||
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
|
||||
|
||||
.texi:
|
||||
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
|
||||
cd $(srcdir) \
|
||||
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
|
||||
|
||||
.texinfo.info:
|
||||
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
|
||||
cd $(srcdir) \
|
||||
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
|
||||
|
||||
.texinfo:
|
||||
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
|
||||
cd $(srcdir) \
|
||||
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
|
||||
|
||||
.texinfo.dvi:
|
||||
TEXINPUTS=$(srcdir):$$TEXINPUTS \
|
||||
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
|
||||
.dvi.ps:
|
||||
$(DVIPS) $< -o $@
|
||||
|
||||
install-info-am: $(INFO_DEPS)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(infodir)
|
||||
@for file in $(INFO_DEPS); do \
|
||||
d=$(srcdir); \
|
||||
for ifile in `cd $$d && echo $$file $$file-[0-9] $$file-[0-9][0-9]`; do \
|
||||
if test -f $$d/$$ifile; then \
|
||||
echo " $(INSTALL_DATA) $$d/$$ifile $(infodir)/$$ifile"; \
|
||||
$(INSTALL_DATA) $$d/$$ifile $(infodir)/$$ifile; \
|
||||
else : ; fi; \
|
||||
done; \
|
||||
done
|
||||
@$(POST_INSTALL)
|
||||
@if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
|
||||
for file in $(INFO_DEPS); do \
|
||||
echo " install-info --info-dir=$(infodir) $(infodir)/$$file";\
|
||||
install-info --info-dir=$(infodir) $(infodir)/$$file || :;\
|
||||
done; \
|
||||
else : ; fi
|
||||
|
||||
uninstall-info:
|
||||
$(PRE_UNINSTALL)
|
||||
@if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
|
||||
ii=yes; \
|
||||
else ii=; fi; \
|
||||
for file in $(INFO_DEPS); do \
|
||||
test -z $ii || install-info --info-dir=$(infodir) --remove $$file; \
|
||||
done
|
||||
$(NORMAL_UNINSTALL)
|
||||
for file in $(INFO_DEPS); do \
|
||||
(cd $(infodir) && rm -f $$file $$file-[0-9] $$file-[0-9][0-9]); \
|
||||
done
|
||||
|
||||
dist-info: $(INFO_DEPS)
|
||||
for base in $(INFO_DEPS); do \
|
||||
d=$(srcdir); \
|
||||
for file in `cd $$d && eval echo $$base*`; do \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file; \
|
||||
done; \
|
||||
done
|
||||
|
||||
mostlyclean-aminfo:
|
||||
-rm -f gdk.aux gdk.cp gdk.cps gdk.dvi gdk.fn gdk.fns gdk.ky gdk.kys \
|
||||
gdk.ps gdk.log gdk.pg gdk.toc gdk.tp gdk.tps gdk.vr gdk.vrs \
|
||||
gdk.op gdk.tr gdk.cv gdk.cn gtk.aux gtk.cp gtk.cps gtk.dvi \
|
||||
gtk.fn gtk.fns gtk.ky gtk.kys gtk.ps gtk.log gtk.pg gtk.toc \
|
||||
gtk.tp gtk.tps gtk.vr gtk.vrs gtk.op gtk.tr gtk.cv gtk.cn
|
||||
|
||||
clean-aminfo:
|
||||
|
||||
distclean-aminfo:
|
||||
|
||||
maintainer-clean-aminfo:
|
||||
for i in $(INFO_DEPS); do \
|
||||
rm -f $$i; \
|
||||
if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then \
|
||||
rm -f $$i-[0-9]*; \
|
||||
fi; \
|
||||
done
|
||||
tags: TAGS
|
||||
TAGS:
|
||||
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = docs
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
here=`cd $(top_builddir) && pwd`; \
|
||||
top_distdir=`cd $(top_distdir) && pwd`; \
|
||||
distdir=`cd $(distdir) && pwd`; \
|
||||
cd $(top_srcdir) \
|
||||
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu docs/Makefile
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file; \
|
||||
done
|
||||
$(MAKE) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-info
|
||||
info: $(INFO_DEPS)
|
||||
dvi: $(DVIS)
|
||||
check: all
|
||||
$(MAKE)
|
||||
installcheck:
|
||||
install-exec:
|
||||
@$(NORMAL_INSTALL)
|
||||
|
||||
install-data: install-info-am
|
||||
@$(NORMAL_INSTALL)
|
||||
|
||||
install: install-exec install-data all
|
||||
@:
|
||||
|
||||
uninstall: uninstall-info
|
||||
|
||||
all: Makefile $(INFO_DEPS)
|
||||
|
||||
install-strip:
|
||||
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
|
||||
installdirs:
|
||||
$(mkinstalldirs) $(infodir)
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
|
||||
|
||||
clean-generic:
|
||||
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(DISTCLEANFILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
|
||||
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
|
||||
mostlyclean: mostlyclean-aminfo mostlyclean-generic
|
||||
|
||||
clean: clean-aminfo clean-generic mostlyclean
|
||||
|
||||
distclean: distclean-aminfo distclean-generic clean
|
||||
-rm -f config.status
|
||||
-rm -f libtool
|
||||
|
||||
maintainer-clean: maintainer-clean-aminfo maintainer-clean-generic \
|
||||
distclean
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
.PHONY: default install-info-am uninstall-info mostlyclean-aminfo \
|
||||
distclean-aminfo clean-aminfo maintainer-clean-aminfo tags distdir info \
|
||||
dvi installcheck install-exec install-data install uninstall all \
|
||||
installdirs mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
files:
|
||||
@files=`ls $(DISTFILES) 2> /dev/null `; for p in $$files; do \
|
||||
echo $$p; \
|
||||
done
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
@@ -8,7 +8,7 @@
|
||||
|
||||
<!-- NOTE: Use only one author tag, otherwise sgml2txt barfs - TRG -->
|
||||
<author>Nathan Froyd, Tony Gale, Shawn T. Amundson.
|
||||
<date>April 6nd 1998
|
||||
<date>May 11th 1998
|
||||
<abstract>
|
||||
This document is intended to answer questions that are likely to be
|
||||
frequently asked by programmers using GTK+ or people who are just
|
||||
@@ -163,6 +163,23 @@ name="http://www.gnome.org">)
|
||||
is using GTK+ to build a free desktop for Linux. Many more programs can be found
|
||||
there.
|
||||
|
||||
<!-- ----------------------------------------------------------------- -->
|
||||
<sect1>I'm looking for an application to write in GTK+. How about an IRC client?
|
||||
<p>
|
||||
|
||||
Ask on gtk-list for suggestions. There are at least four IRC
|
||||
clients already under development.
|
||||
|
||||
<itemize>
|
||||
<item>girc. (Included with GNOME)
|
||||
<item>Bezerk (<htmlurl url="http://www.gtk.org/~trog/"
|
||||
name="http://www.gtk.org/~trog/">)
|
||||
<item>gsirc. (Location?)
|
||||
<item>Gnirc. (<htmlurl url="http://www.imaginet.fr/~dramboz/gnirc"
|
||||
name="http://www.imaginet.fr/~dramboz/gnirc">)
|
||||
</itemize>
|
||||
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<sect>How to find, configure, install, and troubleshoot GTK+
|
||||
|
||||
@@ -202,8 +219,7 @@ handle the automatically generated Makefiles.
|
||||
|
||||
<!-- ----------------------------------------------------------------- -->
|
||||
|
||||
<sect1>I've compiled and installed GTK+, but I can't get any programs to link
|
||||
with it!
|
||||
<sect1>I've compiled and installed GTK+, but I can't get any programs to link with it!
|
||||
<p>
|
||||
This problem is most often encountered when the GTK+ libraries can't be
|
||||
found or are the wrong version. Generally, the compiler will complain about an
|
||||
@@ -249,6 +265,45 @@ the libraries libgtk, libgdk, libglib, or libgck. If they do exist, remove them
|
||||
and reinstall gtk+.
|
||||
</itemize>
|
||||
|
||||
<!-- ----------------------------------------------------------------- -->
|
||||
<sect1>When compiling programs with GTK+, I get compiler error messages about not being able to find <tt/"glibconfig.h"/.
|
||||
|
||||
<p> The header file "glibconfig.h" was moved to the directory
|
||||
$exec_prefix/lib/glib/include/. $exec_prefix is the
|
||||
directory that was specified by giving the --exec-prefix
|
||||
flags to ./configure when compiling GTK+. It defaults to
|
||||
$prefix, (specified with --prefix), which in turn defaults
|
||||
to /usr/local/.
|
||||
|
||||
This was done because "glibconfig.h" includes architecture
|
||||
dependent information, and the rest of the include files
|
||||
are put in $prefix/include, which can be shared between different
|
||||
architectures.
|
||||
|
||||
GTK+ includes a shell script, <tt/gtk-config/, that
|
||||
makes it easy to find out the correct include paths.
|
||||
The GTK+ tutorial includes an example of using <tt/gtk-config/
|
||||
for simple compilation from the command line. For information
|
||||
about more complicated configuration, see the file
|
||||
docs/gtk-config.txt in the GTK+ distribution.
|
||||
|
||||
If you are trying to compile an old program, you may
|
||||
be able to work around the problem by configuring it
|
||||
with a command line like:
|
||||
|
||||
<tscreen><verb>
|
||||
CPPFLAGS="-I/usr/local/include/glib/include" ./configure
|
||||
</verb></tscreen>
|
||||
|
||||
for Bourne-compatible shells like bash, or for csh variants:
|
||||
|
||||
<tscreen><verb>
|
||||
setenv CPPFLAGS "-I/usr/local/include/glib/include"
|
||||
./configure
|
||||
</verb></tscreen>
|
||||
|
||||
(Substitute the appropriate value of $exec_prefix for /usr/local.)
|
||||
|
||||
<!-- ----------------------------------------------------------------- -->
|
||||
<sect1>When installing The GIMP, configure reports that it can't find GTK.
|
||||
<p>
|
||||
@@ -379,13 +434,11 @@ gladly be included.
|
||||
Yes. There is
|
||||
<itemize>
|
||||
<item>a C++ wrapper for GTK+ called gtk--. You can find the home page at:
|
||||
<verb>
|
||||
http://www.cs.tut.fi/~p150650/gtk/gtk--.html
|
||||
</verb>
|
||||
The FTP site is:
|
||||
<verb>
|
||||
ftp://ftp.gtk.org/pub/gtk/gtk--/
|
||||
</verb>
|
||||
<htmlurl url="http://www.cs.tut.fi/~p150650/gtk/gtk--.html"
|
||||
name="http://www.cs.tut.fi/~p150650/gtk/gtk--.html">.
|
||||
The FTP site is
|
||||
<htmlurl url="ftp://ftp.gtk.org/pub/gtk/gtk--"
|
||||
name="ftp://ftp.gtk.org/pub/gtk/gtk--">.
|
||||
<p>
|
||||
|
||||
<item>There are two Objective-c bindings currently in development:
|
||||
@@ -408,14 +461,12 @@ ftp://ftp.gtk.org/pub/gtk/gtk--/
|
||||
</itemize>
|
||||
<p>
|
||||
<item>Perl bindings
|
||||
<verb>
|
||||
ftp://ftp.gtk.org/pub/gtk/perl
|
||||
</verb>
|
||||
|
||||
<item>Guile bindings. The home page is at:
|
||||
<verb>
|
||||
http://www.ping.de/sites/zagadka/guile-gtk/
|
||||
</verb>
|
||||
<htmlurl url="ftp://ftp.gtk.org/pub/gtk/perl"
|
||||
name="ftp://ftp.gtk.org/pub/gtk/perl">
|
||||
<P>
|
||||
<item>Guile bindings. The home page is at
|
||||
<htmlurl url="http://www.ping.de/sites/zagadka/guile-gtk"
|
||||
name="http://www.ping.de/sites/zagadka/guile-gtk">.
|
||||
By the way, Guile is the GNU Project's implemention of R4RS Scheme (the
|
||||
standard). If you like Scheme, you may want to take a look at this.
|
||||
<p>
|
||||
@@ -425,24 +476,28 @@ standard). If you like Scheme, you may want to take a look at this.
|
||||
The basics of the system, including callbacks, work fine.
|
||||
|
||||
The current development is in
|
||||
http://www.ens-lyon.fr/~dmonniau/arcs/
|
||||
<htmlurl url="http://www.ens-lyon.fr/~dmonniau/arcs"
|
||||
name="http://www.ens-lyon.fr/~dmonniau/arcs">
|
||||
</quote>
|
||||
|
||||
<item>
|
||||
Several python-gtk interfaces have been done. python-gtk is at:
|
||||
<verb>
|
||||
http://www.acs.ucalgary.cs/~nashceme/python-gtk/
|
||||
</verb>
|
||||
If you try python-gtk and don't like it, there's also pygtk located at:
|
||||
<verb>
|
||||
ftp://ftp.gtk.org/pub/gtk/python/
|
||||
</verb>
|
||||
|
||||
Several python bindings have been done:
|
||||
<p>
|
||||
<itemize>
|
||||
<item>pygtk is at
|
||||
<htmlurl url="http://www.daa.com.au/~james/pygtk"
|
||||
name="http://www.daa.com.au/~james/pygtk"> and
|
||||
<htmlurl url="ftp://ftp.gtk.org/pub/gtk/python"
|
||||
name="ftp://ftp.gtk.org/pub/gtk/python">
|
||||
<item>python-gtk is at
|
||||
<htmlurl url="http://www.ucalgary.ca/~nascheme/python-gtk"
|
||||
name="http://www.ucalgary.ca/~nascheme/python-gtk">
|
||||
</itemize>
|
||||
<p>
|
||||
<item>
|
||||
There's a OpenGL/Mesa widget available for GTK+. Grab it at:
|
||||
<verb>
|
||||
http://www.sakuranet.or.jp/~aozasa/shige/doc/comp/gtk/gtkGL/files-en.html
|
||||
</verb>
|
||||
There's a OpenGL/Mesa widget available for GTK+. Grab it at
|
||||
<htmlurl url="http://www.sakuranet.or.jp/~aozasa/shige/doc/comp/gtk/gtkGL/files-en.html"
|
||||
name="http://www.sakuranet.or.jp/~aozasa/shige/doc/comp/gtk/gtkGL/files-en.html">
|
||||
|
||||
</itemize>
|
||||
|
||||
@@ -508,6 +563,7 @@ The GTK+ Tutorial lists the following widgets:
|
||||
| | `GtkCheckButton
|
||||
| | `GtkRadioButton
|
||||
| +GtkCList
|
||||
| `GtkCTree
|
||||
| +GtkFixed
|
||||
| +GtkList
|
||||
| +GtkMenuShell
|
||||
@@ -550,6 +606,58 @@ The GTK+ Tutorial lists the following widgets:
|
||||
`GtkVSeparator
|
||||
</verb>
|
||||
|
||||
<!-- ----------------------------------------------------------------- -->
|
||||
<sect1>Is GTK+ thread safe? How do I write multi-threaded GTK+ applications?
|
||||
<p>
|
||||
Although GTK+, like many X toolkits, isn't thread safe, this does
|
||||
not prohibit the development of multi-threaded applications with
|
||||
GTK+.
|
||||
|
||||
Rob Browning (rlb@cs.utexas.edu) describes threading techniques for
|
||||
use with GTK+ (slightly edited):
|
||||
|
||||
There are basically two main approaches, the first is simple, and the
|
||||
second complicated. In the first, you just make sure that all GTK+ (or
|
||||
X) interactions are handled by one, and
|
||||
only one, thread. Any other thread that wants to draw something has
|
||||
to somehow notify the "GTK+" thread, and let it handle the
|
||||
actual work.
|
||||
|
||||
The second approach allows you to call GTK+ (or X) functions from any
|
||||
thread, but it requires some careful synchronization. The
|
||||
basic idea is that you create an X protection mutex, and no one may
|
||||
make any X calls without first acquiring this mutex.
|
||||
|
||||
Note that this is a little effort, but it allows you to be
|
||||
potentially more efficient than a completely thread safe GTK+. You
|
||||
get to decide the granularity of the thread locking. You also have to
|
||||
make sure that the thread that calls gtk_main is holding the lock when
|
||||
it calls gtk_main.
|
||||
|
||||
The next thing to worry about is that since you were holding the
|
||||
global mutex when you entered gtk_main, all callbacks will also be
|
||||
holding it. This means that the callback must release it if it's
|
||||
going to call any other code that might reacquire it. Otherwise
|
||||
you'll get deadlock. Also, you must be holding the mutex when you
|
||||
finally return from the callback.
|
||||
|
||||
In order to allow threads other than the one calling gtk_main to
|
||||
get access to the mutex, we also need to register a work function
|
||||
with GTK that allows us to release the mutex periodically.
|
||||
|
||||
Why can't GTK+ be thread safe by default?
|
||||
|
||||
Complexity, overhead, and manpower. The proportion of threaded
|
||||
programs is still reasonably small, and getting thread safety right is
|
||||
both quite difficult and takes valuable time away from the main work
|
||||
of getting a good graphics library finished. It would be nice to have
|
||||
GTK+ thread safe "out of the box", but that's not practical right now,
|
||||
and it also might make GTK+ substantially less efficient if not handled
|
||||
carefully.
|
||||
|
||||
Regardless, it's especially not a priority since relatively good
|
||||
workarounds exist.
|
||||
|
||||
<!-- ----------------------------------------------------------------- -->
|
||||
<sect1>How can I prevent redrawing and resizing while I change multiple widgets?
|
||||
<p>
|
||||
@@ -558,7 +666,7 @@ code where you are changing a lot of stuff. This will result in much faster
|
||||
speed since it will prevent resizing of the entire widget hierarchy.
|
||||
|
||||
<!-- ----------------------------------------------------------------- -->
|
||||
<sect1>How do I catch a double click event in a list widget?
|
||||
<sect1>How do I catch a double click event (in a list widget, for example)?
|
||||
<p>
|
||||
Tim Janik wrote to gtk-list (slightly modified):
|
||||
|
||||
@@ -601,7 +709,15 @@ And connect the handler to your object:
|
||||
/* something else */
|
||||
}
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
and, Owen Taylor wrote:
|
||||
|
||||
Note that a single button press will be received beforehand, and
|
||||
if you are doing this for a button, you will therefore also get a
|
||||
"clicked" signal for the button. (This is going to be true for
|
||||
any toolkit, since computers aren't good at reading one's
|
||||
mind.)
|
||||
|
||||
<!-- ----------------------------------------------------------------- -->
|
||||
<sect1>How do I find out about the selection of a GtkList?
|
||||
<p>
|
||||
|
49
docs/gtk-config.1
Normal file
49
docs/gtk-config.1
Normal file
@@ -0,0 +1,49 @@
|
||||
.TH GTK+ 1 "11 May 1998" Version 1.0.2
|
||||
.SH NAME
|
||||
gtk-config - script to get information about the installed version of GTK+
|
||||
.SH SYNOPSIS
|
||||
.B gtk-config
|
||||
[\-\-prefix\fI[=DIR]\fP] [\-\-exec\-prefix\fI[=DIR]\fP] [\-\-version] [\-\-libs] [\-\-cflags]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
\fIgtk-config\fP is a tool that is used to configure to determine
|
||||
the compiler and linker flags that should be used to compile
|
||||
and link programs that use \fIGTK+\fP. It is also used internally
|
||||
to the .m4 macros for GNU autoconf that are included with \fIGTK+\fP.
|
||||
.
|
||||
.SH OPTIONS
|
||||
.l
|
||||
\fIgtk-config\fP accepts the following options:
|
||||
.TP 8
|
||||
.B \-\-version
|
||||
Print the currently installed version of \fIGTK+\fP on the standard output.
|
||||
.TP 8
|
||||
.B \-\-libs
|
||||
Print the linker flags that are necessary to link a \fIGTK+\fP program.
|
||||
.TP 8
|
||||
.B \-\-cflags
|
||||
Print the compiler flags that are necessary to compile a \fIGTK+\fP program.
|
||||
.TP 8
|
||||
.B \-\-prefix=PREFIX
|
||||
If specified, use PREFIX instead of the installation prefix that \fIGTK+\fP
|
||||
was built with when computing the output for the \-\-cflags and
|
||||
\-\-libs options. This option is also used for the exec prefix
|
||||
if \-\-exec\-prefix was not specified. This option must be specified
|
||||
before any \-\-libs or \-\-cflags options.
|
||||
.TP 8
|
||||
.B \-\-exec\-prefix=PREFIX
|
||||
If specified, use PREFIX instead of the installation exec prefix that
|
||||
\fIGTK+\fP was built with when computing the output for the \-\-cflags
|
||||
and \-\-libs options. This option must be specified before any
|
||||
\-\-libs or \-\-cflags options.
|
||||
.SH SEE ALSO
|
||||
.BR gimp (1),
|
||||
.BR gimptool (1)
|
||||
.SH COPYRIGHT
|
||||
Copyright \(co 1995 Spencer Kimball and Peter Mattis
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation.
|
7587
docs/gtk_tut.sgml
7587
docs/gtk_tut.sgml
File diff suppressed because it is too large
Load Diff
3200
docs/gtk_tut_it.sgml
3200
docs/gtk_tut_it.sgml
File diff suppressed because it is too large
Load Diff
184
docs/gtkfaq.sgml
184
docs/gtkfaq.sgml
@@ -8,7 +8,7 @@
|
||||
|
||||
<!-- NOTE: Use only one author tag, otherwise sgml2txt barfs - TRG -->
|
||||
<author>Nathan Froyd, Tony Gale, Shawn T. Amundson.
|
||||
<date>April 6nd 1998
|
||||
<date>May 11th 1998
|
||||
<abstract>
|
||||
This document is intended to answer questions that are likely to be
|
||||
frequently asked by programmers using GTK+ or people who are just
|
||||
@@ -163,6 +163,23 @@ name="http://www.gnome.org">)
|
||||
is using GTK+ to build a free desktop for Linux. Many more programs can be found
|
||||
there.
|
||||
|
||||
<!-- ----------------------------------------------------------------- -->
|
||||
<sect1>I'm looking for an application to write in GTK+. How about an IRC client?
|
||||
<p>
|
||||
|
||||
Ask on gtk-list for suggestions. There are at least four IRC
|
||||
clients already under development.
|
||||
|
||||
<itemize>
|
||||
<item>girc. (Included with GNOME)
|
||||
<item>Bezerk (<htmlurl url="http://www.gtk.org/~trog/"
|
||||
name="http://www.gtk.org/~trog/">)
|
||||
<item>gsirc. (Location?)
|
||||
<item>Gnirc. (<htmlurl url="http://www.imaginet.fr/~dramboz/gnirc"
|
||||
name="http://www.imaginet.fr/~dramboz/gnirc">)
|
||||
</itemize>
|
||||
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<sect>How to find, configure, install, and troubleshoot GTK+
|
||||
|
||||
@@ -202,8 +219,7 @@ handle the automatically generated Makefiles.
|
||||
|
||||
<!-- ----------------------------------------------------------------- -->
|
||||
|
||||
<sect1>I've compiled and installed GTK+, but I can't get any programs to link
|
||||
with it!
|
||||
<sect1>I've compiled and installed GTK+, but I can't get any programs to link with it!
|
||||
<p>
|
||||
This problem is most often encountered when the GTK+ libraries can't be
|
||||
found or are the wrong version. Generally, the compiler will complain about an
|
||||
@@ -249,6 +265,45 @@ the libraries libgtk, libgdk, libglib, or libgck. If they do exist, remove them
|
||||
and reinstall gtk+.
|
||||
</itemize>
|
||||
|
||||
<!-- ----------------------------------------------------------------- -->
|
||||
<sect1>When compiling programs with GTK+, I get compiler error messages about not being able to find <tt/"glibconfig.h"/.
|
||||
|
||||
<p> The header file "glibconfig.h" was moved to the directory
|
||||
$exec_prefix/lib/glib/include/. $exec_prefix is the
|
||||
directory that was specified by giving the --exec-prefix
|
||||
flags to ./configure when compiling GTK+. It defaults to
|
||||
$prefix, (specified with --prefix), which in turn defaults
|
||||
to /usr/local/.
|
||||
|
||||
This was done because "glibconfig.h" includes architecture
|
||||
dependent information, and the rest of the include files
|
||||
are put in $prefix/include, which can be shared between different
|
||||
architectures.
|
||||
|
||||
GTK+ includes a shell script, <tt/gtk-config/, that
|
||||
makes it easy to find out the correct include paths.
|
||||
The GTK+ tutorial includes an example of using <tt/gtk-config/
|
||||
for simple compilation from the command line. For information
|
||||
about more complicated configuration, see the file
|
||||
docs/gtk-config.txt in the GTK+ distribution.
|
||||
|
||||
If you are trying to compile an old program, you may
|
||||
be able to work around the problem by configuring it
|
||||
with a command line like:
|
||||
|
||||
<tscreen><verb>
|
||||
CPPFLAGS="-I/usr/local/include/glib/include" ./configure
|
||||
</verb></tscreen>
|
||||
|
||||
for Bourne-compatible shells like bash, or for csh variants:
|
||||
|
||||
<tscreen><verb>
|
||||
setenv CPPFLAGS "-I/usr/local/include/glib/include"
|
||||
./configure
|
||||
</verb></tscreen>
|
||||
|
||||
(Substitute the appropriate value of $exec_prefix for /usr/local.)
|
||||
|
||||
<!-- ----------------------------------------------------------------- -->
|
||||
<sect1>When installing The GIMP, configure reports that it can't find GTK.
|
||||
<p>
|
||||
@@ -379,13 +434,11 @@ gladly be included.
|
||||
Yes. There is
|
||||
<itemize>
|
||||
<item>a C++ wrapper for GTK+ called gtk--. You can find the home page at:
|
||||
<verb>
|
||||
http://www.cs.tut.fi/~p150650/gtk/gtk--.html
|
||||
</verb>
|
||||
The FTP site is:
|
||||
<verb>
|
||||
ftp://ftp.gtk.org/pub/gtk/gtk--/
|
||||
</verb>
|
||||
<htmlurl url="http://www.cs.tut.fi/~p150650/gtk/gtk--.html"
|
||||
name="http://www.cs.tut.fi/~p150650/gtk/gtk--.html">.
|
||||
The FTP site is
|
||||
<htmlurl url="ftp://ftp.gtk.org/pub/gtk/gtk--"
|
||||
name="ftp://ftp.gtk.org/pub/gtk/gtk--">.
|
||||
<p>
|
||||
|
||||
<item>There are two Objective-c bindings currently in development:
|
||||
@@ -408,14 +461,12 @@ ftp://ftp.gtk.org/pub/gtk/gtk--/
|
||||
</itemize>
|
||||
<p>
|
||||
<item>Perl bindings
|
||||
<verb>
|
||||
ftp://ftp.gtk.org/pub/gtk/perl
|
||||
</verb>
|
||||
|
||||
<item>Guile bindings. The home page is at:
|
||||
<verb>
|
||||
http://www.ping.de/sites/zagadka/guile-gtk/
|
||||
</verb>
|
||||
<htmlurl url="ftp://ftp.gtk.org/pub/gtk/perl"
|
||||
name="ftp://ftp.gtk.org/pub/gtk/perl">
|
||||
<P>
|
||||
<item>Guile bindings. The home page is at
|
||||
<htmlurl url="http://www.ping.de/sites/zagadka/guile-gtk"
|
||||
name="http://www.ping.de/sites/zagadka/guile-gtk">.
|
||||
By the way, Guile is the GNU Project's implemention of R4RS Scheme (the
|
||||
standard). If you like Scheme, you may want to take a look at this.
|
||||
<p>
|
||||
@@ -425,24 +476,28 @@ standard). If you like Scheme, you may want to take a look at this.
|
||||
The basics of the system, including callbacks, work fine.
|
||||
|
||||
The current development is in
|
||||
http://www.ens-lyon.fr/~dmonniau/arcs/
|
||||
<htmlurl url="http://www.ens-lyon.fr/~dmonniau/arcs"
|
||||
name="http://www.ens-lyon.fr/~dmonniau/arcs">
|
||||
</quote>
|
||||
|
||||
<item>
|
||||
Several python-gtk interfaces have been done. python-gtk is at:
|
||||
<verb>
|
||||
http://www.acs.ucalgary.cs/~nashceme/python-gtk/
|
||||
</verb>
|
||||
If you try python-gtk and don't like it, there's also pygtk located at:
|
||||
<verb>
|
||||
ftp://ftp.gtk.org/pub/gtk/python/
|
||||
</verb>
|
||||
|
||||
Several python bindings have been done:
|
||||
<p>
|
||||
<itemize>
|
||||
<item>pygtk is at
|
||||
<htmlurl url="http://www.daa.com.au/~james/pygtk"
|
||||
name="http://www.daa.com.au/~james/pygtk"> and
|
||||
<htmlurl url="ftp://ftp.gtk.org/pub/gtk/python"
|
||||
name="ftp://ftp.gtk.org/pub/gtk/python">
|
||||
<item>python-gtk is at
|
||||
<htmlurl url="http://www.ucalgary.ca/~nascheme/python-gtk"
|
||||
name="http://www.ucalgary.ca/~nascheme/python-gtk">
|
||||
</itemize>
|
||||
<p>
|
||||
<item>
|
||||
There's a OpenGL/Mesa widget available for GTK+. Grab it at:
|
||||
<verb>
|
||||
http://www.sakuranet.or.jp/~aozasa/shige/doc/comp/gtk/gtkGL/files-en.html
|
||||
</verb>
|
||||
There's a OpenGL/Mesa widget available for GTK+. Grab it at
|
||||
<htmlurl url="http://www.sakuranet.or.jp/~aozasa/shige/doc/comp/gtk/gtkGL/files-en.html"
|
||||
name="http://www.sakuranet.or.jp/~aozasa/shige/doc/comp/gtk/gtkGL/files-en.html">
|
||||
|
||||
</itemize>
|
||||
|
||||
@@ -508,6 +563,7 @@ The GTK+ Tutorial lists the following widgets:
|
||||
| | `GtkCheckButton
|
||||
| | `GtkRadioButton
|
||||
| +GtkCList
|
||||
| `GtkCTree
|
||||
| +GtkFixed
|
||||
| +GtkList
|
||||
| +GtkMenuShell
|
||||
@@ -550,6 +606,58 @@ The GTK+ Tutorial lists the following widgets:
|
||||
`GtkVSeparator
|
||||
</verb>
|
||||
|
||||
<!-- ----------------------------------------------------------------- -->
|
||||
<sect1>Is GTK+ thread safe? How do I write multi-threaded GTK+ applications?
|
||||
<p>
|
||||
Although GTK+, like many X toolkits, isn't thread safe, this does
|
||||
not prohibit the development of multi-threaded applications with
|
||||
GTK+.
|
||||
|
||||
Rob Browning (rlb@cs.utexas.edu) describes threading techniques for
|
||||
use with GTK+ (slightly edited):
|
||||
|
||||
There are basically two main approaches, the first is simple, and the
|
||||
second complicated. In the first, you just make sure that all GTK+ (or
|
||||
X) interactions are handled by one, and
|
||||
only one, thread. Any other thread that wants to draw something has
|
||||
to somehow notify the "GTK+" thread, and let it handle the
|
||||
actual work.
|
||||
|
||||
The second approach allows you to call GTK+ (or X) functions from any
|
||||
thread, but it requires some careful synchronization. The
|
||||
basic idea is that you create an X protection mutex, and no one may
|
||||
make any X calls without first acquiring this mutex.
|
||||
|
||||
Note that this is a little effort, but it allows you to be
|
||||
potentially more efficient than a completely thread safe GTK+. You
|
||||
get to decide the granularity of the thread locking. You also have to
|
||||
make sure that the thread that calls gtk_main is holding the lock when
|
||||
it calls gtk_main.
|
||||
|
||||
The next thing to worry about is that since you were holding the
|
||||
global mutex when you entered gtk_main, all callbacks will also be
|
||||
holding it. This means that the callback must release it if it's
|
||||
going to call any other code that might reacquire it. Otherwise
|
||||
you'll get deadlock. Also, you must be holding the mutex when you
|
||||
finally return from the callback.
|
||||
|
||||
In order to allow threads other than the one calling gtk_main to
|
||||
get access to the mutex, we also need to register a work function
|
||||
with GTK that allows us to release the mutex periodically.
|
||||
|
||||
Why can't GTK+ be thread safe by default?
|
||||
|
||||
Complexity, overhead, and manpower. The proportion of threaded
|
||||
programs is still reasonably small, and getting thread safety right is
|
||||
both quite difficult and takes valuable time away from the main work
|
||||
of getting a good graphics library finished. It would be nice to have
|
||||
GTK+ thread safe "out of the box", but that's not practical right now,
|
||||
and it also might make GTK+ substantially less efficient if not handled
|
||||
carefully.
|
||||
|
||||
Regardless, it's especially not a priority since relatively good
|
||||
workarounds exist.
|
||||
|
||||
<!-- ----------------------------------------------------------------- -->
|
||||
<sect1>How can I prevent redrawing and resizing while I change multiple widgets?
|
||||
<p>
|
||||
@@ -558,7 +666,7 @@ code where you are changing a lot of stuff. This will result in much faster
|
||||
speed since it will prevent resizing of the entire widget hierarchy.
|
||||
|
||||
<!-- ----------------------------------------------------------------- -->
|
||||
<sect1>How do I catch a double click event in a list widget?
|
||||
<sect1>How do I catch a double click event (in a list widget, for example)?
|
||||
<p>
|
||||
Tim Janik wrote to gtk-list (slightly modified):
|
||||
|
||||
@@ -601,7 +709,15 @@ And connect the handler to your object:
|
||||
/* something else */
|
||||
}
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
and, Owen Taylor wrote:
|
||||
|
||||
Note that a single button press will be received beforehand, and
|
||||
if you are doing this for a button, you will therefore also get a
|
||||
"clicked" signal for the button. (This is going to be true for
|
||||
any toolkit, since computers aren't good at reading one's
|
||||
mind.)
|
||||
|
||||
<!-- ----------------------------------------------------------------- -->
|
||||
<sect1>How do I find out about the selection of a GtkList?
|
||||
<p>
|
||||
|
26
docs/man/gtk.pod
Normal file
26
docs/man/gtk.pod
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
=head1 NAME
|
||||
|
||||
GTK+ - The GIMP Toolkit
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
For information on GTK+, see the man pages below.
|
||||
|
||||
=head1 COMMANDS
|
||||
|
||||
=head1 CONTAINER WIDGETS
|
||||
|
||||
gtk_box(3)
|
||||
gtk_vbox(3)
|
||||
gtk_hbox(3)
|
||||
|
||||
=head1 WIDGETS
|
||||
|
||||
gtk_button(3)
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
The author of this man page is Shawn T. Amundson E<lt>amundson@gtk.orgE<gt>.
|
||||
For the authors of GTK+, see the AUTHORS file in the GTK+ distribution.
|
||||
|
206
docs/man/gtk_button.pod
Normal file
206
docs/man/gtk_button.pod
Normal file
@@ -0,0 +1,206 @@
|
||||
|
||||
=head1 NAME
|
||||
|
||||
gtk_button - GTK+ push button widget
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
#include <gtk/gtkbutton.h>
|
||||
|
||||
GtkType gtk_button_get_type (void);
|
||||
GtkWidget* gtk_button_new (void);
|
||||
GtkWidget* gtk_button_new_with_label (const gchar *label);
|
||||
void gtk_button_pressed (GtkButton *button);
|
||||
void gtk_button_released (GtkButton *button);
|
||||
void gtk_button_clicked (GtkButton *button);
|
||||
void gtk_button_enter (GtkButton *button);
|
||||
void gtk_button_leave (GtkButton *button);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This widget is a standard push button widget. Push button widgets
|
||||
are generally used for allowing the user to click on them to initiate
|
||||
a command.
|
||||
|
||||
This widget is a container widget which contains one child.
|
||||
|
||||
=head1 OBJECT HIERARCHY
|
||||
|
||||
gtk_object
|
||||
gtk_widget
|
||||
gtk_container
|
||||
gtk_button
|
||||
|
||||
=head1 SIGNAL PROTOTYPES
|
||||
|
||||
"clicked" void user_function (GtkWidget *widget, gpointer data);
|
||||
"pressed" void user_function (GtkWidget *widget, gpointer data);
|
||||
"released" void user_function (GtkWidget *widget, gpointer data);
|
||||
"enter" void user_function (GtkWidget *widget, gpointer data);
|
||||
"leave" void user_function (GtkWidget *widget, gpointer data);
|
||||
|
||||
=head1 USAGE
|
||||
|
||||
=head2 Creation
|
||||
|
||||
The most common way to create a button is with a label in it, which
|
||||
contains text for the user to read. The child of the button will then
|
||||
be a L<gtk_label(3)> widget with the text you passwd in. You can
|
||||
do this in one command:
|
||||
|
||||
GtkWidget *button;
|
||||
button = gtk_button_new_with_label ("This is a button");
|
||||
|
||||
To create a gtk_button widget which does not already have a child,
|
||||
use gtk_button_new():
|
||||
|
||||
GtkWidget *button;
|
||||
button = gtk_button_new ();
|
||||
|
||||
After you have created a button you can then add a widget to the
|
||||
button (such as a label or pixmap) using gtk_container_add(). See
|
||||
L<gtk_container(3)> for more information on adding widgets to
|
||||
containers.
|
||||
|
||||
=head2 Creating a pixmap in a button in a window
|
||||
|
||||
After we have an empty gtk_button, such as above, and we have a gtk_pixmap,
|
||||
we can simply add the gtk_pixmap to the gtk_button with gtk_container_add().
|
||||
|
||||
The following code will open the file "gimp.xpm" and place it in a
|
||||
button.
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *button;
|
||||
GtkWidget *pixmap;
|
||||
GtkStyle *style;
|
||||
GdkPixmap *gdkpixmap;
|
||||
GdkBitmap *mask;
|
||||
char *filename = "gimp.xpm";
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
button = gtk_button_new ();
|
||||
gtk_container_add (GTK_CONTAINER (window), button);
|
||||
|
||||
/* The button is realized now, which creates button->window
|
||||
used below to create the pixmap. */
|
||||
gtk_widget_realize (button);
|
||||
|
||||
style = gtk_widget_get_style (button);
|
||||
gdkpixmap = gdk_pixmap_create_from_xpm (button->window, &mask,
|
||||
&style->bg[GTK_STATE_NORMAL],
|
||||
filename);
|
||||
pixmap = gtk_pixmap_new (gdkpixmap, mask);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (button), pixmap);
|
||||
|
||||
gtk_widget_show (pixmap);
|
||||
gtk_widget_show (button);
|
||||
gtk_widget_show (window);
|
||||
|
||||
gtk_main ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
=head2 Executing a command when the button is pressed
|
||||
|
||||
To execute a function when a button is pressed, use
|
||||
gtk_signal_connect() to connect to the "clicked" signal.
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (user_function),
|
||||
NULL);
|
||||
|
||||
user_function is a user defined function, like the following:
|
||||
|
||||
void user_function (GtkWidget *button, gpointer data)
|
||||
{
|
||||
printf("clicked\n");
|
||||
}
|
||||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
GtkType gtk_button_get_type (void);
|
||||
|
||||
This function returns the GtkType which is assigned to the
|
||||
object class for gtk_button.
|
||||
|
||||
GtkWidget* gtk_button_new (void);
|
||||
|
||||
This functions returns a new button widget which can then be
|
||||
used as a container for another widget.
|
||||
|
||||
GtkWidget* gtk_button_new_with_label (const gchar *label);
|
||||
|
||||
This function returns a new button widget with a label widget
|
||||
as a child. The label widget will have the text passed into
|
||||
the commant.
|
||||
|
||||
void gtk_button_pressed (GtkButton *button);
|
||||
|
||||
This function sends a "pressed" signal to the button.
|
||||
|
||||
void gtk_button_released (GtkButton *button);
|
||||
|
||||
This function sends a "released" signal to the button.
|
||||
|
||||
void gtk_button_clicked (GtkButton *button);
|
||||
|
||||
This function sends a "clicked" signal to the button.
|
||||
|
||||
void gtk_button_enter (GtkButton *button);
|
||||
|
||||
This function sends a "enter" signal to the button.
|
||||
|
||||
void gtk_button_leave (GtkButton *button);
|
||||
|
||||
This function sends a "leave" signal to the button.
|
||||
|
||||
=head1 SIGNALS
|
||||
|
||||
"clicked"
|
||||
|
||||
void user_function (GtkWidget *widget, gpointer data);
|
||||
|
||||
Gets emitted when the button is clicked. A click is
|
||||
a press and release of the button when the cursor is
|
||||
inside the button on release.
|
||||
|
||||
"pressed"
|
||||
|
||||
void user_function (GtkWidget *widget, gpointer data);
|
||||
|
||||
Gets emitted when the left mouse button is pressed.
|
||||
|
||||
"released"
|
||||
|
||||
void user_function (GtkWidget *widget, gpointer data);
|
||||
|
||||
Gets emitted when the left mouse button is released and
|
||||
the widget was previously pressed.
|
||||
|
||||
"enter"
|
||||
|
||||
void user_function (GtkWidget *widget, gpointer data);
|
||||
|
||||
Emitted when the mouse cursor enters the button.
|
||||
|
||||
"leave"
|
||||
|
||||
void user_function (GtkWidget *widget, gpointer data);
|
||||
|
||||
Emitted when the mouse cursor leaves the button.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
The author of this man page is Shawn T. Amundson E<lt>amundson@gtk.orgE<gt>.
|
||||
For the authors of GTK+, see the AUTHORS file in the GTK+ distribution.
|
||||
|
||||
|
73
docs/man/gtk_hbox.pod
Normal file
73
docs/man/gtk_hbox.pod
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
=head1 NAME
|
||||
|
||||
gtk_hbox - GTK+ horizontal box widget
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
#include <gtk/gtkhbox.h>
|
||||
|
||||
guint gtk_hbox_get_type (void);
|
||||
GtkWidget* gtk_hbox_new (gint homogeneous,
|
||||
gint spacing);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This widget is a container used to place widgets horizontally in relation
|
||||
to each other. This is done by "packing" them into the box with
|
||||
the functions gtk_box_pack_start and gtk_box_pack_end.
|
||||
|
||||
General box functions can be found in gtk_box(1).
|
||||
|
||||
=head1 OBJECT HIERARCHY
|
||||
|
||||
gtk_object
|
||||
gtk_widget
|
||||
gtk_container
|
||||
gtk_box
|
||||
gtk_hbox
|
||||
|
||||
=head1 USAGE
|
||||
|
||||
=head2 Creation
|
||||
|
||||
To create a hbox, use the function gtk_hbox_new(). The arguments
|
||||
you pass to gtk_hbox_new indicate if the hbox should be homogeneous
|
||||
(that is, if the children should all be given the same amount of
|
||||
space all the time), and the amount of space inbetween the children.
|
||||
|
||||
The following creates a hbox which is non-homogeneous and will have
|
||||
4 spacing pixels between the children:
|
||||
|
||||
GtkWidget *hbox;
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
|
||||
For instructions on adding children to this newly created hbox,
|
||||
consult gtk_box(3).
|
||||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
guint gtk_hbox_get_type (void);
|
||||
|
||||
This function returns the GtkType which is assigned to the
|
||||
object class for gtk_hbox.
|
||||
|
||||
GtkWidget* gtk_hbox_new (gint homogeneous, gint spacing);
|
||||
|
||||
This functions returns a new hbox widget which can then be
|
||||
used as a container for other widgets. Homogeneous can be
|
||||
either TRUE or FALSE and indicates if the children widgets
|
||||
will be always be allocated equal area. Spacing is the
|
||||
number of pixels to put inbetween the children of the box.
|
||||
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
gtk_box(3), gtk_vbox(3), gtk_container(3), gtk_widget(3)
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
The author of this man page is Shawn T. Amundson E<lt>amundson@gtk.orgE<gt>.
|
||||
For the authors of GTK+, see the AUTHORS file in the GTK+ distribution.
|
||||
|
||||
|
73
docs/man/gtk_vbox.pod
Normal file
73
docs/man/gtk_vbox.pod
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
=head1 NAME
|
||||
|
||||
gtk_vbox - GTK+ vertical box widget
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
#include <gtk/gtkvbox.h>
|
||||
|
||||
guint gtk_vbox_get_type (void);
|
||||
GtkWidget* gtk_vbox_new (gint homogeneous,
|
||||
gint spacing);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This widget is a container used to place widgets vertically in relation
|
||||
to each other. This is done by "packing" them into the boxes with
|
||||
the functions gtk_box_pack_start and gtk_box_pack_end.
|
||||
|
||||
General box functions can be found in gtk_box(1).
|
||||
|
||||
=head1 OBJECT HIERARCHY
|
||||
|
||||
gtk_object
|
||||
gtk_widget
|
||||
gtk_container
|
||||
gtk_box
|
||||
gtk_vbox
|
||||
|
||||
=head1 USAGE
|
||||
|
||||
=head2 Creation
|
||||
|
||||
To create a vbox, use the function gtk_vbox_new(). The arguments
|
||||
you pass to gtk_vbox_new indicate if the vbox should be homogeneous
|
||||
(that is, if the children should all be given the same amount of
|
||||
space all the time), and the amount of space inbetween the children.
|
||||
|
||||
The following creates a vbox which is non-homogeneous and will have
|
||||
4 spacing pixels between the children:
|
||||
|
||||
GtkWidget *vbox;
|
||||
vbox = gtk_vbox_new (FALSE, 4);
|
||||
|
||||
For instructions on adding children to this newly created vbox,
|
||||
consult gtk_box(3).
|
||||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
guint gtk_vbox_get_type (void);
|
||||
|
||||
This function returns the GtkType which is assigned to the
|
||||
object class for gtk_vbox.
|
||||
|
||||
GtkWidget* gtk_vbox_new (gint homogeneous, gint spacing);
|
||||
|
||||
This functions returns a new vbox widget which can then be
|
||||
used as a container for other widgets. Homogeneous can be
|
||||
either TRUE or FALSE and indicates if the children widgets
|
||||
will be always be allocated equal area. Spacing is the
|
||||
number of pixels to put inbetween the children of the box.
|
||||
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
gtk_box(3), gtk_hbox(3), gtk_container(3), gtk_widget(3)
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
The author of this man page is Shawn T. Amundson E<lt>amundson@gtk.orgE<gt>.
|
||||
For the authors of GTK+, see the AUTHORS file in the GTK+ distribution.
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
41
examples/README.1ST
Normal file
41
examples/README.1ST
Normal file
@@ -0,0 +1,41 @@
|
||||
GTK Example Code - Tony Gale <gale@gtk.org> 980623
|
||||
--------------------------------------------------
|
||||
|
||||
I have written an awk script to automatically extract the code
|
||||
examples from the GTK Tutorial (in sgml), so they only have to be
|
||||
changed in one place.
|
||||
|
||||
It's called 'extract.awk', and there is a shell wrapper to invoke
|
||||
it called 'extract.sh'
|
||||
|
||||
It takes the following switches:
|
||||
-c : Just do checking rather than output files
|
||||
-f <filename> : Extract a specific file
|
||||
-d : Extract file(s) to current directory
|
||||
|
||||
Without the -d switch, the code will be placed in the appropriate
|
||||
sub-directory. Those sub-directories will be created if they do not
|
||||
exist.
|
||||
|
||||
Without the -f switch, all code examples will be extracted.
|
||||
|
||||
The shell wrapper assumes that the GTK Tutorial is in the
|
||||
file "../docs/gtk_tut.sgml"
|
||||
|
||||
It works by looking for sections of text in the tutorial surrounded
|
||||
by, for example:
|
||||
|
||||
/* example-start helloworld helloworld.c */
|
||||
|
||||
and
|
||||
|
||||
/* example-end */
|
||||
|
||||
Where "helloworld" is the directory into which the file will be
|
||||
placed (which can also be a directory spec like hello/hello1), and
|
||||
"helloworld.c" is the file name for the code.
|
||||
|
||||
So, the code between these lines would be extracted to the file
|
||||
helloworld/helloworld.c
|
||||
|
||||
It also handles replacing the sgml tag '&' with '&'
|
@@ -46,7 +46,7 @@ GtkWidget *xpm_label_box (GtkWidget *parent, gchar *xpm_filename, gchar *label_t
|
||||
}
|
||||
|
||||
/* our usual callback function */
|
||||
void callback (GtkWidget *widget, gpointer *data)
|
||||
void callback (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
g_print ("Hello again - %s was pressed\n", (char *) data);
|
||||
}
|
||||
|
8
examples/clist/Makefile
Normal file
8
examples/clist/Makefile
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
CC = gcc
|
||||
|
||||
clist: clist.c
|
||||
$(CC) `gtk-config --cflags` `gtk-config --libs` clist.c -o clist
|
||||
|
||||
clean:
|
||||
rm -f *.o clist
|
173
examples/clist/clist.c
Normal file
173
examples/clist/clist.c
Normal file
@@ -0,0 +1,173 @@
|
||||
/* example-start clist clist.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib.h>
|
||||
|
||||
/* These are just the prototypes of the various callbacks */
|
||||
void button_add_clicked( GtkWidget *button, gpointer data);
|
||||
void button_clear_clicked( GtkWidget *button, gpointer data);
|
||||
void button_hide_show_clicked( GtkWidget *button, gpointer data);
|
||||
void selection_made( GtkWidget *clist, gint row, gint column,
|
||||
GdkEventButton *event, gpointer data);
|
||||
|
||||
gint main (int argc, gchar *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *vbox, *hbox;
|
||||
GtkWidget *clist;
|
||||
GtkWidget *button_add, *button_clear, *button_hide_show;
|
||||
gchar *titles[2] = {"Ingredients","Amount"};
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
|
||||
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_widget_set_usize(GTK_WIDGET(window), 300, 150);
|
||||
|
||||
gtk_window_set_title(GTK_WINDOW(window), "GtkCList Example");
|
||||
gtk_signal_connect(GTK_OBJECT(window),
|
||||
"destroy",
|
||||
GTK_SIGNAL_FUNC(gtk_main_quit),
|
||||
NULL);
|
||||
|
||||
vbox=gtk_vbox_new(FALSE, 5);
|
||||
gtk_container_border_width(GTK_CONTAINER(vbox), 5);
|
||||
gtk_container_add(GTK_CONTAINER(window), vbox);
|
||||
gtk_widget_show(vbox);
|
||||
|
||||
/* Create the GtkCList. For this example we use 2 columns */
|
||||
clist = gtk_clist_new_with_titles( 2, titles);
|
||||
|
||||
/* When a selection is made, we want to know about it. The callback
|
||||
* used is selection_made, and it's code can be found further down */
|
||||
gtk_signal_connect(GTK_OBJECT(clist), "select_row",
|
||||
GTK_SIGNAL_FUNC(selection_made),
|
||||
NULL);
|
||||
|
||||
/* It isn't necessary to shadow the border, but it looks nice :) */
|
||||
gtk_clist_set_border(GTK_CLIST(clist), GTK_SHADOW_OUT);
|
||||
|
||||
/* What however is important, is that we set the column widths as
|
||||
* they will never be right otherwise. Note that the columns are
|
||||
* numbered from 0 and up (to 1 in this case).
|
||||
*/
|
||||
gtk_clist_set_column_width (GTK_CLIST(clist), 0, 150);
|
||||
|
||||
/* Scollbars _only when needed_ */
|
||||
gtk_clist_set_policy(GTK_CLIST(clist), GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
/* Add the GtkCList widget to the vertical box and show it. */
|
||||
gtk_box_pack_start(GTK_BOX(vbox), clist, TRUE, TRUE, 0);
|
||||
gtk_widget_show(clist);
|
||||
|
||||
/* Create the buttons and add them to the window. See the button
|
||||
* tutorial for more examples and comments on this.
|
||||
*/
|
||||
hbox = gtk_hbox_new(FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
|
||||
gtk_widget_show(hbox);
|
||||
|
||||
button_add = gtk_button_new_with_label("Add List");
|
||||
button_clear = gtk_button_new_with_label("Clear List");
|
||||
button_hide_show = gtk_button_new_with_label("Hide/Show titles");
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(hbox), button_add, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), button_clear, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), button_hide_show, TRUE, TRUE, 0);
|
||||
|
||||
/* Connect our callbacks to the three buttons */
|
||||
gtk_signal_connect_object(GTK_OBJECT(button_add), "clicked",
|
||||
GTK_SIGNAL_FUNC(button_add_clicked),
|
||||
(gpointer) clist);
|
||||
gtk_signal_connect_object(GTK_OBJECT(button_clear), "clicked",
|
||||
GTK_SIGNAL_FUNC(button_clear_clicked),
|
||||
(gpointer) clist);
|
||||
gtk_signal_connect_object(GTK_OBJECT(button_hide_show), "clicked",
|
||||
GTK_SIGNAL_FUNC(button_hide_show_clicked),
|
||||
(gpointer) clist);
|
||||
|
||||
gtk_widget_show(button_add);
|
||||
gtk_widget_show(button_clear);
|
||||
gtk_widget_show(button_hide_show);
|
||||
|
||||
/* The interface is completely set up so we show the window and
|
||||
* enter the gtk_main loop.
|
||||
*/
|
||||
gtk_widget_show(window);
|
||||
gtk_main();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* User clicked the "Add List" button. */
|
||||
void button_add_clicked( GtkWidget *button, gpointer data)
|
||||
{
|
||||
int indx;
|
||||
|
||||
/* Something silly to add to the list. 4 rows of 2 columns each */
|
||||
gchar *drink[4][2] = {{"Milk", "3 Oz"},
|
||||
{"Water", "6 l"},
|
||||
{"Carrots", "2"},
|
||||
{"Snakes", "55"}};
|
||||
|
||||
/* Here we do the actual adding of the text. It's done once for
|
||||
* each row.
|
||||
*/
|
||||
for( indx=0; indx < 4; indx++)
|
||||
gtk_clist_append( (GtkCList*) data, drink[indx]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* User clicked the "Clear List" button. */
|
||||
void button_clear_clicked( GtkWidget *button, gpointer data)
|
||||
{
|
||||
/* Clear the list using gtk_clist_clear. This is much faster than
|
||||
* calling gtk_clist_remove once for each row.
|
||||
*/
|
||||
gtk_clist_clear((GtkCList*) data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* The user clicked the "Hide/Show titles" button. */
|
||||
void button_hide_show_clicked( GtkWidget *button, gpointer data)
|
||||
{
|
||||
/* Just a flag to remember the status. 0 = currently visible */
|
||||
static short int flag = 0;
|
||||
|
||||
if (flag == 0)
|
||||
{
|
||||
/* Hide the titles and set the flag to 1 */
|
||||
gtk_clist_column_titles_hide((GtkCList*) data);
|
||||
flag++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Show the titles and reset flag to 0 */
|
||||
gtk_clist_column_titles_show((GtkCList*) data);
|
||||
flag--;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* If we come here, then the user has selected a row in the list. */
|
||||
void selection_made( GtkWidget *clist, gint row, gint column,
|
||||
GdkEventButton *event, gpointer data)
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
/* Get the text that is stored in the selected row and column
|
||||
* which was clicked in. We will receive it as a pointer in the
|
||||
* argument text.
|
||||
*/
|
||||
gtk_clist_get_text(GTK_CLIST(clist), row, column, &text);
|
||||
|
||||
/* Just prints some information about the selected row */
|
||||
g_print("You selected row %d. More specifically you clicked in column %d, and the text in this cell is %s\n\n", row, column, text);
|
||||
|
||||
return;
|
||||
}
|
||||
/* example-end */
|
57
examples/extract.awk
Normal file
57
examples/extract.awk
Normal file
@@ -0,0 +1,57 @@
|
||||
# extract - extract C source files from GTK Tutorial
|
||||
# Copyright (C) Tony Gale 1998
|
||||
# Contact: gale@gtk.org
|
||||
#
|
||||
# Command Switches:
|
||||
# -c : Just do checking rather than output files
|
||||
# -f <filename> : Extract a specific file
|
||||
# -d : Extract files to current directory
|
||||
|
||||
BEGIN {in_example=0; check=0; spec_example=""; do_output=0; flatten=0
|
||||
for (i=0 ; i < ARGC ; i++) {
|
||||
if ( ARGV[i] == "-c" ) {
|
||||
check = 1;
|
||||
ARGV[i]="";
|
||||
} else if ( ARGV[i] == "-f" ) {
|
||||
spec_example=ARGV[i+1];
|
||||
ARGV[i]="";
|
||||
ARGV[i+1]="";
|
||||
if ( length(spec_example) == 0 ) {
|
||||
print "usage: -f <filename>";
|
||||
exit;
|
||||
}
|
||||
} else if ( ARGV[i] == "-d" ) {
|
||||
flatten = 1;
|
||||
ARGV[i]="";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$2 == "example-start" && in_example == 1 { printf("\nERROR: nested example at line %d\n", NR) > "/dev/stderr";
|
||||
exit}
|
||||
|
||||
$2 == "example-start" { in_example=1 }
|
||||
|
||||
$2 == "example-start" && check == 0 \
|
||||
{ if ( (spec_example == "") || (spec_example == $4) ) {
|
||||
if ( flatten == 0 ) {
|
||||
file_name = sprintf("%s/%s",$3, $4);
|
||||
command = sprintf("mkdir -p %s", $3);
|
||||
system(command);
|
||||
} else {
|
||||
file_name = $4;
|
||||
}
|
||||
do_output=1;
|
||||
}
|
||||
}
|
||||
|
||||
in_example==1 && check==0 && do_output==1 { gsub(/&/, "\\&", $0);
|
||||
print $0 >file_name }
|
||||
|
||||
$2 == "example-end" && in_example == 0 { printf("\nERROR: multiple ends at line %d\n", NR) > "/dev/stderr";
|
||||
exit}
|
||||
$2 == "example-end" { in_example=0; do_output=0 }
|
||||
|
||||
|
||||
END {}
|
||||
|
2
examples/extract.sh
Executable file
2
examples/extract.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#! /bin/sh
|
||||
awk -f extract.awk ../docs/gtk_tut.sgml $1 $2 $3 $4 $5
|
@@ -10,7 +10,7 @@ void file_ok_sel (GtkWidget *w, GtkFileSelection *fs)
|
||||
g_print ("%s\n", gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)));
|
||||
}
|
||||
|
||||
void destroy (GtkWidget *widget, gpointer *data)
|
||||
void destroy (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ void hello (GtkWidget *widget, gpointer data)
|
||||
}
|
||||
|
||||
|
||||
gint delete_event(GtkWidget *widget, gpointer data)
|
||||
gint delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
g_print ("delete event occured\n");
|
||||
/* if you return FALSE in the "delete_event" signal handler,
|
||||
|
@@ -12,7 +12,7 @@ void callback (GtkWidget *widget, gpointer *data)
|
||||
}
|
||||
|
||||
/* another callback */
|
||||
void delete_event (GtkWidget *widget, gpointer *data)
|
||||
void delete_event (GtkWidget *widget, GdkEvent *event, gpointer *data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
@@ -1,17 +1,11 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* menufactory.c */
|
||||
/* example-start menu menufactory.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include "mfmain.h"
|
||||
|
||||
|
||||
static void menus_remove_accel(GtkWidget * widget, gchar * signal_name, gchar * path);
|
||||
static gint menus_install_accel(GtkWidget * widget, gchar * signal_name, gchar key, gchar modifiers, gchar * path);
|
||||
void menus_init(void);
|
||||
void menus_create(GtkMenuEntry * entries, int nmenu_entries);
|
||||
static void print_hello(GtkWidget *widget, gpointer data);
|
||||
|
||||
|
||||
/* this is the GtkMenuEntry structure used to create new menus. The
|
||||
@@ -24,128 +18,37 @@ void menus_create(GtkMenuEntry * entries, int nmenu_entries);
|
||||
|
||||
static GtkMenuEntry menu_items[] =
|
||||
{
|
||||
{"<Main>/File/New", "<control>N", NULL, NULL},
|
||||
{"<Main>/File/Open", "<control>O", NULL, NULL},
|
||||
{"<Main>/File/Save", "<control>S", NULL, NULL},
|
||||
{"<Main>/File/Save as", NULL, NULL, NULL},
|
||||
{"<Main>/File/<separator>", NULL, NULL, NULL},
|
||||
{"<Main>/File/Quit", "<control>Q", file_quit_cmd_callback, "OK, I'll quit"},
|
||||
{"<Main>/Options/Test", NULL, NULL, NULL}
|
||||
{"<Main>/File/New", "<control>N", print_hello, NULL},
|
||||
{"<Main>/File/Open", "<control>O", print_hello, NULL},
|
||||
{"<Main>/File/Save", "<control>S", print_hello, NULL},
|
||||
{"<Main>/File/Save as", NULL, NULL, NULL},
|
||||
{"<Main>/File/<separator>", NULL, NULL, NULL},
|
||||
{"<Main>/File/Quit", "<control>Q", file_quit_cmd_callback, "OK, I'll quit"},
|
||||
{"<Main>/Options/Test", NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
/* calculate the number of menu_item's */
|
||||
static int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
|
||||
|
||||
static int initialize = TRUE;
|
||||
static GtkMenuFactory *factory = NULL;
|
||||
static GtkMenuFactory *subfactory[1];
|
||||
static GHashTable *entry_ht = NULL;
|
||||
|
||||
void get_main_menu(GtkWidget ** menubar, GtkAcceleratorTable ** table)
|
||||
static void
|
||||
print_hello(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
if (initialize)
|
||||
menus_init();
|
||||
printf("hello!\n");
|
||||
}
|
||||
|
||||
void get_main_menu(GtkWidget *window, GtkWidget ** menubar)
|
||||
{
|
||||
int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
|
||||
GtkMenuFactory *factory;
|
||||
GtkMenuFactory *subfactory;
|
||||
|
||||
factory = gtk_menu_factory_new(GTK_MENU_FACTORY_MENU_BAR);
|
||||
subfactory = gtk_menu_factory_new(GTK_MENU_FACTORY_MENU_BAR);
|
||||
|
||||
gtk_menu_factory_add_subfactory(factory, subfactory, "<Main>");
|
||||
gtk_menu_factory_add_entries(factory, menu_items, nmenu_items);
|
||||
gtk_window_add_accelerator_table(GTK_WINDOW(window), subfactory->table);
|
||||
|
||||
if (menubar)
|
||||
*menubar = subfactory[0]->widget;
|
||||
if (table)
|
||||
*table = subfactory[0]->table;
|
||||
*menubar = subfactory->widget;
|
||||
}
|
||||
|
||||
void menus_init(void)
|
||||
{
|
||||
if (initialize) {
|
||||
initialize = FALSE;
|
||||
|
||||
factory = gtk_menu_factory_new(GTK_MENU_FACTORY_MENU_BAR);
|
||||
subfactory[0] = gtk_menu_factory_new(GTK_MENU_FACTORY_MENU_BAR);
|
||||
|
||||
gtk_menu_factory_add_subfactory(factory, subfactory[0], "<Main>");
|
||||
menus_create(menu_items, nmenu_items);
|
||||
}
|
||||
}
|
||||
|
||||
void menus_create(GtkMenuEntry * entries, int nmenu_entries)
|
||||
{
|
||||
char *accelerator;
|
||||
int i;
|
||||
|
||||
if (initialize)
|
||||
menus_init();
|
||||
|
||||
if (entry_ht)
|
||||
for (i = 0; i < nmenu_entries; i++) {
|
||||
accelerator = g_hash_table_lookup(entry_ht, entries[i].path);
|
||||
if (accelerator) {
|
||||
if (accelerator[0] == '\0')
|
||||
entries[i].accelerator = NULL;
|
||||
else
|
||||
entries[i].accelerator = accelerator;
|
||||
}
|
||||
}
|
||||
gtk_menu_factory_add_entries(factory, entries, nmenu_entries);
|
||||
|
||||
for (i = 0; i < nmenu_entries; i++)
|
||||
if (entries[i].widget) {
|
||||
gtk_signal_connect(GTK_OBJECT(entries[i].widget), "install_accelerator",
|
||||
(GtkSignalFunc) menus_install_accel,
|
||||
entries[i].path);
|
||||
gtk_signal_connect(GTK_OBJECT(entries[i].widget), "remove_accelerator",
|
||||
(GtkSignalFunc) menus_remove_accel,
|
||||
entries[i].path);
|
||||
}
|
||||
}
|
||||
|
||||
static gint menus_install_accel(GtkWidget * widget, gchar * signal_name, gchar key, gchar modifiers, gchar * path)
|
||||
{
|
||||
char accel[64];
|
||||
char *t1, t2[2];
|
||||
|
||||
accel[0] = '\0';
|
||||
if (modifiers & GDK_CONTROL_MASK)
|
||||
strcat(accel, "<control>");
|
||||
if (modifiers & GDK_SHIFT_MASK)
|
||||
strcat(accel, "<shift>");
|
||||
if (modifiers & GDK_MOD1_MASK)
|
||||
strcat(accel, "<alt>");
|
||||
|
||||
t2[0] = key;
|
||||
t2[1] = '\0';
|
||||
strcat(accel, t2);
|
||||
|
||||
if (entry_ht) {
|
||||
t1 = g_hash_table_lookup(entry_ht, path);
|
||||
g_free(t1);
|
||||
} else
|
||||
entry_ht = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
|
||||
g_hash_table_insert(entry_ht, path, g_strdup(accel));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void menus_remove_accel(GtkWidget * widget, gchar * signal_name, gchar * path)
|
||||
{
|
||||
char *t;
|
||||
|
||||
if (entry_ht) {
|
||||
t = g_hash_table_lookup(entry_ht, path);
|
||||
g_free(t);
|
||||
|
||||
g_hash_table_insert(entry_ht, path, g_strdup(""));
|
||||
}
|
||||
}
|
||||
|
||||
void menus_set_sensitive(char *path, int sensitive)
|
||||
{
|
||||
GtkMenuPath *menu_path;
|
||||
|
||||
if (initialize)
|
||||
menus_init();
|
||||
|
||||
menu_path = gtk_menu_factory_find(factory, path);
|
||||
if (menu_path)
|
||||
gtk_widget_set_sensitive(menu_path->widget, sensitive);
|
||||
else
|
||||
g_warning("Unable to set sensitivity for menu which doesn't exist: %s", path);
|
||||
}
|
||||
/* example-end */
|
||||
|
@@ -1,6 +1,4 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* menufactory.h */
|
||||
/* example-start menu menufactory.h */
|
||||
|
||||
#ifndef __MENUFACTORY_H__
|
||||
#define __MENUFACTORY_H__
|
||||
@@ -9,11 +7,12 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void get_main_menu (GtkWidget **menubar, GtkAcceleratorTable **table);
|
||||
void menus_create(GtkMenuEntry *entries, int nmenu_entries);
|
||||
void get_main_menu (GtkWidget *, GtkWidget **menubar);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __MENUFACTORY_H__ */
|
||||
|
||||
/* example-end */
|
||||
|
@@ -1,21 +1,16 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* mfmain.c */
|
||||
/* example-start menu mfmain.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "mfmain.h"
|
||||
#include "menufactory.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *menubar;
|
||||
|
||||
GtkAcceleratorTable *accel;
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
@@ -30,8 +25,7 @@ int main(int argc, char *argv[])
|
||||
gtk_container_add(GTK_CONTAINER(window), main_vbox);
|
||||
gtk_widget_show(main_vbox);
|
||||
|
||||
get_main_menu(&menubar, &accel);
|
||||
gtk_window_add_accelerator_table(GTK_WINDOW(window), accel);
|
||||
get_main_menu(window, &menubar);
|
||||
gtk_box_pack_start(GTK_BOX(main_vbox), menubar, FALSE, TRUE, 0);
|
||||
gtk_widget_show(menubar);
|
||||
|
||||
@@ -50,3 +44,5 @@ void file_quit_cmd_callback (GtkWidget *widget, gpointer data)
|
||||
g_print ("%s\n", (char *) data);
|
||||
gtk_exit(0);
|
||||
}
|
||||
|
||||
/* example-end */
|
||||
|
@@ -1,6 +1,4 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* mfmain.h */
|
||||
/* example-start menu mfmain.h */
|
||||
|
||||
#ifndef __MFMAIN_H__
|
||||
#define __MFMAIN_H__
|
||||
@@ -17,3 +15,5 @@ void file_quit_cmd_callback(GtkWidget *widget, gpointer data);
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __MFMAIN_H__ */
|
||||
|
||||
/* example-end */
|
||||
|
@@ -36,7 +36,7 @@ void remove_book (GtkButton *button, GtkNotebook *notebook)
|
||||
gtk_widget_draw(GTK_WIDGET(notebook), NULL);
|
||||
}
|
||||
|
||||
void delete (GtkWidget *widget, gpointer *data)
|
||||
void delete (GtkWidget *widget, GdkEvent *event, gpointer *data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#include "gtk/gtk.h"
|
||||
|
||||
void
|
||||
delete_event (GtkWidget *widget, gpointer *data)
|
||||
delete_event (GtkWidget *widget, GdkEvent *event, gpointer *data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ static const char * xpm_data[] = {
|
||||
|
||||
/* when invoked (via signal delete_event), terminates the application.
|
||||
*/
|
||||
void close_application( GtkWidget *widget, gpointer *data ) {
|
||||
void close_application( GtkWidget *widget, GdkEvent *event, gpointer *data ) {
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
|
@@ -33,7 +33,7 @@ void progress_r (void)
|
||||
pstat = FALSE;
|
||||
}
|
||||
|
||||
void destroy (GtkWidget *widget, gpointer *data)
|
||||
void destroy (GtkWidget *widget, GdkEvent *event, gpointer *data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib.h>
|
||||
|
||||
void close_application( GtkWidget *widget, gpointer *data ) {
|
||||
void close_application( GtkWidget *widget, GdkEvent *event, gpointer *data ) {
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
|
8
examples/rangewidgets/Makefile
Normal file
8
examples/rangewidgets/Makefile
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
CC = gcc
|
||||
|
||||
rangewidgets: rangewidgets.c
|
||||
$(CC) `gtk-config --cflags` `gtk-config --libs` rangewidgets.c -o rangewidgets
|
||||
|
||||
clean:
|
||||
rm -f *.o rangewidgets
|
287
examples/rangewidgets/rangewidgets.c
Normal file
287
examples/rangewidgets/rangewidgets.c
Normal file
@@ -0,0 +1,287 @@
|
||||
/* example-start rangewidgets rangewidgets.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
GtkWidget *hscale, *vscale;
|
||||
|
||||
void cb_pos_menu_select (GtkWidget *item, GtkPositionType pos)
|
||||
{
|
||||
/* set the value position on both scale widgets */
|
||||
gtk_scale_set_value_pos (GTK_SCALE (hscale), pos);
|
||||
gtk_scale_set_value_pos (GTK_SCALE (vscale), pos);
|
||||
}
|
||||
|
||||
void cb_update_menu_select (GtkWidget *item, GtkUpdateType policy)
|
||||
{
|
||||
/* set the update policy for both scale widgets */
|
||||
gtk_range_set_update_policy (GTK_RANGE (hscale), policy);
|
||||
gtk_range_set_update_policy (GTK_RANGE (vscale), policy);
|
||||
}
|
||||
|
||||
void cb_digits_scale (GtkAdjustment *adj)
|
||||
{
|
||||
/* set the number of decimal places to which adj->vaule is rounded
|
||||
*/
|
||||
gtk_scale_set_digits (GTK_SCALE (hscale), (gint) adj->value);
|
||||
gtk_scale_set_digits (GTK_SCALE (vscale), (gint) adj->value);
|
||||
}
|
||||
|
||||
void cb_page_size (GtkAdjustment *get, GtkAdjustment *set)
|
||||
{
|
||||
/* set the page size and page increment size of the sample
|
||||
adjustment to the value specified by the "Page Size" scale */
|
||||
set->page_size = get->value;
|
||||
set->page_increment = get->value;
|
||||
/* now emit the "changed" signal to reconfigure all the widgets that
|
||||
are attached to this adjustment */
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (set), "changed");
|
||||
}
|
||||
|
||||
void cb_draw_value (GtkToggleButton *button)
|
||||
{
|
||||
/* turn the value display on the scale widgets off or on depending
|
||||
on the state of the checkbutton */
|
||||
gtk_scale_set_draw_value (GTK_SCALE (hscale), button->active);
|
||||
gtk_scale_set_draw_value (GTK_SCALE (vscale), button->active);
|
||||
}
|
||||
|
||||
/* convenience functions */
|
||||
|
||||
GtkWidget *make_menu_item (gchar *name, GtkSignalFunc callback,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *item;
|
||||
|
||||
item = gtk_menu_item_new_with_label (name);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "activate",
|
||||
callback, data);
|
||||
gtk_widget_show (item);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
void scale_set_default_values (GtkScale *scale)
|
||||
{
|
||||
gtk_range_set_update_policy (GTK_RANGE (scale),
|
||||
GTK_UPDATE_CONTINUOUS);
|
||||
gtk_scale_set_digits (scale, 1);
|
||||
gtk_scale_set_value_pos (scale, GTK_POS_TOP);
|
||||
gtk_scale_set_draw_value (scale, TRUE);
|
||||
}
|
||||
|
||||
/* makes the sample window */
|
||||
|
||||
void create_range_controls (void)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *box1, *box2, *box3;
|
||||
GtkWidget *button;
|
||||
GtkWidget *scrollbar;
|
||||
GtkWidget *separator;
|
||||
GtkWidget *opt, *menu, *item;
|
||||
GtkWidget *label;
|
||||
GtkWidget *scale;
|
||||
GtkObject *adj1, *adj2;
|
||||
|
||||
/* standard window-creating stuff */
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC(gtk_main_quit),
|
||||
NULL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "range controls");
|
||||
|
||||
box1 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), box1);
|
||||
gtk_widget_show (box1);
|
||||
|
||||
box2 = gtk_hbox_new (FALSE, 10);
|
||||
gtk_container_border_width (GTK_CONTAINER (box2), 10);
|
||||
gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
|
||||
gtk_widget_show (box2);
|
||||
|
||||
/* value, lower, upper, step_increment, page_increment, page_size */
|
||||
/* note that the page_size value only makes a difference for
|
||||
scrollbar widgets, and the highest value you'll get is actually
|
||||
(upper - page_size). */
|
||||
adj1 = gtk_adjustment_new (0.0, 0.0, 101.0, 0.1, 1.0, 1.0);
|
||||
|
||||
vscale = gtk_vscale_new (GTK_ADJUSTMENT (adj1));
|
||||
scale_set_default_values (GTK_SCALE (vscale));
|
||||
gtk_box_pack_start (GTK_BOX (box2), vscale, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vscale);
|
||||
|
||||
box3 = gtk_vbox_new (FALSE, 10);
|
||||
gtk_box_pack_start (GTK_BOX (box2), box3, TRUE, TRUE, 0);
|
||||
gtk_widget_show (box3);
|
||||
|
||||
/* reuse the same adjustment */
|
||||
hscale = gtk_hscale_new (GTK_ADJUSTMENT (adj1));
|
||||
gtk_widget_set_usize (GTK_WIDGET (hscale), 200, 30);
|
||||
scale_set_default_values (GTK_SCALE (hscale));
|
||||
gtk_box_pack_start (GTK_BOX (box3), hscale, TRUE, TRUE, 0);
|
||||
gtk_widget_show (hscale);
|
||||
|
||||
/* reuse the same adjustment again */
|
||||
scrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (adj1));
|
||||
/* notice how this causes the scales to always be updated
|
||||
continuously when the scrollbar is moved */
|
||||
gtk_range_set_update_policy (GTK_RANGE (scrollbar),
|
||||
GTK_UPDATE_CONTINUOUS);
|
||||
gtk_box_pack_start (GTK_BOX (box3), scrollbar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (scrollbar);
|
||||
|
||||
box2 = gtk_hbox_new (FALSE, 10);
|
||||
gtk_container_border_width (GTK_CONTAINER (box2), 10);
|
||||
gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
|
||||
gtk_widget_show (box2);
|
||||
|
||||
/* a checkbutton to control whether the value is displayed or not */
|
||||
button = gtk_check_button_new_with_label
|
||||
("Display value on scale widgets");
|
||||
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "toggled", GTK_SIGNAL_FUNC
|
||||
(cb_draw_value), NULL);
|
||||
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
box2 = gtk_hbox_new (FALSE, 10);
|
||||
gtk_container_border_width (GTK_CONTAINER (box2), 10);
|
||||
|
||||
/* an option menu to change the position of the value */
|
||||
label = gtk_label_new ("Scale Value Position:");
|
||||
gtk_box_pack_start (GTK_BOX (box2), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
opt = gtk_option_menu_new();
|
||||
menu = gtk_menu_new();
|
||||
|
||||
item = make_menu_item ("Top", GTK_SIGNAL_FUNC (cb_pos_menu_select),
|
||||
GINT_TO_POINTER (GTK_POS_TOP));
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
|
||||
item = make_menu_item ("Bottom", GTK_SIGNAL_FUNC (cb_pos_menu_select),
|
||||
GINT_TO_POINTER (GTK_POS_BOTTOM));
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
|
||||
item = make_menu_item ("Left", GTK_SIGNAL_FUNC (cb_pos_menu_select),
|
||||
GINT_TO_POINTER (GTK_POS_LEFT));
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
|
||||
item = make_menu_item ("Right", GTK_SIGNAL_FUNC (cb_pos_menu_select),
|
||||
GINT_TO_POINTER (GTK_POS_RIGHT));
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
|
||||
gtk_option_menu_set_menu (GTK_OPTION_MENU (opt), menu);
|
||||
gtk_box_pack_start (GTK_BOX (box2), opt, TRUE, TRUE, 0);
|
||||
gtk_widget_show (opt);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
|
||||
gtk_widget_show (box2);
|
||||
|
||||
box2 = gtk_hbox_new (FALSE, 10);
|
||||
gtk_container_border_width (GTK_CONTAINER (box2), 10);
|
||||
|
||||
/* yet another option menu, this time for the update policy of the
|
||||
scale widgets */
|
||||
label = gtk_label_new ("Scale Update Policy:");
|
||||
gtk_box_pack_start (GTK_BOX (box2), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
opt = gtk_option_menu_new();
|
||||
menu = gtk_menu_new();
|
||||
|
||||
item = make_menu_item ("Continuous",
|
||||
GTK_SIGNAL_FUNC (cb_update_menu_select),
|
||||
GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
|
||||
item = make_menu_item ("Discontinuous",
|
||||
GTK_SIGNAL_FUNC (cb_update_menu_select),
|
||||
GINT_TO_POINTER (GTK_UPDATE_DISCONTINUOUS));
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
|
||||
item = make_menu_item ("Delayed",
|
||||
GTK_SIGNAL_FUNC (cb_update_menu_select),
|
||||
GINT_TO_POINTER (GTK_UPDATE_DELAYED));
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
|
||||
gtk_option_menu_set_menu (GTK_OPTION_MENU (opt), menu);
|
||||
gtk_box_pack_start (GTK_BOX (box2), opt, TRUE, TRUE, 0);
|
||||
gtk_widget_show (opt);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
|
||||
gtk_widget_show (box2);
|
||||
|
||||
box2 = gtk_hbox_new (FALSE, 10);
|
||||
gtk_container_border_width (GTK_CONTAINER (box2), 10);
|
||||
|
||||
/* a GtkHScale widget for adjusting the number of digits on the
|
||||
sample scales. */
|
||||
label = gtk_label_new ("Scale Digits:");
|
||||
gtk_box_pack_start (GTK_BOX (box2), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
adj2 = gtk_adjustment_new (1.0, 0.0, 5.0, 1.0, 1.0, 0.0);
|
||||
gtk_signal_connect (GTK_OBJECT (adj2), "value_changed",
|
||||
GTK_SIGNAL_FUNC (cb_digits_scale), NULL);
|
||||
scale = gtk_hscale_new (GTK_ADJUSTMENT (adj2));
|
||||
gtk_scale_set_digits (GTK_SCALE (scale), 0);
|
||||
gtk_box_pack_start (GTK_BOX (box2), scale, TRUE, TRUE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
|
||||
gtk_widget_show (box2);
|
||||
|
||||
box2 = gtk_hbox_new (FALSE, 10);
|
||||
gtk_container_border_width (GTK_CONTAINER (box2), 10);
|
||||
|
||||
/* And, one last GtkHScale widget for adjusting the page size of the
|
||||
scrollbar. */
|
||||
label = gtk_label_new ("Scrollbar Page Size:");
|
||||
gtk_box_pack_start (GTK_BOX (box2), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
adj2 = gtk_adjustment_new (1.0, 1.0, 101.0, 1.0, 1.0, 0.0);
|
||||
gtk_signal_connect (GTK_OBJECT (adj2), "value_changed",
|
||||
GTK_SIGNAL_FUNC (cb_page_size), adj1);
|
||||
scale = gtk_hscale_new (GTK_ADJUSTMENT (adj2));
|
||||
gtk_scale_set_digits (GTK_SCALE (scale), 0);
|
||||
gtk_box_pack_start (GTK_BOX (box2), scale, TRUE, TRUE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
|
||||
gtk_widget_show (box2);
|
||||
|
||||
separator = gtk_hseparator_new ();
|
||||
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
|
||||
gtk_widget_show (separator);
|
||||
|
||||
box2 = gtk_vbox_new (FALSE, 10);
|
||||
gtk_container_border_width (GTK_CONTAINER (box2), 10);
|
||||
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
|
||||
gtk_widget_show (box2);
|
||||
|
||||
button = gtk_button_new_with_label ("Quit");
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC(gtk_main_quit),
|
||||
NULL);
|
||||
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
create_range_controls();
|
||||
|
||||
gtk_main();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* example-end */
|
@@ -11,7 +11,7 @@
|
||||
|
||||
/* this routine gets control when the close button is clicked
|
||||
*/
|
||||
void close_application( GtkWidget *widget, gpointer *data ) {
|
||||
void close_application( GtkWidget *widget, GdkEvent *event, gpointer *data ) {
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
void destroy(GtkWidget *widget, gpointer *data)
|
||||
void destroy(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
GtkWidget *status_bar;
|
||||
|
||||
void push_item (GtkWidget *widget, gpointer *data)
|
||||
void push_item (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
static int count = 1;
|
||||
char buff[20];
|
||||
@@ -18,7 +18,7 @@ void push_item (GtkWidget *widget, gpointer *data)
|
||||
return;
|
||||
}
|
||||
|
||||
void pop_item (GtkWidget *widget, gpointer *data)
|
||||
void pop_item (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
gtk_statusbar_pop( GTK_STATUSBAR(status_bar), (guint) &data );
|
||||
return;
|
||||
|
@@ -11,7 +11,7 @@ void callback (GtkWidget *widget, gpointer *data)
|
||||
}
|
||||
|
||||
/* this callback quits the program */
|
||||
void delete_event (GtkWidget *widget, gpointer *data)
|
||||
void delete_event (GtkWidget *widget, GdkEvent *event, gpointer *data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
8
examples/text/Makefile
Normal file
8
examples/text/Makefile
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
CC = gcc
|
||||
|
||||
text: text.c
|
||||
$(CC) `gtk-config --cflags` `gtk-config --libs` text.c -o text
|
||||
|
||||
clean:
|
||||
rm -f *.o text
|
181
examples/text/text.c
Normal file
181
examples/text/text.c
Normal file
@@ -0,0 +1,181 @@
|
||||
/* example-start text text.c */
|
||||
|
||||
/* text.c */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
void text_toggle_editable (GtkWidget *checkbutton,
|
||||
GtkWidget *text)
|
||||
{
|
||||
gtk_text_set_editable(GTK_TEXT(text),
|
||||
GTK_TOGGLE_BUTTON(checkbutton)->active);
|
||||
}
|
||||
|
||||
void text_toggle_word_wrap (GtkWidget *checkbutton,
|
||||
GtkWidget *text)
|
||||
{
|
||||
gtk_text_set_word_wrap(GTK_TEXT(text),
|
||||
GTK_TOGGLE_BUTTON(checkbutton)->active);
|
||||
}
|
||||
|
||||
void close_application( GtkWidget *widget, gpointer data )
|
||||
{
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *box1;
|
||||
GtkWidget *box2;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *button;
|
||||
GtkWidget *check;
|
||||
GtkWidget *separator;
|
||||
GtkWidget *table;
|
||||
GtkWidget *vscrollbar;
|
||||
GtkWidget *text;
|
||||
GdkColormap *cmap;
|
||||
GdkColor colour;
|
||||
GdkFont *fixed_font;
|
||||
|
||||
FILE *infile;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_widget_set_usize (window, 600, 500);
|
||||
gtk_window_set_policy (GTK_WINDOW(window), TRUE, TRUE, FALSE);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC(close_application),
|
||||
NULL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Text Widget Example");
|
||||
gtk_container_border_width (GTK_CONTAINER (window), 0);
|
||||
|
||||
|
||||
box1 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), box1);
|
||||
gtk_widget_show (box1);
|
||||
|
||||
|
||||
box2 = gtk_vbox_new (FALSE, 10);
|
||||
gtk_container_border_width (GTK_CONTAINER (box2), 10);
|
||||
gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
|
||||
gtk_widget_show (box2);
|
||||
|
||||
|
||||
table = gtk_table_new (2, 2, FALSE);
|
||||
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
|
||||
gtk_box_pack_start (GTK_BOX (box2), table, TRUE, TRUE, 0);
|
||||
gtk_widget_show (table);
|
||||
|
||||
/* Create the GtkText widget */
|
||||
text = gtk_text_new (NULL, NULL);
|
||||
gtk_text_set_editable (GTK_TEXT (text), TRUE);
|
||||
gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1,
|
||||
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
|
||||
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
|
||||
gtk_widget_show (text);
|
||||
|
||||
/* Add a vertical scrollbar to the GtkText widget */
|
||||
vscrollbar = gtk_vscrollbar_new (GTK_TEXT (text)->vadj);
|
||||
gtk_table_attach (GTK_TABLE (table), vscrollbar, 1, 2, 0, 1,
|
||||
GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
|
||||
gtk_widget_show (vscrollbar);
|
||||
|
||||
/* Get the system colour map and allocate the colour red */
|
||||
cmap = gdk_colormap_get_system();
|
||||
colour.red = 0xffff;
|
||||
colour.green = 0;
|
||||
colour.blue = 0;
|
||||
if (!gdk_color_alloc(cmap, &colour)) {
|
||||
g_error("couldn't allocate colour");
|
||||
}
|
||||
|
||||
/* Load a fixed font */
|
||||
fixed_font = gdk_font_load ("-misc-fixed-medium-r-*-*-*-140-*-*-*-*-*-*");
|
||||
|
||||
/* Realizing a widget creates a window for it, ready for us to insert some text */
|
||||
gtk_widget_realize (text);
|
||||
|
||||
/* Freeze the text widget, ready for multiple updates */
|
||||
gtk_text_freeze (GTK_TEXT (text));
|
||||
|
||||
/* Insert some coloured text */
|
||||
gtk_text_insert (GTK_TEXT (text), NULL, &text->style->black, NULL,
|
||||
"Supports ", -1);
|
||||
gtk_text_insert (GTK_TEXT (text), NULL, &colour, NULL,
|
||||
"colored ", -1);
|
||||
gtk_text_insert (GTK_TEXT (text), NULL, &text->style->black, NULL,
|
||||
"text and different ", -1);
|
||||
gtk_text_insert (GTK_TEXT (text), fixed_font, &text->style->black, NULL,
|
||||
"fonts\n\n", -1);
|
||||
|
||||
/* Load the file text.c into the text window */
|
||||
|
||||
infile = fopen("text.c", "r");
|
||||
|
||||
if (infile) {
|
||||
char buffer[1024];
|
||||
int nchars;
|
||||
|
||||
while (1)
|
||||
{
|
||||
nchars = fread(buffer, 1, 1024, infile);
|
||||
gtk_text_insert (GTK_TEXT (text), fixed_font, NULL,
|
||||
NULL, buffer, nchars);
|
||||
|
||||
if (nchars < 1024)
|
||||
break;
|
||||
}
|
||||
|
||||
fclose (infile);
|
||||
}
|
||||
|
||||
/* Thaw the text widget, allowing the updates to become visible */
|
||||
gtk_text_thaw (GTK_TEXT (text));
|
||||
|
||||
hbox = gtk_hbutton_box_new ();
|
||||
gtk_box_pack_start (GTK_BOX (box2), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
check = gtk_check_button_new_with_label("Editable");
|
||||
gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, FALSE, 0);
|
||||
gtk_signal_connect (GTK_OBJECT(check), "toggled",
|
||||
GTK_SIGNAL_FUNC(text_toggle_editable), text);
|
||||
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(check), TRUE);
|
||||
gtk_widget_show (check);
|
||||
check = gtk_check_button_new_with_label("Wrap Words");
|
||||
gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, TRUE, 0);
|
||||
gtk_signal_connect (GTK_OBJECT(check), "toggled",
|
||||
GTK_SIGNAL_FUNC(text_toggle_word_wrap), text);
|
||||
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(check), FALSE);
|
||||
gtk_widget_show (check);
|
||||
|
||||
separator = gtk_hseparator_new ();
|
||||
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
|
||||
gtk_widget_show (separator);
|
||||
|
||||
box2 = gtk_vbox_new (FALSE, 10);
|
||||
gtk_container_border_width (GTK_CONTAINER (box2), 10);
|
||||
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
|
||||
gtk_widget_show (box2);
|
||||
|
||||
button = gtk_button_new_with_label ("close");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC(close_application),
|
||||
NULL);
|
||||
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (window);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* example-end */
|
8
examples/tree/Makefile
Normal file
8
examples/tree/Makefile
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
CC = gcc
|
||||
|
||||
tree: tree.c
|
||||
$(CC) `gtk-config --cflags` `gtk-config --libs` tree.c -o tree
|
||||
|
||||
clean:
|
||||
rm -f *.o tree
|
178
examples/tree/tree.c
Normal file
178
examples/tree/tree.c
Normal file
@@ -0,0 +1,178 @@
|
||||
/* example-start tree tree.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
/* for all the GtkItem:: and GtkTreeItem:: signals */
|
||||
static void cb_itemsignal (GtkWidget *item, gchar *signame)
|
||||
{
|
||||
gchar *name;
|
||||
GtkLabel *label;
|
||||
|
||||
/* It's a GtkBin, so it has one child, which we know to be a
|
||||
label, so get that */
|
||||
label = GTK_LABEL (GTK_BIN (item)->child);
|
||||
/* Get the text of the label */
|
||||
gtk_label_get (label, &name);
|
||||
/* Get the level of the tree which the item is in */
|
||||
g_print ("%s called for item %s->%p, level %d\n", signame, name,
|
||||
item, GTK_TREE (item->parent)->level);
|
||||
}
|
||||
|
||||
/* Note that this is never called */
|
||||
static void cb_unselect_child (GtkWidget *root_tree, GtkWidget *child,
|
||||
GtkWidget *subtree)
|
||||
{
|
||||
g_print ("unselect_child called for root tree %p, subtree %p, child %p\n",
|
||||
root_tree, subtree, child);
|
||||
}
|
||||
|
||||
/* Note that this is called every time the user clicks on an item,
|
||||
whether it is already selected or not. */
|
||||
static void cb_select_child (GtkWidget *root_tree, GtkWidget *child,
|
||||
GtkWidget *subtree)
|
||||
{
|
||||
g_print ("select_child called for root tree %p, subtree %p, child %p\n",
|
||||
root_tree, subtree, child);
|
||||
}
|
||||
|
||||
static void cb_selection_changed (GtkWidget *tree)
|
||||
{
|
||||
GList *i;
|
||||
|
||||
g_print ("selection_change called for tree %p\n", tree);
|
||||
g_print ("selected objects are:\n");
|
||||
|
||||
i = GTK_TREE_SELECTION(tree);
|
||||
while (i){
|
||||
gchar *name;
|
||||
GtkLabel *label;
|
||||
GtkWidget *item;
|
||||
|
||||
/* Get a GtkWidget pointer from the list node */
|
||||
item = GTK_WIDGET (i->data);
|
||||
label = GTK_LABEL (GTK_BIN (item)->child);
|
||||
gtk_label_get (label, &name);
|
||||
g_print ("\t%s on level %d\n", name, GTK_TREE
|
||||
(item->parent)->level);
|
||||
i = i->next;
|
||||
}
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window, *scrolled_win, *tree;
|
||||
static gchar *itemnames[] = {"Foo", "Bar", "Baz", "Quux",
|
||||
"Maurice"};
|
||||
gint i;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
/* a generic toplevel window */
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_signal_connect (GTK_OBJECT(window), "delete_event",
|
||||
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
|
||||
gtk_container_border_width (GTK_CONTAINER(window), 5);
|
||||
|
||||
/* A generic scrolled window */
|
||||
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_widget_set_usize (scrolled_win, 150, 200);
|
||||
gtk_container_add (GTK_CONTAINER(window), scrolled_win);
|
||||
gtk_widget_show (scrolled_win);
|
||||
|
||||
/* Create the root tree */
|
||||
tree = gtk_tree_new();
|
||||
g_print ("root tree is %p\n", tree);
|
||||
/* connect all GtkTree:: signals */
|
||||
gtk_signal_connect (GTK_OBJECT(tree), "select_child",
|
||||
GTK_SIGNAL_FUNC(cb_select_child), tree);
|
||||
gtk_signal_connect (GTK_OBJECT(tree), "unselect_child",
|
||||
GTK_SIGNAL_FUNC(cb_unselect_child), tree);
|
||||
gtk_signal_connect (GTK_OBJECT(tree), "selection_changed",
|
||||
GTK_SIGNAL_FUNC(cb_selection_changed), tree);
|
||||
/* Add it to the scrolled window */
|
||||
gtk_container_add (GTK_CONTAINER(scrolled_win), tree);
|
||||
/* Set the selection mode */
|
||||
gtk_tree_set_selection_mode (GTK_TREE(tree),
|
||||
GTK_SELECTION_MULTIPLE);
|
||||
/* Show it */
|
||||
gtk_widget_show (tree);
|
||||
|
||||
for (i = 0; i < 5; i++){
|
||||
GtkWidget *subtree, *item;
|
||||
gint j;
|
||||
|
||||
/* Create a tree item */
|
||||
item = gtk_tree_item_new_with_label (itemnames[i]);
|
||||
/* Connect all GtkItem:: and GtkTreeItem:: signals */
|
||||
gtk_signal_connect (GTK_OBJECT(item), "select",
|
||||
GTK_SIGNAL_FUNC(cb_itemsignal), "select");
|
||||
gtk_signal_connect (GTK_OBJECT(item), "deselect",
|
||||
GTK_SIGNAL_FUNC(cb_itemsignal), "deselect");
|
||||
gtk_signal_connect (GTK_OBJECT(item), "toggle",
|
||||
GTK_SIGNAL_FUNC(cb_itemsignal), "toggle");
|
||||
gtk_signal_connect (GTK_OBJECT(item), "expand",
|
||||
GTK_SIGNAL_FUNC(cb_itemsignal), "expand");
|
||||
gtk_signal_connect (GTK_OBJECT(item), "collapse",
|
||||
GTK_SIGNAL_FUNC(cb_itemsignal), "collapse");
|
||||
/* Add it to the parent tree */
|
||||
gtk_tree_append (GTK_TREE(tree), item);
|
||||
/* Show it - this can be done at any time */
|
||||
gtk_widget_show (item);
|
||||
/* Create this item's subtree */
|
||||
subtree = gtk_tree_new();
|
||||
g_print ("-> item %s->%p, subtree %p\n", itemnames[i], item,
|
||||
subtree);
|
||||
|
||||
/* This is still necesary if you want these signals to be called
|
||||
for the subtree's children. Note that selection_change will be
|
||||
signalled for the root tree regardless. */
|
||||
gtk_signal_connect (GTK_OBJECT(subtree), "select_child",
|
||||
GTK_SIGNAL_FUNC(cb_select_child), subtree);
|
||||
gtk_signal_connect (GTK_OBJECT(subtree), "unselect_child",
|
||||
GTK_SIGNAL_FUNC(cb_unselect_child), subtree);
|
||||
/* This has absolutely no effect, because it is completely ignored
|
||||
in subtrees */
|
||||
gtk_tree_set_selection_mode (GTK_TREE(subtree),
|
||||
GTK_SELECTION_SINGLE);
|
||||
/* Neither does this, but for a rather different reason - the
|
||||
view_mode and view_line values of a tree are propagated to
|
||||
subtrees when they are mapped. So, setting it later on would
|
||||
actually have a (somewhat unpredictable) effect */
|
||||
gtk_tree_set_view_mode (GTK_TREE(subtree), GTK_TREE_VIEW_ITEM);
|
||||
/* Set this item's subtree - note that you cannot do this until
|
||||
AFTER the item has been added to its parent tree! */
|
||||
gtk_tree_item_set_subtree (GTK_TREE_ITEM(item), subtree);
|
||||
|
||||
for (j = 0; j < 5; j++){
|
||||
GtkWidget *subitem;
|
||||
|
||||
/* Create a subtree item, in much the same way */
|
||||
subitem = gtk_tree_item_new_with_label (itemnames[j]);
|
||||
/* Connect all GtkItem:: and GtkTreeItem:: signals */
|
||||
gtk_signal_connect (GTK_OBJECT(subitem), "select",
|
||||
GTK_SIGNAL_FUNC(cb_itemsignal), "select");
|
||||
gtk_signal_connect (GTK_OBJECT(subitem), "deselect",
|
||||
GTK_SIGNAL_FUNC(cb_itemsignal), "deselect");
|
||||
gtk_signal_connect (GTK_OBJECT(subitem), "toggle",
|
||||
GTK_SIGNAL_FUNC(cb_itemsignal), "toggle");
|
||||
gtk_signal_connect (GTK_OBJECT(subitem), "expand",
|
||||
GTK_SIGNAL_FUNC(cb_itemsignal), "expand");
|
||||
gtk_signal_connect (GTK_OBJECT(subitem), "collapse",
|
||||
GTK_SIGNAL_FUNC(cb_itemsignal), "collapse");
|
||||
g_print ("-> -> item %s->%p\n", itemnames[j], subitem);
|
||||
/* Add it to its parent tree */
|
||||
gtk_tree_append (GTK_TREE(subtree), subitem);
|
||||
/* Show it */
|
||||
gtk_widget_show (subitem);
|
||||
}
|
||||
}
|
||||
|
||||
/* Show the window and loop endlessly */
|
||||
gtk_widget_show (window);
|
||||
gtk_main();
|
||||
return 0;
|
||||
}
|
||||
/* example-end */
|
@@ -123,7 +123,7 @@ static char * WheelbarrowFull_xpm[] = {
|
||||
|
||||
/* when invoked (via signal delete_event), terminates the application.
|
||||
*/
|
||||
void close_application( GtkWidget *widget, gpointer *data ) {
|
||||
void close_application( GtkWidget *widget, GdkEvent *event, gpointer *data ) {
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
|
@@ -46,7 +46,7 @@ gdkinclude_HEADERS = \
|
||||
gdktypes.h \
|
||||
gdkx.h
|
||||
|
||||
libgdk_la_LDFLAGS = -version-info 1:0:0 \
|
||||
libgdk_la_LDFLAGS = -version-info $(GTK_MAJOR_VERSION):$(GTK_MICRO_VERSION):0 \
|
||||
@x_ldflags@ @x_libs@
|
||||
|
||||
INCLUDES = -I$(top_srcdir) -I../glib -I$(top_srcdir)/glib @x_cflags@
|
||||
@@ -78,5 +78,3 @@ files:
|
||||
@files=`ls $(DISTFILES) 2> /dev/null `; for p in $$files; do \
|
||||
echo $$p; \
|
||||
done
|
||||
|
||||
$(DEP_FILES) : $(BUILT_SOURCES)
|
||||
|
80
gdk/gdk.c
80
gdk/gdk.c
@@ -51,8 +51,8 @@
|
||||
#include "gdkinput.h"
|
||||
#ifdef USE_XIM
|
||||
#include "gdkx.h"
|
||||
#include "gdkkeysyms.h"
|
||||
#endif
|
||||
#include "gdkkeysyms.h"
|
||||
#include "gdki18n.h"
|
||||
|
||||
#ifndef X_GETTIMEOFDAY
|
||||
@@ -625,7 +625,7 @@ gdk_exit (int errorcode)
|
||||
*/
|
||||
|
||||
gchar*
|
||||
gdk_set_locale ()
|
||||
gdk_set_locale (void)
|
||||
{
|
||||
if (!setlocale (LC_ALL,""))
|
||||
g_print ("locale not supported by C library\n");
|
||||
@@ -663,7 +663,7 @@ gdk_set_locale ()
|
||||
*/
|
||||
|
||||
gint
|
||||
gdk_events_pending ()
|
||||
gdk_events_pending (void)
|
||||
{
|
||||
gint result;
|
||||
GList *tmp_list;
|
||||
@@ -827,6 +827,7 @@ gdk_event_get (void)
|
||||
#else
|
||||
XNextEvent (gdk_display, &xevent);
|
||||
#endif
|
||||
|
||||
event = gdk_event_new ();
|
||||
|
||||
event->any.type = GDK_NOTHING;
|
||||
@@ -1023,13 +1024,13 @@ gdk_set_use_xshm (gint use_xshm)
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_get_show_events ()
|
||||
gdk_get_show_events (void)
|
||||
{
|
||||
return gdk_debug_flags & GDK_DEBUG_EVENTS;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_get_use_xshm ()
|
||||
gdk_get_use_xshm (void)
|
||||
{
|
||||
return gdk_use_xshm;
|
||||
}
|
||||
@@ -1055,7 +1056,7 @@ gdk_get_use_xshm ()
|
||||
*/
|
||||
|
||||
guint32
|
||||
gdk_time_get ()
|
||||
gdk_time_get (void)
|
||||
{
|
||||
struct timeval end;
|
||||
struct timeval elapsed;
|
||||
@@ -1094,7 +1095,7 @@ gdk_time_get ()
|
||||
*/
|
||||
|
||||
guint32
|
||||
gdk_timer_get ()
|
||||
gdk_timer_get (void)
|
||||
{
|
||||
return timer_val;
|
||||
}
|
||||
@@ -1129,13 +1130,13 @@ gdk_timer_set (guint32 milliseconds)
|
||||
}
|
||||
|
||||
void
|
||||
gdk_timer_enable ()
|
||||
gdk_timer_enable (void)
|
||||
{
|
||||
timerp = &timer;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_timer_disable ()
|
||||
gdk_timer_disable (void)
|
||||
{
|
||||
timerp = NULL;
|
||||
}
|
||||
@@ -1306,8 +1307,7 @@ gdk_pointer_grab (GdkWindow * window,
|
||||
xevent_mask |= event_mask_table[i];
|
||||
}
|
||||
|
||||
if (((GdkWindowPrivate *)window)->extension_events &&
|
||||
gdk_input_vtable.grab_pointer)
|
||||
if (gdk_input_vtable.grab_pointer)
|
||||
return_val = gdk_input_vtable.grab_pointer (window,
|
||||
owner_events,
|
||||
event_mask,
|
||||
@@ -1463,7 +1463,7 @@ gdk_keyboard_ungrab (guint32 time)
|
||||
*/
|
||||
|
||||
gint
|
||||
gdk_screen_width ()
|
||||
gdk_screen_width (void)
|
||||
{
|
||||
gint return_val;
|
||||
|
||||
@@ -1488,7 +1488,7 @@ gdk_screen_width ()
|
||||
*/
|
||||
|
||||
gint
|
||||
gdk_screen_height ()
|
||||
gdk_screen_height (void)
|
||||
{
|
||||
gint return_val;
|
||||
|
||||
@@ -1498,13 +1498,13 @@ gdk_screen_height ()
|
||||
}
|
||||
|
||||
void
|
||||
gdk_key_repeat_disable ()
|
||||
gdk_key_repeat_disable (void)
|
||||
{
|
||||
XAutoRepeatOff (gdk_display);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_key_repeat_restore ()
|
||||
gdk_key_repeat_restore (void)
|
||||
{
|
||||
if (autorepeat)
|
||||
XAutoRepeatOn (gdk_display);
|
||||
@@ -1531,14 +1531,14 @@ gdk_key_repeat_restore ()
|
||||
*--------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void gdk_flush ()
|
||||
void gdk_flush (void)
|
||||
{
|
||||
XSync (gdk_display, False);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gdk_beep ()
|
||||
gdk_beep (void)
|
||||
{
|
||||
XBell(gdk_display, 100);
|
||||
}
|
||||
@@ -1562,7 +1562,7 @@ gdk_beep ()
|
||||
*/
|
||||
|
||||
static gint
|
||||
gdk_event_wait ()
|
||||
gdk_event_wait (void)
|
||||
{
|
||||
GList *list;
|
||||
GdkInput *input;
|
||||
@@ -1685,7 +1685,8 @@ gdk_event_translate (GdkEvent *event,
|
||||
|
||||
GdkWindow *window;
|
||||
GdkWindowPrivate *window_private;
|
||||
XComposeStatus compose;
|
||||
static XComposeStatus compose;
|
||||
KeySym keysym;
|
||||
int charcount;
|
||||
#ifdef USE_XIM
|
||||
static gchar* buf = NULL;
|
||||
@@ -1726,6 +1727,10 @@ gdk_event_translate (GdkEvent *event,
|
||||
|
||||
if (window != NULL)
|
||||
gdk_window_ref (window);
|
||||
#ifdef USE_XIM
|
||||
else if (XFilterEvent(xevent, None)) /* for xlib XIM handling */
|
||||
return FALSE;
|
||||
#endif
|
||||
else if(gdk_null_window_warnings) /* Special purpose programs that
|
||||
get events for other windows may
|
||||
want to disable this */
|
||||
@@ -1767,16 +1772,16 @@ gdk_event_translate (GdkEvent *event,
|
||||
buf_len = 128;
|
||||
buf = g_new (gchar, buf_len);
|
||||
}
|
||||
keysym = GDK_VoidSymbol;
|
||||
|
||||
if (xim_using == TRUE && xim_ic)
|
||||
{
|
||||
Status status;
|
||||
|
||||
/* Clear keyval. Depending on status, may not be set */
|
||||
event->key.keyval = GDK_VoidSymbol;
|
||||
charcount = XmbLookupString(xim_ic->xic,
|
||||
&xevent->xkey, buf, buf_len-1,
|
||||
(KeySym*) &event->key.keyval,
|
||||
&status);
|
||||
&keysym, &status);
|
||||
if (status == XBufferOverflow)
|
||||
{ /* retry */
|
||||
/* alloc adequate size of buffer */
|
||||
@@ -1789,8 +1794,7 @@ gdk_event_translate (GdkEvent *event,
|
||||
|
||||
charcount = XmbLookupString (xim_ic->xic,
|
||||
&xevent->xkey, buf, buf_len-1,
|
||||
(KeySym*) &event->key.keyval,
|
||||
&status);
|
||||
&keysym, &status);
|
||||
}
|
||||
if (status == XLookupNone)
|
||||
{
|
||||
@@ -1800,13 +1804,13 @@ gdk_event_translate (GdkEvent *event,
|
||||
}
|
||||
else
|
||||
charcount = XLookupString (&xevent->xkey, buf, buf_len,
|
||||
(KeySym*) &event->key.keyval,
|
||||
&compose);
|
||||
&keysym, &compose);
|
||||
#else
|
||||
charcount = XLookupString (&xevent->xkey, buf, 16,
|
||||
(KeySym*) &event->key.keyval,
|
||||
&compose);
|
||||
&keysym, &compose);
|
||||
#endif
|
||||
event->key.keyval = keysym;
|
||||
|
||||
if (charcount > 0 && buf[charcount-1] == '\0')
|
||||
charcount --;
|
||||
else
|
||||
@@ -1844,9 +1848,10 @@ gdk_event_translate (GdkEvent *event,
|
||||
case KeyRelease:
|
||||
/* Lookup the string corresponding to the given keysym.
|
||||
*/
|
||||
keysym = GDK_VoidSymbol;
|
||||
charcount = XLookupString (&xevent->xkey, buf, 16,
|
||||
(KeySym*) &event->key.keyval,
|
||||
&compose);
|
||||
&keysym, &compose);
|
||||
event->key.keyval = keysym;
|
||||
|
||||
/* Print debugging info.
|
||||
*/
|
||||
@@ -1964,7 +1969,7 @@ gdk_event_translate (GdkEvent *event,
|
||||
window_private->dnd_drag_savedeventmask = dnd_winattr.your_event_mask;
|
||||
dnd_setwinattr.event_mask =
|
||||
window_private->dnd_drag_eventmask = ButtonMotionMask | ButtonPressMask | ButtonReleaseMask |
|
||||
EnterWindowMask | LeaveWindowMask;
|
||||
EnterWindowMask | LeaveWindowMask | ExposureMask;
|
||||
XChangeWindowAttributes(gdk_display, window_private->xwindow,
|
||||
CWEventMask, &dnd_setwinattr);
|
||||
}
|
||||
@@ -2204,6 +2209,7 @@ gdk_event_translate (GdkEvent *event,
|
||||
|
||||
/* Tell XInput stuff about it if appropriate */
|
||||
if (window_private &&
|
||||
!window_private->destroyed &&
|
||||
(window_private->extension_events != 0) &&
|
||||
gdk_input_vtable.enter_event)
|
||||
gdk_input_vtable.enter_event (&xevent->xcrossing, window);
|
||||
@@ -2333,7 +2339,7 @@ gdk_event_translate (GdkEvent *event,
|
||||
ButtonMotionMask | PointerMotionMask |
|
||||
/* PointerMotionHintMask | */ /* HINTME */
|
||||
ButtonPressMask | ButtonReleaseMask,
|
||||
GrabModeAsync, GrabModeAsync, gdk_root_window,
|
||||
GrabModeAsync, GrabModeAsync, None,
|
||||
None, CurrentTime);
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
GDK_NOTE(DND, g_print("xgpret = %d\n", xgpret));
|
||||
@@ -2581,7 +2587,8 @@ gdk_event_translate (GdkEvent *event,
|
||||
|
||||
if (window_private)
|
||||
{
|
||||
if ((window_private->extension_events != 0) &&
|
||||
if (!window_private->destroyed &&
|
||||
(window_private->extension_events != 0) &&
|
||||
gdk_input_vtable.configure_event)
|
||||
gdk_input_vtable.configure_event (&xevent->xconfigure, window);
|
||||
|
||||
@@ -2944,6 +2951,7 @@ gdk_event_translate (GdkEvent *event,
|
||||
/* something else - (e.g., a Xinput event) */
|
||||
|
||||
if (window_private &&
|
||||
!window_private->destroyed &&
|
||||
(window_private->extension_events != 0) &&
|
||||
gdk_input_vtable.other_event)
|
||||
return_val = gdk_input_vtable.other_event(event, xevent, window);
|
||||
@@ -3028,7 +3036,7 @@ gdk_synthesize_click (GdkEvent *event,
|
||||
*/
|
||||
|
||||
static void
|
||||
gdk_exit_func ()
|
||||
gdk_exit_func (void)
|
||||
{
|
||||
static gboolean in_gdk_exit_func = FALSE;
|
||||
|
||||
@@ -4004,8 +4012,8 @@ gdk_dnd_check_types (GdkWindow *window,
|
||||
|
||||
if (realfmt != (sizeof(Atom) * 8))
|
||||
{
|
||||
g_warning("XdeTypelist property had format of %d instead of the expected %d, on window %#lx\n",
|
||||
realfmt, sizeof(Atom) * 8, xevent->xclient.data.l[0]);
|
||||
g_warning("XdeTypelist property had format of %d instead of the expected %ld, on window %#lx\n",
|
||||
realfmt, (glong)sizeof(Atom) * 8, xevent->xclient.data.l[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -60,11 +60,11 @@ gdk_dnd_set_drag_shape(GdkWindow *default_pixmapwin,
|
||||
gdk_window_ref(default_pixmapwin);
|
||||
gdk_dnd.c->drag_pm_default = default_pixmapwin;
|
||||
gdk_dnd.c->default_hotspot = *default_hotspot;
|
||||
gdk_dnd.c->xids = g_list_append(gdk_dnd.c->xids, (gpointer)(glong)((GdkWindowPrivate *)default_pixmapwin)->xwindow);
|
||||
gdk_dnd.c->xids = g_list_append(gdk_dnd.c->xids, GUINT_TO_POINTER (((GdkWindowPrivate *)default_pixmapwin)->xwindow));
|
||||
if(goahead_pixmapwin)
|
||||
{
|
||||
gdk_window_ref(goahead_pixmapwin);
|
||||
gdk_dnd.c->xids = g_list_append(gdk_dnd.c->xids, (gpointer)(glong)((GdkWindowPrivate *)goahead_pixmapwin)->xwindow);
|
||||
gdk_dnd.c->xids = g_list_append(gdk_dnd.c->xids, GUINT_TO_POINTER (((GdkWindowPrivate *)goahead_pixmapwin)->xwindow));
|
||||
gdk_dnd.c->drag_pm_ok = goahead_pixmapwin;
|
||||
gdk_dnd.c->ok_hotspot = *goahead_hotspot;
|
||||
}
|
||||
|
@@ -64,7 +64,7 @@ static GList *image_list = NULL;
|
||||
|
||||
|
||||
void
|
||||
gdk_image_exit ()
|
||||
gdk_image_exit (void)
|
||||
{
|
||||
GdkImage *image;
|
||||
|
||||
@@ -131,7 +131,7 @@ gdk_image_check_xshm(Display *display)
|
||||
}
|
||||
|
||||
void
|
||||
gdk_image_init ()
|
||||
gdk_image_init (void)
|
||||
{
|
||||
if (gdk_use_xshm)
|
||||
{
|
||||
|
@@ -70,7 +70,7 @@ static GList *gdk_input_windows;
|
||||
#include "gdkinputgxi.h"
|
||||
|
||||
GList *
|
||||
gdk_input_list_devices ()
|
||||
gdk_input_list_devices (void)
|
||||
{
|
||||
return gdk_input_devices;
|
||||
}
|
||||
|
@@ -186,7 +186,7 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
|
||||
if ((xki->min_keycode == 8) && (xki->max_keycode == 32))
|
||||
{
|
||||
gdkdev->info.num_keys = 32;
|
||||
gdkdev->min_keycode = 0;
|
||||
gdkdev->min_keycode = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -591,23 +591,35 @@ gdk_input_gxi_grab_pointer (GdkWindow * window,
|
||||
GdkWindow * confine_to,
|
||||
guint32 time)
|
||||
{
|
||||
GdkInputWindow *input_window, *new_window;
|
||||
GList *tmp_list;
|
||||
GdkInputWindow *input_window;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
|
||||
tmp_list = gdk_input_windows;
|
||||
while (tmp_list)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->grabbed)
|
||||
return AlreadyGrabbed;
|
||||
|
||||
if (input_window->window == window)
|
||||
new_window = input_window;
|
||||
input_window->grabbed = TRUE;
|
||||
else if (input_window->grabbed)
|
||||
input_window->grabbed = FALSE;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
tmp_list = gdk_input_devices;
|
||||
while (tmp_list)
|
||||
{
|
||||
gdkdev = (GdkDevicePrivate *)tmp_list->data;
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
|
||||
gdkdev->xdevice &&
|
||||
(gdkdev->button_state != 0))
|
||||
gdkdev->button_state = 0;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
new_window->grabbed = TRUE;
|
||||
return Success;
|
||||
}
|
||||
|
||||
|
@@ -29,7 +29,7 @@ static void gdk_input_none_get_pointer (GdkWindow *window,
|
||||
GdkModifierType *mask);
|
||||
|
||||
void
|
||||
gdk_input_init ()
|
||||
gdk_input_init (void)
|
||||
{
|
||||
gdk_input_vtable.set_mode = NULL;
|
||||
gdk_input_vtable.set_axes = NULL;
|
||||
|
@@ -22,7 +22,7 @@
|
||||
/* forward declarations */
|
||||
|
||||
static gint gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode);
|
||||
static void gdk_input_check_proximity();
|
||||
static void gdk_input_check_proximity (void);
|
||||
static void gdk_input_xfree_configure_event (XConfigureEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static void gdk_input_xfree_enter_event (XCrossingEvent *xevent,
|
||||
@@ -115,7 +115,7 @@ gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode)
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_check_proximity()
|
||||
gdk_input_check_proximity (void)
|
||||
{
|
||||
gint new_proximity = 0;
|
||||
GList *tmp_list = gdk_input_devices;
|
||||
@@ -173,7 +173,7 @@ gdk_input_xfree_configure_event (XConfigureEvent *xevent, GdkWindow *window)
|
||||
|
||||
static void
|
||||
gdk_input_xfree_enter_event (XCrossingEvent *xevent,
|
||||
GdkWindow *window)
|
||||
GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
gint root_x, root_y;
|
||||
@@ -257,6 +257,7 @@ gdk_input_xfree_grab_pointer (GdkWindow * window,
|
||||
guint32 time)
|
||||
{
|
||||
GdkInputWindow *input_window, *new_window;
|
||||
gboolean need_ungrab;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
GList *tmp_list;
|
||||
XEventClass event_classes[GDK_MAX_DEVICE_CLASSES];
|
||||
@@ -265,47 +266,70 @@ gdk_input_xfree_grab_pointer (GdkWindow * window,
|
||||
|
||||
tmp_list = gdk_input_windows;
|
||||
new_window = NULL;
|
||||
need_ungrab = FALSE;
|
||||
|
||||
while (tmp_list)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->grabbed)
|
||||
return AlreadyGrabbed;
|
||||
|
||||
if (input_window->window == window)
|
||||
new_window = input_window;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (new_window != NULL, Success); /* shouldn't happen */
|
||||
|
||||
new_window->grabbed = TRUE;
|
||||
|
||||
tmp_list = gdk_input_devices;
|
||||
while (tmp_list)
|
||||
{
|
||||
gdkdev = (GdkDevicePrivate *)tmp_list->data;
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
|
||||
gdkdev->xdevice)
|
||||
else if (input_window->grabbed)
|
||||
{
|
||||
gdk_input_common_find_events (window, gdkdev,
|
||||
event_mask,
|
||||
event_classes, &num_classes);
|
||||
|
||||
result = XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
|
||||
GDK_WINDOW_XWINDOW (window),
|
||||
owner_events, num_classes, event_classes,
|
||||
GrabModeAsync, GrabModeAsync, time);
|
||||
|
||||
/* FIXME: if failure occurs on something other than the first
|
||||
device, things will be badly inconsistent */
|
||||
if (result != Success)
|
||||
return result;
|
||||
input_window->grabbed = FALSE;
|
||||
need_ungrab = TRUE;
|
||||
}
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
|
||||
if (new_window)
|
||||
{
|
||||
new_window->grabbed = TRUE;
|
||||
|
||||
tmp_list = gdk_input_devices;
|
||||
while (tmp_list)
|
||||
{
|
||||
gdkdev = (GdkDevicePrivate *)tmp_list->data;
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
|
||||
gdkdev->xdevice)
|
||||
{
|
||||
gdk_input_common_find_events (window, gdkdev,
|
||||
event_mask,
|
||||
event_classes, &num_classes);
|
||||
|
||||
result = XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
|
||||
GDK_WINDOW_XWINDOW (window),
|
||||
owner_events, num_classes, event_classes,
|
||||
GrabModeAsync, GrabModeAsync, time);
|
||||
|
||||
/* FIXME: if failure occurs on something other than the first
|
||||
device, things will be badly inconsistent */
|
||||
if (result != Success)
|
||||
return result;
|
||||
}
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_list = gdk_input_devices;
|
||||
while (tmp_list)
|
||||
{
|
||||
gdkdev = (GdkDevicePrivate *)tmp_list->data;
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER && gdkdev->xdevice &&
|
||||
((gdkdev->button_state != 0) || need_ungrab))
|
||||
{
|
||||
XUngrabDevice( gdk_display, gdkdev->xdevice, time);
|
||||
gdkdev->button_state = 0;
|
||||
}
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
}
|
||||
|
||||
return Success;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -55,7 +55,7 @@ gdk_pixmap_new (GdkWindow *window,
|
||||
return NULL;
|
||||
|
||||
if (depth == -1)
|
||||
gdk_window_get_geometry (window, NULL, NULL, NULL, NULL, &depth);
|
||||
depth = gdk_window_get_visual (window)->depth;
|
||||
|
||||
private = g_new (GdkWindowPrivate, 1);
|
||||
pixmap = (GdkPixmap*) private;
|
||||
@@ -64,6 +64,7 @@ gdk_pixmap_new (GdkWindow *window,
|
||||
private->window_type = GDK_WINDOW_PIXMAP;
|
||||
private->xwindow = XCreatePixmap (private->xdisplay, window_private->xwindow,
|
||||
width, height, depth);
|
||||
private->colormap = NULL;
|
||||
private->parent = NULL;
|
||||
private->x = 0;
|
||||
private->y = 0;
|
||||
@@ -148,7 +149,7 @@ gdk_pixmap_create_from_data (GdkWindow *window,
|
||||
return NULL;
|
||||
|
||||
if (depth == -1)
|
||||
gdk_window_get_geometry (window, NULL, NULL, NULL, NULL, &depth);
|
||||
depth = gdk_window_get_visual (window)->depth;
|
||||
|
||||
private = g_new (GdkWindowPrivate, 1);
|
||||
pixmap = (GdkPixmap*) private;
|
||||
@@ -255,8 +256,14 @@ gdk_pixmap_read_string (FILE *infile,
|
||||
{
|
||||
if (cnt == (*buffer_size))
|
||||
{
|
||||
(*buffer_size) *= 2;
|
||||
(*buffer) = (gchar *) g_realloc ((*buffer), *buffer_size); }
|
||||
guint new_size = (*buffer_size) * 2;
|
||||
if (new_size > (*buffer_size))
|
||||
*buffer_size = new_size;
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
(*buffer) = (gchar *) g_realloc ((*buffer), *buffer_size);
|
||||
}
|
||||
|
||||
if (c != '"')
|
||||
(*buffer)[cnt++] = c;
|
||||
@@ -292,12 +299,16 @@ gdk_pixmap_skip_string (gchar *buffer)
|
||||
return &buffer[index];
|
||||
}
|
||||
|
||||
/* Xlib crashed ince at a color name lengths around 125 */
|
||||
#define MAX_COLOR_LEN 120
|
||||
|
||||
gchar*
|
||||
gdk_pixmap_extract_color (gchar *buffer)
|
||||
{
|
||||
gint counter, finished = FALSE, numnames;
|
||||
gint counter, numnames;
|
||||
gchar *ptr = NULL, ch, temp[128];
|
||||
gchar color[128], *retcol;
|
||||
gchar color[MAX_COLOR_LEN], *retcol;
|
||||
gint space;
|
||||
|
||||
counter = 0;
|
||||
while (ptr == NULL)
|
||||
@@ -314,34 +325,53 @@ gdk_pixmap_extract_color (gchar *buffer)
|
||||
counter++;
|
||||
}
|
||||
|
||||
if (ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
ptr = gdk_pixmap_skip_whitespaces (ptr);
|
||||
|
||||
if (ptr[0] == 0)
|
||||
return NULL;
|
||||
else if (ptr[0] == '#')
|
||||
{
|
||||
retcol = g_strdup (ptr);
|
||||
counter = 1;
|
||||
while (ptr[counter] != 0 &&
|
||||
((ptr[counter] >= '0' && ptr[counter] <= '9') ||
|
||||
(ptr[counter] >= 'a' && ptr[counter] <= 'f') ||
|
||||
(ptr[counter] >= 'A' && ptr[counter] <= 'F')))
|
||||
counter++;
|
||||
|
||||
retcol = g_new (gchar, counter+1);
|
||||
strncpy (retcol, ptr, counter);
|
||||
|
||||
retcol[counter] = 0;
|
||||
|
||||
return retcol;
|
||||
}
|
||||
|
||||
color[0] = 0;
|
||||
numnames = 0;
|
||||
|
||||
while (finished == FALSE)
|
||||
space = MAX_COLOR_LEN - 1;
|
||||
while (space > 0)
|
||||
{
|
||||
sscanf (ptr, "%127s", temp);
|
||||
|
||||
if ((gint)ptr[0] == 0 || strcmp ("s", temp) == 0 || strcmp ("m", temp) == 0 ||
|
||||
strcmp ("g", temp) == 0 || strcmp ("g4", temp) == 0)
|
||||
finished = TRUE;
|
||||
if (((gint)ptr[0] == 0) ||
|
||||
(strcmp ("s", temp) == 0) || (strcmp ("m", temp) == 0) ||
|
||||
(strcmp ("g", temp) == 0) || (strcmp ("g4", temp) == 0))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (numnames > 0)
|
||||
strcat (color, " ");
|
||||
strcat (color, temp);
|
||||
{
|
||||
space -= 1;
|
||||
strcat (color, " ");
|
||||
}
|
||||
if (space > 0)
|
||||
{
|
||||
strncat (color, temp, space);
|
||||
space -= MIN (space, strlen (temp));
|
||||
}
|
||||
ptr = gdk_pixmap_skip_string (ptr);
|
||||
ptr = gdk_pixmap_skip_whitespaces (ptr);
|
||||
numnames++;
|
||||
@@ -352,7 +382,6 @@ gdk_pixmap_extract_color (gchar *buffer)
|
||||
return retcol;
|
||||
}
|
||||
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_colormap_create_from_xpm (GdkWindow *window,
|
||||
GdkColormap *colormap,
|
||||
@@ -398,6 +427,11 @@ gdk_pixmap_colormap_create_from_xpm (GdkWindow *window,
|
||||
gdk_pixmap_read_string (infile, &buffer, &buffer_size);
|
||||
|
||||
sscanf (buffer,"%d %d %d %d", &width, &height, &num_cols, &cpp);
|
||||
if (cpp >= 32)
|
||||
{
|
||||
g_warning ("Pixmap has more than 31 characters per color\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
colors = g_new(_GdkPixmapColor, num_cols);
|
||||
|
||||
@@ -573,6 +607,11 @@ gdk_pixmap_colormap_create_from_xpm_d (GdkWindow *window,
|
||||
i = 0;
|
||||
buffer = data[i++];
|
||||
sscanf (buffer,"%d %d %d %d", &width, &height, &num_cols, &cpp);
|
||||
if (cpp >= 32)
|
||||
{
|
||||
g_warning ("Pixmap has more than 31 characters per color\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
colors = g_new(_GdkPixmapColor, num_cols);
|
||||
|
||||
|
@@ -81,6 +81,8 @@ struct _GdkWindowPrivate
|
||||
gint extension_events;
|
||||
|
||||
GList *filters;
|
||||
GdkColormap *colormap;
|
||||
GList *children;
|
||||
};
|
||||
|
||||
struct _GdkImagePrivate
|
||||
|
@@ -127,7 +127,7 @@ gdk_region_polygon (GdkPoint *points,
|
||||
GdkRegionPrivate *private;
|
||||
GdkRegion *region;
|
||||
Region xregion;
|
||||
int xfill_rule;
|
||||
gint xfill_rule = EvenOddRule;
|
||||
|
||||
g_return_val_if_fail (points != NULL, NULL);
|
||||
g_return_val_if_fail (npoints != 0, NULL); /* maybe we should check for at least three points */
|
||||
|
@@ -58,7 +58,7 @@ static gchar* visual_names[] =
|
||||
static GHashTable *visual_hash = NULL;
|
||||
|
||||
void
|
||||
gdk_visual_init ()
|
||||
gdk_visual_init (void)
|
||||
{
|
||||
static gint possible_depths[6] = { 32, 24, 16, 15, 8, 1 };
|
||||
static GdkVisualType possible_types[6] =
|
||||
@@ -263,25 +263,25 @@ gdk_visual_unref (GdkVisual *visual)
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_visual_get_best_depth ()
|
||||
gdk_visual_get_best_depth (void)
|
||||
{
|
||||
return available_depths[0];
|
||||
}
|
||||
|
||||
GdkVisualType
|
||||
gdk_visual_get_best_type ()
|
||||
gdk_visual_get_best_type (void)
|
||||
{
|
||||
return available_types[0];
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_system ()
|
||||
gdk_visual_get_system (void)
|
||||
{
|
||||
return ((GdkVisual*) system_visual);
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_best ()
|
||||
gdk_visual_get_best (void)
|
||||
{
|
||||
return ((GdkVisual*) &(visuals[0]));
|
||||
}
|
||||
|
184
gdk/gdkwindow.c
184
gdk/gdkwindow.c
@@ -20,7 +20,6 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/extensions/shape.h>
|
||||
#include <netinet/in.h>
|
||||
#include "gdk.h"
|
||||
#include "../config.h"
|
||||
@@ -30,6 +29,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_SHAPE_EXT
|
||||
#include <X11/extensions/shape.h>
|
||||
#endif
|
||||
|
||||
int nevent_masks = 17;
|
||||
int event_mask_table[19] =
|
||||
{
|
||||
@@ -65,18 +68,18 @@ gdk_window_xid_at(Window base, gint bx, gint by, gint x, gint y,
|
||||
Display *disp;
|
||||
Window *list=NULL;
|
||||
Window child=0,parent_win=0,root_win=0;
|
||||
int i;
|
||||
guint num;
|
||||
int wx,wy;
|
||||
guint ww,wh,wb,wd;
|
||||
|
||||
int i;
|
||||
unsigned int ww, wh, wb, wd, num;
|
||||
int wx,wy;
|
||||
|
||||
window=(GdkWindow*)&gdk_root_parent;
|
||||
private=(GdkWindowPrivate*)window;
|
||||
disp=private->xdisplay;
|
||||
if (!XGetGeometry(disp,base,&root_win,&wx,&wy,&ww,&wh,&wb,&wd))
|
||||
return 0;
|
||||
wx+=bx;wy+=by;
|
||||
if (!((x>=wx)&&(y>=wy)&&(x<(wx+ww))&&(y<(wy+wh))))
|
||||
if (!((x>=wx)&&(y>=wy)&&(x<(int)(wx+ww))&&(y<(int)(wy+wh))))
|
||||
return 0;
|
||||
if (!XQueryTree(disp,base,&root_win,&parent_win,&list,&num))
|
||||
return base;
|
||||
@@ -172,7 +175,7 @@ gdk_window_xid_at_coords(gint x, gint y, GList *excludes, gboolean excl_child)
|
||||
}
|
||||
|
||||
void
|
||||
gdk_window_init ()
|
||||
gdk_window_init (void)
|
||||
{
|
||||
XWindowAttributes xattributes;
|
||||
unsigned int width;
|
||||
@@ -191,6 +194,8 @@ gdk_window_init ()
|
||||
gdk_root_parent.window.user_data = NULL;
|
||||
gdk_root_parent.width = width;
|
||||
gdk_root_parent.height = height;
|
||||
gdk_root_parent.children = NULL;
|
||||
gdk_root_parent.colormap = NULL;
|
||||
}
|
||||
|
||||
GdkWindow*
|
||||
@@ -202,7 +207,6 @@ gdk_window_new (GdkWindow *parent,
|
||||
GdkWindowPrivate *private;
|
||||
GdkWindowPrivate *parent_private;
|
||||
GdkVisual *visual;
|
||||
GdkColormap *colormap;
|
||||
Display *parent_display;
|
||||
Window xparent;
|
||||
Visual *xvisual;
|
||||
@@ -232,6 +236,10 @@ gdk_window_new (GdkWindow *parent,
|
||||
window = (GdkWindow*) private;
|
||||
|
||||
private->parent = parent;
|
||||
|
||||
if (parent_private != &gdk_root_parent)
|
||||
parent_private->children = g_list_prepend (parent_private->children, window);
|
||||
|
||||
private->xdisplay = parent_display;
|
||||
private->destroyed = FALSE;
|
||||
private->resize_count = 0;
|
||||
@@ -264,6 +272,7 @@ gdk_window_new (GdkWindow *parent,
|
||||
private->dnd_drag_eventmask = private->dnd_drag_savedeventmask = 0;
|
||||
|
||||
private->filters = NULL;
|
||||
private->children = NULL;
|
||||
|
||||
window->user_data = NULL;
|
||||
|
||||
@@ -296,9 +305,9 @@ gdk_window_new (GdkWindow *parent,
|
||||
depth = visual->depth;
|
||||
|
||||
if (attributes_mask & GDK_WA_COLORMAP)
|
||||
colormap = attributes->colormap;
|
||||
private->colormap = attributes->colormap;
|
||||
else
|
||||
colormap = gdk_colormap_get_system ();
|
||||
private->colormap = gdk_colormap_get_system ();
|
||||
|
||||
xattributes.background_pixel = BlackPixel (gdk_display, gdk_screen);
|
||||
xattributes.border_pixel = BlackPixel (gdk_display, gdk_screen);
|
||||
@@ -307,26 +316,26 @@ gdk_window_new (GdkWindow *parent,
|
||||
switch (private->window_type)
|
||||
{
|
||||
case GDK_WINDOW_TOPLEVEL:
|
||||
xattributes.colormap = ((GdkColormapPrivate*) colormap)->xcolormap;
|
||||
xattributes.colormap = ((GdkColormapPrivate*) private->colormap)->xcolormap;
|
||||
xattributes_mask |= CWColormap;
|
||||
|
||||
xparent = gdk_root_window;
|
||||
break;
|
||||
|
||||
case GDK_WINDOW_CHILD:
|
||||
xattributes.colormap = ((GdkColormapPrivate*) colormap)->xcolormap;
|
||||
xattributes.colormap = ((GdkColormapPrivate*) private->colormap)->xcolormap;
|
||||
xattributes_mask |= CWColormap;
|
||||
break;
|
||||
|
||||
case GDK_WINDOW_DIALOG:
|
||||
xattributes.colormap = ((GdkColormapPrivate*) colormap)->xcolormap;
|
||||
xattributes.colormap = ((GdkColormapPrivate*) private->colormap)->xcolormap;
|
||||
xattributes_mask |= CWColormap;
|
||||
|
||||
xparent = gdk_root_window;
|
||||
break;
|
||||
|
||||
case GDK_WINDOW_TEMP:
|
||||
xattributes.colormap = ((GdkColormapPrivate*) colormap)->xcolormap;
|
||||
xattributes.colormap = ((GdkColormapPrivate*) private->colormap)->xcolormap;
|
||||
xattributes_mask |= CWColormap;
|
||||
|
||||
xparent = gdk_root_window;
|
||||
@@ -348,7 +357,7 @@ gdk_window_new (GdkWindow *parent,
|
||||
{
|
||||
depth = 0;
|
||||
class = InputOnly;
|
||||
colormap = NULL;
|
||||
private->colormap = NULL;
|
||||
}
|
||||
|
||||
private->xwindow = XCreateWindow (private->xdisplay, xparent,
|
||||
@@ -358,6 +367,9 @@ gdk_window_new (GdkWindow *parent,
|
||||
gdk_window_ref (window);
|
||||
gdk_xid_table_insert (&private->xwindow, window);
|
||||
|
||||
if (private->colormap)
|
||||
gdk_colormap_ref (private->colormap);
|
||||
|
||||
gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
|
||||
(attributes->cursor) :
|
||||
NULL));
|
||||
@@ -372,8 +384,8 @@ gdk_window_new (GdkWindow *parent,
|
||||
break;
|
||||
case GDK_WINDOW_CHILD:
|
||||
if ((attributes->wclass == GDK_INPUT_OUTPUT) &&
|
||||
(colormap != gdk_colormap_get_system ()) &&
|
||||
(colormap != gdk_window_get_colormap (gdk_window_get_toplevel (window))))
|
||||
(private->colormap != gdk_colormap_get_system ()) &&
|
||||
(private->colormap != gdk_window_get_colormap (gdk_window_get_toplevel (window))))
|
||||
{
|
||||
GDK_NOTE (MISC, g_print ("adding colormap window\n"));
|
||||
gdk_window_add_colormap_windows (window);
|
||||
@@ -430,6 +442,7 @@ gdk_window_foreign_new (guint32 anid)
|
||||
{
|
||||
GdkWindow *window;
|
||||
GdkWindowPrivate *private;
|
||||
GdkWindowPrivate *parent_private;
|
||||
XWindowAttributes attrs;
|
||||
Window root, parent;
|
||||
Window *children;
|
||||
@@ -446,6 +459,11 @@ gdk_window_foreign_new (guint32 anid)
|
||||
XFree (children);
|
||||
private->parent = gdk_xid_table_lookup (parent);
|
||||
|
||||
parent_private = (GdkWindowPrivate *)private->parent;
|
||||
|
||||
if (parent_private)
|
||||
parent_private->children = g_list_prepend (parent_private->children, window);
|
||||
|
||||
private->xwindow = anid;
|
||||
private->xdisplay = gdk_display;
|
||||
private->x = attrs.x;
|
||||
@@ -458,6 +476,7 @@ gdk_window_foreign_new (guint32 anid)
|
||||
private->destroyed = FALSE;
|
||||
private->extension_events = 0;
|
||||
|
||||
private->colormap = NULL;
|
||||
|
||||
private->dnd_drag_data_type = None;
|
||||
private->dnd_drag_data_typesavail =
|
||||
@@ -469,6 +488,7 @@ gdk_window_foreign_new (guint32 anid)
|
||||
private->dnd_drag_eventmask = private->dnd_drag_savedeventmask = 0;
|
||||
|
||||
private->filters = NULL;
|
||||
private->children = NULL;
|
||||
|
||||
window->user_data = NULL;
|
||||
|
||||
@@ -507,10 +527,17 @@ gdk_window_internal_destroy (GdkWindow *window, gboolean xdestroy,
|
||||
case GDK_WINDOW_FOREIGN:
|
||||
if (!private->destroyed)
|
||||
{
|
||||
if (private->parent)
|
||||
{
|
||||
GdkWindowPrivate *parent_private = (GdkWindowPrivate *)private->parent;
|
||||
if (parent_private->children)
|
||||
parent_private->children = g_list_remove (parent_private->children, window);
|
||||
}
|
||||
|
||||
if (private->window_type != GDK_WINDOW_FOREIGN)
|
||||
{
|
||||
children = gdk_window_get_children (window);
|
||||
tmp = children;
|
||||
children = tmp = private->children;
|
||||
private->children = NULL;
|
||||
|
||||
while (tmp)
|
||||
{
|
||||
@@ -522,7 +549,7 @@ gdk_window_internal_destroy (GdkWindow *window, gboolean xdestroy,
|
||||
gdk_window_internal_destroy (temp_window, FALSE,
|
||||
our_destroy);
|
||||
}
|
||||
|
||||
|
||||
g_list_free (children);
|
||||
}
|
||||
|
||||
@@ -581,6 +608,9 @@ gdk_window_internal_destroy (GdkWindow *window, gboolean xdestroy,
|
||||
else if (xdestroy)
|
||||
XDestroyWindow (private->xdisplay, private->xwindow);
|
||||
|
||||
if (private->colormap)
|
||||
gdk_colormap_unref (private->colormap);
|
||||
|
||||
private->destroyed = TRUE;
|
||||
}
|
||||
break;
|
||||
@@ -785,6 +815,7 @@ gdk_window_reparent (GdkWindow *window,
|
||||
{
|
||||
GdkWindowPrivate *window_private;
|
||||
GdkWindowPrivate *parent_private;
|
||||
GdkWindowPrivate *old_parent_private;
|
||||
|
||||
g_return_if_fail (window != NULL);
|
||||
|
||||
@@ -792,6 +823,7 @@ gdk_window_reparent (GdkWindow *window,
|
||||
new_parent = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
window_private = (GdkWindowPrivate*) window;
|
||||
old_parent_private = (GdkWindowPrivate*)window_private->parent;
|
||||
parent_private = (GdkWindowPrivate*) new_parent;
|
||||
|
||||
if (!window_private->destroyed && !parent_private->destroyed)
|
||||
@@ -799,6 +831,10 @@ gdk_window_reparent (GdkWindow *window,
|
||||
window_private->xwindow,
|
||||
parent_private->xwindow,
|
||||
x, y);
|
||||
|
||||
old_parent_private->children = g_list_remove (old_parent_private->children, window);
|
||||
parent_private->children = g_list_prepend (parent_private->children, window);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1059,6 +1095,11 @@ gdk_window_set_colormap (GdkWindow *window,
|
||||
XSetWindowColormap (window_private->xdisplay,
|
||||
window_private->xwindow,
|
||||
colormap_private->xcolormap);
|
||||
|
||||
if (window_private->colormap)
|
||||
gdk_colormap_unref (window_private->colormap);
|
||||
window_private->colormap = colormap;
|
||||
gdk_colormap_ref (window_private->colormap);
|
||||
|
||||
if (window_private->window_type != GDK_WINDOW_TOPLEVEL)
|
||||
gdk_window_add_colormap_windows (window);
|
||||
@@ -1153,20 +1194,27 @@ gdk_window_get_visual (GdkWindow *window)
|
||||
{
|
||||
GdkWindowPrivate *window_private;
|
||||
XWindowAttributes window_attributes;
|
||||
|
||||
|
||||
g_return_val_if_fail (window != NULL, NULL);
|
||||
|
||||
|
||||
window_private = (GdkWindowPrivate*) window;
|
||||
/* Huh? ->parent is never set for a pixmap. We should just return
|
||||
* null immeditately
|
||||
*/
|
||||
while (window_private && (window_private->window_type == GDK_WINDOW_PIXMAP))
|
||||
window_private = (GdkWindowPrivate*) window_private->parent;
|
||||
|
||||
if (window_private && !window_private->destroyed)
|
||||
{
|
||||
XGetWindowAttributes (window_private->xdisplay,
|
||||
window_private->xwindow,
|
||||
&window_attributes);
|
||||
|
||||
return gdk_visual_lookup (window_attributes.visual);
|
||||
if (window_private->colormap == NULL)
|
||||
{
|
||||
XGetWindowAttributes (window_private->xdisplay,
|
||||
window_private->xwindow,
|
||||
&window_attributes);
|
||||
return gdk_visual_lookup (window_attributes.visual);
|
||||
}
|
||||
else
|
||||
return ((GdkColormapPrivate *)window_private->colormap)->visual;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -1179,16 +1227,20 @@ gdk_window_get_colormap (GdkWindow *window)
|
||||
XWindowAttributes window_attributes;
|
||||
|
||||
g_return_val_if_fail (window != NULL, NULL);
|
||||
|
||||
window_private = (GdkWindowPrivate*) window;
|
||||
|
||||
|
||||
g_return_val_if_fail (window_private->window_type != GDK_WINDOW_PIXMAP, NULL);
|
||||
if (!window_private->destroyed)
|
||||
{
|
||||
XGetWindowAttributes (window_private->xdisplay,
|
||||
window_private->xwindow,
|
||||
&window_attributes);
|
||||
|
||||
return gdk_colormap_lookup (window_attributes.colormap);
|
||||
if (window_private->colormap == NULL)
|
||||
{
|
||||
XGetWindowAttributes (window_private->xdisplay,
|
||||
window_private->xwindow,
|
||||
&window_attributes);
|
||||
return gdk_colormap_lookup (window_attributes.colormap);
|
||||
}
|
||||
else
|
||||
return window_private->colormap;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -1436,8 +1488,7 @@ gdk_window_add_colormap_windows (GdkWindow *window)
|
||||
|
||||
/*
|
||||
* This needs the X11 shape extension.
|
||||
* If not available, simply remove the call to
|
||||
* XShapeCombineMask. Shaped windows will look
|
||||
* If not available, shaped windows will look
|
||||
* ugly, but programs still work. Stefan Wille
|
||||
*/
|
||||
void
|
||||
@@ -1445,38 +1496,53 @@ gdk_window_shape_combine_mask (GdkWindow *window,
|
||||
GdkBitmap *mask,
|
||||
gint x, gint y)
|
||||
{
|
||||
enum { UNKNOWN, NO, YES };
|
||||
|
||||
static gint have_shape = UNKNOWN;
|
||||
|
||||
GdkWindowPrivate *window_private;
|
||||
Pixmap pixmap;
|
||||
|
||||
g_return_if_fail (window != NULL);
|
||||
|
||||
/* This is needed, according to raster */
|
||||
gdk_window_set_override_redirect(window, TRUE);
|
||||
|
||||
window_private = (GdkWindowPrivate*) window;
|
||||
if (window_private->destroyed)
|
||||
return;
|
||||
|
||||
if (mask)
|
||||
#ifdef HAVE_SHAPE_EXT
|
||||
if (have_shape == UNKNOWN)
|
||||
{
|
||||
GdkWindowPrivate *pixmap_private;
|
||||
|
||||
pixmap_private = (GdkWindowPrivate*) mask;
|
||||
pixmap = (Pixmap) pixmap_private->xwindow;
|
||||
int ignore;
|
||||
if (XQueryExtension(gdk_display, "SHAPE", &ignore, &ignore, &ignore))
|
||||
have_shape = YES;
|
||||
else
|
||||
have_shape = NO;
|
||||
}
|
||||
else
|
||||
|
||||
if (have_shape == YES)
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
pixmap = None;
|
||||
window_private = (GdkWindowPrivate*) window;
|
||||
if (window_private->destroyed)
|
||||
return;
|
||||
|
||||
if (mask)
|
||||
{
|
||||
GdkWindowPrivate *pixmap_private;
|
||||
|
||||
pixmap_private = (GdkWindowPrivate*) mask;
|
||||
pixmap = (Pixmap) pixmap_private->xwindow;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
pixmap = None;
|
||||
}
|
||||
|
||||
XShapeCombineMask (window_private->xdisplay,
|
||||
window_private->xwindow,
|
||||
ShapeBounding,
|
||||
x, y,
|
||||
pixmap,
|
||||
ShapeSet);
|
||||
}
|
||||
|
||||
XShapeCombineMask (window_private->xdisplay,
|
||||
window_private->xwindow,
|
||||
ShapeBounding,
|
||||
x, y,
|
||||
pixmap,
|
||||
ShapeSet);
|
||||
#endif /* HAVE_SHAPE_EXT */
|
||||
}
|
||||
|
||||
void
|
||||
|
47
gdk/gxid.c
47
gdk/gxid.c
@@ -61,7 +61,7 @@ handler(int signal)
|
||||
}
|
||||
|
||||
void
|
||||
init_socket()
|
||||
init_socket(void)
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
|
||||
@@ -130,7 +130,7 @@ enable_device(GxidDevice *dev)
|
||||
/* switch the core pointer from whatever it is now to something else,
|
||||
return true on success, false otherwise */
|
||||
static int
|
||||
switch_core_pointer()
|
||||
switch_core_pointer(void)
|
||||
{
|
||||
GxidDevice *old_pointer = 0;
|
||||
GxidDevice *new_pointer = 0;
|
||||
@@ -222,7 +222,7 @@ init_device(XDeviceInfo *xdevice)
|
||||
}
|
||||
|
||||
void
|
||||
init_xinput()
|
||||
init_xinput(void)
|
||||
{
|
||||
char **extensions;
|
||||
XDeviceInfo *xdevices;
|
||||
@@ -279,12 +279,22 @@ int
|
||||
handle_claim_device(GxidClaimDevice *msg)
|
||||
{
|
||||
int i,j;
|
||||
XID devid = ntohl(msg->device);
|
||||
XID winid = ntohl(msg->window);
|
||||
int exclusive = ntohl(msg->exclusive);
|
||||
XID devid;
|
||||
XID winid;
|
||||
int exclusive;
|
||||
GxidDevice *device = NULL;
|
||||
GxidWindow *window = NULL;
|
||||
|
||||
if (msg->length != sizeof(GxidClaimDevice))
|
||||
{
|
||||
fprintf(stderr,"Bad length for ClaimDevice message\n");
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
devid = ntohl(msg->device);
|
||||
winid = ntohl(msg->window);
|
||||
exclusive = ntohl(msg->exclusive);
|
||||
|
||||
#ifdef DEBUG_CLIENTS
|
||||
fprintf(stderr,"device %ld claimed (window 0x%lx)\n",devid,winid);
|
||||
#endif
|
||||
@@ -397,11 +407,20 @@ int
|
||||
handle_release_device(GxidReleaseDevice *msg)
|
||||
{
|
||||
int i,j;
|
||||
XID devid = ntohl(msg->device);
|
||||
XID winid = ntohl(msg->window);
|
||||
XID devid;
|
||||
XID winid;
|
||||
|
||||
GxidDevice *device = NULL;
|
||||
|
||||
if (msg->length != sizeof(GxidReleaseDevice))
|
||||
{
|
||||
fprintf(stderr,"Bad length for ReleaseDevice message\n");
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
devid = ntohl(msg->device);
|
||||
winid = ntohl(msg->window);
|
||||
|
||||
#ifdef DEBUG_CLIENTS
|
||||
fprintf(stderr,"device %ld released (window 0x%lx)\n",devid,winid);
|
||||
#endif
|
||||
@@ -460,11 +479,11 @@ handle_release_device(GxidReleaseDevice *msg)
|
||||
}
|
||||
|
||||
void
|
||||
handle_connection()
|
||||
handle_connection (void)
|
||||
{
|
||||
GxidMessage msg;
|
||||
GxidU32 type;
|
||||
int length;
|
||||
GxidU32 length;
|
||||
GxidI32 retval;
|
||||
|
||||
int conn_fd;
|
||||
@@ -496,7 +515,7 @@ handle_connection()
|
||||
|
||||
/* read rest of message */
|
||||
|
||||
if (length > sizeof(GxidMessage))
|
||||
if ((length > sizeof(GxidMessage)) || (length < 2*sizeof(GxidU32)))
|
||||
{
|
||||
fprintf(stderr,"%s: Bad message length\n",
|
||||
program_name);
|
||||
@@ -689,7 +708,7 @@ handle_destroy_notify(XDestroyWindowEvent *event)
|
||||
}
|
||||
|
||||
void
|
||||
handle_xevent()
|
||||
handle_xevent(void)
|
||||
{
|
||||
int i;
|
||||
XEvent event;
|
||||
@@ -743,7 +762,7 @@ handle_xevent()
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,"Usage: %s [-d display] [-p --gxid-port port]\n",
|
||||
program_name);
|
||||
@@ -833,7 +852,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (FD_ISSET(socket_fd,&readfds))
|
||||
handle_connection(socket_fd);
|
||||
handle_connection();
|
||||
|
||||
while (XPending(dpy))
|
||||
handle_xevent();
|
||||
|
@@ -1,132 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 1995 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of the GNU LessTif Library.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef MWMUTIL_H_INCLUDED
|
||||
#define MWMUTIL_H_INCLUDED
|
||||
|
||||
#include <X11/Xmd.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
CARD32 flags;
|
||||
CARD32 functions;
|
||||
CARD32 decorations;
|
||||
INT32 input_mode;
|
||||
CARD32 status;
|
||||
} MotifWmHints, MwmHints;
|
||||
|
||||
#define MWM_HINTS_FUNCTIONS (1L << 0)
|
||||
#define MWM_HINTS_DECORATIONS (1L << 1)
|
||||
#define MWM_HINTS_INPUT_MODE (1L << 2)
|
||||
#define MWM_HINTS_STATUS (1L << 3)
|
||||
|
||||
#define MWM_FUNC_ALL (1L << 0)
|
||||
#define MWM_FUNC_RESIZE (1L << 1)
|
||||
#define MWM_FUNC_MOVE (1L << 2)
|
||||
#define MWM_FUNC_MINIMIZE (1L << 3)
|
||||
#define MWM_FUNC_MAXIMIZE (1L << 4)
|
||||
#define MWM_FUNC_CLOSE (1L << 5)
|
||||
|
||||
#define MWM_DECOR_ALL (1L << 0)
|
||||
#define MWM_DECOR_BORDER (1L << 1)
|
||||
#define MWM_DECOR_RESIZEH (1L << 2)
|
||||
#define MWM_DECOR_TITLE (1L << 3)
|
||||
#define MWM_DECOR_MENU (1L << 4)
|
||||
#define MWM_DECOR_MINIMIZE (1L << 5)
|
||||
#define MWM_DECOR_MAXIMIZE (1L << 6)
|
||||
|
||||
#define MWM_INPUT_MODELESS 0
|
||||
#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
|
||||
#define MWM_INPUT_SYSTEM_MODAL 2
|
||||
#define MWM_INPUT_FULL_APPLICATION_MODAL 3
|
||||
#define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
|
||||
|
||||
#define MWM_TEAROFF_WINDOW (1L<<0)
|
||||
|
||||
/*
|
||||
* atoms
|
||||
*/
|
||||
#define _XA_MOTIF_BINDINGS "_MOTIF_BINDINGS"
|
||||
#define _XA_MOTIF_WM_HINTS "_MOTIF_WM_HINTS"
|
||||
#define _XA_MOTIF_WM_MESSAGES "_MOTIF_WM_MESSAGES"
|
||||
#define _XA_MOTIF_WM_OFFSET "_MOTIF_WM_OFFSET"
|
||||
#define _XA_MOTIF_WM_MENU "_MOTIF_WM_MENU"
|
||||
#define _XA_MOTIF_WM_INFO "_MOTIF_WM_INFO"
|
||||
#define _XA_MWM_HINTS _XA_MOTIF_WM_HINTS
|
||||
#define _XA_MWM_MESSAGES _XA_MOTIF_WM_MESSAGES
|
||||
#define _XA_MWM_MENU _XA_MOTIF_WM_MENU
|
||||
#define _XA_MWM_INFO _XA_MOTIF_WM_INFO
|
||||
|
||||
|
||||
/*
|
||||
* _MWM_INFO property
|
||||
*/
|
||||
typedef struct {
|
||||
long flags;
|
||||
Window wm_window;
|
||||
} MotifWmInfo;
|
||||
|
||||
typedef MotifWmInfo MwmInfo;
|
||||
|
||||
#define MWM_INFO_STARTUP_STANDARD (1L<<0)
|
||||
#define MWM_INFO_STARTUP_CUSTOM (1L<<1)
|
||||
|
||||
/*
|
||||
* _MWM_HINTS property
|
||||
*/
|
||||
typedef struct {
|
||||
CARD32 flags;
|
||||
CARD32 functions;
|
||||
CARD32 decorations;
|
||||
INT32 inputMode;
|
||||
CARD32 status;
|
||||
} PropMotifWmHints;
|
||||
|
||||
typedef PropMotifWmHints PropMwmHints;
|
||||
|
||||
#define PROP_MOTIF_WM_HINTS_ELEMENTS 5
|
||||
#define PROP_MWM_HINTS_ELEMENTS PROP_MOTIF_WM_HINTS_ELEMENTS
|
||||
|
||||
/*
|
||||
* _MWM_INFO property, slight return
|
||||
*/
|
||||
typedef struct {
|
||||
CARD32 flags;
|
||||
CARD32 wmWindow;
|
||||
} PropMotifWmInfo;
|
||||
|
||||
typedef PropMotifWmInfo PropMwmInfo;
|
||||
|
||||
#define PROP_MOTIF_WM_INFO_ELEMENTS 2
|
||||
#define PROP_MWM_INFO_ELEMENTS PROP_MOTIF_WM_INFO_ELEMENTS
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MWMUTIL_H_INCLUDED */
|
1725
gdk/x11/gdkcc-x11.c
1725
gdk/x11/gdkcc-x11.c
File diff suppressed because it is too large
Load Diff
@@ -1,749 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
static gint gdk_colormap_match_color (GdkColormap *cmap,
|
||||
GdkColor *color,
|
||||
const gchar *available);
|
||||
static void gdk_colormap_add (GdkColormap *cmap);
|
||||
static void gdk_colormap_remove (GdkColormap *cmap);
|
||||
static guint gdk_colormap_hash (Colormap *cmap);
|
||||
static gint gdk_colormap_cmp (Colormap *a,
|
||||
Colormap *b);
|
||||
static void gdk_colormap_real_destroy (GdkColormap *colormap);
|
||||
|
||||
static GHashTable *colormap_hash = NULL;
|
||||
|
||||
|
||||
GdkColormap*
|
||||
gdk_colormap_new (GdkVisual *visual,
|
||||
gint private_cmap)
|
||||
{
|
||||
GdkColormap *colormap;
|
||||
GdkColormapPrivate *private;
|
||||
Visual *xvisual;
|
||||
int size;
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (visual != NULL, NULL);
|
||||
|
||||
private = g_new (GdkColormapPrivate, 1);
|
||||
colormap = (GdkColormap*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->visual = visual;
|
||||
private->next_color = 0;
|
||||
private->ref_count = 1;
|
||||
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
|
||||
|
||||
colormap->size = visual->colormap_size;
|
||||
colormap->colors = g_new (GdkColor, colormap->size);
|
||||
|
||||
switch (visual->type)
|
||||
{
|
||||
case GDK_VISUAL_GRAYSCALE:
|
||||
case GDK_VISUAL_PSEUDO_COLOR:
|
||||
private->private_val = private_cmap;
|
||||
private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
|
||||
xvisual, (private_cmap) ? (AllocAll) : (AllocNone));
|
||||
|
||||
if (private_cmap)
|
||||
{
|
||||
XColor *default_colors;
|
||||
|
||||
default_colors = g_new (XColor, colormap->size);
|
||||
|
||||
for (i = 0; i < colormap->size; i++)
|
||||
default_colors[i].pixel = i;
|
||||
|
||||
XQueryColors (private->xdisplay,
|
||||
DefaultColormap (private->xdisplay, gdk_screen),
|
||||
default_colors, colormap->size);
|
||||
|
||||
for (i = 0; i < colormap->size; i++)
|
||||
{
|
||||
colormap->colors[i].pixel = default_colors[i].pixel;
|
||||
colormap->colors[i].red = default_colors[i].red;
|
||||
colormap->colors[i].green = default_colors[i].green;
|
||||
colormap->colors[i].blue = default_colors[i].blue;
|
||||
}
|
||||
|
||||
gdk_colormap_change (colormap, colormap->size);
|
||||
|
||||
g_free (default_colors);
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_VISUAL_DIRECT_COLOR:
|
||||
private->private_val = TRUE;
|
||||
private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
|
||||
xvisual, AllocAll);
|
||||
|
||||
size = 1 << visual->red_prec;
|
||||
for (i = 0; i < size; i++)
|
||||
colormap->colors[i].red = i * 65535 / (size - 1);
|
||||
|
||||
size = 1 << visual->green_prec;
|
||||
for (i = 0; i < size; i++)
|
||||
colormap->colors[i].green = i * 65535 / (size - 1);
|
||||
|
||||
size = 1 << visual->blue_prec;
|
||||
for (i = 0; i < size; i++)
|
||||
colormap->colors[i].blue = i * 65535 / (size - 1);
|
||||
|
||||
gdk_colormap_change (colormap, colormap->size);
|
||||
break;
|
||||
|
||||
case GDK_VISUAL_STATIC_GRAY:
|
||||
case GDK_VISUAL_STATIC_COLOR:
|
||||
case GDK_VISUAL_TRUE_COLOR:
|
||||
private->private_val = FALSE;
|
||||
private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
|
||||
xvisual, AllocNone);
|
||||
break;
|
||||
}
|
||||
|
||||
gdk_colormap_add (colormap);
|
||||
|
||||
return colormap;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_colormap_real_destroy (GdkColormap *colormap)
|
||||
{
|
||||
GdkColormapPrivate *private = (GdkColormapPrivate*) colormap;
|
||||
|
||||
g_return_if_fail (colormap != NULL);
|
||||
|
||||
if (private->ref_count > 0)
|
||||
return;
|
||||
|
||||
gdk_colormap_remove (colormap);
|
||||
XFreeColormap (private->xdisplay, private->xcolormap);
|
||||
g_free (colormap->colors);
|
||||
g_free (colormap);
|
||||
}
|
||||
|
||||
GdkColormap*
|
||||
gdk_colormap_ref (GdkColormap *cmap)
|
||||
{
|
||||
GdkColormapPrivate *private = (GdkColormapPrivate *)cmap;
|
||||
g_return_val_if_fail (cmap != NULL, NULL);
|
||||
|
||||
private->ref_count += 1;
|
||||
return cmap;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colormap_unref (GdkColormap *cmap)
|
||||
{
|
||||
GdkColormapPrivate *private = (GdkColormapPrivate *)cmap;
|
||||
g_return_if_fail (cmap != NULL);
|
||||
|
||||
private->ref_count -= 1;
|
||||
if (private->ref_count == 0)
|
||||
gdk_colormap_real_destroy (cmap);
|
||||
}
|
||||
|
||||
GdkColormap*
|
||||
gdk_colormap_get_system (void)
|
||||
{
|
||||
static GdkColormap *colormap = NULL;
|
||||
GdkColormapPrivate *private;
|
||||
XColor *xpalette;
|
||||
gint i;
|
||||
|
||||
if (!colormap)
|
||||
{
|
||||
private = g_new (GdkColormapPrivate, 1);
|
||||
colormap = (GdkColormap*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->xcolormap = DefaultColormap (gdk_display, gdk_screen);
|
||||
private->visual = gdk_visual_get_system ();
|
||||
private->private_val = FALSE;
|
||||
private->next_color = 0;
|
||||
private->ref_count = 1;
|
||||
|
||||
colormap->size = private->visual->colormap_size;
|
||||
colormap->colors = g_new (GdkColor, colormap->size);
|
||||
|
||||
if ((private->visual->type == GDK_VISUAL_GRAYSCALE) ||
|
||||
(private->visual->type == GDK_VISUAL_PSEUDO_COLOR))
|
||||
{
|
||||
xpalette = g_new (XColor, colormap->size);
|
||||
|
||||
for (i = 0; i < colormap->size; i++)
|
||||
{
|
||||
xpalette[i].pixel = i;
|
||||
xpalette[i].red = 0;
|
||||
xpalette[i].green = 0;
|
||||
xpalette[i].blue = 0;
|
||||
}
|
||||
|
||||
XQueryColors (gdk_display, private->xcolormap, xpalette,
|
||||
colormap->size);
|
||||
|
||||
for (i = 0; i < colormap->size; i++)
|
||||
{
|
||||
colormap->colors[i].pixel = xpalette[i].pixel;
|
||||
colormap->colors[i].red = xpalette[i].red;
|
||||
colormap->colors[i].green = xpalette[i].green;
|
||||
colormap->colors[i].blue = xpalette[i].blue;
|
||||
}
|
||||
|
||||
g_free (xpalette);
|
||||
}
|
||||
|
||||
gdk_colormap_add (colormap);
|
||||
}
|
||||
|
||||
return colormap;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_colormap_get_system_size (void)
|
||||
{
|
||||
return DisplayCells (gdk_display, gdk_screen);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colormap_change (GdkColormap *colormap,
|
||||
gint ncolors)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
GdkVisual *visual;
|
||||
XColor *palette;
|
||||
gint shift;
|
||||
int max_colors;
|
||||
int size;
|
||||
int i;
|
||||
|
||||
g_return_if_fail (colormap != NULL);
|
||||
|
||||
palette = g_new (XColor, ncolors);
|
||||
|
||||
private = (GdkColormapPrivate*) colormap;
|
||||
switch (private->visual->type)
|
||||
{
|
||||
case GDK_VISUAL_GRAYSCALE:
|
||||
case GDK_VISUAL_PSEUDO_COLOR:
|
||||
for (i = 0; i < ncolors; i++)
|
||||
{
|
||||
palette[i].pixel = colormap->colors[i].pixel;
|
||||
palette[i].red = colormap->colors[i].red;
|
||||
palette[i].green = colormap->colors[i].green;
|
||||
palette[i].blue = colormap->colors[i].blue;
|
||||
palette[i].flags = DoRed | DoGreen | DoBlue;
|
||||
}
|
||||
|
||||
XStoreColors (private->xdisplay, private->xcolormap, palette, ncolors);
|
||||
private->next_color = MAX (private->next_color, ncolors);
|
||||
break;
|
||||
|
||||
case GDK_VISUAL_DIRECT_COLOR:
|
||||
visual = private->visual;
|
||||
|
||||
shift = visual->red_shift;
|
||||
max_colors = 1 << visual->red_prec;
|
||||
size = (ncolors < max_colors) ? (ncolors) : (max_colors);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
palette[i].pixel = i << shift;
|
||||
palette[i].red = colormap->colors[i].red;
|
||||
palette[i].flags = DoRed;
|
||||
}
|
||||
|
||||
XStoreColors (private->xdisplay, private->xcolormap, palette, size);
|
||||
|
||||
shift = visual->green_shift;
|
||||
max_colors = 1 << visual->green_prec;
|
||||
size = (ncolors < max_colors) ? (ncolors) : (max_colors);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
palette[i].pixel = i << shift;
|
||||
palette[i].green = colormap->colors[i].green;
|
||||
palette[i].flags = DoGreen;
|
||||
}
|
||||
|
||||
XStoreColors (private->xdisplay, private->xcolormap, palette, size);
|
||||
|
||||
shift = visual->blue_shift;
|
||||
max_colors = 1 << visual->blue_prec;
|
||||
size = (ncolors < max_colors) ? (ncolors) : (max_colors);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
palette[i].pixel = i << shift;
|
||||
palette[i].blue = colormap->colors[i].blue;
|
||||
palette[i].flags = DoBlue;
|
||||
}
|
||||
|
||||
XStoreColors (private->xdisplay, private->xcolormap, palette, size);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (palette);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colors_store (GdkColormap *colormap,
|
||||
GdkColor *colors,
|
||||
gint ncolors)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < ncolors; i++)
|
||||
{
|
||||
colormap->colors[i].pixel = colors[i].pixel;
|
||||
colormap->colors[i].red = colors[i].red;
|
||||
colormap->colors[i].green = colors[i].green;
|
||||
colormap->colors[i].blue = colors[i].blue;
|
||||
}
|
||||
|
||||
gdk_colormap_change (colormap, ncolors);
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_colors_alloc (GdkColormap *colormap,
|
||||
gint contiguous,
|
||||
gulong *planes,
|
||||
gint nplanes,
|
||||
gulong *pixels,
|
||||
gint npixels)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
gint return_val;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, 0);
|
||||
|
||||
private = (GdkColormapPrivate*) colormap;
|
||||
|
||||
return_val = XAllocColorCells (private->xdisplay, private->xcolormap,
|
||||
contiguous, planes, nplanes, pixels, npixels);
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colors_free (GdkColormap *colormap,
|
||||
gulong *pixels,
|
||||
gint npixels,
|
||||
gulong planes)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
|
||||
g_return_if_fail (colormap != NULL);
|
||||
|
||||
private = (GdkColormapPrivate*) colormap;
|
||||
|
||||
XFreeColors (private->xdisplay, private->xcolormap,
|
||||
pixels, npixels, planes);
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_white (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
gint return_val;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, FALSE);
|
||||
|
||||
if (color)
|
||||
{
|
||||
color->pixel = WhitePixel (gdk_display, gdk_screen);
|
||||
color->red = 65535;
|
||||
color->green = 65535;
|
||||
color->blue = 65535;
|
||||
|
||||
return_val = gdk_color_alloc (colormap, color);
|
||||
}
|
||||
else
|
||||
return_val = FALSE;
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_black (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
gint return_val;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, FALSE);
|
||||
|
||||
if (color)
|
||||
{
|
||||
color->pixel = BlackPixel (gdk_display, gdk_screen);
|
||||
color->red = 0;
|
||||
color->green = 0;
|
||||
color->blue = 0;
|
||||
|
||||
return_val = gdk_color_alloc (colormap, color);
|
||||
}
|
||||
else
|
||||
return_val = FALSE;
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_parse (const gchar *spec,
|
||||
GdkColor *color)
|
||||
{
|
||||
Colormap xcolormap;
|
||||
XColor xcolor;
|
||||
gint return_val;
|
||||
|
||||
g_return_val_if_fail (spec != NULL, FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
|
||||
xcolormap = DefaultColormap (gdk_display, gdk_screen);
|
||||
|
||||
if (XParseColor (gdk_display, xcolormap, spec, &xcolor))
|
||||
{
|
||||
return_val = TRUE;
|
||||
color->red = xcolor.red;
|
||||
color->green = xcolor.green;
|
||||
color->blue = xcolor.blue;
|
||||
}
|
||||
else
|
||||
return_val = FALSE;
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_alloc (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
GdkVisual *visual;
|
||||
XColor xcolor;
|
||||
gchar *available = NULL;
|
||||
gint return_val;
|
||||
gint i, index;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
|
||||
xcolor.red = color->red;
|
||||
xcolor.green = color->green;
|
||||
xcolor.blue = color->blue;
|
||||
xcolor.pixel = color->pixel;
|
||||
xcolor.flags = DoRed | DoGreen | DoBlue;
|
||||
|
||||
return_val = FALSE;
|
||||
private = (GdkColormapPrivate*) colormap;
|
||||
|
||||
switch (private->visual->type)
|
||||
{
|
||||
case GDK_VISUAL_GRAYSCALE:
|
||||
case GDK_VISUAL_PSEUDO_COLOR:
|
||||
if (private->private_val)
|
||||
{
|
||||
if (private->next_color >= colormap->size)
|
||||
{
|
||||
available = g_new (gchar, colormap->size);
|
||||
for (i = 0; i < colormap->size; i++)
|
||||
available[i] = TRUE;
|
||||
|
||||
index = gdk_colormap_match_color (colormap, color, available);
|
||||
if (index != -1)
|
||||
{
|
||||
available[index] = FALSE;
|
||||
*color = colormap->colors[index];
|
||||
return_val = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return_val = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xcolor.pixel = colormap->size - 1 -private->next_color;
|
||||
color->pixel = xcolor.pixel;
|
||||
private->next_color += 1;
|
||||
|
||||
XStoreColor (private->xdisplay, private->xcolormap, &xcolor);
|
||||
return_val = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
if (XAllocColor (private->xdisplay, private->xcolormap, &xcolor))
|
||||
{
|
||||
color->pixel = xcolor.pixel;
|
||||
color->red = xcolor.red;
|
||||
color->green = xcolor.green;
|
||||
color->blue = xcolor.blue;
|
||||
|
||||
if (color->pixel < colormap->size)
|
||||
colormap->colors[color->pixel] = *color;
|
||||
|
||||
return_val = TRUE;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (available == NULL)
|
||||
{
|
||||
available = g_new (gchar, colormap->size);
|
||||
for (i = 0; i < colormap->size; i++)
|
||||
available[i] = TRUE;
|
||||
}
|
||||
|
||||
index = gdk_colormap_match_color (colormap, color, available);
|
||||
if (index != -1)
|
||||
{
|
||||
available[index] = FALSE;
|
||||
xcolor.red = colormap->colors[index].red;
|
||||
xcolor.green = colormap->colors[index].green;
|
||||
xcolor.blue = colormap->colors[index].blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return_val = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_VISUAL_DIRECT_COLOR:
|
||||
visual = private->visual;
|
||||
xcolor.pixel = (((xcolor.red >> (16 - visual->red_prec)) << visual->red_shift) +
|
||||
((xcolor.green >> (16 - visual->green_prec)) << visual->green_shift) +
|
||||
((xcolor.blue >> (16 - visual->blue_prec)) << visual->blue_shift));
|
||||
color->pixel = xcolor.pixel;
|
||||
return_val = TRUE;
|
||||
break;
|
||||
|
||||
case GDK_VISUAL_STATIC_GRAY:
|
||||
case GDK_VISUAL_STATIC_COLOR:
|
||||
case GDK_VISUAL_TRUE_COLOR:
|
||||
if (XAllocColor (private->xdisplay, private->xcolormap, &xcolor))
|
||||
{
|
||||
color->pixel = xcolor.pixel;
|
||||
return_val = TRUE;
|
||||
}
|
||||
else
|
||||
return_val = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (available)
|
||||
g_free (available);
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_change (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
XColor xcolor;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
|
||||
xcolor.pixel = color->pixel;
|
||||
xcolor.red = color->red;
|
||||
xcolor.green = color->green;
|
||||
xcolor.blue = color->blue;
|
||||
xcolor.flags = DoRed | DoGreen | DoBlue;
|
||||
|
||||
private = (GdkColormapPrivate*) colormap;
|
||||
XStoreColor (private->xdisplay, private->xcolormap, &xcolor);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_equal (GdkColor *colora,
|
||||
GdkColor *colorb)
|
||||
{
|
||||
g_return_val_if_fail (colora != NULL, FALSE);
|
||||
g_return_val_if_fail (colorb != NULL, FALSE);
|
||||
|
||||
return ((colora->red == colorb->red) &&
|
||||
(colora->green == colorb->green) &&
|
||||
(colora->blue == colorb->blue));
|
||||
}
|
||||
|
||||
GdkColormap*
|
||||
gdkx_colormap_get (Colormap xcolormap)
|
||||
{
|
||||
GdkColormap *colormap;
|
||||
GdkColormapPrivate *private;
|
||||
|
||||
colormap = gdk_colormap_lookup (xcolormap);
|
||||
if (colormap)
|
||||
return colormap;
|
||||
|
||||
if (xcolormap == DefaultColormap (gdk_display, gdk_screen))
|
||||
return gdk_colormap_get_system ();
|
||||
|
||||
private = g_new (GdkColormapPrivate, 1);
|
||||
colormap = (GdkColormap*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->xcolormap = xcolormap;
|
||||
private->visual = NULL;
|
||||
private->private_val = TRUE;
|
||||
private->next_color = 0;
|
||||
|
||||
/* To do the following safely, we would have to have some way of finding
|
||||
* out what the size or visual of the given colormap is. It seems
|
||||
* X doesn't allow this
|
||||
*/
|
||||
|
||||
#if 0
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
xpalette[i].pixel = i;
|
||||
xpalette[i].red = 0;
|
||||
xpalette[i].green = 0;
|
||||
xpalette[i].blue = 0;
|
||||
}
|
||||
|
||||
XQueryColors (gdk_display, private->xcolormap, xpalette, 256);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
colormap->colors[i].pixel = xpalette[i].pixel;
|
||||
colormap->colors[i].red = xpalette[i].red;
|
||||
colormap->colors[i].green = xpalette[i].green;
|
||||
colormap->colors[i].blue = xpalette[i].blue;
|
||||
}
|
||||
#endif
|
||||
|
||||
colormap->colors = NULL;
|
||||
colormap->size = 0;
|
||||
|
||||
gdk_colormap_add (colormap);
|
||||
|
||||
return colormap;
|
||||
}
|
||||
|
||||
|
||||
static gint
|
||||
gdk_colormap_match_color (GdkColormap *cmap,
|
||||
GdkColor *color,
|
||||
const gchar *available)
|
||||
{
|
||||
GdkColor *colors;
|
||||
guint sum, max;
|
||||
gint rdiff, gdiff, bdiff;
|
||||
gint i, index;
|
||||
|
||||
g_return_val_if_fail (cmap != NULL, 0);
|
||||
g_return_val_if_fail (color != NULL, 0);
|
||||
|
||||
colors = cmap->colors;
|
||||
max = 3 * (65536);
|
||||
index = -1;
|
||||
|
||||
for (i = 0; i < cmap->size; i++)
|
||||
{
|
||||
if ((!available) || (available && available[i]))
|
||||
{
|
||||
rdiff = (color->red - colors[i].red);
|
||||
gdiff = (color->green - colors[i].green);
|
||||
bdiff = (color->blue - colors[i].blue);
|
||||
|
||||
sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
|
||||
|
||||
if (sum < max)
|
||||
{
|
||||
index = i;
|
||||
max = sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
GdkColormap*
|
||||
gdk_colormap_lookup (Colormap xcolormap)
|
||||
{
|
||||
GdkColormap *cmap;
|
||||
|
||||
if (!colormap_hash)
|
||||
return NULL;
|
||||
|
||||
cmap = g_hash_table_lookup (colormap_hash, &xcolormap);
|
||||
return cmap;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_colormap_add (GdkColormap *cmap)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
|
||||
if (!colormap_hash)
|
||||
colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
|
||||
(GCompareFunc) gdk_colormap_cmp);
|
||||
|
||||
private = (GdkColormapPrivate*) cmap;
|
||||
|
||||
g_hash_table_insert (colormap_hash, &private->xcolormap, cmap);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_colormap_remove (GdkColormap *cmap)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
|
||||
if (!colormap_hash)
|
||||
colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
|
||||
(GCompareFunc) gdk_colormap_cmp);
|
||||
|
||||
private = (GdkColormapPrivate*) cmap;
|
||||
|
||||
g_hash_table_remove (colormap_hash, &private->xcolormap);
|
||||
}
|
||||
|
||||
static guint
|
||||
gdk_colormap_hash (Colormap *cmap)
|
||||
{
|
||||
return *cmap;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_colormap_cmp (Colormap *a,
|
||||
Colormap *b)
|
||||
{
|
||||
return (*a == *b);
|
||||
}
|
@@ -1,84 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/cursorfont.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
GdkCursor*
|
||||
gdk_cursor_new (GdkCursorType cursor_type)
|
||||
{
|
||||
GdkCursorPrivate *private;
|
||||
GdkCursor *cursor;
|
||||
Cursor xcursor;
|
||||
|
||||
xcursor = XCreateFontCursor (gdk_display, cursor_type);
|
||||
private = g_new (GdkCursorPrivate, 1);
|
||||
private->xdisplay = gdk_display;
|
||||
private->xcursor = xcursor;
|
||||
cursor = (GdkCursor*) private;
|
||||
cursor->type = cursor_type;
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
source_pixmap = ((GdkPixmapPrivate *) source)->xwindow;
|
||||
mask_pixmap = ((GdkPixmapPrivate *) mask)->xwindow;
|
||||
|
||||
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_display, source_pixmap, mask_pixmap, &xfg, &xbg, x, y);
|
||||
private = g_new (GdkCursorPrivate, 1);
|
||||
private->xdisplay = gdk_display;
|
||||
private->xcursor = xcursor;
|
||||
cursor = (GdkCursor *) private;
|
||||
cursor->type = GDK_CURSOR_IS_PIXMAP;
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_cursor_destroy (GdkCursor *cursor)
|
||||
{
|
||||
GdkCursorPrivate *private;
|
||||
|
||||
g_return_if_fail (cursor != NULL);
|
||||
|
||||
private = (GdkCursorPrivate *) cursor;
|
||||
XFreeCursor (private->xdisplay, private->xcursor);
|
||||
|
||||
g_free (private);
|
||||
}
|
@@ -1,158 +0,0 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <string.h>
|
||||
#include "gdkx.h"
|
||||
#include "gdk.h"
|
||||
|
||||
/* Nothing much here now, but we have to make a start some time ;-) */
|
||||
|
||||
void
|
||||
gdk_dnd_set_drag_cursors(GdkCursor *default_cursor, GdkCursor *goahead_cursor)
|
||||
{
|
||||
gdk_dnd.c->gdk_cursor_dragdefault =
|
||||
((GdkCursorPrivate *)default_cursor)->xcursor;
|
||||
gdk_dnd.c->gdk_cursor_dragok = ((GdkCursorPrivate *)goahead_cursor)->xcursor;
|
||||
|
||||
if(gdk_dnd.dnd_grabbed)
|
||||
{
|
||||
if(gdk_dnd.c->drag_pm_default)
|
||||
/* We were displaying pixmaps for the drag */
|
||||
{
|
||||
gdk_window_hide(gdk_dnd.c->drag_pm_default);
|
||||
gdk_window_unref(gdk_dnd.c->drag_pm_default);
|
||||
if(gdk_dnd.c->drag_pm_ok)
|
||||
{
|
||||
gdk_window_hide(gdk_dnd.c->drag_pm_ok);
|
||||
gdk_window_unref(gdk_dnd.c->drag_pm_ok);
|
||||
}
|
||||
gdk_dnd.c->drag_pm_default = gdk_dnd.c->drag_pm_ok = NULL;
|
||||
g_list_free(gdk_dnd.c->xids);
|
||||
gdk_dnd.c->xids = NULL;
|
||||
}
|
||||
gdk_dnd_display_drag_cursor(-1, -1,
|
||||
gdk_dnd.dnd_drag_target?TRUE:FALSE,
|
||||
TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_dnd_set_drag_shape(GdkWindow *default_pixmapwin,
|
||||
GdkPoint *default_hotspot,
|
||||
GdkWindow *goahead_pixmapwin,
|
||||
GdkPoint *goahead_hotspot)
|
||||
{
|
||||
g_return_if_fail(default_pixmapwin != NULL);
|
||||
|
||||
g_list_free(gdk_dnd.c->xids); gdk_dnd.c->xids = NULL;
|
||||
if(gdk_dnd.c->drag_pm_default)
|
||||
{
|
||||
gdk_window_hide(gdk_dnd.c->drag_pm_default);
|
||||
gdk_window_unref(gdk_dnd.c->drag_pm_default);
|
||||
}
|
||||
if(gdk_dnd.c->drag_pm_ok)
|
||||
{
|
||||
gdk_window_hide(gdk_dnd.c->drag_pm_ok);
|
||||
gdk_window_unref(gdk_dnd.c->drag_pm_ok);
|
||||
}
|
||||
|
||||
gdk_dnd.c->drag_pm_ok = NULL;
|
||||
|
||||
gdk_window_ref(default_pixmapwin);
|
||||
gdk_dnd.c->drag_pm_default = default_pixmapwin;
|
||||
gdk_dnd.c->default_hotspot = *default_hotspot;
|
||||
gdk_dnd.c->xids = g_list_append(gdk_dnd.c->xids, (gpointer)(glong)((GdkWindowPrivate *)default_pixmapwin)->xwindow);
|
||||
if(goahead_pixmapwin)
|
||||
{
|
||||
gdk_window_ref(goahead_pixmapwin);
|
||||
gdk_dnd.c->xids = g_list_append(gdk_dnd.c->xids, (gpointer)(glong)((GdkWindowPrivate *)goahead_pixmapwin)->xwindow);
|
||||
gdk_dnd.c->drag_pm_ok = goahead_pixmapwin;
|
||||
gdk_dnd.c->ok_hotspot = *goahead_hotspot;
|
||||
}
|
||||
|
||||
if(gdk_dnd.dnd_grabbed)
|
||||
{
|
||||
gdk_dnd_display_drag_cursor(-1, -1,
|
||||
gdk_dnd.dnd_drag_target?TRUE:FALSE,
|
||||
TRUE);
|
||||
XChangeActivePointerGrab (gdk_display,
|
||||
ButtonMotionMask |
|
||||
ButtonPressMask |
|
||||
ButtonReleaseMask |
|
||||
EnterWindowMask | LeaveWindowMask,
|
||||
None,
|
||||
CurrentTime);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_dnd_display_drag_cursor(gint x, gint y, gboolean drag_ok,
|
||||
gboolean change_made)
|
||||
{
|
||||
if(!gdk_dnd.dnd_grabbed)
|
||||
return;
|
||||
|
||||
if(gdk_dnd.c->drag_pm_default)
|
||||
{
|
||||
/* We're doing pixmaps here... */
|
||||
GdkWindow *mypix, *opix;
|
||||
GdkPoint *myhotspot;
|
||||
gint itmp;
|
||||
guint masktmp;
|
||||
Window wtmp;
|
||||
|
||||
if(x == -2 && y == -2) /* Hide the cursors */
|
||||
{
|
||||
gdk_window_hide(gdk_dnd.c->drag_pm_ok);
|
||||
gdk_window_hide(gdk_dnd.c->drag_pm_default);
|
||||
GDK_NOTE(DND, g_print("Hiding both drag cursors\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(x == -1 && y == -1) /* We're supposed to find it out for ourselves */
|
||||
XQueryPointer(gdk_display, gdk_root_window,
|
||||
&wtmp, &wtmp, &x, &y, &itmp, &itmp, &masktmp);
|
||||
|
||||
if(drag_ok)
|
||||
{
|
||||
GDK_NOTE(DND, g_print("Switching to drag_ok cursor\n"));
|
||||
mypix = gdk_dnd.c->drag_pm_ok;
|
||||
opix = gdk_dnd.c->drag_pm_default;
|
||||
myhotspot = &gdk_dnd.c->ok_hotspot;
|
||||
}
|
||||
else
|
||||
{
|
||||
GDK_NOTE(DND, g_print("Switching to drag_default cursor\n"));
|
||||
mypix = gdk_dnd.c->drag_pm_default;
|
||||
opix = gdk_dnd.c->drag_pm_ok;
|
||||
myhotspot = &gdk_dnd.c->default_hotspot;
|
||||
}
|
||||
gdk_window_move(mypix, x - myhotspot->x, y - myhotspot->y);
|
||||
if(change_made)
|
||||
{
|
||||
GDK_NOTE(DND, g_print("Cursors switched, hide & show\n"));
|
||||
gdk_window_hide(opix);
|
||||
}
|
||||
gdk_window_move(mypix, x - myhotspot->x, y - myhotspot->y);
|
||||
if (change_made)
|
||||
{
|
||||
gdk_window_show(mypix); /* There ought to be a way to know if
|
||||
a window is already mapped etc. */
|
||||
}
|
||||
}
|
||||
else if(change_made)
|
||||
{
|
||||
Cursor c;
|
||||
/* Move cursors around */
|
||||
if(drag_ok)
|
||||
c = gdk_dnd.c->gdk_cursor_dragok;
|
||||
else
|
||||
c = gdk_dnd.c->gdk_cursor_dragdefault;
|
||||
XChangeActivePointerGrab (gdk_display,
|
||||
ButtonMotionMask |
|
||||
ButtonPressMask |
|
||||
ButtonReleaseMask |
|
||||
EnterWindowMask | LeaveWindowMask,
|
||||
c,
|
||||
CurrentTime);
|
||||
}
|
||||
}
|
@@ -1,387 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xos.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
GdkFont*
|
||||
gdk_font_load (const gchar *font_name)
|
||||
{
|
||||
GdkFont *font;
|
||||
GdkFontPrivate *private;
|
||||
|
||||
private = g_new (GdkFontPrivate, 1);
|
||||
font = (GdkFont*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->xfont = XLoadQueryFont (private->xdisplay, font_name);
|
||||
private->ref_count = 1;
|
||||
|
||||
if (!private->xfont)
|
||||
{
|
||||
g_free (font);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
font->type = GDK_FONT_FONT;
|
||||
font->ascent = ((XFontStruct *) private->xfont)->ascent;
|
||||
font->descent = ((XFontStruct *) private->xfont)->descent;
|
||||
}
|
||||
|
||||
gdk_xid_table_insert (&((XFontStruct *) private->xfont)->fid, font);
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
GdkFont*
|
||||
gdk_fontset_load (gchar *fontset_name)
|
||||
{
|
||||
GdkFont *font;
|
||||
GdkFontPrivate *private;
|
||||
XFontSet fontset;
|
||||
gint missing_charset_count;
|
||||
gchar **missing_charset_list;
|
||||
gchar *def_string;
|
||||
|
||||
private = g_new (GdkFontPrivate, 1);
|
||||
font = (GdkFont*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
fontset = XCreateFontSet (gdk_display, fontset_name,
|
||||
&missing_charset_list, &missing_charset_count,
|
||||
&def_string);
|
||||
|
||||
if (missing_charset_count)
|
||||
{
|
||||
gint i;
|
||||
g_print ("Missing charsets in FontSet creation\n");
|
||||
for (i=0;i<missing_charset_count;i++)
|
||||
g_print (" %s\n", missing_charset_list[i]);
|
||||
XFreeStringList (missing_charset_list);
|
||||
}
|
||||
|
||||
private->ref_count = 1;
|
||||
|
||||
if (!fontset)
|
||||
{
|
||||
g_free (font);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
gint num_fonts;
|
||||
gint i;
|
||||
XFontStruct **font_structs;
|
||||
gchar **font_names;
|
||||
|
||||
private->xfont = fontset;
|
||||
font->type = GDK_FONT_FONTSET;
|
||||
num_fonts = XFontsOfFontSet (fontset, &font_structs, &font_names);
|
||||
|
||||
font->ascent = font->descent = 0;
|
||||
|
||||
for (i = 0; i < num_fonts; i++)
|
||||
{
|
||||
font->ascent = MAX (font->ascent, font_structs[i]->ascent);
|
||||
font->descent = MAX (font->descent, font_structs[i]->descent);
|
||||
}
|
||||
}
|
||||
return font;
|
||||
}
|
||||
|
||||
GdkFont*
|
||||
gdk_font_ref (GdkFont *font)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
|
||||
g_return_val_if_fail (font != NULL, NULL);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
private->ref_count += 1;
|
||||
return font;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_font_unref (GdkFont *font)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
|
||||
g_return_if_fail (font != NULL);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
|
||||
private->ref_count -= 1;
|
||||
if (private->ref_count == 0)
|
||||
{
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
gdk_xid_table_remove (((XFontStruct *) private->xfont)->fid);
|
||||
XFreeFont (private->xdisplay, (XFontStruct *) private->xfont);
|
||||
break;
|
||||
case GDK_FONT_FONTSET:
|
||||
XFreeFontSet (private->xdisplay, (XFontSet) private->xfont);
|
||||
break;
|
||||
default:
|
||||
g_error ("unknown font type.");
|
||||
break;
|
||||
}
|
||||
g_free (font);
|
||||
}
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_font_id (GdkFont *font)
|
||||
{
|
||||
GdkFontPrivate *font_private;
|
||||
|
||||
g_return_val_if_fail (font != NULL, 0);
|
||||
|
||||
font_private = (GdkFontPrivate*) font;
|
||||
|
||||
if (font->type == GDK_FONT_FONT)
|
||||
{
|
||||
return ((XFontStruct *) font_private->xfont)->fid;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_font_equal (GdkFont *fonta,
|
||||
GdkFont *fontb)
|
||||
{
|
||||
GdkFontPrivate *privatea;
|
||||
GdkFontPrivate *privateb;
|
||||
|
||||
g_return_val_if_fail (fonta != NULL, FALSE);
|
||||
g_return_val_if_fail (fontb != NULL, FALSE);
|
||||
|
||||
privatea = (GdkFontPrivate*) fonta;
|
||||
privateb = (GdkFontPrivate*) fontb;
|
||||
|
||||
if (fonta->type == GDK_FONT_FONT && fontb->type == GDK_FONT_FONT)
|
||||
{
|
||||
return (((XFontStruct *) privatea->xfont)->fid ==
|
||||
((XFontStruct *) privateb->xfont)->fid);
|
||||
}
|
||||
else if (fonta->type == GDK_FONT_FONTSET && fontb->type == GDK_FONT_FONTSET)
|
||||
{
|
||||
/* how to compare two fontsets ?? by basename or XFontSet ?? */
|
||||
return (((XFontSet) privatea->xfont) == ((XFontSet) privateb->xfont));
|
||||
}
|
||||
else
|
||||
/* fontset != font */
|
||||
return 0;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_string_width (GdkFont *font,
|
||||
const gchar *string)
|
||||
{
|
||||
GdkFontPrivate *font_private;
|
||||
gint width;
|
||||
XFontStruct *xfont;
|
||||
XFontSet fontset;
|
||||
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (string != NULL, -1);
|
||||
|
||||
font_private = (GdkFontPrivate*) font;
|
||||
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
xfont = (XFontStruct *) font_private->xfont;
|
||||
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
||||
{
|
||||
width = XTextWidth (xfont, string, strlen (string));
|
||||
}
|
||||
else
|
||||
{
|
||||
width = XTextWidth16 (xfont, (XChar2b *) string, strlen (string) / 2);
|
||||
}
|
||||
break;
|
||||
case GDK_FONT_FONTSET:
|
||||
fontset = (XFontSet) font_private->xfont;
|
||||
width = XmbTextEscapement (fontset, string, strlen(string));
|
||||
break;
|
||||
default:
|
||||
width = 0;
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_text_width (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
gint width;
|
||||
XFontStruct *xfont;
|
||||
XFontSet fontset;
|
||||
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (text != NULL, -1);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
xfont = (XFontStruct *) private->xfont;
|
||||
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
||||
{
|
||||
width = XTextWidth (xfont, text, text_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
width = XTextWidth16 (xfont, (XChar2b *) text, text_length / 2);
|
||||
}
|
||||
break;
|
||||
case GDK_FONT_FONTSET:
|
||||
fontset = (XFontSet) private->xfont;
|
||||
width = XmbTextEscapement (fontset, text, text_length);
|
||||
break;
|
||||
default:
|
||||
width = 0;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
/* Problem: What if a character is a 16 bits character ?? */
|
||||
gint
|
||||
gdk_char_width (GdkFont *font,
|
||||
gchar character)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
XCharStruct *chars;
|
||||
gint width;
|
||||
guint ch = character & 0xff; /* get rid of sign-extension */
|
||||
XFontStruct *xfont;
|
||||
XFontSet fontset;
|
||||
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
/* only 8 bits characters are considered here */
|
||||
xfont = (XFontStruct *) private->xfont;
|
||||
if ((xfont->min_byte1 == 0) &&
|
||||
(xfont->max_byte1 == 0) &&
|
||||
(ch >= xfont->min_char_or_byte2) &&
|
||||
(ch <= xfont->max_char_or_byte2))
|
||||
{
|
||||
chars = xfont->per_char;
|
||||
if (chars)
|
||||
width = chars[ch - xfont->min_char_or_byte2].width;
|
||||
else
|
||||
width = xfont->min_bounds.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = XTextWidth (xfont, &character, 1);
|
||||
}
|
||||
break;
|
||||
case GDK_FONT_FONTSET:
|
||||
fontset = (XFontSet) private->xfont;
|
||||
width = XmbTextEscapement (fontset, &character, 1) ;
|
||||
break;
|
||||
default:
|
||||
width = 0;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_string_measure (GdkFont *font,
|
||||
const gchar *string)
|
||||
{
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (string != NULL, -1);
|
||||
|
||||
return gdk_text_measure (font, string, strlen (string));
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_text_measure (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
XCharStruct overall;
|
||||
XFontStruct *xfont;
|
||||
XFontSet fontset;
|
||||
XRectangle ink, log;
|
||||
int direction;
|
||||
int font_ascent;
|
||||
int font_descent;
|
||||
gint width;
|
||||
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (text != NULL, -1);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
xfont = (XFontStruct *) private->xfont;
|
||||
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
||||
{
|
||||
XTextExtents (xfont, text, text_length,
|
||||
&direction, &font_ascent, &font_descent,
|
||||
&overall);
|
||||
}
|
||||
else
|
||||
{
|
||||
XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
|
||||
&direction, &font_ascent, &font_descent,
|
||||
&overall);
|
||||
}
|
||||
width = overall.rbearing;
|
||||
break;
|
||||
case GDK_FONT_FONTSET:
|
||||
fontset = (XFontSet) private->xfont;
|
||||
XmbTextExtents (fontset, text, text_length, &ink, &log);
|
||||
width = log.width;
|
||||
break;
|
||||
default:
|
||||
width = 0;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_char_measure (GdkFont *font,
|
||||
gchar character)
|
||||
{
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
|
||||
return gdk_text_measure (font, &character, 1);
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include "gdktypes.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
guint gdk_debug_flags = 0;
|
||||
gint gdk_use_xshm = TRUE;
|
||||
gchar *gdk_display_name = NULL;
|
||||
Display *gdk_display = NULL;
|
||||
gint gdk_screen;
|
||||
Window gdk_root_window;
|
||||
Window gdk_leader_window;
|
||||
GdkWindowPrivate gdk_root_parent;
|
||||
Atom gdk_wm_delete_window;
|
||||
Atom gdk_wm_take_focus;
|
||||
Atom gdk_wm_protocols;
|
||||
Atom gdk_wm_window_protocols[2];
|
||||
Atom gdk_selection_property;
|
||||
GdkDndCursorInfo gdk_dnd_cursorinfo = {None, None, NULL, NULL,
|
||||
{0,0}, {0,0}, NULL};
|
||||
GdkDndGlobals gdk_dnd = {None,None,None,
|
||||
None,None,None,
|
||||
None,
|
||||
&gdk_dnd_cursorinfo,
|
||||
NULL,
|
||||
0,
|
||||
FALSE, FALSE, FALSE,
|
||||
None,
|
||||
{0,0},
|
||||
{0,0}, {0,0},
|
||||
{0,0,0,0}, NULL, None, 0};
|
||||
gchar *gdk_progname = NULL;
|
||||
gchar *gdk_progclass = NULL;
|
||||
gint gdk_error_code;
|
||||
gint gdk_error_warnings = TRUE;
|
||||
gint gdk_null_window_warnings = TRUE;
|
||||
GList *gdk_default_filters = NULL;
|
@@ -1,496 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
#include "../config.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined (HAVE_IPC_H) && defined (HAVE_SHM_H) && defined (HAVE_XSHM_H)
|
||||
#define USE_SHM
|
||||
#endif
|
||||
|
||||
#ifdef USE_SHM
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#endif /* USE_SHM */
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#ifdef USE_SHM
|
||||
#include <X11/extensions/XShm.h>
|
||||
#endif /* USE_SHM */
|
||||
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
static void gdk_image_put_normal (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkImage *image,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height);
|
||||
static void gdk_image_put_shared (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkImage *image,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
|
||||
static GList *image_list = NULL;
|
||||
|
||||
|
||||
void
|
||||
gdk_image_exit ()
|
||||
{
|
||||
GdkImage *image;
|
||||
|
||||
while (image_list)
|
||||
{
|
||||
image = image_list->data;
|
||||
gdk_image_destroy (image);
|
||||
}
|
||||
}
|
||||
|
||||
GdkImage *
|
||||
gdk_image_new_bitmap(GdkVisual *visual, gpointer data, gint w, gint h)
|
||||
/*
|
||||
* Desc: create a new bitmap image
|
||||
*/
|
||||
{
|
||||
Visual *xvisual;
|
||||
GdkImage *image;
|
||||
GdkImagePrivate *private;
|
||||
private = g_new(GdkImagePrivate, 1);
|
||||
image = (GdkImage *) private;
|
||||
private->xdisplay = gdk_display;
|
||||
private->image_put = gdk_image_put_normal;
|
||||
image->type = GDK_IMAGE_NORMAL;
|
||||
image->visual = visual;
|
||||
image->width = w;
|
||||
image->height = h;
|
||||
image->depth = 1;
|
||||
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
|
||||
private->ximage = XCreateImage(private->xdisplay, xvisual, 1, XYBitmap,
|
||||
0, 0, w ,h, 8, 0);
|
||||
private->ximage->data = data;
|
||||
private->ximage->bitmap_bit_order = MSBFirst;
|
||||
private->ximage->byte_order = MSBFirst;
|
||||
image->byte_order = MSBFirst;
|
||||
image->mem = private->ximage->data;
|
||||
image->bpl = private->ximage->bytes_per_line;
|
||||
image->bpp = 1;
|
||||
return(image);
|
||||
} /* gdk_image_new_bitmap() */
|
||||
|
||||
static int
|
||||
gdk_image_check_xshm(Display *display)
|
||||
/*
|
||||
* Desc: query the server for support for the MIT_SHM extension
|
||||
* Return: 0 = not available
|
||||
* 1 = shared XImage support available
|
||||
* 2 = shared Pixmap support available also
|
||||
*/
|
||||
{
|
||||
#ifdef USE_SHM
|
||||
int major, minor, ignore;
|
||||
Bool pixmaps;
|
||||
|
||||
if (XQueryExtension(display, "MIT-SHM", &ignore, &ignore, &ignore))
|
||||
{
|
||||
if (XShmQueryVersion(display, &major, &minor, &pixmaps )==True)
|
||||
{
|
||||
return (pixmaps==True) ? 2 : 1;
|
||||
}
|
||||
}
|
||||
#endif /* USE_SHM */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_image_init ()
|
||||
{
|
||||
if (gdk_use_xshm)
|
||||
{
|
||||
if (!gdk_image_check_xshm (gdk_display))
|
||||
{
|
||||
gdk_use_xshm = False;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GdkImage*
|
||||
gdk_image_new (GdkImageType type,
|
||||
GdkVisual *visual,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkImage *image;
|
||||
GdkImagePrivate *private;
|
||||
#ifdef USE_SHM
|
||||
XShmSegmentInfo *x_shm_info;
|
||||
#endif /* USE_SHM */
|
||||
Visual *xvisual;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GDK_IMAGE_FASTEST:
|
||||
image = gdk_image_new (GDK_IMAGE_SHARED, visual, width, height);
|
||||
|
||||
if (!image)
|
||||
image = gdk_image_new (GDK_IMAGE_NORMAL, visual, width, height);
|
||||
break;
|
||||
|
||||
default:
|
||||
private = g_new (GdkImagePrivate, 1);
|
||||
image = (GdkImage*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->image_put = NULL;
|
||||
|
||||
image->type = type;
|
||||
image->visual = visual;
|
||||
image->width = width;
|
||||
image->height = height;
|
||||
image->depth = visual->depth;
|
||||
|
||||
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GDK_IMAGE_SHARED:
|
||||
#ifdef USE_SHM
|
||||
if (gdk_use_xshm)
|
||||
{
|
||||
private->image_put = gdk_image_put_shared;
|
||||
|
||||
private->x_shm_info = g_new (XShmSegmentInfo, 1);
|
||||
x_shm_info = private->x_shm_info;
|
||||
|
||||
private->ximage = XShmCreateImage (private->xdisplay, xvisual, visual->depth,
|
||||
ZPixmap, NULL, x_shm_info, width, height);
|
||||
if (private->ximage == NULL)
|
||||
{
|
||||
g_warning ("XShmCreateImage failed");
|
||||
|
||||
g_free (image);
|
||||
gdk_use_xshm = False;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
x_shm_info->shmid = shmget (IPC_PRIVATE,
|
||||
private->ximage->bytes_per_line * private->ximage->height,
|
||||
IPC_CREAT | 0777);
|
||||
|
||||
if (x_shm_info->shmid == -1)
|
||||
{
|
||||
g_warning ("shmget failed!");
|
||||
|
||||
XDestroyImage (private->ximage);
|
||||
g_free (private->x_shm_info);
|
||||
g_free (image);
|
||||
|
||||
gdk_use_xshm = False;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
x_shm_info->readOnly = False;
|
||||
x_shm_info->shmaddr = shmat (x_shm_info->shmid, 0, 0);
|
||||
private->ximage->data = x_shm_info->shmaddr;
|
||||
|
||||
if (x_shm_info->shmaddr == (char*) -1)
|
||||
{
|
||||
g_warning ("shmat failed!");
|
||||
|
||||
XDestroyImage (private->ximage);
|
||||
shmctl (x_shm_info->shmid, IPC_RMID, 0);
|
||||
|
||||
g_free (private->x_shm_info);
|
||||
g_free (image);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef IPC_RMID_DEFERRED_RELEASE
|
||||
if (x_shm_info->shmaddr != (char*) -1)
|
||||
shmctl (x_shm_info->shmid, IPC_RMID, 0);
|
||||
#endif
|
||||
|
||||
gdk_error_code = 0;
|
||||
gdk_error_warnings = 0;
|
||||
|
||||
XShmAttach (private->xdisplay, x_shm_info);
|
||||
XSync (private->xdisplay, False);
|
||||
|
||||
gdk_error_warnings = 1;
|
||||
if (gdk_error_code == -1)
|
||||
{
|
||||
/* this is the common failure case so omit warning */
|
||||
XDestroyImage (private->ximage);
|
||||
shmdt (x_shm_info->shmaddr);
|
||||
shmctl (x_shm_info->shmid, IPC_RMID, 0);
|
||||
|
||||
g_free (private->x_shm_info);
|
||||
g_free (image);
|
||||
|
||||
gdk_use_xshm = False;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (image)
|
||||
image_list = g_list_prepend (image_list, image);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (image);
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
#else /* USE_SHM */
|
||||
g_free (image);
|
||||
return NULL;
|
||||
#endif /* USE_SHM */
|
||||
case GDK_IMAGE_NORMAL:
|
||||
private->image_put = gdk_image_put_normal;
|
||||
|
||||
private->ximage = XCreateImage (private->xdisplay, xvisual, visual->depth,
|
||||
ZPixmap, 0, 0, width, height, 32, 0);
|
||||
|
||||
private->ximage->data = g_new (char, private->ximage->bytes_per_line *
|
||||
private->ximage->height);
|
||||
break;
|
||||
|
||||
case GDK_IMAGE_FASTEST:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
if (image)
|
||||
{
|
||||
image->byte_order = private->ximage->byte_order;
|
||||
image->mem = private->ximage->data;
|
||||
image->bpl = private->ximage->bytes_per_line;
|
||||
|
||||
switch (private->ximage->bits_per_pixel)
|
||||
{
|
||||
case 8:
|
||||
image->bpp = 1;
|
||||
break;
|
||||
case 16:
|
||||
image->bpp = 2;
|
||||
break;
|
||||
case 24:
|
||||
image->bpp = 3;
|
||||
break;
|
||||
case 32:
|
||||
image->bpp = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
GdkImage*
|
||||
gdk_image_get (GdkWindow *window,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkImage *image;
|
||||
GdkImagePrivate *private;
|
||||
GdkWindowPrivate *win_private;
|
||||
|
||||
g_return_val_if_fail (window != NULL, NULL);
|
||||
|
||||
win_private = (GdkWindowPrivate *) window;
|
||||
if (win_private->destroyed)
|
||||
return NULL;
|
||||
|
||||
private = g_new (GdkImagePrivate, 1);
|
||||
image = (GdkImage*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->image_put = gdk_image_put_normal;
|
||||
private->ximage = XGetImage (private->xdisplay,
|
||||
win_private->xwindow,
|
||||
x, y, width, height,
|
||||
AllPlanes, ZPixmap);
|
||||
|
||||
image->type = GDK_IMAGE_NORMAL;
|
||||
image->visual = gdk_window_get_visual (window);
|
||||
image->width = width;
|
||||
image->height = height;
|
||||
image->depth = private->ximage->depth;
|
||||
|
||||
image->mem = private->ximage->data;
|
||||
image->bpl = private->ximage->bytes_per_line;
|
||||
image->bpp = 1;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
guint32
|
||||
gdk_image_get_pixel (GdkImage *image,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
guint32 pixel;
|
||||
GdkImagePrivate *private;
|
||||
|
||||
g_return_val_if_fail (image != NULL, 0);
|
||||
|
||||
private = (GdkImagePrivate *) image;
|
||||
|
||||
pixel = XGetPixel (private->ximage, x, y);
|
||||
|
||||
return pixel;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_image_put_pixel (GdkImage *image,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 pixel)
|
||||
{
|
||||
GdkImagePrivate *private;
|
||||
|
||||
g_return_if_fail (image != NULL);
|
||||
|
||||
private = (GdkImagePrivate *) image;
|
||||
|
||||
pixel = XPutPixel (private->ximage, x, y, pixel);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_image_destroy (GdkImage *image)
|
||||
{
|
||||
GdkImagePrivate *private;
|
||||
#ifdef USE_SHM
|
||||
XShmSegmentInfo *x_shm_info;
|
||||
#endif /* USE_SHM */
|
||||
|
||||
g_return_if_fail (image != NULL);
|
||||
|
||||
private = (GdkImagePrivate*) image;
|
||||
switch (image->type)
|
||||
{
|
||||
case GDK_IMAGE_NORMAL:
|
||||
XDestroyImage (private->ximage);
|
||||
break;
|
||||
|
||||
case GDK_IMAGE_SHARED:
|
||||
#ifdef USE_SHM
|
||||
XShmDetach (private->xdisplay, private->x_shm_info);
|
||||
XDestroyImage (private->ximage);
|
||||
|
||||
x_shm_info = private->x_shm_info;
|
||||
shmdt (x_shm_info->shmaddr);
|
||||
shmctl (x_shm_info->shmid, IPC_RMID, 0);
|
||||
|
||||
g_free (private->x_shm_info);
|
||||
|
||||
image_list = g_list_remove (image_list, image);
|
||||
#else /* USE_SHM */
|
||||
g_error ("trying to destroy shared memory image when gdk was compiled without shared memory support");
|
||||
#endif /* USE_SHM */
|
||||
break;
|
||||
|
||||
case GDK_IMAGE_FASTEST:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
g_free (image);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_image_put_normal (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkImage *image,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkWindowPrivate *drawable_private;
|
||||
GdkImagePrivate *image_private;
|
||||
GdkGCPrivate *gc_private;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (image != NULL);
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
drawable_private = (GdkWindowPrivate*) drawable;
|
||||
if (drawable_private->destroyed)
|
||||
return;
|
||||
image_private = (GdkImagePrivate*) image;
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
|
||||
g_return_if_fail (image->type == GDK_IMAGE_NORMAL);
|
||||
|
||||
XPutImage (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, image_private->ximage,
|
||||
xsrc, ysrc, xdest, ydest, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_image_put_shared (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkImage *image,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
#ifdef USE_SHM
|
||||
GdkWindowPrivate *drawable_private;
|
||||
GdkImagePrivate *image_private;
|
||||
GdkGCPrivate *gc_private;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (image != NULL);
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
drawable_private = (GdkWindowPrivate*) drawable;
|
||||
if (drawable_private->destroyed)
|
||||
return;
|
||||
image_private = (GdkImagePrivate*) image;
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
|
||||
g_return_if_fail (image->type == GDK_IMAGE_SHARED);
|
||||
|
||||
XShmPutImage (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, image_private->ximage,
|
||||
xsrc, ysrc, xdest, ydest, width, height, False);
|
||||
#else /* USE_SHM */
|
||||
g_error ("trying to draw shared memory image when gdk was compiled without shared memory support");
|
||||
#endif /* USE_SHM */
|
||||
}
|
@@ -1,630 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
|
||||
#ifdef XINPUT_GXI
|
||||
|
||||
/* #define DEBUG_SWITCHING */
|
||||
|
||||
#include <gxid_lib.h>
|
||||
|
||||
/* Forward declarations */
|
||||
static void gdk_input_gxi_select_notify (GdkDevicePrivate *gdkdev);
|
||||
static gint gdk_input_gxi_set_mode (guint32 deviceid, GdkInputMode mode);
|
||||
static gint gdk_input_is_extension_device (guint32 deviceid);
|
||||
static void gdk_input_gxi_configure_event (XConfigureEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static void gdk_input_gxi_enter_event (XCrossingEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static gint gdk_input_gxi_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static void gdk_input_gxi_update_device (GdkDevicePrivate *gdkdev);
|
||||
|
||||
static gint gdk_input_gxi_window_none_event (GdkEvent *event, XEvent *xevent);
|
||||
static gint gdk_input_gxi_enable_window (GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static gint gdk_input_gxi_disable_window (GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static Window gdk_input_find_root_child(Display *dpy, Window w);
|
||||
static void gdk_input_compute_obscuring(GdkInputWindow *input_window);
|
||||
static gint gdk_input_is_obscured(GdkInputWindow *input_window, gdouble x,
|
||||
gdouble y);
|
||||
static GdkTimeCoord *gdk_input_gxi_motion_events (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return);
|
||||
static void gdk_input_gxi_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask);
|
||||
static gint gdk_input_gxi_grab_pointer (GdkWindow * window,
|
||||
gint owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindow * confine_to,
|
||||
guint32 time);
|
||||
static void gdk_input_gxi_ungrab_pointer (guint32 time);
|
||||
|
||||
/* Local variables */
|
||||
|
||||
static GdkDevicePrivate *gdk_input_current_device;
|
||||
static GdkDevicePrivate *gdk_input_core_pointer;
|
||||
|
||||
void
|
||||
gdk_input_init(void)
|
||||
{
|
||||
GList *tmp_list;
|
||||
|
||||
gdk_input_vtable.set_mode = gdk_input_gxi_set_mode;
|
||||
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
|
||||
gdk_input_vtable.set_key = gdk_input_common_set_key;
|
||||
gdk_input_vtable.motion_events = gdk_input_gxi_motion_events;
|
||||
gdk_input_vtable.get_pointer = gdk_input_gxi_get_pointer;
|
||||
gdk_input_vtable.grab_pointer = gdk_input_gxi_grab_pointer;
|
||||
gdk_input_vtable.ungrab_pointer = gdk_input_gxi_ungrab_pointer;
|
||||
gdk_input_vtable.configure_event = gdk_input_gxi_configure_event;
|
||||
gdk_input_vtable.enter_event = gdk_input_gxi_enter_event;
|
||||
gdk_input_vtable.other_event = gdk_input_gxi_other_event;
|
||||
gdk_input_vtable.window_none_event = gdk_input_gxi_window_none_event;
|
||||
gdk_input_vtable.enable_window = gdk_input_gxi_enable_window;
|
||||
gdk_input_vtable.disable_window = gdk_input_gxi_disable_window;
|
||||
|
||||
gdk_input_ignore_core = FALSE;
|
||||
gdk_input_core_pointer = NULL;
|
||||
|
||||
if (!gdk_input_gxid_host)
|
||||
{
|
||||
gdk_input_gxid_host = getenv("GXID_HOST");
|
||||
}
|
||||
if (!gdk_input_gxid_port)
|
||||
{
|
||||
char *t = getenv("GXID_PORT");
|
||||
if (t)
|
||||
gdk_input_gxid_port = atoi(t);
|
||||
}
|
||||
|
||||
gdk_input_common_init(TRUE);
|
||||
|
||||
/* find initial core pointer */
|
||||
|
||||
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)tmp_list->data;
|
||||
if (gdk_input_is_extension_device(gdkdev->info.deviceid))
|
||||
{
|
||||
gdk_input_gxi_select_notify (gdkdev);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER)
|
||||
gdk_input_core_pointer = gdkdev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_select_notify (GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
XEventClass class;
|
||||
|
||||
ChangeDeviceNotify (gdkdev->xdevice, gdkdev->changenotify_type, class);
|
||||
|
||||
XSelectExtensionEvent (gdk_display, gdk_root_window, &class, 1);
|
||||
}
|
||||
|
||||
/* Set the core pointer. Device should already be enabled. */
|
||||
static gint
|
||||
gdk_input_gxi_set_core_pointer(GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
int x_axis,y_axis;
|
||||
|
||||
g_return_val_if_fail(gdkdev->xdevice,FALSE);
|
||||
|
||||
x_axis = gdkdev->axis_for_use[GDK_AXIS_X];
|
||||
y_axis = gdkdev->axis_for_use[GDK_AXIS_Y];
|
||||
|
||||
g_return_val_if_fail(x_axis != -1 && y_axis != -1,FALSE);
|
||||
|
||||
/* core_pointer might not be up to date so we check with the server
|
||||
before change the pointer */
|
||||
|
||||
if ( !gdk_input_is_extension_device(gdkdev->info.deviceid) )
|
||||
{
|
||||
#if 0
|
||||
if (gdkdev != gdk_input_core_pointer)
|
||||
g_warning("core pointer inconsistency");
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( XChangePointerDevice(gdk_display,gdkdev->xdevice, x_axis, y_axis)
|
||||
!= Success )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_input_gxi_update_device (gdk_input_core_pointer);
|
||||
gdk_input_core_pointer = gdkdev;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* FIXME, merge with gdk_input_xfree_set_mode */
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_set_mode (guint32 deviceid, GdkInputMode mode)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
GdkInputMode old_mode;
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
gdkdev = gdk_input_find_device(deviceid);
|
||||
g_return_val_if_fail (gdkdev != NULL,FALSE);
|
||||
old_mode = gdkdev->info.mode;
|
||||
|
||||
if (gdkdev->info.mode == mode)
|
||||
return TRUE;
|
||||
|
||||
gdkdev->info.mode = mode;
|
||||
|
||||
if (old_mode != GDK_MODE_DISABLED)
|
||||
{
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
|
||||
gdk_input_disable_window (input_window->window, gdkdev);
|
||||
}
|
||||
}
|
||||
|
||||
if (mode != GDK_MODE_DISABLED)
|
||||
{
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
|
||||
if (!gdk_input_enable_window(input_window->window, gdkdev))
|
||||
{
|
||||
gdk_input_set_mode(deviceid, old_mode);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_input_is_extension_device (guint32 deviceid)
|
||||
{
|
||||
XDeviceInfo *devices;
|
||||
int num_devices, loop;
|
||||
|
||||
if (deviceid == GDK_CORE_POINTER)
|
||||
return FALSE;
|
||||
|
||||
devices = XListInputDevices(gdk_display, &num_devices);
|
||||
for(loop=0; loop<num_devices; loop++)
|
||||
{
|
||||
if ((devices[loop].id == deviceid) && (devices[loop].use == IsXExtensionDevice))
|
||||
{
|
||||
XFreeDeviceList(devices);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
XFreeDeviceList(devices);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_configure_event (XConfigureEvent *xevent, GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
gint root_x, root_y;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_if_fail (input_window != NULL);
|
||||
|
||||
gdk_input_get_root_relative_geometry(gdk_display,GDK_WINDOW_XWINDOW(window),
|
||||
&root_x, &root_y, NULL, NULL);
|
||||
input_window->root_x = root_x;
|
||||
input_window->root_y = root_y;
|
||||
gdk_input_compute_obscuring(input_window);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_enter_event (XCrossingEvent *xevent, GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_if_fail (input_window != NULL);
|
||||
|
||||
gdk_input_compute_obscuring(input_window);
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
GdkDevicePrivate *gdkdev;
|
||||
gint return_val;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_val_if_fail (window != NULL, -1);
|
||||
|
||||
/* This is a sort of a hack, as there isn't any XDeviceAnyEvent -
|
||||
but it's potentially faster than scanning through the types of
|
||||
every device. If we were deceived, then it won't match any of
|
||||
the types for the device anyways */
|
||||
gdkdev = gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
|
||||
|
||||
if (!gdkdev) {
|
||||
return -1; /* we don't handle it - not an XInput event */
|
||||
}
|
||||
|
||||
if (gdkdev->info.mode == GDK_MODE_DISABLED ||
|
||||
input_window->mode == GDK_EXTENSION_EVENTS_CURSOR)
|
||||
return FALSE;
|
||||
|
||||
if (gdkdev != gdk_input_current_device &&
|
||||
xevent->type != gdkdev->changenotify_type)
|
||||
{
|
||||
gdk_input_current_device = gdkdev;
|
||||
}
|
||||
|
||||
return_val = gdk_input_common_other_event (event, xevent,
|
||||
input_window, gdkdev);
|
||||
|
||||
if (return_val > 0 && event->type == GDK_MOTION_NOTIFY &&
|
||||
(!gdkdev->button_state) && (!input_window->grabbed) &&
|
||||
((event->motion.x < 0) || (event->motion.y < 0) ||
|
||||
(event->motion.x > ((GdkWindowPrivate *)window)->width) ||
|
||||
(event->motion.y > ((GdkWindowPrivate *)window)->height) ||
|
||||
gdk_input_is_obscured(input_window,event->motion.x,event->motion.y)))
|
||||
{
|
||||
#ifdef DEBUG_SWITCHING
|
||||
g_print("gdkinput: Setting core pointer to %d on motion at (%f,%f)\n",
|
||||
gdkdev->info.deviceid,event->motion.x,event->motion.y);
|
||||
g_print(" window geometry is: %dx%d\n",
|
||||
((GdkWindowPrivate *)window)->width,
|
||||
((GdkWindowPrivate *)window)->height);
|
||||
#endif
|
||||
gdk_input_gxi_set_core_pointer(gdkdev);
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
return return_val;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_update_device (GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
GList *t;
|
||||
|
||||
if (gdk_input_is_extension_device (gdkdev->info.deviceid))
|
||||
{
|
||||
if (!gdkdev->xdevice)
|
||||
{
|
||||
gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->info.deviceid);
|
||||
gdk_input_gxi_select_notify (gdkdev);
|
||||
gdkdev->needs_update = 1;
|
||||
}
|
||||
if (gdkdev->needs_update && gdkdev->xdevice)
|
||||
{
|
||||
for (t = gdk_input_windows; t; t = t->next)
|
||||
gdk_input_common_select_events (((GdkInputWindow *)t->data)->window,
|
||||
gdkdev);
|
||||
gdkdev->needs_update = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_window_none_event (GdkEvent *event, XEvent *xevent)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev =
|
||||
gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
|
||||
|
||||
if (!gdkdev) {
|
||||
return -1; /* we don't handle it - not an XInput event */
|
||||
}
|
||||
|
||||
if (xevent->type == gdkdev->changenotify_type)
|
||||
{
|
||||
if (gdk_input_core_pointer != gdkdev)
|
||||
{
|
||||
#ifdef DEBUG_SWITCHING
|
||||
g_print("ChangeNotify from %d to %d:\n",
|
||||
gdk_input_core_pointer->info.deviceid,
|
||||
gdkdev->info.deviceid);
|
||||
#endif
|
||||
gdk_input_gxi_update_device (gdk_input_core_pointer);
|
||||
gdk_input_core_pointer = gdkdev;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
input_window = gdk_input_window_find (window);
|
||||
g_return_val_if_fail (input_window != NULL, FALSE);
|
||||
|
||||
if (!gdkdev->claimed)
|
||||
{
|
||||
if (gxid_claim_device(gdk_input_gxid_host, gdk_input_gxid_port,
|
||||
gdkdev->info.deviceid,
|
||||
GDK_WINDOW_XWINDOW(window), FALSE) !=
|
||||
GXID_RETURN_OK)
|
||||
{
|
||||
g_warning("Could not get device (is gxid running?)\n");
|
||||
return FALSE;
|
||||
}
|
||||
gdkdev->claimed = TRUE;
|
||||
}
|
||||
|
||||
if (gdkdev->xdevice && gdkdev != gdk_input_core_pointer)
|
||||
gdk_input_common_select_events(window, gdkdev);
|
||||
else
|
||||
gdkdev->needs_update = TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_disable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
input_window = gdk_input_window_find (window);
|
||||
g_return_val_if_fail (input_window != NULL, FALSE);
|
||||
|
||||
if (gdkdev->claimed)
|
||||
{
|
||||
gxid_release_device(gdk_input_gxid_host, gdk_input_gxid_port,
|
||||
gdkdev->info.deviceid,
|
||||
GDK_WINDOW_XWINDOW(window));
|
||||
|
||||
gdkdev->claimed = FALSE;
|
||||
}
|
||||
|
||||
if (gdkdev->xdevice && gdkdev != gdk_input_core_pointer)
|
||||
gdk_input_common_select_events(window, gdkdev);
|
||||
else
|
||||
gdkdev->needs_update = TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_is_obscured(GdkInputWindow *input_window, gdouble x, gdouble y)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<input_window->num_obscuring;i++)
|
||||
{
|
||||
GdkRectangle *rect = &input_window->obscuring[i];
|
||||
if ((x >= rect->x) &&
|
||||
(y >= rect->y) &&
|
||||
(x < rect->x + rect->width) &&
|
||||
(y < rect->y + rect->height))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If this routine needs fixing, the corresponding routine
|
||||
in gxid.c will need it too. */
|
||||
|
||||
static Window
|
||||
gdk_input_find_root_child(Display *dpy, Window w)
|
||||
{
|
||||
Window root,parent;
|
||||
Window *children;
|
||||
int nchildren;
|
||||
|
||||
parent = w;
|
||||
do
|
||||
{
|
||||
w = parent;
|
||||
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
|
||||
if (children) XFree(children);
|
||||
}
|
||||
while (parent != root);
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_compute_obscuring(GdkInputWindow *input_window)
|
||||
{
|
||||
int i;
|
||||
int x,y,width,height;
|
||||
int xc,yc,widthc,heightc,border_widthc,depthc;
|
||||
|
||||
Window root,parent;
|
||||
Window *children;
|
||||
int nchildren;
|
||||
|
||||
Window w = GDK_WINDOW_XWINDOW(input_window->window);
|
||||
Window root_child = gdk_input_find_root_child(gdk_display,w);
|
||||
gdk_input_get_root_relative_geometry(gdk_display,w,&x,&y,&width,&height);
|
||||
|
||||
input_window->root_x = x;
|
||||
input_window->root_y = y;
|
||||
|
||||
XQueryTree(gdk_display,GDK_ROOT_WINDOW(),
|
||||
&root,&parent,&children,&nchildren);
|
||||
|
||||
|
||||
if (input_window->obscuring)
|
||||
g_free(input_window->obscuring);
|
||||
input_window->obscuring = 0;
|
||||
input_window->num_obscuring = 0;
|
||||
|
||||
for (i=0;i<nchildren;i++)
|
||||
if (children[i] == root_child)
|
||||
break;
|
||||
|
||||
if (i>=nchildren-1)
|
||||
{
|
||||
if (nchildren)
|
||||
XFree(children);
|
||||
return;
|
||||
}
|
||||
|
||||
input_window->obscuring = g_new(GdkRectangle,(nchildren-i-1));
|
||||
|
||||
for (i=i+1;i<nchildren;i++)
|
||||
{
|
||||
int xmin, xmax, ymin, ymax;
|
||||
XGetGeometry(gdk_display,children[i],&root,&xc,&yc,&widthc,&heightc,
|
||||
&border_widthc, &depthc);
|
||||
xmin = xc>x ? xc : x;
|
||||
xmax = (xc+widthc)<(x+width) ? xc+widthc : x+width;
|
||||
ymin = yc>y ? yc : y;
|
||||
ymax = (yc+heightc)<(y+height) ? yc+heightc : y+height;
|
||||
if ((xmin < xmax) && (ymin < ymax))
|
||||
{
|
||||
XWindowAttributes attributes;
|
||||
XGetWindowAttributes(gdk_display,children[i],&attributes);
|
||||
if (attributes.map_state == IsViewable)
|
||||
{
|
||||
GdkRectangle *rect = &input_window->obscuring[input_window->num_obscuring];
|
||||
|
||||
/* we store the whole window, not just the obscuring part */
|
||||
rect->x = xc - x;
|
||||
rect->y = yc - y;
|
||||
rect->width = widthc;
|
||||
rect->height = heightc;
|
||||
input_window->num_obscuring++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nchildren)
|
||||
XFree(children);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev;
|
||||
|
||||
gdkdev = gdk_input_find_device (deviceid);
|
||||
g_return_if_fail (gdkdev != NULL);
|
||||
|
||||
if (gdkdev == gdk_input_core_pointer)
|
||||
gdk_input_common_get_pointer (window, GDK_CORE_POINTER, x, y,
|
||||
pressure, xtilt, ytilt, mask);
|
||||
else
|
||||
gdk_input_common_get_pointer (window, deviceid, x, y,
|
||||
pressure, xtilt, ytilt, mask);
|
||||
}
|
||||
|
||||
static GdkTimeCoord *
|
||||
gdk_input_gxi_motion_events (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev;
|
||||
|
||||
gdkdev = gdk_input_find_device (deviceid);
|
||||
g_return_val_if_fail (gdkdev != NULL, NULL);
|
||||
|
||||
|
||||
if (gdkdev == gdk_input_core_pointer)
|
||||
return gdk_input_motion_events (window, GDK_CORE_POINTER, start, stop,
|
||||
nevents_return);
|
||||
else
|
||||
return gdk_input_common_motion_events (window, deviceid, start, stop,
|
||||
nevents_return);
|
||||
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_grab_pointer (GdkWindow * window,
|
||||
gint owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindow * confine_to,
|
||||
guint32 time)
|
||||
{
|
||||
GdkInputWindow *input_window, *new_window;
|
||||
GList *tmp_list;
|
||||
|
||||
tmp_list = gdk_input_windows;
|
||||
while (tmp_list)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->grabbed)
|
||||
return AlreadyGrabbed;
|
||||
|
||||
if (input_window->window == window)
|
||||
new_window = input_window;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
new_window->grabbed = TRUE;
|
||||
return Success;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_ungrab_pointer (guint32 time)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
GList *tmp_list;
|
||||
|
||||
tmp_list = gdk_input_windows;
|
||||
while (tmp_list)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->grabbed)
|
||||
input_window->grabbed = FALSE;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* XINPUT_GXI */
|
@@ -1,74 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
|
||||
#ifdef XINPUT_NONE
|
||||
|
||||
static void gdk_input_none_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask);
|
||||
|
||||
void
|
||||
gdk_input_init ()
|
||||
{
|
||||
gdk_input_vtable.set_mode = NULL;
|
||||
gdk_input_vtable.set_axes = NULL;
|
||||
gdk_input_vtable.set_key = NULL;
|
||||
gdk_input_vtable.motion_events = NULL;
|
||||
gdk_input_vtable.get_pointer = gdk_input_none_get_pointer;
|
||||
gdk_input_vtable.grab_pointer = NULL;
|
||||
gdk_input_vtable.ungrab_pointer = NULL;
|
||||
gdk_input_vtable.configure_event = NULL;
|
||||
gdk_input_vtable.enter_event = NULL;
|
||||
gdk_input_vtable.other_event = NULL;
|
||||
gdk_input_vtable.window_none_event = NULL;
|
||||
gdk_input_vtable.enable_window = NULL;
|
||||
gdk_input_vtable.disable_window = NULL;
|
||||
|
||||
gdk_input_devices = g_list_append (NULL, &gdk_input_core_info);
|
||||
|
||||
gdk_input_ignore_core = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_none_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
gint x_int, y_int;
|
||||
|
||||
gdk_window_get_pointer (window, &x_int, &y_int, mask);
|
||||
|
||||
if (x) *x = x_int;
|
||||
if (y) *y = y_int;
|
||||
if (pressure) *pressure = 0.5;
|
||||
if (xtilt) *xtilt = 0;
|
||||
if (ytilt) *ytilt = 0;
|
||||
}
|
||||
|
||||
#endif /* XINPUT_NONE */
|
@@ -1,883 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
|
||||
#if defined(XINPUT_GXI) || defined(XINPUT_XFREE)
|
||||
|
||||
/* Forward declarations */
|
||||
static void gdk_input_get_root_relative_geometry (Display *dpy, Window w,
|
||||
int *x_ret, int *y_ret,
|
||||
int *width_ret,
|
||||
int *height_ret);
|
||||
static GdkDevicePrivate *gdk_input_device_new(XDeviceInfo *device,
|
||||
gint include_core);
|
||||
static void gdk_input_common_find_events(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev,
|
||||
gint mask,
|
||||
XEventClass *classes,
|
||||
int *num_classes);
|
||||
static void gdk_input_common_select_events(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static void gdk_input_translate_coordinates(GdkDevicePrivate *gdkdev,
|
||||
GdkInputWindow *input_window,
|
||||
gint *axis_data,
|
||||
gdouble *x, gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt, gdouble *ytilt);
|
||||
static guint gdk_input_translate_state(guint state, guint device_state);
|
||||
static gint gdk_input_common_init(gint include_core);
|
||||
static gint gdk_input_common_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkInputWindow *input_window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static void gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes);
|
||||
static GdkTimeCoord * gdk_input_common_motion_events (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return);
|
||||
static void gdk_input_common_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask);
|
||||
|
||||
#define GDK_MAX_DEVICE_CLASSES 13
|
||||
|
||||
/* Global variables */
|
||||
|
||||
static gint gdk_input_root_width;
|
||||
static gint gdk_input_root_height;
|
||||
|
||||
static void
|
||||
gdk_input_get_root_relative_geometry(Display *dpy, Window w, int *x_ret, int *y_ret,
|
||||
int *width_ret, int *height_ret)
|
||||
{
|
||||
Window root,parent;
|
||||
Window *children;
|
||||
guint nchildren;
|
||||
gint x,y;
|
||||
guint width, height;
|
||||
gint xc,yc;
|
||||
guint widthc,heightc,border_widthc,depthc;
|
||||
|
||||
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
|
||||
if (children) XFree(children);
|
||||
XGetGeometry(dpy,w,&root,&x,&y,&width,&height,&border_widthc,
|
||||
&depthc);
|
||||
x += border_widthc;
|
||||
y += border_widthc;
|
||||
|
||||
while (root != parent)
|
||||
{
|
||||
w = parent;
|
||||
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
|
||||
if (children) XFree(children);
|
||||
XGetGeometry(dpy,w,&root,&xc,&yc,&widthc,&heightc,
|
||||
&border_widthc,&depthc);
|
||||
x += xc + border_widthc;
|
||||
y += yc + border_widthc;
|
||||
}
|
||||
|
||||
if (x_ret)
|
||||
*x_ret = x;
|
||||
if (y_ret)
|
||||
*y_ret = y;
|
||||
if (width_ret)
|
||||
*width_ret = width;
|
||||
if (height_ret)
|
||||
*height_ret = height;
|
||||
}
|
||||
|
||||
static GdkDevicePrivate *
|
||||
gdk_input_device_new(XDeviceInfo *device, gint include_core)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev;
|
||||
gchar *tmp_name, *p;
|
||||
XAnyClassPtr class;
|
||||
gint i,j;
|
||||
|
||||
gdkdev = g_new(GdkDevicePrivate,1);
|
||||
|
||||
gdkdev->info.deviceid = device->id;
|
||||
if (device->name[0]) {
|
||||
gdkdev->info.name = g_new(char, strlen(device->name)+1);
|
||||
strcpy(gdkdev->info.name,device->name);
|
||||
} else {
|
||||
/* XFree86 3.2 gives an empty name to the default core devices,
|
||||
(fixed in 3.2A) */
|
||||
gdkdev->info.name = g_strdup("pointer");
|
||||
strcpy(gdkdev->info.name,"pointer");
|
||||
gdkdev->info.source = GDK_SOURCE_MOUSE;
|
||||
}
|
||||
|
||||
gdkdev->info.mode = GDK_MODE_DISABLED;
|
||||
|
||||
/* Try to figure out what kind of device this is by its name -
|
||||
could invite a very, very, long list... Lowercase name
|
||||
for comparison purposes */
|
||||
|
||||
tmp_name = g_strdup(gdkdev->info.name);
|
||||
for (p = tmp_name; *p; p++)
|
||||
{
|
||||
if (*p >= 'A' && *p <= 'Z')
|
||||
*p += 'a' - 'A';
|
||||
}
|
||||
|
||||
if (!strcmp (tmp_name, "pointer"))
|
||||
gdkdev->info.source = GDK_SOURCE_MOUSE;
|
||||
else if (!strcmp (tmp_name, "wacom") ||
|
||||
!strcmp (tmp_name, "pen"))
|
||||
gdkdev->info.source = GDK_SOURCE_PEN;
|
||||
else if (!strcmp (tmp_name, "eraser"))
|
||||
gdkdev->info.source = GDK_SOURCE_ERASER;
|
||||
else if (!strcmp (tmp_name, "cursor"))
|
||||
gdkdev->info.source = GDK_SOURCE_CURSOR;
|
||||
else
|
||||
gdkdev->info.source = GDK_SOURCE_PEN;
|
||||
|
||||
g_free(tmp_name);
|
||||
|
||||
gdkdev->xdevice = NULL;
|
||||
|
||||
/* step through the classes */
|
||||
|
||||
gdkdev->info.num_axes = 0;
|
||||
gdkdev->info.num_keys = 0;
|
||||
gdkdev->info.keys = NULL;
|
||||
gdkdev->axes = 0;
|
||||
gdkdev->info.has_cursor = 0;
|
||||
gdkdev->needs_update = FALSE;
|
||||
gdkdev->claimed = FALSE;
|
||||
gdkdev->button_state = 0;
|
||||
|
||||
class = device->inputclassinfo;
|
||||
for (i=0;i<device->num_classes;i++)
|
||||
{
|
||||
switch (class->class) {
|
||||
case ButtonClass:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case KeyClass:
|
||||
{
|
||||
XKeyInfo *xki = (XKeyInfo *)class;
|
||||
/* Hack to catch XFree86 3.3.1 bug. Other devices better
|
||||
* not have exactly 25 keys...
|
||||
*/
|
||||
if ((xki->min_keycode == 8) && (xki->max_keycode == 32))
|
||||
{
|
||||
gdkdev->info.num_keys = 32;
|
||||
gdkdev->min_keycode = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
gdkdev->info.num_keys = xki->max_keycode - xki->min_keycode + 1;
|
||||
gdkdev->min_keycode = xki->min_keycode;
|
||||
}
|
||||
gdkdev->info.keys = g_new (GdkDeviceKey, gdkdev->info.num_keys);
|
||||
|
||||
for (j=0; j<gdkdev->info.num_keys; j++)
|
||||
{
|
||||
gdkdev->info.keys[j].keyval = 0;
|
||||
gdkdev->info.keys[j].modifiers = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ValuatorClass:
|
||||
{
|
||||
XValuatorInfo *xvi = (XValuatorInfo *)class;
|
||||
gdkdev->info.num_axes = xvi->num_axes;
|
||||
gdkdev->axes = g_new(GdkAxisInfo, xvi->num_axes);
|
||||
gdkdev->info.axes = g_new(GdkAxisUse, xvi->num_axes);
|
||||
for (j=0;j<xvi->num_axes;j++)
|
||||
{
|
||||
gdkdev->axes[j].resolution =
|
||||
gdkdev->axes[j].xresolution = xvi->axes[j].resolution;
|
||||
gdkdev->axes[j].min_value =
|
||||
gdkdev->axes[j].xmin_value = xvi->axes[j].min_value;
|
||||
gdkdev->axes[j].max_value =
|
||||
gdkdev->axes[j].xmax_value = xvi->axes[j].max_value;
|
||||
gdkdev->info.axes[j] = GDK_AXIS_IGNORE;
|
||||
}
|
||||
j=0;
|
||||
if (j<xvi->num_axes)
|
||||
gdkdev->info.axes[j++] = GDK_AXIS_X;
|
||||
if (j<xvi->num_axes)
|
||||
gdkdev->info.axes[j++] = GDK_AXIS_Y;
|
||||
if (j<xvi->num_axes)
|
||||
gdkdev->info.axes[j++] = GDK_AXIS_PRESSURE;
|
||||
if (j<xvi->num_axes)
|
||||
gdkdev->info.axes[j++] = GDK_AXIS_XTILT;
|
||||
if (j<xvi->num_axes)
|
||||
gdkdev->info.axes[j++] = GDK_AXIS_YTILT;
|
||||
|
||||
/* set up reverse lookup on axis use */
|
||||
for (j=GDK_AXIS_IGNORE;j<GDK_AXIS_LAST;j++)
|
||||
gdkdev->axis_for_use[j] = -1;
|
||||
|
||||
for (j=0;j<xvi->num_axes;j++)
|
||||
if (gdkdev->info.axes[j] != GDK_AXIS_IGNORE)
|
||||
gdkdev->axis_for_use[gdkdev->info.axes[j]] = j;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
class = (XAnyClassPtr)(((char *)class) + class->length);
|
||||
}
|
||||
/* return NULL if no axes */
|
||||
if (!gdkdev->info.num_axes || !gdkdev->axes ||
|
||||
(!include_core && device->use == IsXPointer))
|
||||
{
|
||||
g_free(gdkdev->info.name);
|
||||
if (gdkdev->axes)
|
||||
g_free(gdkdev->axes);
|
||||
if (gdkdev->info.keys)
|
||||
g_free(gdkdev->info.keys);
|
||||
g_free(gdkdev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (device->use != IsXPointer)
|
||||
{
|
||||
int error_warn = gdk_error_warnings;
|
||||
|
||||
gdk_error_warnings = 0;
|
||||
gdk_error_code = 0;
|
||||
gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->info.deviceid);
|
||||
gdk_error_warnings = error_warn;
|
||||
|
||||
/* return NULL if device is not ready */
|
||||
if (gdk_error_code)
|
||||
{
|
||||
g_free (gdkdev->info.name);
|
||||
if (gdkdev->axes)
|
||||
g_free (gdkdev->axes);
|
||||
if (gdkdev->info.keys)
|
||||
g_free (gdkdev->info.keys);
|
||||
if (gdkdev->info.axes)
|
||||
g_free (gdkdev->info.axes);
|
||||
g_free (gdkdev);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gdkdev->buttonpress_type = 0;
|
||||
gdkdev->buttonrelease_type = 0;
|
||||
gdkdev->keypress_type = 0;
|
||||
gdkdev->keyrelease_type = 0;
|
||||
gdkdev->motionnotify_type = 0;
|
||||
gdkdev->proximityin_type = 0;
|
||||
gdkdev->proximityout_type = 0;
|
||||
gdkdev->changenotify_type = 0;
|
||||
|
||||
return gdkdev;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_common_find_events(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev,
|
||||
gint mask,
|
||||
XEventClass *classes,
|
||||
int *num_classes)
|
||||
{
|
||||
gint i;
|
||||
XEventClass class;
|
||||
|
||||
i = 0;
|
||||
/* We have to track press and release events in pairs to keep
|
||||
track of button state correctly and implement grabbing for
|
||||
the gxi support */
|
||||
if (mask & GDK_BUTTON_PRESS_MASK || mask & GDK_BUTTON_RELEASE_MASK)
|
||||
{
|
||||
DeviceButtonPress (gdkdev->xdevice, gdkdev->buttonpress_type,
|
||||
class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
DeviceButtonPressGrab (gdkdev->xdevice, 0, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
DeviceButtonRelease (gdkdev->xdevice, gdkdev->buttonrelease_type,
|
||||
class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_POINTER_MOTION_MASK)
|
||||
{
|
||||
DeviceMotionNotify (gdkdev->xdevice, gdkdev->motionnotify_type, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
else
|
||||
if (mask & (GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK |
|
||||
GDK_BUTTON3_MOTION_MASK | GDK_BUTTON_MOTION_MASK |
|
||||
GDK_POINTER_MOTION_HINT_MASK))
|
||||
{
|
||||
/* Make sure gdkdev->motionnotify_type is set */
|
||||
DeviceMotionNotify (gdkdev->xdevice, gdkdev->motionnotify_type, class);
|
||||
}
|
||||
if (mask & GDK_BUTTON1_MOTION_MASK)
|
||||
{
|
||||
DeviceButton1Motion (gdkdev->xdevice, 0, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_BUTTON2_MOTION_MASK)
|
||||
{
|
||||
DeviceButton2Motion (gdkdev->xdevice, 0, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_BUTTON3_MOTION_MASK)
|
||||
{
|
||||
DeviceButton3Motion (gdkdev->xdevice, 0, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_BUTTON_MOTION_MASK)
|
||||
{
|
||||
DeviceButtonMotion (gdkdev->xdevice, 0, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_POINTER_MOTION_HINT_MASK)
|
||||
{
|
||||
/* We'll get into trouble if the macros change, but at least we'll
|
||||
know about it, and we avoid warnings now */
|
||||
DevicePointerMotionHint (gdkdev->xdevice, 0, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_KEY_PRESS_MASK)
|
||||
{
|
||||
DeviceKeyPress (gdkdev->xdevice, gdkdev->keypress_type, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_KEY_RELEASE_MASK)
|
||||
{
|
||||
DeviceKeyRelease (gdkdev->xdevice, gdkdev->keyrelease_type, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_PROXIMITY_IN_MASK)
|
||||
{
|
||||
ProximityIn (gdkdev->xdevice, gdkdev->proximityin_type, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_PROXIMITY_OUT_MASK)
|
||||
{
|
||||
ProximityOut (gdkdev->xdevice, gdkdev->proximityout_type, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
|
||||
*num_classes = i;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_common_select_events(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
XEventClass classes[GDK_MAX_DEVICE_CLASSES];
|
||||
gint num_classes;
|
||||
|
||||
if (gdkdev->info.mode == GDK_MODE_DISABLED)
|
||||
gdk_input_common_find_events(window, gdkdev, 0, classes, &num_classes);
|
||||
else
|
||||
gdk_input_common_find_events(window, gdkdev,
|
||||
((GdkWindowPrivate *)window)->extension_events,
|
||||
classes, &num_classes);
|
||||
|
||||
XSelectExtensionEvent (gdk_display,
|
||||
GDK_WINDOW_XWINDOW(window),
|
||||
classes, num_classes);
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_input_common_init(gint include_core)
|
||||
{
|
||||
char **extensions;
|
||||
XDeviceInfo *devices;
|
||||
int num_devices;
|
||||
int num_extensions, loop;
|
||||
Display *display = gdk_display;
|
||||
|
||||
/* Init global vars */
|
||||
gdk_window_get_geometry(NULL, /* use root window */
|
||||
NULL,NULL,
|
||||
&gdk_input_root_width,&gdk_input_root_height,
|
||||
NULL);
|
||||
|
||||
/* Init XInput extension */
|
||||
|
||||
extensions = XListExtensions(display, &num_extensions);
|
||||
for (loop = 0; loop < num_extensions &&
|
||||
(strcmp(extensions[loop], "XInputExtension") != 0); loop++);
|
||||
XFreeExtensionList(extensions);
|
||||
if (loop == num_extensions) /* XInput extension not found */
|
||||
return FALSE;
|
||||
|
||||
gdk_input_devices = 0;
|
||||
devices = XListInputDevices(display, &num_devices);
|
||||
|
||||
for(loop=0; loop<num_devices; loop++)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev = gdk_input_device_new(&devices[loop],
|
||||
include_core);
|
||||
if (gdkdev)
|
||||
gdk_input_devices = g_list_append(gdk_input_devices, gdkdev);
|
||||
}
|
||||
XFreeDeviceList(devices);
|
||||
|
||||
gdk_input_devices = g_list_append (gdk_input_devices, &gdk_input_core_info);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
|
||||
GdkInputWindow *input_window,
|
||||
gint *axis_data,
|
||||
gdouble *x, gdouble *y, gdouble *pressure,
|
||||
gdouble *xtilt, gdouble *ytilt)
|
||||
{
|
||||
GdkWindowPrivate *win_priv;
|
||||
|
||||
int x_axis, y_axis, pressure_axis, xtilt_axis, ytilt_axis;
|
||||
|
||||
double device_width, device_height;
|
||||
double x_offset, y_offset, x_scale, y_scale;
|
||||
|
||||
win_priv = (GdkWindowPrivate *) input_window->window;
|
||||
|
||||
x_axis = gdkdev->axis_for_use[GDK_AXIS_X];
|
||||
y_axis = gdkdev->axis_for_use[GDK_AXIS_Y];
|
||||
pressure_axis = gdkdev->axis_for_use[GDK_AXIS_PRESSURE];
|
||||
xtilt_axis = gdkdev->axis_for_use[GDK_AXIS_XTILT];
|
||||
ytilt_axis = gdkdev->axis_for_use[GDK_AXIS_YTILT];
|
||||
|
||||
device_width = gdkdev->axes[x_axis].max_value -
|
||||
gdkdev->axes[x_axis].min_value;
|
||||
device_height = gdkdev->axes[y_axis].max_value -
|
||||
gdkdev->axes[y_axis].min_value;
|
||||
|
||||
if (gdkdev->info.mode == GDK_MODE_SCREEN)
|
||||
{
|
||||
x_scale = gdk_input_root_width / device_width;
|
||||
y_scale = gdk_input_root_height / device_height;
|
||||
|
||||
x_offset = - input_window->root_x;
|
||||
y_offset = - input_window->root_y;
|
||||
}
|
||||
else /* GDK_MODE_WINDOW */
|
||||
{
|
||||
double device_aspect = (device_height*gdkdev->axes[y_axis].resolution) /
|
||||
(device_width*gdkdev->axes[x_axis].resolution);
|
||||
|
||||
if (device_aspect * win_priv->width >= win_priv->height)
|
||||
{
|
||||
/* device taller than window */
|
||||
x_scale = win_priv->width / device_width;
|
||||
y_scale = (x_scale * gdkdev->axes[x_axis].resolution)
|
||||
/ gdkdev->axes[y_axis].resolution;
|
||||
|
||||
x_offset = 0;
|
||||
y_offset = -(device_height * y_scale -
|
||||
win_priv->height)/2;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* window taller than device */
|
||||
y_scale = win_priv->height / device_height;
|
||||
x_scale = (y_scale * gdkdev->axes[y_axis].resolution)
|
||||
/ gdkdev->axes[x_axis].resolution;
|
||||
|
||||
y_offset = 0;
|
||||
x_offset = - (device_width * x_scale - win_priv->width)/2;
|
||||
}
|
||||
}
|
||||
|
||||
if (x) *x = x_offset + x_scale*axis_data[x_axis];
|
||||
if (y) *y = y_offset + y_scale*axis_data[y_axis];
|
||||
|
||||
if (pressure)
|
||||
{
|
||||
if (pressure_axis != -1)
|
||||
*pressure = ((double)axis_data[pressure_axis]
|
||||
- gdkdev->axes[pressure_axis].min_value)
|
||||
/ (gdkdev->axes[pressure_axis].max_value
|
||||
- gdkdev->axes[pressure_axis].min_value);
|
||||
else
|
||||
*pressure = 0.5;
|
||||
}
|
||||
|
||||
if (xtilt)
|
||||
{
|
||||
if (xtilt_axis != -1)
|
||||
{
|
||||
*xtilt = 2. * (double)(axis_data[xtilt_axis] -
|
||||
(gdkdev->axes[xtilt_axis].min_value +
|
||||
gdkdev->axes[xtilt_axis].max_value)/2) /
|
||||
(gdkdev->axes[xtilt_axis].max_value -
|
||||
gdkdev->axes[xtilt_axis].min_value);
|
||||
}
|
||||
else *xtilt = 0;
|
||||
}
|
||||
|
||||
if (ytilt)
|
||||
{
|
||||
if (ytilt_axis != -1)
|
||||
{
|
||||
*ytilt = 2. * (double)(axis_data[ytilt_axis] -
|
||||
(gdkdev->axes[ytilt_axis].min_value +
|
||||
gdkdev->axes[ytilt_axis].max_value)/2) /
|
||||
(gdkdev->axes[ytilt_axis].max_value -
|
||||
gdkdev->axes[ytilt_axis].min_value);
|
||||
}
|
||||
else
|
||||
*ytilt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* combine the state of the core device and the device state
|
||||
into one - for now we do this in a simple-minded manner -
|
||||
we just take the keyboard portion of the core device and
|
||||
the button portion (all of?) the device state.
|
||||
Any button remapping should go on here. */
|
||||
static guint
|
||||
gdk_input_translate_state(guint state, guint device_state)
|
||||
{
|
||||
return device_state | (state & 0xFF);
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_common_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkInputWindow *input_window,
|
||||
GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
if ((xevent->type == gdkdev->buttonpress_type) ||
|
||||
(xevent->type == gdkdev->buttonrelease_type))
|
||||
{
|
||||
XDeviceButtonEvent *xdbe = (XDeviceButtonEvent *)(xevent);
|
||||
|
||||
if (xdbe->type == gdkdev->buttonpress_type)
|
||||
{
|
||||
event->button.type = GDK_BUTTON_PRESS;
|
||||
gdkdev->button_state |= 1 << xdbe->button;
|
||||
}
|
||||
else
|
||||
{
|
||||
event->button.type = GDK_BUTTON_RELEASE;
|
||||
gdkdev->button_state &= ~(1 << xdbe->button);
|
||||
}
|
||||
event->button.window = input_window->window;
|
||||
event->button.time = xdbe->time;
|
||||
event->button.source = gdkdev->info.source;
|
||||
event->button.deviceid = xdbe->deviceid;
|
||||
|
||||
gdk_input_translate_coordinates (gdkdev,input_window, xdbe->axis_data,
|
||||
&event->button.x,&event->button.y,
|
||||
&event->button.pressure,
|
||||
&event->button.xtilt,
|
||||
&event->button.ytilt);
|
||||
event->button.state = gdk_input_translate_state(xdbe->state,xdbe->device_state);
|
||||
event->button.button = xdbe->button;
|
||||
|
||||
GDK_NOTE (EVENTS,
|
||||
g_print ("button %s:\t\twindow: %ld device: %ld x,y: %f %f button: %d\n",
|
||||
(event->button.type == GDK_BUTTON_PRESS) ? "press" : "release",
|
||||
xdbe->window,
|
||||
xdbe->deviceid,
|
||||
event->button.x, event->button.y,
|
||||
xdbe->button));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ((xevent->type == gdkdev->keypress_type) ||
|
||||
(xevent->type == gdkdev->keyrelease_type))
|
||||
{
|
||||
XDeviceKeyEvent *xdke = (XDeviceKeyEvent *)(xevent);
|
||||
|
||||
GDK_NOTE (EVENTS,
|
||||
g_print ("device key %s:\twindow: %ld device: %ld keycode: %d\n",
|
||||
(event->key.type == GDK_KEY_PRESS) ? "press" : "release",
|
||||
xdke->window,
|
||||
xdke->deviceid,
|
||||
xdke->keycode));
|
||||
|
||||
if (xdke->keycode < gdkdev->min_keycode ||
|
||||
xdke->keycode >= gdkdev->min_keycode + gdkdev->info.num_keys)
|
||||
{
|
||||
g_warning ("Invalid device key code received");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
event->key.keyval = gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].keyval;
|
||||
|
||||
if (event->key.keyval == 0)
|
||||
{
|
||||
GDK_NOTE (EVENTS,
|
||||
g_print ("\t\ttranslation - NONE\n"));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
event->key.type = (xdke->type == gdkdev->keypress_type) ?
|
||||
GDK_KEY_PRESS : GDK_KEY_RELEASE;
|
||||
|
||||
event->key.window = input_window->window;
|
||||
event->key.time = xdke->time;
|
||||
|
||||
event->key.state = gdk_input_translate_state(xdke->state, xdke->device_state)
|
||||
| gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].modifiers;
|
||||
|
||||
/* Add a string translation for the key event */
|
||||
if ((event->key.keyval >= 0x20) && (event->key.keyval <= 0xFF))
|
||||
{
|
||||
event->key.length = 1;
|
||||
event->key.string = g_new (gchar, 2);
|
||||
event->key.string[0] = (gchar)event->key.keyval;
|
||||
event->key.string[1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
event->key.length = 0;
|
||||
event->key.string = g_new0 (gchar, 1);
|
||||
}
|
||||
|
||||
GDK_NOTE (EVENTS,
|
||||
g_print ("\t\ttranslation - keyval: %d modifiers: %#x\n",
|
||||
event->key.keyval,
|
||||
event->key.state));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (xevent->type == gdkdev->motionnotify_type)
|
||||
{
|
||||
XDeviceMotionEvent *xdme = (XDeviceMotionEvent *)(xevent);
|
||||
|
||||
gdk_input_translate_coordinates(gdkdev,input_window,xdme->axis_data,
|
||||
&event->motion.x,&event->motion.y,
|
||||
&event->motion.pressure,
|
||||
&event->motion.xtilt,
|
||||
&event->motion.ytilt);
|
||||
|
||||
event->motion.type = GDK_MOTION_NOTIFY;
|
||||
event->motion.window = input_window->window;
|
||||
event->motion.time = xdme->time;
|
||||
event->motion.deviceid = xdme->deviceid;
|
||||
event->motion.state = gdk_input_translate_state(xdme->state,
|
||||
xdme->device_state);
|
||||
event->motion.is_hint = xdme->is_hint;
|
||||
event->motion.source = gdkdev->info.source;
|
||||
event->motion.deviceid = xdme->deviceid;
|
||||
|
||||
GDK_NOTE (EVENTS,
|
||||
g_print ("motion notify:\t\twindow: %ld device: %ld x,y: %f %f state %#4x hint: %s\n",
|
||||
xdme->window,
|
||||
xdme->deviceid,
|
||||
event->motion.x, event->motion.y,
|
||||
event->motion.state,
|
||||
(xdme->is_hint) ? "true" : "false"));
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (xevent->type == gdkdev->proximityin_type ||
|
||||
xevent->type == gdkdev->proximityout_type)
|
||||
{
|
||||
XProximityNotifyEvent *xpne = (XProximityNotifyEvent *)(xevent);
|
||||
|
||||
event->proximity.type = (xevent->type == gdkdev->proximityin_type)?
|
||||
GDK_PROXIMITY_IN:GDK_PROXIMITY_OUT;
|
||||
event->proximity.window = input_window->window;
|
||||
event->proximity.time = xpne->time;
|
||||
event->proximity.source = gdkdev->info.source;
|
||||
event->proximity.deviceid = xpne->deviceid;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return -1; /* wasn't one of our event types */
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes)
|
||||
{
|
||||
int i;
|
||||
GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
|
||||
g_return_if_fail (gdkdev != NULL);
|
||||
|
||||
for (i=GDK_AXIS_IGNORE;i<GDK_AXIS_LAST;i++)
|
||||
{
|
||||
gdkdev->axis_for_use[i] = -1;
|
||||
}
|
||||
|
||||
for (i=0;i<gdkdev->info.num_axes;i++)
|
||||
{
|
||||
gdkdev->info.axes[i] = axes[i];
|
||||
gdkdev->axis_for_use[axes[i]] = i;
|
||||
}
|
||||
}
|
||||
|
||||
void gdk_input_common_set_key (guint32 deviceid,
|
||||
guint index,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
|
||||
|
||||
gdkdev = gdk_input_find_device (deviceid);
|
||||
g_return_if_fail (gdkdev != NULL);
|
||||
g_return_if_fail (index < gdkdev->info.num_keys);
|
||||
|
||||
gdkdev->info.keys[index].keyval = keyval;
|
||||
gdkdev->info.keys[index].modifiers = modifiers;
|
||||
}
|
||||
|
||||
static GdkTimeCoord *
|
||||
gdk_input_common_motion_events (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return)
|
||||
{
|
||||
GdkTimeCoord *coords;
|
||||
XDeviceTimeCoord *device_coords;
|
||||
GdkInputWindow *input_window;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
|
||||
int mode_return;
|
||||
int axis_count_return;
|
||||
int i;
|
||||
|
||||
gdkdev = gdk_input_find_device (deviceid);
|
||||
input_window = gdk_input_window_find (window);
|
||||
|
||||
g_return_val_if_fail (gdkdev != NULL, NULL);
|
||||
g_return_val_if_fail (gdkdev->xdevice != NULL, NULL);
|
||||
g_return_val_if_fail (input_window != NULL, NULL);
|
||||
|
||||
device_coords = XGetDeviceMotionEvents (gdk_display,
|
||||
gdkdev->xdevice,
|
||||
start, stop,
|
||||
nevents_return, &mode_return,
|
||||
&axis_count_return);
|
||||
|
||||
if (device_coords)
|
||||
{
|
||||
coords = g_new (GdkTimeCoord, *nevents_return);
|
||||
|
||||
for (i=0; i<*nevents_return; i++)
|
||||
{
|
||||
gdk_input_translate_coordinates (gdkdev, input_window,
|
||||
device_coords[i].data,
|
||||
&coords[i].x, &coords[i].y,
|
||||
&coords[i].pressure,
|
||||
&coords[i].xtilt, &coords[i].ytilt);
|
||||
}
|
||||
XFreeDeviceMotionEvents (device_coords);
|
||||
|
||||
return coords;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_common_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev;
|
||||
GdkInputWindow *input_window;
|
||||
XDeviceState *state;
|
||||
XInputClass *input_class;
|
||||
gint x_int, y_int;
|
||||
gint i;
|
||||
|
||||
/* we probably need to get the mask in any case */
|
||||
|
||||
if (deviceid == GDK_CORE_POINTER)
|
||||
{
|
||||
gdk_window_get_pointer (window, &x_int, &y_int, mask);
|
||||
if (x) *x = x_int;
|
||||
if (y) *y = y_int;
|
||||
if (pressure) *pressure = 0.5;
|
||||
if (xtilt) *xtilt = 0;
|
||||
if (ytilt) *ytilt = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mask)
|
||||
gdk_window_get_pointer (window, NULL, NULL, mask);
|
||||
|
||||
gdkdev = gdk_input_find_device (deviceid);
|
||||
input_window = gdk_input_window_find (window);
|
||||
|
||||
g_return_if_fail (gdkdev != NULL);
|
||||
g_return_if_fail (gdkdev->xdevice != NULL);
|
||||
g_return_if_fail (input_window != NULL);
|
||||
|
||||
state = XQueryDeviceState (gdk_display, gdkdev->xdevice);
|
||||
input_class = state->data;
|
||||
for (i=0; i<state->num_classes; i++)
|
||||
{
|
||||
switch (input_class->class)
|
||||
{
|
||||
case ValuatorClass:
|
||||
gdk_input_translate_coordinates (gdkdev, input_window,
|
||||
((XValuatorState *)input_class)->valuators,
|
||||
x, y, pressure,
|
||||
xtilt, ytilt);
|
||||
|
||||
|
||||
break;
|
||||
case ButtonClass:
|
||||
if (mask)
|
||||
{
|
||||
*mask &= 0xFF;
|
||||
if (((XButtonState *)input_class)->num_buttons > 0)
|
||||
*mask |= ((XButtonState *)input_class)->buttons[0] << 7;
|
||||
/* GDK_BUTTON1_MASK = 1 << 8, and button n is stored
|
||||
* in bit 1<<(n%8) in byte n/8. n = 1,2,... */
|
||||
}
|
||||
break;
|
||||
}
|
||||
input_class = (XInputClass *)(((char *)input_class)+input_class->length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@@ -1,343 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
|
||||
#ifdef XINPUT_XFREE
|
||||
|
||||
/* forward declarations */
|
||||
|
||||
static gint gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode);
|
||||
static void gdk_input_check_proximity();
|
||||
static void gdk_input_xfree_configure_event (XConfigureEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static void gdk_input_xfree_enter_event (XCrossingEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static gint gdk_input_xfree_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static gint gdk_input_xfree_enable_window(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static gint gdk_input_xfree_disable_window(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static gint gdk_input_xfree_grab_pointer (GdkWindow * window,
|
||||
gint owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindow * confine_to,
|
||||
guint32 time);
|
||||
static void gdk_input_xfree_ungrab_pointer (guint32 time);
|
||||
|
||||
void
|
||||
gdk_input_init(void)
|
||||
{
|
||||
gdk_input_vtable.set_mode = gdk_input_xfree_set_mode;
|
||||
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
|
||||
gdk_input_vtable.set_key = gdk_input_common_set_key;
|
||||
gdk_input_vtable.motion_events = gdk_input_common_motion_events;
|
||||
gdk_input_vtable.get_pointer = gdk_input_common_get_pointer;
|
||||
gdk_input_vtable.grab_pointer = gdk_input_xfree_grab_pointer;
|
||||
gdk_input_vtable.ungrab_pointer = gdk_input_xfree_ungrab_pointer;
|
||||
gdk_input_vtable.configure_event = gdk_input_xfree_configure_event;
|
||||
gdk_input_vtable.enter_event = gdk_input_xfree_enter_event;
|
||||
gdk_input_vtable.other_event = gdk_input_xfree_other_event;
|
||||
gdk_input_vtable.window_none_event = NULL;
|
||||
gdk_input_vtable.enable_window = gdk_input_xfree_enable_window;
|
||||
gdk_input_vtable.disable_window = gdk_input_xfree_disable_window;
|
||||
|
||||
gdk_input_ignore_core = FALSE;
|
||||
gdk_input_common_init(FALSE);
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
GdkInputMode old_mode;
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
gdkdev = gdk_input_find_device(deviceid);
|
||||
g_return_val_if_fail (gdkdev != NULL,FALSE);
|
||||
old_mode = gdkdev->info.mode;
|
||||
|
||||
if (gdkdev->info.mode == mode)
|
||||
return TRUE;
|
||||
|
||||
gdkdev->info.mode = mode;
|
||||
|
||||
if (mode == GDK_MODE_WINDOW)
|
||||
{
|
||||
gdkdev->info.has_cursor = FALSE;
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
|
||||
gdk_input_enable_window (input_window->window, gdkdev);
|
||||
else
|
||||
if (old_mode != GDK_MODE_DISABLED)
|
||||
gdk_input_disable_window (input_window->window, gdkdev);
|
||||
}
|
||||
}
|
||||
else if (mode == GDK_MODE_SCREEN)
|
||||
{
|
||||
gdkdev->info.has_cursor = TRUE;
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
gdk_input_enable_window (((GdkInputWindow *)tmp_list->data)->window,
|
||||
gdkdev);
|
||||
}
|
||||
else /* mode == GDK_MODE_DISABLED */
|
||||
{
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (old_mode != GDK_MODE_WINDOW ||
|
||||
input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
|
||||
gdk_input_disable_window (input_window->window, gdkdev);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_check_proximity()
|
||||
{
|
||||
gint new_proximity = 0;
|
||||
GList *tmp_list = gdk_input_devices;
|
||||
|
||||
while (tmp_list && !new_proximity)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)(tmp_list->data);
|
||||
|
||||
if (gdkdev->info.mode != GDK_MODE_DISABLED
|
||||
&& gdkdev->info.deviceid != GDK_CORE_POINTER
|
||||
&& gdkdev->xdevice)
|
||||
{
|
||||
XDeviceState *state = XQueryDeviceState(GDK_DISPLAY(),
|
||||
gdkdev->xdevice);
|
||||
XInputClass *xic;
|
||||
int i;
|
||||
|
||||
xic = state->data;
|
||||
for (i=0; i<state->num_classes; i++)
|
||||
{
|
||||
if (xic->class == ValuatorClass)
|
||||
{
|
||||
XValuatorState *xvs = (XValuatorState *)xic;
|
||||
if ((xvs->mode & ProximityState) == InProximity)
|
||||
{
|
||||
new_proximity = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
xic = (XInputClass *)((char *)xic + xic->length);
|
||||
}
|
||||
}
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
gdk_input_ignore_core = new_proximity;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_xfree_configure_event (XConfigureEvent *xevent, GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
gint root_x, root_y;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_if_fail (window != NULL);
|
||||
|
||||
gdk_input_get_root_relative_geometry(GDK_DISPLAY(),GDK_WINDOW_XWINDOW(window),
|
||||
&root_x,
|
||||
&root_y, NULL, NULL);
|
||||
|
||||
input_window->root_x = root_x;
|
||||
input_window->root_y = root_y;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_xfree_enter_event (XCrossingEvent *xevent,
|
||||
GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
gint root_x, root_y;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_if_fail (window != NULL);
|
||||
|
||||
gdk_input_check_proximity();
|
||||
|
||||
gdk_input_get_root_relative_geometry(GDK_DISPLAY(),GDK_WINDOW_XWINDOW(window),
|
||||
&root_x,
|
||||
&root_y, NULL, NULL);
|
||||
|
||||
input_window->root_x = root_x;
|
||||
input_window->root_y = root_y;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_xfree_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
GdkDevicePrivate *gdkdev;
|
||||
gint return_val;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_val_if_fail (window != NULL, -1);
|
||||
|
||||
/* This is a sort of a hack, as there isn't any XDeviceAnyEvent -
|
||||
but it's potentially faster than scanning through the types of
|
||||
every device. If we were deceived, then it won't match any of
|
||||
the types for the device anyways */
|
||||
gdkdev = gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
|
||||
|
||||
if (!gdkdev) {
|
||||
return -1; /* we don't handle it - not an XInput event */
|
||||
}
|
||||
|
||||
/* FIXME: It would be nice if we could just get rid of the events
|
||||
entirely, instead of having to ignore them */
|
||||
if (gdkdev->info.mode == GDK_MODE_DISABLED ||
|
||||
(gdkdev->info.mode == GDK_MODE_WINDOW
|
||||
&& input_window->mode == GDK_EXTENSION_EVENTS_CURSOR))
|
||||
return FALSE;
|
||||
|
||||
if (!gdk_input_ignore_core)
|
||||
gdk_input_check_proximity();
|
||||
|
||||
return_val = gdk_input_common_other_event (event, xevent,
|
||||
input_window, gdkdev);
|
||||
|
||||
if (return_val > 0 && event->type == GDK_PROXIMITY_OUT &&
|
||||
gdk_input_ignore_core)
|
||||
gdk_input_check_proximity();
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_xfree_enable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
/* FIXME: watchout, gdkdev might be core pointer, never opened */
|
||||
gdk_input_common_select_events (window, gdkdev);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_xfree_disable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
gdk_input_common_select_events (window, gdkdev);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_xfree_grab_pointer (GdkWindow * window,
|
||||
gint owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindow * confine_to,
|
||||
guint32 time)
|
||||
{
|
||||
GdkInputWindow *input_window, *new_window;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
GList *tmp_list;
|
||||
XEventClass event_classes[GDK_MAX_DEVICE_CLASSES];
|
||||
gint num_classes;
|
||||
gint result;
|
||||
|
||||
tmp_list = gdk_input_windows;
|
||||
new_window = NULL;
|
||||
while (tmp_list)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->grabbed)
|
||||
return AlreadyGrabbed;
|
||||
|
||||
if (input_window->window == window)
|
||||
new_window = input_window;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (new_window != NULL, Success); /* shouldn't happen */
|
||||
|
||||
new_window->grabbed = TRUE;
|
||||
|
||||
tmp_list = gdk_input_devices;
|
||||
while (tmp_list)
|
||||
{
|
||||
gdkdev = (GdkDevicePrivate *)tmp_list->data;
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
|
||||
gdkdev->xdevice)
|
||||
{
|
||||
gdk_input_common_find_events (window, gdkdev,
|
||||
event_mask,
|
||||
event_classes, &num_classes);
|
||||
|
||||
result = XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
|
||||
GDK_WINDOW_XWINDOW (window),
|
||||
owner_events, num_classes, event_classes,
|
||||
GrabModeAsync, GrabModeAsync, time);
|
||||
|
||||
/* FIXME: if failure occurs on something other than the first
|
||||
device, things will be badly inconsistent */
|
||||
if (result != Success)
|
||||
return result;
|
||||
}
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_xfree_ungrab_pointer (guint32 time)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
GList *tmp_list;
|
||||
|
||||
tmp_list = gdk_input_windows;
|
||||
while (tmp_list)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->grabbed)
|
||||
break;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
if (tmp_list) /* we found a grabbed window */
|
||||
{
|
||||
input_window->grabbed = FALSE;
|
||||
|
||||
tmp_list = gdk_input_devices;
|
||||
while (tmp_list)
|
||||
{
|
||||
gdkdev = (GdkDevicePrivate *)tmp_list->data;
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER && gdkdev->xdevice)
|
||||
XUngrabDevice( gdk_display, gdkdev->xdevice, time);
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* XINPUT_XFREE */
|
@@ -1,345 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "../config.h"
|
||||
#include "gdk.h"
|
||||
#include "gdkx.h"
|
||||
#include "gdkprivate.h"
|
||||
#include "gdkinput.h"
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
|
||||
static gint gdk_input_enable_window (GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static gint gdk_input_disable_window (GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static GdkInputWindow *gdk_input_window_find (GdkWindow *window);
|
||||
static GdkDevicePrivate *gdk_input_find_device (guint32 id);
|
||||
|
||||
|
||||
/* Incorporate the specific routines depending on compilation options */
|
||||
|
||||
static GdkAxisUse gdk_input_core_axes[] = { GDK_AXIS_X, GDK_AXIS_Y };
|
||||
|
||||
static GdkDeviceInfo gdk_input_core_info =
|
||||
{
|
||||
GDK_CORE_POINTER,
|
||||
"Core Pointer",
|
||||
GDK_SOURCE_MOUSE,
|
||||
GDK_MODE_SCREEN,
|
||||
TRUE,
|
||||
2,
|
||||
gdk_input_core_axes
|
||||
};
|
||||
|
||||
/* Global variables */
|
||||
|
||||
GdkInputVTable gdk_input_vtable;
|
||||
/* information about network port and host for gxid daemon */
|
||||
gchar *gdk_input_gxid_host;
|
||||
gint gdk_input_gxid_port;
|
||||
gint gdk_input_ignore_core;
|
||||
|
||||
/* Local variables */
|
||||
|
||||
static GList *gdk_input_devices;
|
||||
static GList *gdk_input_windows;
|
||||
|
||||
#include "gdkinputnone.h"
|
||||
#include "gdkinputcommon.h"
|
||||
#include "gdkinputxfree.h"
|
||||
#include "gdkinputgxi.h"
|
||||
|
||||
GList *
|
||||
gdk_input_list_devices ()
|
||||
{
|
||||
return gdk_input_devices;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_set_source (guint32 deviceid, GdkInputSource source)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
|
||||
g_return_if_fail (gdkdev != NULL);
|
||||
|
||||
gdkdev->info.source = source;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_input_set_mode (guint32 deviceid, GdkInputMode mode)
|
||||
{
|
||||
if (deviceid == GDK_CORE_POINTER)
|
||||
return FALSE;
|
||||
|
||||
if (gdk_input_vtable.set_mode)
|
||||
return gdk_input_vtable.set_mode(deviceid,mode);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_set_axes (guint32 deviceid, GdkAxisUse *axes)
|
||||
{
|
||||
if (deviceid != GDK_CORE_POINTER && gdk_input_vtable.set_axes)
|
||||
gdk_input_vtable.set_axes (deviceid, axes);
|
||||
}
|
||||
|
||||
void gdk_input_set_key (guint32 deviceid,
|
||||
guint index,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers)
|
||||
{
|
||||
if (deviceid != GDK_CORE_POINTER && gdk_input_vtable.set_key)
|
||||
gdk_input_vtable.set_key (deviceid, index, keyval, modifiers);
|
||||
}
|
||||
|
||||
GdkTimeCoord *
|
||||
gdk_input_motion_events (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return)
|
||||
{
|
||||
GdkWindowPrivate *window_private;
|
||||
XTimeCoord *xcoords;
|
||||
GdkTimeCoord *coords;
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (window != NULL, NULL);
|
||||
window_private = (GdkWindowPrivate *) window;
|
||||
if (window_private->destroyed)
|
||||
return NULL;
|
||||
|
||||
if (deviceid == GDK_CORE_POINTER)
|
||||
{
|
||||
xcoords = XGetMotionEvents (gdk_display,
|
||||
window_private->xwindow,
|
||||
start, stop, nevents_return);
|
||||
if (xcoords)
|
||||
{
|
||||
coords = g_new (GdkTimeCoord, *nevents_return);
|
||||
for (i=0; i<*nevents_return; i++)
|
||||
{
|
||||
coords[i].time = xcoords[i].time;
|
||||
coords[i].x = xcoords[i].x;
|
||||
coords[i].y = xcoords[i].y;
|
||||
coords[i].pressure = 0.5;
|
||||
coords[i].xtilt = 0.0;
|
||||
coords[i].ytilt = 0.0;
|
||||
}
|
||||
|
||||
XFree(xcoords);
|
||||
|
||||
return coords;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gdk_input_vtable.motion_events)
|
||||
{
|
||||
return gdk_input_vtable.motion_events(window,
|
||||
deviceid, start, stop,
|
||||
nevents_return);
|
||||
}
|
||||
else
|
||||
{
|
||||
*nevents_return = 0;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
if (gdk_input_vtable.enable_window)
|
||||
return gdk_input_vtable.enable_window (window, gdkdev);
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_disable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
if (gdk_input_vtable.disable_window)
|
||||
return gdk_input_vtable.disable_window(window,gdkdev);
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static GdkInputWindow *
|
||||
gdk_input_window_find(GdkWindow *window)
|
||||
{
|
||||
GList *tmp_list;
|
||||
|
||||
for (tmp_list=gdk_input_windows; tmp_list; tmp_list=tmp_list->next)
|
||||
if (((GdkInputWindow *)(tmp_list->data))->window == window)
|
||||
return (GdkInputWindow *)(tmp_list->data);
|
||||
|
||||
return NULL; /* Not found */
|
||||
}
|
||||
|
||||
/* FIXME: this routine currently needs to be called between creation
|
||||
and the corresponding configure event (because it doesn't get the
|
||||
root_relative_geometry). This should work with
|
||||
gtk_window_set_extension_events, but will likely fail in other
|
||||
cases */
|
||||
|
||||
void
|
||||
gdk_input_set_extension_events (GdkWindow *window, gint mask,
|
||||
GdkExtensionMode mode)
|
||||
{
|
||||
GdkWindowPrivate *window_private;
|
||||
GList *tmp_list;
|
||||
GdkInputWindow *iw;
|
||||
|
||||
g_return_if_fail (window != NULL);
|
||||
window_private = (GdkWindowPrivate*) window;
|
||||
if (window_private->destroyed)
|
||||
return;
|
||||
|
||||
if (mode == GDK_EXTENSION_EVENTS_NONE)
|
||||
mask = 0;
|
||||
|
||||
if (mask != 0)
|
||||
{
|
||||
iw = g_new(GdkInputWindow,1);
|
||||
|
||||
iw->window = window;
|
||||
iw->mode = mode;
|
||||
|
||||
iw->obscuring = NULL;
|
||||
iw->num_obscuring = 0;
|
||||
iw->grabbed = FALSE;
|
||||
|
||||
gdk_input_windows = g_list_append(gdk_input_windows,iw);
|
||||
window_private->extension_events = mask;
|
||||
|
||||
/* Add enter window events to the event mask */
|
||||
/* FIXME, this is not needed for XINPUT_NONE */
|
||||
gdk_window_set_events (window,
|
||||
gdk_window_get_events (window) |
|
||||
GDK_ENTER_NOTIFY_MASK);
|
||||
}
|
||||
else
|
||||
{
|
||||
iw = gdk_input_window_find (window);
|
||||
if (iw)
|
||||
{
|
||||
gdk_input_windows = g_list_remove(gdk_input_windows,iw);
|
||||
g_free(iw);
|
||||
}
|
||||
|
||||
window_private->extension_events = 0;
|
||||
}
|
||||
|
||||
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)(tmp_list->data);
|
||||
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER)
|
||||
{
|
||||
if (mask != 0 && gdkdev->info.mode != GDK_MODE_DISABLED
|
||||
&& (gdkdev->info.has_cursor || mode == GDK_EXTENSION_EVENTS_ALL))
|
||||
gdk_input_enable_window(window,gdkdev);
|
||||
else
|
||||
gdk_input_disable_window(window,gdkdev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_window_destroy (GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
input_window = gdk_input_window_find (window);
|
||||
g_return_if_fail (input_window != NULL);
|
||||
|
||||
gdk_input_windows = g_list_remove (gdk_input_windows,input_window);
|
||||
g_free(input_window);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_exit (void)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
|
||||
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
gdkdev = (GdkDevicePrivate *)(tmp_list->data);
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER)
|
||||
{
|
||||
gdk_input_set_mode(gdkdev->info.deviceid,GDK_MODE_DISABLED);
|
||||
|
||||
g_free(gdkdev->info.name);
|
||||
#ifndef XINPUT_NONE
|
||||
g_free(gdkdev->axes);
|
||||
#endif
|
||||
g_free(gdkdev->info.axes);
|
||||
g_free(gdkdev->info.keys);
|
||||
g_free(gdkdev);
|
||||
}
|
||||
}
|
||||
|
||||
g_list_free(gdk_input_devices);
|
||||
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
g_free(tmp_list->data);
|
||||
}
|
||||
g_list_free(gdk_input_windows);
|
||||
}
|
||||
|
||||
static GdkDevicePrivate *
|
||||
gdk_input_find_device(guint32 id)
|
||||
{
|
||||
GList *tmp_list = gdk_input_devices;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
while (tmp_list)
|
||||
{
|
||||
gdkdev = (GdkDevicePrivate *)(tmp_list->data);
|
||||
if (gdkdev->info.deviceid == id)
|
||||
return gdkdev;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_window_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
if (gdk_input_vtable.get_pointer)
|
||||
gdk_input_vtable.get_pointer (window, deviceid, x, y, pressure,
|
||||
xtilt, ytilt, mask);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,743 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
#include "../config.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
/* Needed for SEEK_END in SunOS */
|
||||
#include <unistd.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *color_string;
|
||||
GdkColor color;
|
||||
gint transparent;
|
||||
} _GdkPixmapColor;
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_new (GdkWindow *window,
|
||||
gint width,
|
||||
gint height,
|
||||
gint depth)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkWindowPrivate *private;
|
||||
GdkWindowPrivate *window_private;
|
||||
|
||||
g_return_val_if_fail ((window != NULL) || (depth != -1), NULL);
|
||||
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
|
||||
|
||||
if (!window)
|
||||
window = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
window_private = (GdkWindowPrivate*) window;
|
||||
if (window_private->destroyed)
|
||||
return NULL;
|
||||
|
||||
if (depth == -1)
|
||||
gdk_window_get_geometry (window, NULL, NULL, NULL, NULL, &depth);
|
||||
|
||||
private = g_new (GdkWindowPrivate, 1);
|
||||
pixmap = (GdkPixmap*) private;
|
||||
|
||||
private->xdisplay = window_private->xdisplay;
|
||||
private->window_type = GDK_WINDOW_PIXMAP;
|
||||
private->xwindow = XCreatePixmap (private->xdisplay, window_private->xwindow,
|
||||
width, height, depth);
|
||||
private->parent = NULL;
|
||||
private->x = 0;
|
||||
private->y = 0;
|
||||
private->width = width;
|
||||
private->height = height;
|
||||
private->resize_count = 0;
|
||||
private->ref_count = 1;
|
||||
private->destroyed = 0;
|
||||
|
||||
gdk_xid_table_insert (&private->xwindow, pixmap);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
GdkPixmap *
|
||||
gdk_bitmap_create_from_data (GdkWindow *window,
|
||||
gchar *data,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkWindowPrivate *private;
|
||||
GdkWindowPrivate *window_private;
|
||||
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
|
||||
|
||||
if (!window)
|
||||
window = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
window_private = (GdkWindowPrivate*) window;
|
||||
if (window_private->destroyed)
|
||||
return NULL;
|
||||
|
||||
private = g_new (GdkWindowPrivate, 1);
|
||||
pixmap = (GdkPixmap*) private;
|
||||
|
||||
private->parent = NULL;
|
||||
private->xdisplay = window_private->xdisplay;
|
||||
private->window_type = GDK_WINDOW_PIXMAP;
|
||||
private->x = 0;
|
||||
private->y = 0;
|
||||
private->width = width;
|
||||
private->height = height;
|
||||
private->resize_count = 0;
|
||||
private->ref_count = 1;
|
||||
private->destroyed = FALSE;
|
||||
|
||||
private->xwindow = XCreateBitmapFromData (private->xdisplay,
|
||||
window_private->xwindow,
|
||||
data, width, height);
|
||||
|
||||
gdk_xid_table_insert (&private->xwindow, pixmap);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_create_from_data (GdkWindow *window,
|
||||
gchar *data,
|
||||
gint width,
|
||||
gint height,
|
||||
gint depth,
|
||||
GdkColor *fg,
|
||||
GdkColor *bg)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkWindowPrivate *private;
|
||||
GdkWindowPrivate *window_private;
|
||||
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
g_return_val_if_fail (fg != NULL, NULL);
|
||||
g_return_val_if_fail (bg != NULL, NULL);
|
||||
g_return_val_if_fail ((window != NULL) || (depth != -1), NULL);
|
||||
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
|
||||
|
||||
if (!window)
|
||||
window = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
window_private = (GdkWindowPrivate*) window;
|
||||
if (window_private->destroyed)
|
||||
return NULL;
|
||||
|
||||
if (depth == -1)
|
||||
gdk_window_get_geometry (window, NULL, NULL, NULL, NULL, &depth);
|
||||
|
||||
private = g_new (GdkWindowPrivate, 1);
|
||||
pixmap = (GdkPixmap*) private;
|
||||
|
||||
private->parent = NULL;
|
||||
private->xdisplay = window_private->xdisplay;
|
||||
private->window_type = GDK_WINDOW_PIXMAP;
|
||||
private->x = 0;
|
||||
private->y = 0;
|
||||
private->width = width;
|
||||
private->height = height;
|
||||
private->resize_count = 0;
|
||||
private->ref_count = 1;
|
||||
private->destroyed = FALSE;
|
||||
|
||||
private->xwindow = XCreatePixmapFromBitmapData (private->xdisplay,
|
||||
window_private->xwindow,
|
||||
data, width, height,
|
||||
fg->pixel, bg->pixel, depth);
|
||||
|
||||
gdk_xid_table_insert (&private->xwindow, pixmap);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_pixmap_seek_string (FILE *infile,
|
||||
const gchar *str,
|
||||
gint skip_comments)
|
||||
{
|
||||
char instr[1024];
|
||||
|
||||
while (!feof (infile))
|
||||
{
|
||||
fscanf (infile, "%1023s", instr);
|
||||
if (skip_comments == TRUE && strcmp (instr, "/*") == 0)
|
||||
{
|
||||
fscanf (infile, "%1023s", instr);
|
||||
while (!feof (infile) && strcmp (instr, "*/") != 0)
|
||||
fscanf (infile, "%1023s", instr);
|
||||
fscanf(infile, "%1023s", instr);
|
||||
}
|
||||
if (strcmp (instr, str)==0)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_pixmap_seek_char (FILE *infile,
|
||||
gchar c)
|
||||
{
|
||||
gint b, oldb;
|
||||
|
||||
while ((b = getc(infile)) != EOF)
|
||||
{
|
||||
if (c != b && b == '/')
|
||||
{
|
||||
b = getc (infile);
|
||||
if (b == EOF)
|
||||
return FALSE;
|
||||
else if (b == '*') /* we have a comment */
|
||||
{
|
||||
b = -1;
|
||||
do
|
||||
{
|
||||
oldb = b;
|
||||
b = getc (infile);
|
||||
if (b == EOF)
|
||||
return FALSE;
|
||||
}
|
||||
while (!(oldb == '*' && b == '/'));
|
||||
}
|
||||
}
|
||||
else if (c == b)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_pixmap_read_string (FILE *infile,
|
||||
gchar **buffer,
|
||||
guint *buffer_size)
|
||||
{
|
||||
gint c;
|
||||
guint cnt = 0;
|
||||
|
||||
if ((*buffer) == NULL)
|
||||
{
|
||||
(*buffer_size) = 10 * sizeof (gchar);
|
||||
(*buffer) = g_new(gchar, *buffer_size);
|
||||
}
|
||||
|
||||
do
|
||||
c = getc (infile);
|
||||
while (c != EOF && c != '"');
|
||||
|
||||
if (c != '"')
|
||||
return FALSE;
|
||||
|
||||
while ((c = getc(infile)) != EOF)
|
||||
{
|
||||
if (cnt == (*buffer_size))
|
||||
{
|
||||
(*buffer_size) *= 2;
|
||||
(*buffer) = (gchar *) g_realloc ((*buffer), *buffer_size); }
|
||||
|
||||
if (c != '"')
|
||||
(*buffer)[cnt++] = c;
|
||||
else
|
||||
{
|
||||
(*buffer)[cnt++] = 0;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gchar*
|
||||
gdk_pixmap_skip_whitespaces (gchar *buffer)
|
||||
{
|
||||
gint32 index = 0;
|
||||
|
||||
while (buffer[index] != 0 && (buffer[index] == 0x20 || buffer[index] == 0x09))
|
||||
index++;
|
||||
|
||||
return &buffer[index];
|
||||
}
|
||||
|
||||
gchar*
|
||||
gdk_pixmap_skip_string (gchar *buffer)
|
||||
{
|
||||
gint32 index = 0;
|
||||
|
||||
while (buffer[index] != 0 && buffer[index] != 0x20 && buffer[index] != 0x09)
|
||||
index++;
|
||||
|
||||
return &buffer[index];
|
||||
}
|
||||
|
||||
gchar*
|
||||
gdk_pixmap_extract_color (gchar *buffer)
|
||||
{
|
||||
gint counter, finished = FALSE, numnames;
|
||||
gchar *ptr = NULL, ch, temp[128];
|
||||
gchar color[128], *retcol;
|
||||
|
||||
counter = 0;
|
||||
while (ptr == NULL)
|
||||
{
|
||||
if (buffer[counter] == 'c')
|
||||
{
|
||||
ch = buffer[counter + 1];
|
||||
if (ch == 0x20 || ch == 0x09)
|
||||
ptr = &buffer[counter + 1];
|
||||
}
|
||||
else if (buffer[counter] == 0)
|
||||
return NULL;
|
||||
|
||||
counter++;
|
||||
}
|
||||
|
||||
if (ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
ptr = gdk_pixmap_skip_whitespaces (ptr);
|
||||
|
||||
if (ptr[0] == 0)
|
||||
return NULL;
|
||||
else if (ptr[0] == '#')
|
||||
{
|
||||
retcol = g_strdup (ptr);
|
||||
return retcol;
|
||||
}
|
||||
|
||||
color[0] = 0;
|
||||
numnames = 0;
|
||||
|
||||
while (finished == FALSE)
|
||||
{
|
||||
sscanf (ptr, "%127s", temp);
|
||||
|
||||
if ((gint)ptr[0] == 0 || strcmp ("s", temp) == 0 || strcmp ("m", temp) == 0 ||
|
||||
strcmp ("g", temp) == 0 || strcmp ("g4", temp) == 0)
|
||||
finished = TRUE;
|
||||
else
|
||||
{
|
||||
if (numnames > 0)
|
||||
strcat (color, " ");
|
||||
strcat (color, temp);
|
||||
ptr = gdk_pixmap_skip_string (ptr);
|
||||
ptr = gdk_pixmap_skip_whitespaces (ptr);
|
||||
numnames++;
|
||||
}
|
||||
}
|
||||
|
||||
retcol = g_strdup (color);
|
||||
return retcol;
|
||||
}
|
||||
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_colormap_create_from_xpm (GdkWindow *window,
|
||||
GdkColormap *colormap,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
const gchar *filename)
|
||||
{
|
||||
FILE *infile = NULL;
|
||||
GdkPixmap *pixmap = NULL;
|
||||
GdkImage *image = NULL;
|
||||
GdkVisual *visual;
|
||||
GdkGC *gc;
|
||||
GdkColor tmp_color;
|
||||
gint width, height, num_cols, cpp, cnt, n, ns, xcnt, ycnt;
|
||||
gchar *buffer = NULL, pixel_str[32];
|
||||
guint buffer_size = 0;
|
||||
_GdkPixmapColor *colors = NULL, *color = NULL;
|
||||
gulong index;
|
||||
|
||||
if ((window == NULL) && (colormap == NULL))
|
||||
g_warning ("Creating pixmap from xpm with NULL window and colormap");
|
||||
|
||||
if (window == NULL)
|
||||
window = (GdkWindow *)&gdk_root_parent;
|
||||
|
||||
if (colormap == NULL)
|
||||
{
|
||||
colormap = gdk_window_get_colormap (window);
|
||||
visual = gdk_window_get_visual (window);
|
||||
}
|
||||
else
|
||||
visual = ((GdkColormapPrivate *)colormap)->visual;
|
||||
|
||||
infile = fopen (filename, "rb");
|
||||
if (infile != NULL)
|
||||
{
|
||||
if (gdk_pixmap_seek_string (infile, "XPM", FALSE) == TRUE)
|
||||
{
|
||||
if (gdk_pixmap_seek_char (infile,'{') == TRUE)
|
||||
{
|
||||
gdk_pixmap_seek_char (infile, '"');
|
||||
fseek (infile, -1, SEEK_CUR);
|
||||
gdk_pixmap_read_string (infile, &buffer, &buffer_size);
|
||||
|
||||
sscanf (buffer,"%d %d %d %d", &width, &height, &num_cols, &cpp);
|
||||
|
||||
colors = g_new(_GdkPixmapColor, num_cols);
|
||||
|
||||
if (transparent_color == NULL)
|
||||
{
|
||||
gdk_color_white (colormap, &tmp_color);
|
||||
transparent_color = &tmp_color;
|
||||
}
|
||||
|
||||
for (cnt = 0; cnt < num_cols; cnt++)
|
||||
{
|
||||
gchar *color_name;
|
||||
|
||||
gdk_pixmap_seek_char (infile, '"');
|
||||
fseek (infile, -1, SEEK_CUR);
|
||||
gdk_pixmap_read_string (infile, &buffer, &buffer_size);
|
||||
|
||||
colors[cnt].color_string = g_new(gchar, cpp + 1);
|
||||
for (n = 0; n < cpp; n++)
|
||||
colors[cnt].color_string[n] = buffer[n];
|
||||
colors[cnt].color_string[n] = 0;
|
||||
colors[cnt].transparent = FALSE;
|
||||
|
||||
color_name = gdk_pixmap_extract_color (&buffer[cpp]);
|
||||
|
||||
if (color_name != NULL)
|
||||
{
|
||||
if (gdk_color_parse (color_name, &colors[cnt].color) == FALSE)
|
||||
{
|
||||
colors[cnt].color = *transparent_color;
|
||||
colors[cnt].transparent = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
colors[cnt].color = *transparent_color;
|
||||
colors[cnt].transparent = TRUE;
|
||||
}
|
||||
|
||||
g_free (color_name);
|
||||
|
||||
gdk_color_alloc (colormap, &colors[cnt].color);
|
||||
}
|
||||
|
||||
index = 0;
|
||||
image = gdk_image_new (GDK_IMAGE_FASTEST, visual, width, height);
|
||||
|
||||
gc = NULL;
|
||||
if (mask)
|
||||
{
|
||||
/* The pixmap mask is just a bits pattern.
|
||||
* Color 0 is used for background and 1 for foreground.
|
||||
* We don't care about the colormap, we just need 0 and 1.
|
||||
*/
|
||||
GdkColor mask_pattern;
|
||||
|
||||
*mask = gdk_pixmap_new (window, width, height, 1);
|
||||
gc = gdk_gc_new (*mask);
|
||||
|
||||
mask_pattern.pixel = 0;
|
||||
gdk_gc_set_foreground (gc, &mask_pattern);
|
||||
gdk_draw_rectangle (*mask, gc, TRUE, 0, 0, -1, -1);
|
||||
|
||||
mask_pattern.pixel = 1;
|
||||
gdk_gc_set_foreground (gc, &mask_pattern);
|
||||
}
|
||||
|
||||
for (ycnt = 0; ycnt < height; ycnt++)
|
||||
{
|
||||
gdk_pixmap_read_string (infile, &buffer, &buffer_size);
|
||||
|
||||
for (n = 0, cnt = 0, xcnt = 0; n < (width * cpp); n += cpp, xcnt++)
|
||||
{
|
||||
strncpy (pixel_str, &buffer[n], cpp);
|
||||
pixel_str[cpp] = 0;
|
||||
color = NULL;
|
||||
ns = 0;
|
||||
|
||||
while ((color == NULL) && (ns < num_cols))
|
||||
{
|
||||
if (strcmp (pixel_str, colors[ns].color_string) == 0)
|
||||
color = &colors[ns];
|
||||
else
|
||||
ns++;
|
||||
}
|
||||
|
||||
if (!color) /* screwed up XPM file */
|
||||
color = &colors[0];
|
||||
|
||||
gdk_image_put_pixel (image, xcnt, ycnt, color->color.pixel);
|
||||
|
||||
if (mask && color->transparent)
|
||||
{
|
||||
if (cnt < xcnt)
|
||||
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
|
||||
cnt = xcnt + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (mask && (cnt < xcnt))
|
||||
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
|
||||
}
|
||||
|
||||
if (mask)
|
||||
gdk_gc_destroy (gc);
|
||||
|
||||
pixmap = gdk_pixmap_new (window, width, height, visual->depth);
|
||||
|
||||
gc = gdk_gc_new (pixmap);
|
||||
gdk_gc_set_foreground (gc, transparent_color);
|
||||
gdk_draw_image (pixmap, gc, image, 0, 0, 0, 0, image->width, image->height);
|
||||
gdk_gc_destroy (gc);
|
||||
gdk_image_destroy (image);
|
||||
}
|
||||
}
|
||||
|
||||
fclose (infile);
|
||||
free (buffer);
|
||||
|
||||
if (colors != NULL)
|
||||
{
|
||||
for (cnt = 0; cnt < num_cols; cnt++)
|
||||
g_free (colors[cnt].color_string);
|
||||
g_free (colors);
|
||||
}
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_create_from_xpm (GdkWindow *window,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
const gchar *filename)
|
||||
{
|
||||
return gdk_pixmap_colormap_create_from_xpm (window, NULL, mask,
|
||||
transparent_color, filename);
|
||||
}
|
||||
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_colormap_create_from_xpm_d (GdkWindow *window,
|
||||
GdkColormap *colormap,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
gchar **data)
|
||||
{
|
||||
GdkPixmap *pixmap = NULL;
|
||||
GdkImage *image = NULL;
|
||||
GdkVisual *visual;
|
||||
GdkGC *gc;
|
||||
GdkColor tmp_color;
|
||||
gint width, height, num_cols, cpp, cnt, n, ns, xcnt, ycnt, i;
|
||||
gchar *buffer, pixel_str[32];
|
||||
_GdkPixmapColor *colors = NULL, *color = NULL;
|
||||
gulong index;
|
||||
|
||||
if ((window == NULL) && (colormap == NULL))
|
||||
g_warning ("Creating pixmap from xpm with NULL window and colormap");
|
||||
|
||||
if (window == NULL)
|
||||
window = (GdkWindow *)&gdk_root_parent;
|
||||
|
||||
if (colormap == NULL)
|
||||
{
|
||||
colormap = gdk_window_get_colormap (window);
|
||||
visual = gdk_window_get_visual (window);
|
||||
}
|
||||
else
|
||||
visual = ((GdkColormapPrivate *)colormap)->visual;
|
||||
|
||||
i = 0;
|
||||
buffer = data[i++];
|
||||
sscanf (buffer,"%d %d %d %d", &width, &height, &num_cols, &cpp);
|
||||
|
||||
colors = g_new(_GdkPixmapColor, num_cols);
|
||||
|
||||
if (transparent_color == NULL)
|
||||
{
|
||||
gdk_color_white (colormap, &tmp_color);
|
||||
transparent_color = &tmp_color;
|
||||
}
|
||||
|
||||
for (cnt = 0; cnt < num_cols; cnt++)
|
||||
{
|
||||
gchar *color_name;
|
||||
|
||||
buffer = data[i++];
|
||||
|
||||
colors[cnt].color_string = g_new(gchar, cpp + 1);
|
||||
for (n = 0; n < cpp; n++)
|
||||
colors[cnt].color_string[n] = buffer[n];
|
||||
colors[cnt].color_string[n] = 0;
|
||||
colors[cnt].transparent = FALSE;
|
||||
|
||||
color_name = gdk_pixmap_extract_color (&buffer[cpp]);
|
||||
|
||||
if (color_name != NULL)
|
||||
{
|
||||
if (gdk_color_parse (color_name, &colors[cnt].color) == FALSE)
|
||||
{
|
||||
colors[cnt].color = *transparent_color;
|
||||
colors[cnt].transparent = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
colors[cnt].color = *transparent_color;
|
||||
colors[cnt].transparent = TRUE;
|
||||
}
|
||||
|
||||
g_free (color_name);
|
||||
|
||||
gdk_color_alloc (colormap, &colors[cnt].color);
|
||||
}
|
||||
|
||||
index = 0;
|
||||
image = gdk_image_new (GDK_IMAGE_FASTEST, visual, width, height);
|
||||
|
||||
gc = NULL;
|
||||
if (mask)
|
||||
{
|
||||
/* The pixmap mask is just a bits pattern.
|
||||
* Color 0 is used for background and 1 for foreground.
|
||||
* We don't care about the colormap, we just need 0 and 1.
|
||||
*/
|
||||
GdkColor mask_pattern;
|
||||
|
||||
*mask = gdk_pixmap_new (window, width, height, 1);
|
||||
gc = gdk_gc_new (*mask);
|
||||
|
||||
mask_pattern.pixel = 0;
|
||||
gdk_gc_set_foreground (gc, &mask_pattern);
|
||||
gdk_draw_rectangle (*mask, gc, TRUE, 0, 0, -1, -1);
|
||||
|
||||
mask_pattern.pixel = 1;
|
||||
gdk_gc_set_foreground (gc, &mask_pattern);
|
||||
}
|
||||
|
||||
for (ycnt = 0; ycnt < height; ycnt++)
|
||||
{
|
||||
buffer = data[i++];
|
||||
|
||||
for (n = 0, cnt = 0, xcnt = 0; n < (width * cpp); n += cpp, xcnt++)
|
||||
{
|
||||
strncpy (pixel_str, &buffer[n], cpp);
|
||||
pixel_str[cpp] = 0;
|
||||
color = NULL;
|
||||
ns = 0;
|
||||
|
||||
while ((color == NULL) && (ns < num_cols))
|
||||
{
|
||||
if (strcmp (pixel_str, colors[ns].color_string) == 0)
|
||||
color = &colors[ns];
|
||||
else
|
||||
ns++;
|
||||
}
|
||||
|
||||
if (!color) /* screwed up XPM file */
|
||||
color = &colors[0];
|
||||
|
||||
gdk_image_put_pixel (image, xcnt, ycnt, color->color.pixel);
|
||||
|
||||
if (mask && color->transparent)
|
||||
{
|
||||
if (cnt < xcnt)
|
||||
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
|
||||
cnt = xcnt + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (mask && (cnt < xcnt))
|
||||
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
|
||||
}
|
||||
|
||||
if (mask)
|
||||
gdk_gc_destroy (gc);
|
||||
|
||||
pixmap = gdk_pixmap_new (window, width, height, visual->depth);
|
||||
|
||||
gc = gdk_gc_new (pixmap);
|
||||
gdk_gc_set_foreground (gc, transparent_color);
|
||||
gdk_draw_image (pixmap, gc, image, 0, 0, 0, 0, image->width, image->height);
|
||||
gdk_gc_destroy (gc);
|
||||
gdk_image_destroy (image);
|
||||
|
||||
if (colors != NULL)
|
||||
{
|
||||
for (cnt = 0; cnt < num_cols; cnt++)
|
||||
g_free (colors[cnt].color_string);
|
||||
g_free (colors);
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_create_from_xpm_d (GdkWindow *window,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
gchar **data)
|
||||
{
|
||||
return gdk_pixmap_colormap_create_from_xpm_d (window, NULL, mask,
|
||||
transparent_color, data);
|
||||
}
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_ref (GdkPixmap *pixmap)
|
||||
{
|
||||
GdkWindowPrivate *private = (GdkWindowPrivate *)pixmap;
|
||||
g_return_val_if_fail (pixmap != NULL, NULL);
|
||||
|
||||
private->ref_count += 1;
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_pixmap_unref (GdkPixmap *pixmap)
|
||||
{
|
||||
GdkWindowPrivate *private = (GdkWindowPrivate *)pixmap;
|
||||
g_return_if_fail(pixmap != NULL);
|
||||
|
||||
private->ref_count -= 1;
|
||||
if (private->ref_count == 0)
|
||||
{
|
||||
XFreePixmap (private->xdisplay, private->xwindow);
|
||||
gdk_xid_table_remove (private->xwindow);
|
||||
g_free (private);
|
||||
}
|
||||
}
|
||||
|
||||
GdkBitmap *
|
||||
gdk_bitmap_ref (GdkBitmap *bitmap)
|
||||
{
|
||||
return (GdkBitmap *)gdk_pixmap_ref ((GdkPixmap *)bitmap);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_bitmap_unref (GdkBitmap *bitmap)
|
||||
{
|
||||
gdk_pixmap_unref ((GdkPixmap *)bitmap);
|
||||
}
|
@@ -1,214 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <string.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
GdkAtom
|
||||
gdk_atom_intern (const gchar *atom_name,
|
||||
gint only_if_exists)
|
||||
{
|
||||
return XInternAtom (gdk_display, atom_name, only_if_exists);
|
||||
}
|
||||
|
||||
gchar *
|
||||
gdk_atom_name (GdkAtom atom)
|
||||
{
|
||||
gchar *t;
|
||||
gchar *name;
|
||||
|
||||
/* If this atom doesn't exist, we'll die with an X error unless
|
||||
we take precautions */
|
||||
|
||||
gdk_error_warnings = 0;
|
||||
gdk_error_code = 0;
|
||||
t = XGetAtomName (gdk_display, atom);
|
||||
gdk_error_warnings = 1;
|
||||
|
||||
if (gdk_error_code == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = g_strdup (t);
|
||||
XFree (t);
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_property_get (GdkWindow *window,
|
||||
GdkAtom property,
|
||||
GdkAtom type,
|
||||
gulong offset,
|
||||
gulong length,
|
||||
gint pdelete,
|
||||
GdkAtom *actual_property_type,
|
||||
gint *actual_format_type,
|
||||
gint *actual_length,
|
||||
guchar **data)
|
||||
{
|
||||
Display *xdisplay;
|
||||
Window xwindow;
|
||||
Atom ret_prop_type;
|
||||
gint ret_format;
|
||||
gulong ret_nitems;
|
||||
gulong ret_bytes_after;
|
||||
gulong ret_length;
|
||||
guchar *ret_data;
|
||||
|
||||
if (window)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
|
||||
private = (GdkWindowPrivate*) window;
|
||||
if (private->destroyed)
|
||||
return FALSE;
|
||||
|
||||
xdisplay = private->xdisplay;
|
||||
xwindow = private->xwindow;
|
||||
}
|
||||
else
|
||||
{
|
||||
xdisplay = gdk_display;
|
||||
xwindow = gdk_root_window;
|
||||
}
|
||||
|
||||
XGetWindowProperty (xdisplay, xwindow, property,
|
||||
offset, (length + 3) / 4, pdelete,
|
||||
type, &ret_prop_type, &ret_format,
|
||||
&ret_nitems, &ret_bytes_after,
|
||||
&ret_data);
|
||||
|
||||
if ((ret_prop_type == None) && (ret_format == 0)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (actual_property_type)
|
||||
*actual_property_type = ret_prop_type;
|
||||
if (actual_format_type)
|
||||
*actual_format_type = ret_format;
|
||||
|
||||
if (ret_prop_type != type)
|
||||
{
|
||||
gchar *rn, *pn;
|
||||
XFree (ret_data);
|
||||
rn = gdk_atom_name(ret_prop_type);
|
||||
pn = gdk_atom_name(type);
|
||||
g_warning("Couldn't match property type %s to %s\n", rn, pn);
|
||||
g_free(rn); g_free(pn);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* FIXME: ignoring bytes_after could have very bad effects */
|
||||
|
||||
if (data)
|
||||
{
|
||||
switch (ret_format)
|
||||
{
|
||||
case 8:
|
||||
ret_length = ret_nitems;
|
||||
break;
|
||||
case 16:
|
||||
ret_length = 2 * ret_nitems;
|
||||
break;
|
||||
case 32:
|
||||
ret_length = 4 * ret_nitems;
|
||||
break;
|
||||
default:
|
||||
g_warning ("unknown property return format: %d", ret_format);
|
||||
XFree (ret_data);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*data = g_new (guchar, ret_length);
|
||||
memcpy (*data, ret_data, ret_length);
|
||||
if (actual_length)
|
||||
*actual_length = ret_length;
|
||||
}
|
||||
|
||||
XFree (ret_data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_property_change (GdkWindow *window,
|
||||
GdkAtom property,
|
||||
GdkAtom type,
|
||||
gint format,
|
||||
GdkPropMode mode,
|
||||
guchar *data,
|
||||
gint nelements)
|
||||
{
|
||||
Display *xdisplay;
|
||||
Window xwindow;
|
||||
|
||||
if (window)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
|
||||
private = (GdkWindowPrivate*) window;
|
||||
if (private->destroyed)
|
||||
return;
|
||||
|
||||
xdisplay = private->xdisplay;
|
||||
xwindow = private->xwindow;
|
||||
}
|
||||
else
|
||||
{
|
||||
xdisplay = gdk_display;
|
||||
xwindow = gdk_root_window;
|
||||
}
|
||||
|
||||
XChangeProperty (xdisplay, xwindow, property, type,
|
||||
format, mode, data, nelements);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_property_delete (GdkWindow *window,
|
||||
GdkAtom property)
|
||||
{
|
||||
Display *xdisplay;
|
||||
Window xwindow;
|
||||
|
||||
if (window)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
|
||||
private = (GdkWindowPrivate*) window;
|
||||
if (private->destroyed)
|
||||
return;
|
||||
|
||||
xdisplay = private->xdisplay;
|
||||
xwindow = private->xwindow;
|
||||
}
|
||||
else
|
||||
{
|
||||
xdisplay = gdk_display;
|
||||
xwindow = gdk_root_window;
|
||||
}
|
||||
|
||||
XDeleteProperty (xdisplay, xwindow, property);
|
||||
}
|
@@ -1,302 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
|
||||
|
||||
GdkRegion*
|
||||
gdk_region_new (void)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
GdkRegion *region;
|
||||
Region xregion;
|
||||
|
||||
xregion = XCreateRegion();
|
||||
private = g_new (GdkRegionPrivate, 1);
|
||||
private->xregion = xregion;
|
||||
region = (GdkRegion*) private;
|
||||
region->user_data = NULL;
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_region_destroy (GdkRegion *region)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
|
||||
g_return_if_fail (region != NULL);
|
||||
|
||||
private = (GdkRegionPrivate *) region;
|
||||
XDestroyRegion (private->xregion);
|
||||
|
||||
g_free (private);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_region_empty (GdkRegion *region)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
|
||||
g_return_val_if_fail (region != NULL, 0);
|
||||
|
||||
private = (GdkRegionPrivate *) region;
|
||||
|
||||
return XEmptyRegion (private->xregion);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_region_equal (GdkRegion *region1,
|
||||
GdkRegion *region2)
|
||||
{
|
||||
GdkRegionPrivate *private1;
|
||||
GdkRegionPrivate *private2;
|
||||
|
||||
g_return_val_if_fail (region1 != NULL, 0);
|
||||
g_return_val_if_fail (region2 != NULL, 0);
|
||||
|
||||
private1 = (GdkRegionPrivate *) region1;
|
||||
private2 = (GdkRegionPrivate *) region2;
|
||||
|
||||
return XEqualRegion (private1->xregion, private2->xregion);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_region_point_in (GdkRegion *region,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
|
||||
g_return_val_if_fail (region != NULL, 0);
|
||||
|
||||
private = (GdkRegionPrivate *) region;
|
||||
|
||||
return XPointInRegion (private->xregion, x, y);
|
||||
}
|
||||
|
||||
GdkOverlapType
|
||||
gdk_region_rect_in (GdkRegion *region,
|
||||
GdkRectangle *rect)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
int res;
|
||||
|
||||
g_return_val_if_fail (region != NULL, 0);
|
||||
|
||||
private = (GdkRegionPrivate *) region;
|
||||
|
||||
res = XRectInRegion (private->xregion, rect->x, rect->y, rect->width, rect->height);
|
||||
|
||||
switch (res)
|
||||
{
|
||||
case RectangleIn: return GDK_OVERLAP_RECTANGLE_IN;
|
||||
case RectangleOut: return GDK_OVERLAP_RECTANGLE_OUT;
|
||||
case RectanglePart: return GDK_OVERLAP_RECTANGLE_PART;
|
||||
}
|
||||
|
||||
return GDK_OVERLAP_RECTANGLE_OUT; /*what else ? */
|
||||
}
|
||||
|
||||
GdkRegion *
|
||||
gdk_region_polygon (GdkPoint *points,
|
||||
gint npoints,
|
||||
GdkFillRule fill_rule)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
GdkRegion *region;
|
||||
Region xregion;
|
||||
int xfill_rule;
|
||||
|
||||
g_return_val_if_fail (points != NULL, NULL);
|
||||
g_return_val_if_fail (npoints != 0, NULL); /* maybe we should check for at least three points */
|
||||
|
||||
switch (fill_rule)
|
||||
{
|
||||
case GDK_EVEN_ODD_RULE:
|
||||
xfill_rule = EvenOddRule;
|
||||
break;
|
||||
|
||||
case GDK_WINDING_RULE:
|
||||
xfill_rule = WindingRule;
|
||||
break;
|
||||
}
|
||||
|
||||
xregion = XPolygonRegion ((XPoint *) points, npoints, xfill_rule);
|
||||
private = g_new (GdkRegionPrivate, 1);
|
||||
private->xregion = xregion;
|
||||
region = (GdkRegion *) private;
|
||||
region->user_data = NULL;
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_region_offset (GdkRegion *region,
|
||||
gint dx,
|
||||
gint dy)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
|
||||
g_return_if_fail (region != NULL);
|
||||
|
||||
private = (GdkRegionPrivate *) region;
|
||||
|
||||
XOffsetRegion (private->xregion, dx, dy);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_region_shrink (GdkRegion *region,
|
||||
gint dx,
|
||||
gint dy)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
|
||||
g_return_if_fail (region != NULL);
|
||||
|
||||
private = (GdkRegionPrivate *) region;
|
||||
|
||||
XShrinkRegion (private->xregion, dx, dy);
|
||||
}
|
||||
|
||||
GdkRegion*
|
||||
gdk_region_union_with_rect (GdkRegion *region,
|
||||
GdkRectangle *rect)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
GdkRegion *res;
|
||||
GdkRegionPrivate *res_private;
|
||||
XRectangle xrect;
|
||||
|
||||
g_return_val_if_fail (region != NULL, NULL);
|
||||
|
||||
private = (GdkRegionPrivate *) region;
|
||||
|
||||
xrect.x = rect->x;
|
||||
xrect.y = rect->y;
|
||||
xrect.width = rect->width;
|
||||
xrect.height = rect->height;
|
||||
|
||||
res = gdk_region_new ();
|
||||
res_private = (GdkRegionPrivate *) res;
|
||||
|
||||
XUnionRectWithRegion (&xrect, private->xregion, res_private->xregion);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GdkRegion*
|
||||
gdk_regions_intersect (GdkRegion *source1,
|
||||
GdkRegion *source2)
|
||||
{
|
||||
GdkRegionPrivate *private1;
|
||||
GdkRegionPrivate *private2;
|
||||
GdkRegion *res;
|
||||
GdkRegionPrivate *res_private;
|
||||
|
||||
g_return_val_if_fail (source1 != NULL, NULL);
|
||||
g_return_val_if_fail (source2 != NULL, NULL);
|
||||
|
||||
private1 = (GdkRegionPrivate *) source1;
|
||||
private2 = (GdkRegionPrivate *) source2;
|
||||
|
||||
res = gdk_region_new ();
|
||||
res_private = (GdkRegionPrivate *) res;
|
||||
|
||||
XIntersectRegion (private1->xregion, private2->xregion, res_private->xregion);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GdkRegion*
|
||||
gdk_regions_union (GdkRegion *source1,
|
||||
GdkRegion *source2)
|
||||
{
|
||||
GdkRegionPrivate *private1;
|
||||
GdkRegionPrivate *private2;
|
||||
GdkRegion *res;
|
||||
GdkRegionPrivate *res_private;
|
||||
|
||||
g_return_val_if_fail (source1 != NULL, NULL);
|
||||
g_return_val_if_fail (source2 != NULL, NULL);
|
||||
|
||||
private1 = (GdkRegionPrivate *) source1;
|
||||
private2 = (GdkRegionPrivate *) source2;
|
||||
|
||||
res = gdk_region_new ();
|
||||
res_private = (GdkRegionPrivate *) res;
|
||||
|
||||
XUnionRegion (private1->xregion, private2->xregion, res_private->xregion);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GdkRegion*
|
||||
gdk_regions_subtract (GdkRegion *source1,
|
||||
GdkRegion *source2)
|
||||
{
|
||||
GdkRegionPrivate *private1;
|
||||
GdkRegionPrivate *private2;
|
||||
GdkRegion *res;
|
||||
GdkRegionPrivate *res_private;
|
||||
|
||||
g_return_val_if_fail (source1 != NULL, NULL);
|
||||
g_return_val_if_fail (source2 != NULL, NULL);
|
||||
|
||||
private1 = (GdkRegionPrivate *) source1;
|
||||
private2 = (GdkRegionPrivate *) source2;
|
||||
|
||||
res = gdk_region_new ();
|
||||
res_private = (GdkRegionPrivate *) res;
|
||||
|
||||
XSubtractRegion (private1->xregion, private2->xregion, res_private->xregion);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GdkRegion*
|
||||
gdk_regions_xor (GdkRegion *source1,
|
||||
GdkRegion *source2)
|
||||
{
|
||||
GdkRegionPrivate *private1;
|
||||
GdkRegionPrivate *private2;
|
||||
GdkRegion *res;
|
||||
GdkRegionPrivate *res_private;
|
||||
|
||||
g_return_val_if_fail (source1 != NULL, NULL);
|
||||
g_return_val_if_fail (source2 != NULL, NULL);
|
||||
|
||||
private1 = (GdkRegionPrivate *) source1;
|
||||
private2 = (GdkRegionPrivate *) source2;
|
||||
|
||||
res = gdk_region_new ();
|
||||
res_private = (GdkRegionPrivate *) res;
|
||||
|
||||
XXorRegion (private1->xregion, private2->xregion, res_private->xregion);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,246 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <string.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
#include "gdkx.h"
|
||||
|
||||
|
||||
gint
|
||||
gdk_selection_owner_set (GdkWindow *owner,
|
||||
GdkAtom selection,
|
||||
guint32 time,
|
||||
gint send_event)
|
||||
{
|
||||
Display *xdisplay;
|
||||
Window xwindow;
|
||||
|
||||
if (owner)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
|
||||
private = (GdkWindowPrivate*) owner;
|
||||
if (private->destroyed)
|
||||
return FALSE;
|
||||
|
||||
xdisplay = private->xdisplay;
|
||||
xwindow = private->xwindow;
|
||||
}
|
||||
else
|
||||
{
|
||||
xdisplay = gdk_display;
|
||||
xwindow = None;
|
||||
}
|
||||
|
||||
XSetSelectionOwner (xdisplay, selection, xwindow, time);
|
||||
|
||||
return (XGetSelectionOwner (xdisplay, selection) == xwindow);
|
||||
}
|
||||
|
||||
GdkWindow*
|
||||
gdk_selection_owner_get (GdkAtom selection)
|
||||
{
|
||||
Window xwindow;
|
||||
|
||||
xwindow = XGetSelectionOwner (gdk_display, selection);
|
||||
if (xwindow == None)
|
||||
return NULL;
|
||||
|
||||
return gdk_window_lookup (xwindow);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_selection_convert (GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
|
||||
g_return_if_fail (requestor != NULL);
|
||||
|
||||
private = (GdkWindowPrivate*) requestor;
|
||||
if (private->destroyed)
|
||||
return;
|
||||
|
||||
XConvertSelection (private->xdisplay, selection, target,
|
||||
gdk_selection_property, private->xwindow, time);
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_selection_property_get (GdkWindow *requestor,
|
||||
guchar **data,
|
||||
GdkAtom *ret_type,
|
||||
gint *ret_format)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
gulong nitems;
|
||||
gulong nbytes;
|
||||
gulong length;
|
||||
GdkAtom prop_type;
|
||||
gint prop_format;
|
||||
guchar *t;
|
||||
|
||||
g_return_val_if_fail (requestor != NULL, 0);
|
||||
|
||||
/* If retrieved chunks are typically small, (and the ICCM says the
|
||||
should be) it would be a win to try first with a buffer of
|
||||
moderate length, to avoid two round trips to the server */
|
||||
|
||||
private = (GdkWindowPrivate*) requestor;
|
||||
if (private->destroyed)
|
||||
return 0;
|
||||
|
||||
XGetWindowProperty (private->xdisplay, private->xwindow,
|
||||
gdk_selection_property, 0, 0, False,
|
||||
AnyPropertyType, &prop_type, &prop_format,
|
||||
&nitems, &nbytes, &t);
|
||||
|
||||
if (ret_type)
|
||||
*ret_type = prop_type;
|
||||
if (ret_format)
|
||||
*ret_format = prop_format;
|
||||
|
||||
if (prop_type == None)
|
||||
{
|
||||
*data = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
XFree (t);
|
||||
|
||||
/* Add on an extra byte to handle null termination. X guarantees
|
||||
that t will be 1 longer than nbytes and null terminated */
|
||||
length = nbytes + 1;
|
||||
|
||||
/* We can't delete the selection here, because it might be the INCR
|
||||
protocol, in which case the client has to make sure they'll be
|
||||
notified of PropertyChange events _before_ the property is deleted.
|
||||
Otherwise there's no guarantee we'll win the race ... */
|
||||
XGetWindowProperty (private->xdisplay, private->xwindow,
|
||||
gdk_selection_property, 0, (nbytes + 3) / 4, False,
|
||||
AnyPropertyType, &prop_type, &prop_format,
|
||||
&nitems, &nbytes, &t);
|
||||
|
||||
if (prop_type != None)
|
||||
{
|
||||
*data = g_new (guchar, length);
|
||||
memcpy (*data, t, length);
|
||||
XFree (t);
|
||||
return length-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*data = NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gdk_selection_send_notify (guint32 requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
GdkAtom property,
|
||||
guint32 time)
|
||||
{
|
||||
XSelectionEvent xevent;
|
||||
|
||||
xevent.type = SelectionNotify;
|
||||
xevent.serial = 0;
|
||||
xevent.send_event = True;
|
||||
xevent.display = gdk_display;
|
||||
xevent.requestor = requestor;
|
||||
xevent.selection = selection;
|
||||
xevent.target = target;
|
||||
xevent.property = property;
|
||||
xevent.time = time;
|
||||
|
||||
XSendEvent (gdk_display, requestor, False, NoEventMask, (XEvent*) &xevent);
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_text_property_to_text_list (GdkAtom encoding, gint format,
|
||||
guchar *text, gint length,
|
||||
gchar ***list)
|
||||
{
|
||||
XTextProperty property;
|
||||
gint count = 0;
|
||||
gint res;
|
||||
|
||||
if (!list)
|
||||
return 0;
|
||||
|
||||
property.value = text;
|
||||
property.encoding = encoding;
|
||||
property.format = format;
|
||||
property.nitems = length;
|
||||
res = XmbTextPropertyToTextList (GDK_DISPLAY(), &property, list, &count);
|
||||
|
||||
if (res == XNoMemory || res == XLocaleNotSupported ||
|
||||
res == XConverterNotFound)
|
||||
return 0;
|
||||
else
|
||||
return count;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_free_text_list (gchar **list)
|
||||
{
|
||||
XFreeStringList (list);
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_string_to_compound_text (gchar *str,
|
||||
GdkAtom *encoding, gint *format,
|
||||
guchar **ctext, gint *length)
|
||||
{
|
||||
gint res;
|
||||
XTextProperty property;
|
||||
|
||||
res = XmbTextListToTextProperty (GDK_DISPLAY(),
|
||||
&str, 1, XCompoundTextStyle,
|
||||
&property);
|
||||
if (res != Success)
|
||||
{
|
||||
property.encoding = None;
|
||||
property.format = None;
|
||||
property.value = NULL;
|
||||
property.nitems = 0;
|
||||
}
|
||||
|
||||
if (encoding)
|
||||
*encoding = property.encoding;
|
||||
if (format)
|
||||
*format = property.format;
|
||||
if (ctext)
|
||||
*ctext = property.value;
|
||||
if (length)
|
||||
*length = property.nitems;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void gdk_free_compound_text (guchar *ctext)
|
||||
{
|
||||
if (ctext)
|
||||
XFree (ctext);
|
||||
}
|
@@ -1,443 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
static void gdk_visual_add (GdkVisual *visual);
|
||||
static void gdk_visual_decompose_mask (gulong mask,
|
||||
gint *shift,
|
||||
gint *prec);
|
||||
static guint gdk_visual_hash (Visual *key);
|
||||
static gint gdk_visual_compare (Visual *a,
|
||||
Visual *b);
|
||||
|
||||
|
||||
static GdkVisualPrivate *system_visual;
|
||||
static GdkVisualPrivate *visuals;
|
||||
static gint nvisuals;
|
||||
|
||||
static gint available_depths[4];
|
||||
static gint navailable_depths;
|
||||
|
||||
static GdkVisualType available_types[6];
|
||||
static gint navailable_types;
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
|
||||
static gchar* visual_names[] =
|
||||
{
|
||||
"static gray",
|
||||
"grayscale",
|
||||
"static color",
|
||||
"pseudo color",
|
||||
"true color",
|
||||
"direct color",
|
||||
};
|
||||
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
|
||||
static GHashTable *visual_hash = NULL;
|
||||
|
||||
void
|
||||
gdk_visual_init ()
|
||||
{
|
||||
static gint possible_depths[6] = { 32, 24, 16, 15, 8, 1 };
|
||||
static GdkVisualType possible_types[6] =
|
||||
{
|
||||
GDK_VISUAL_DIRECT_COLOR,
|
||||
GDK_VISUAL_TRUE_COLOR,
|
||||
GDK_VISUAL_PSEUDO_COLOR,
|
||||
GDK_VISUAL_STATIC_COLOR,
|
||||
GDK_VISUAL_GRAYSCALE,
|
||||
GDK_VISUAL_STATIC_GRAY
|
||||
};
|
||||
|
||||
static gint npossible_depths = 6;
|
||||
static gint npossible_types = 6;
|
||||
|
||||
XVisualInfo *visual_list;
|
||||
XVisualInfo visual_template;
|
||||
GdkVisualPrivate temp_visual;
|
||||
Visual *default_xvisual;
|
||||
int nxvisuals;
|
||||
int i, j;
|
||||
|
||||
visual_template.screen = gdk_screen;
|
||||
visual_list = XGetVisualInfo (gdk_display, VisualScreenMask, &visual_template, &nxvisuals);
|
||||
visuals = g_new (GdkVisualPrivate, nxvisuals);
|
||||
|
||||
default_xvisual = DefaultVisual (gdk_display, gdk_screen);
|
||||
|
||||
nvisuals = 0;
|
||||
for (i = 0; i < nxvisuals; i++)
|
||||
{
|
||||
if (visual_list[i].depth >= 1)
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
switch (visual_list[i].c_class)
|
||||
#else /* __cplusplus */
|
||||
switch (visual_list[i].class)
|
||||
#endif /* __cplusplus */
|
||||
{
|
||||
case StaticGray:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_STATIC_GRAY;
|
||||
break;
|
||||
case GrayScale:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_GRAYSCALE;
|
||||
break;
|
||||
case StaticColor:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_STATIC_COLOR;
|
||||
break;
|
||||
case PseudoColor:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_PSEUDO_COLOR;
|
||||
break;
|
||||
case TrueColor:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_TRUE_COLOR;
|
||||
break;
|
||||
case DirectColor:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_DIRECT_COLOR;
|
||||
break;
|
||||
}
|
||||
|
||||
visuals[nvisuals].visual.depth = visual_list[i].depth;
|
||||
visuals[nvisuals].visual.byte_order =
|
||||
(ImageByteOrder(gdk_display) == LSBFirst) ?
|
||||
GDK_LSB_FIRST : GDK_MSB_FIRST;
|
||||
visuals[nvisuals].visual.red_mask = visual_list[i].red_mask;
|
||||
visuals[nvisuals].visual.green_mask = visual_list[i].green_mask;
|
||||
visuals[nvisuals].visual.blue_mask = visual_list[i].blue_mask;
|
||||
visuals[nvisuals].visual.colormap_size = visual_list[i].colormap_size;
|
||||
visuals[nvisuals].visual.bits_per_rgb = visual_list[i].bits_per_rgb;
|
||||
visuals[nvisuals].xvisual = visual_list[i].visual;
|
||||
|
||||
if ((visuals[nvisuals].visual.type == GDK_VISUAL_TRUE_COLOR) ||
|
||||
(visuals[nvisuals].visual.type == GDK_VISUAL_DIRECT_COLOR))
|
||||
{
|
||||
gdk_visual_decompose_mask (visuals[nvisuals].visual.red_mask,
|
||||
&visuals[nvisuals].visual.red_shift,
|
||||
&visuals[nvisuals].visual.red_prec);
|
||||
|
||||
gdk_visual_decompose_mask (visuals[nvisuals].visual.green_mask,
|
||||
&visuals[nvisuals].visual.green_shift,
|
||||
&visuals[nvisuals].visual.green_prec);
|
||||
|
||||
gdk_visual_decompose_mask (visuals[nvisuals].visual.blue_mask,
|
||||
&visuals[nvisuals].visual.blue_shift,
|
||||
&visuals[nvisuals].visual.blue_prec);
|
||||
}
|
||||
else
|
||||
{
|
||||
visuals[nvisuals].visual.red_mask = 0;
|
||||
visuals[nvisuals].visual.red_shift = 0;
|
||||
visuals[nvisuals].visual.red_prec = 0;
|
||||
|
||||
visuals[nvisuals].visual.green_mask = 0;
|
||||
visuals[nvisuals].visual.green_shift = 0;
|
||||
visuals[nvisuals].visual.green_prec = 0;
|
||||
|
||||
visuals[nvisuals].visual.blue_mask = 0;
|
||||
visuals[nvisuals].visual.blue_shift = 0;
|
||||
visuals[nvisuals].visual.blue_prec = 0;
|
||||
}
|
||||
|
||||
nvisuals += 1;
|
||||
}
|
||||
}
|
||||
|
||||
XFree (visual_list);
|
||||
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
{
|
||||
for (j = i+1; j < nvisuals; j++)
|
||||
{
|
||||
if (visuals[j].visual.depth >= visuals[i].visual.depth)
|
||||
{
|
||||
if ((visuals[j].visual.depth == 8) && (visuals[i].visual.depth == 8))
|
||||
{
|
||||
if (visuals[j].visual.type == GDK_VISUAL_PSEUDO_COLOR)
|
||||
{
|
||||
temp_visual = visuals[j];
|
||||
visuals[j] = visuals[i];
|
||||
visuals[i] = temp_visual;
|
||||
}
|
||||
else if ((visuals[i].visual.type != GDK_VISUAL_PSEUDO_COLOR) &&
|
||||
visuals[j].visual.type > visuals[i].visual.type)
|
||||
{
|
||||
temp_visual = visuals[j];
|
||||
visuals[j] = visuals[i];
|
||||
visuals[i] = temp_visual;
|
||||
}
|
||||
}
|
||||
else if ((visuals[j].visual.depth > visuals[i].visual.depth) ||
|
||||
((visuals[j].visual.depth == visuals[i].visual.depth) &&
|
||||
(visuals[j].visual.type > visuals[i].visual.type)))
|
||||
{
|
||||
temp_visual = visuals[j];
|
||||
visuals[j] = visuals[i];
|
||||
visuals[i] = temp_visual;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
if (default_xvisual->visualid == visuals[i].xvisual->visualid)
|
||||
{
|
||||
system_visual = &visuals[i];
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (gdk_debug_flags & GDK_DEBUG_MISC)
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
g_print ("Gdk: visual: %s: %d\n",
|
||||
visual_names[visuals[i].visual.type],
|
||||
visuals[i].visual.depth);
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
|
||||
navailable_depths = 0;
|
||||
for (i = 0; i < npossible_depths; i++)
|
||||
{
|
||||
for (j = 0; j < nvisuals; j++)
|
||||
{
|
||||
if (visuals[j].visual.depth == possible_depths[i])
|
||||
{
|
||||
available_depths[navailable_depths++] = visuals[j].visual.depth;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (navailable_depths == 0)
|
||||
g_error ("unable to find a usable depth");
|
||||
|
||||
navailable_types = 0;
|
||||
for (i = 0; i < npossible_types; i++)
|
||||
{
|
||||
for (j = 0; j < nvisuals; j++)
|
||||
{
|
||||
if (visuals[j].visual.type == possible_types[i])
|
||||
{
|
||||
available_types[navailable_types++] = visuals[j].visual.type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
gdk_visual_add ((GdkVisual*) &visuals[i]);
|
||||
|
||||
if (npossible_types == 0)
|
||||
g_error ("unable to find a usable visual type");
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_ref (GdkVisual *visual)
|
||||
{
|
||||
return visual;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_visual_unref (GdkVisual *visual)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_visual_get_best_depth ()
|
||||
{
|
||||
return available_depths[0];
|
||||
}
|
||||
|
||||
GdkVisualType
|
||||
gdk_visual_get_best_type ()
|
||||
{
|
||||
return available_types[0];
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_system ()
|
||||
{
|
||||
return ((GdkVisual*) system_visual);
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_best ()
|
||||
{
|
||||
return ((GdkVisual*) &(visuals[0]));
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_best_with_depth (gint depth)
|
||||
{
|
||||
GdkVisual *return_val;
|
||||
int i;
|
||||
|
||||
return_val = NULL;
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
if (depth == visuals[i].visual.depth)
|
||||
{
|
||||
return_val = (GdkVisual*) &(visuals[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_best_with_type (GdkVisualType visual_type)
|
||||
{
|
||||
GdkVisual *return_val;
|
||||
int i;
|
||||
|
||||
return_val = NULL;
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
if (visual_type == visuals[i].visual.type)
|
||||
{
|
||||
return_val = (GdkVisual*) &(visuals[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_best_with_both (gint depth,
|
||||
GdkVisualType visual_type)
|
||||
{
|
||||
GdkVisual *return_val;
|
||||
int i;
|
||||
|
||||
return_val = NULL;
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
if ((depth == visuals[i].visual.depth) &&
|
||||
(visual_type == visuals[i].visual.type))
|
||||
{
|
||||
return_val = (GdkVisual*) &(visuals[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_query_depths (gint **depths,
|
||||
gint *count)
|
||||
{
|
||||
*count = navailable_depths;
|
||||
*depths = available_depths;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_query_visual_types (GdkVisualType **visual_types,
|
||||
gint *count)
|
||||
{
|
||||
*count = navailable_types;
|
||||
*visual_types = available_types;
|
||||
}
|
||||
|
||||
GList*
|
||||
gdk_list_visuals (void)
|
||||
{
|
||||
GList *list;
|
||||
guint i;
|
||||
|
||||
list = NULL;
|
||||
for (i = 0; i < nvisuals; ++i)
|
||||
list = g_list_append (list, (gpointer) &visuals[i]);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_lookup (Visual *xvisual)
|
||||
{
|
||||
GdkVisual *visual;
|
||||
|
||||
if (!visual_hash)
|
||||
return NULL;
|
||||
|
||||
visual = g_hash_table_lookup (visual_hash, xvisual);
|
||||
return visual;
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdkx_visual_get (VisualID xvisualid)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
if (xvisualid == visuals[i].xvisual->visualid)
|
||||
return (GdkVisual*) &visuals[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gdk_visual_add (GdkVisual *visual)
|
||||
{
|
||||
GdkVisualPrivate *private;
|
||||
|
||||
if (!visual_hash)
|
||||
visual_hash = g_hash_table_new ((GHashFunc) gdk_visual_hash,
|
||||
(GCompareFunc) gdk_visual_compare);
|
||||
|
||||
private = (GdkVisualPrivate*) visual;
|
||||
|
||||
g_hash_table_insert (visual_hash, private->xvisual, visual);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_visual_decompose_mask (gulong mask,
|
||||
gint *shift,
|
||||
gint *prec)
|
||||
{
|
||||
*shift = 0;
|
||||
*prec = 0;
|
||||
|
||||
while (!(mask & 0x1))
|
||||
{
|
||||
(*shift)++;
|
||||
mask >>= 1;
|
||||
}
|
||||
|
||||
while (mask & 0x1)
|
||||
{
|
||||
(*prec)++;
|
||||
mask >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
static guint
|
||||
gdk_visual_hash (Visual *key)
|
||||
{
|
||||
return key->visualid;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_visual_compare (Visual *a,
|
||||
Visual *b)
|
||||
{
|
||||
return (a->visualid == b->visualid);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,49 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
#ifndef __GDK_X_H__
|
||||
#define __GDK_X_H__
|
||||
|
||||
#include <gdk/gdkprivate.h>
|
||||
|
||||
|
||||
#define GDK_ROOT_WINDOW() gdk_root_window
|
||||
#define GDK_ROOT_PARENT() ((GdkWindow *)&gdk_root_parent)
|
||||
#define GDK_DISPLAY() gdk_display
|
||||
#define GDK_WINDOW_XDISPLAY(win) (((GdkWindowPrivate*) win)->xdisplay)
|
||||
#define GDK_WINDOW_XWINDOW(win) (((GdkWindowPrivate*) win)->xwindow)
|
||||
#define GDK_IMAGE_XDISPLAY(image) (((GdkImagePrivate*) image)->xdisplay)
|
||||
#define GDK_IMAGE_XIMAGE(image) (((GdkImagePrivate*) image)->ximage)
|
||||
#define GDK_GC_XDISPLAY(gc) (((GdkGCPrivate*) gc)->xdisplay)
|
||||
#define GDK_GC_XGC(gc) (((GdkGCPrivate*) gc)->xgc)
|
||||
#define GDK_COLORMAP_XDISPLAY(cmap) (((GdkColormapPrivate*) cmap)->xdisplay)
|
||||
#define GDK_COLORMAP_XCOLORMAP(cmap) (((GdkColormapPrivate*) cmap)->xcolormap)
|
||||
#define GDK_VISUAL_XVISUAL(vis) (((GdkVisualPrivate*) vis)->xvisual)
|
||||
#define GDK_FONT_XDISPLAY(font) (((GdkFontPrivate*) font)->xdisplay)
|
||||
#define GDK_FONT_XFONT(font) (((GdkFontPrivate*) font)->xfont)
|
||||
|
||||
|
||||
GdkVisual* gdkx_visual_get (VisualID xvisualid);
|
||||
GdkColormap* gdkx_colormap_get (Colormap xcolormap);
|
||||
/* Utility function in gdk.c - not sure where it belongs, but it's
|
||||
needed in more than one place, so make it public */
|
||||
Window gdk_get_client_window (Display *dpy,
|
||||
Window win);
|
||||
|
||||
|
||||
#endif /* __GDK_X_H__ */
|
@@ -1,75 +0,0 @@
|
||||
/* 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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
#include "gdkprivate.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static guint gdk_xid_hash (XID *xid);
|
||||
static gint gdk_xid_compare (XID *a,
|
||||
XID *b);
|
||||
|
||||
|
||||
GHashTable *xid_ht = NULL;
|
||||
|
||||
|
||||
void
|
||||
gdk_xid_table_insert (XID *xid,
|
||||
gpointer data)
|
||||
{
|
||||
g_return_if_fail (xid != NULL);
|
||||
|
||||
if (!xid_ht)
|
||||
xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
|
||||
(GCompareFunc) gdk_xid_compare);
|
||||
|
||||
g_hash_table_insert (xid_ht, xid, data);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_xid_table_remove (XID xid)
|
||||
{
|
||||
if (!xid_ht)
|
||||
xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
|
||||
(GCompareFunc) gdk_xid_compare);
|
||||
|
||||
g_hash_table_remove (xid_ht, &xid);
|
||||
}
|
||||
|
||||
gpointer
|
||||
gdk_xid_table_lookup (XID xid)
|
||||
{
|
||||
gpointer data;
|
||||
|
||||
data = g_hash_table_lookup (xid_ht, &xid);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
static guint
|
||||
gdk_xid_hash (XID *xid)
|
||||
{
|
||||
return *xid;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_xid_compare (XID *a,
|
||||
XID *b)
|
||||
{
|
||||
return (*a == *b);
|
||||
}
|
844
gdk/x11/gxid.c
844
gdk/x11/gxid.c
@@ -1,844 +0,0 @@
|
||||
/*
|
||||
* gxid version 0.3
|
||||
*
|
||||
* Copyright 1997 Owen Taylor <owt1@cornell.edu>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/XInput.h>
|
||||
|
||||
#include "gxid_proto.h"
|
||||
|
||||
/* #define DEBUG_CLIENTS */
|
||||
/* #define DEBUG_EVENTS */
|
||||
|
||||
char *program_name;
|
||||
Display *dpy;
|
||||
Window root_window; /* default root window of dpy */
|
||||
int port = 0; /* port to listen on */
|
||||
int socket_fd = 0; /* file descriptor of socket */
|
||||
typedef struct GxidWindow_ GxidWindow;
|
||||
|
||||
typedef struct GxidDevice_ GxidDevice;
|
||||
struct GxidDevice_ {
|
||||
XID id;
|
||||
int exclusive;
|
||||
int ispointer;
|
||||
|
||||
XDevice *xdevice;
|
||||
int motionnotify_type;
|
||||
int changenotify_type;
|
||||
};
|
||||
|
||||
struct GxidWindow_ {
|
||||
Window xwindow;
|
||||
/* Immediate child of root that is ancestor of window */
|
||||
Window root_child;
|
||||
int num_devices;
|
||||
GxidDevice **devices;
|
||||
};
|
||||
|
||||
GxidDevice **devices = NULL;
|
||||
int num_devices = 0;
|
||||
GxidWindow **windows = NULL;
|
||||
int num_windows = 0;
|
||||
|
||||
void
|
||||
handler(int signal)
|
||||
{
|
||||
fprintf(stderr,"%s: dying on signal %d\n",program_name,signal);
|
||||
if (socket_fd)
|
||||
close(socket_fd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
init_socket()
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
|
||||
socket_fd = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
|
||||
if (socket_fd < 0)
|
||||
{
|
||||
fprintf (stderr, "%s: error getting socket\n",
|
||||
program_name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(port);
|
||||
sin.sin_addr.s_addr = INADDR_ANY;
|
||||
|
||||
if (bind(socket_fd,(struct sockaddr *)(&sin),
|
||||
sizeof(struct sockaddr_in)) < 0)
|
||||
{
|
||||
fprintf (stderr,"%s: cannot bind to port %d\n",
|
||||
program_name,port);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (listen(socket_fd,5) < 0)
|
||||
{
|
||||
fprintf (stderr,"%s: error listening on socket\n",
|
||||
program_name);
|
||||
exit(1);
|
||||
};
|
||||
}
|
||||
|
||||
#define NUM_EVENTC 2
|
||||
static void
|
||||
enable_device(GxidDevice *dev)
|
||||
{
|
||||
XEventClass xevc[NUM_EVENTC];
|
||||
int num_eventc = NUM_EVENTC;
|
||||
int i,j;
|
||||
|
||||
if (!dev->xdevice)
|
||||
{
|
||||
if (dev->ispointer) return;
|
||||
|
||||
dev->xdevice = XOpenDevice(dpy, dev->id);
|
||||
if (!dev->xdevice) return;
|
||||
|
||||
DeviceMotionNotify (dev->xdevice, dev->motionnotify_type,
|
||||
xevc[0]);
|
||||
ChangeDeviceNotify (dev->xdevice, dev->changenotify_type,
|
||||
xevc[1]);
|
||||
|
||||
/* compress out zero event classes */
|
||||
for (i=0,j=0;i<NUM_EVENTC;i++)
|
||||
{
|
||||
if (xevc[i]) {
|
||||
xevc[j] = xevc[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
num_eventc = j;
|
||||
|
||||
XSelectExtensionEvent (dpy, root_window, xevc, num_eventc);
|
||||
}
|
||||
}
|
||||
|
||||
/* switch the core pointer from whatever it is now to something else,
|
||||
return true on success, false otherwise */
|
||||
static int
|
||||
switch_core_pointer()
|
||||
{
|
||||
GxidDevice *old_pointer = 0;
|
||||
GxidDevice *new_pointer = 0;
|
||||
int result;
|
||||
int i;
|
||||
|
||||
for (i=0;i<num_devices;i++)
|
||||
{
|
||||
if (devices[i]->ispointer)
|
||||
old_pointer = devices[i];
|
||||
else
|
||||
if (!new_pointer && !devices[i]->exclusive)
|
||||
new_pointer = devices[i];
|
||||
}
|
||||
|
||||
if (!old_pointer || !new_pointer)
|
||||
return 0;
|
||||
|
||||
#ifdef DEBUG_EVENTS
|
||||
fprintf(stderr,"gxid: Switching core from %ld to %ld\n",
|
||||
old_pointer->id,new_pointer->id);
|
||||
#endif
|
||||
result = XChangePointerDevice(dpy,new_pointer->xdevice, 0, 1);
|
||||
if (result != Success)
|
||||
{
|
||||
fprintf(stderr,"gxid: Error %d switching core from %ld to %ld\n",
|
||||
result, old_pointer->id, new_pointer->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_pointer->ispointer = 1;
|
||||
old_pointer->ispointer = 0;
|
||||
if (!old_pointer->xdevice)
|
||||
enable_device(old_pointer);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
disable_device(GxidDevice *dev)
|
||||
{
|
||||
if (dev->xdevice)
|
||||
{
|
||||
if (dev->ispointer)
|
||||
return;
|
||||
XCloseDevice(dpy,dev->xdevice);
|
||||
dev->xdevice = 0;
|
||||
}
|
||||
}
|
||||
|
||||
GxidDevice *
|
||||
init_device(XDeviceInfo *xdevice)
|
||||
{
|
||||
GxidDevice *dev = (GxidDevice *)malloc(sizeof(GxidDevice));
|
||||
XAnyClassPtr class;
|
||||
int num_axes, i;
|
||||
|
||||
dev->id = xdevice->id;
|
||||
dev->exclusive = 0;
|
||||
dev->xdevice = NULL;
|
||||
|
||||
dev->ispointer = (xdevice->use == IsXPointer);
|
||||
|
||||
/* step through the classes */
|
||||
|
||||
num_axes = 0;
|
||||
class = xdevice->inputclassinfo;
|
||||
for (i=0;i<xdevice->num_classes;i++)
|
||||
{
|
||||
if (class->class == ValuatorClass)
|
||||
{
|
||||
XValuatorInfo *xvi = (XValuatorInfo *)class;
|
||||
num_axes = xvi->num_axes;
|
||||
}
|
||||
class = (XAnyClassPtr)(((char *)class) + class->length);
|
||||
}
|
||||
|
||||
/* return NULL if insufficient axes */
|
||||
if (num_axes < 2)
|
||||
{
|
||||
free((void *)dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!dev->ispointer)
|
||||
enable_device(dev);
|
||||
return dev;
|
||||
}
|
||||
|
||||
void
|
||||
init_xinput()
|
||||
{
|
||||
char **extensions;
|
||||
XDeviceInfo *xdevices;
|
||||
int num_xdevices;
|
||||
int num_extensions;
|
||||
int i;
|
||||
|
||||
extensions = XListExtensions(dpy, &num_extensions);
|
||||
for (i = 0; i < num_extensions &&
|
||||
(strcmp(extensions[i], "XInputExtension") != 0); i++);
|
||||
XFreeExtensionList(extensions);
|
||||
if (i == num_extensions) /* XInput extension not found */
|
||||
{
|
||||
fprintf(stderr,"XInput extension not found\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
xdevices = XListInputDevices(dpy, &num_xdevices);
|
||||
devices = (GxidDevice **)malloc(num_xdevices * sizeof(GxidDevice *));
|
||||
|
||||
num_devices = 0;
|
||||
for(i=0; i<num_xdevices; i++)
|
||||
{
|
||||
GxidDevice *dev = init_device(&xdevices[i]);
|
||||
if (dev)
|
||||
devices[num_devices++] = dev;
|
||||
}
|
||||
XFreeDeviceList(xdevices);
|
||||
}
|
||||
|
||||
/* If this routine needs fixing, the corresponding routine
|
||||
in gdkinputgxi.h will need it too. */
|
||||
|
||||
Window
|
||||
gxi_find_root_child(Display *dpy, Window w)
|
||||
{
|
||||
Window root,parent;
|
||||
Window *children;
|
||||
int nchildren;
|
||||
|
||||
parent = w;
|
||||
do
|
||||
{
|
||||
w = parent;
|
||||
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
|
||||
if (children) XFree(children);
|
||||
}
|
||||
while (parent != root);
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
int
|
||||
handle_claim_device(GxidClaimDevice *msg)
|
||||
{
|
||||
int i,j;
|
||||
XID devid = ntohl(msg->device);
|
||||
XID winid = ntohl(msg->window);
|
||||
int exclusive = ntohl(msg->exclusive);
|
||||
GxidDevice *device = NULL;
|
||||
GxidWindow *window = NULL;
|
||||
|
||||
#ifdef DEBUG_CLIENTS
|
||||
fprintf(stderr,"device %ld claimed (window 0x%lx)\n",devid,winid);
|
||||
#endif
|
||||
|
||||
for (i=0;i<num_devices;i++)
|
||||
{
|
||||
if (devices[i]->id == devid)
|
||||
{
|
||||
device = devices[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!device)
|
||||
{
|
||||
fprintf(stderr,"%s: Unknown device id %ld\n",program_name,devid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (device->exclusive)
|
||||
{
|
||||
/* already in use */
|
||||
fprintf(stderr,
|
||||
"%s: Device %ld already claimed in exclusive mode\n",
|
||||
program_name,devid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (exclusive)
|
||||
{
|
||||
for (i=0;i<num_windows;i++)
|
||||
{
|
||||
for (j=0;j<windows[i]->num_devices;j++)
|
||||
if (windows[i]->devices[j]->id == devid)
|
||||
{
|
||||
/* already in use */
|
||||
fprintf(stderr,
|
||||
"%s: Can't establish exclusive use of device %ld\n",
|
||||
program_name,devid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
if (device->ispointer)
|
||||
if (!switch_core_pointer())
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: Can't free up core pointer %ld\n",
|
||||
program_name,devid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
device->exclusive = 1;
|
||||
disable_device(device);
|
||||
XSelectInput(dpy,winid,StructureNotifyMask);
|
||||
}
|
||||
else /* !exclusive */
|
||||
{
|
||||
/* FIXME: this is a bit improper. We probably should do this only
|
||||
when a window is first claimed. But we might be fooled if
|
||||
an old client died without releasing it's windows. So until
|
||||
we look for client-window closings, do it here
|
||||
|
||||
(We do look for closings now...)
|
||||
*/
|
||||
|
||||
XSelectInput(dpy,winid,EnterWindowMask|StructureNotifyMask);
|
||||
}
|
||||
|
||||
for (i=0;i<num_windows;i++)
|
||||
{
|
||||
if (windows[i]->xwindow == winid)
|
||||
{
|
||||
window = windows[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create window structure if no devices have been previously
|
||||
claimed on it */
|
||||
if (!window)
|
||||
{
|
||||
num_windows++;
|
||||
windows = (GxidWindow **)realloc(windows,
|
||||
sizeof(GxidWindow*)*num_windows);
|
||||
window = (GxidWindow *)malloc(sizeof(GxidWindow));
|
||||
windows[num_windows-1] = window;
|
||||
|
||||
window->xwindow = winid;
|
||||
window->root_child = gxi_find_root_child(dpy,winid);
|
||||
window->num_devices = 0;
|
||||
window->devices = 0;
|
||||
}
|
||||
|
||||
|
||||
for (i=0;i<window->num_devices;i++)
|
||||
{
|
||||
if (window->devices[i] == device)
|
||||
return GXID_RETURN_OK;
|
||||
}
|
||||
|
||||
window->num_devices++;
|
||||
window->devices = (GxidDevice **)realloc(window->devices,
|
||||
sizeof(GxidDevice*)*num_devices);
|
||||
/* we need add the device to the window */
|
||||
window->devices[i] = device;
|
||||
|
||||
return GXID_RETURN_OK;
|
||||
}
|
||||
|
||||
int
|
||||
handle_release_device(GxidReleaseDevice *msg)
|
||||
{
|
||||
int i,j;
|
||||
XID devid = ntohl(msg->device);
|
||||
XID winid = ntohl(msg->window);
|
||||
|
||||
GxidDevice *device = NULL;
|
||||
|
||||
#ifdef DEBUG_CLIENTS
|
||||
fprintf(stderr,"device %ld released (window 0x%lx)\n",devid,winid);
|
||||
#endif
|
||||
|
||||
for (i=0;i<num_devices;i++)
|
||||
{
|
||||
if (devices[i]->id == devid)
|
||||
{
|
||||
device = devices[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!device)
|
||||
{
|
||||
fprintf(stderr,"%s: Unknown device id %ld\n",program_name,devid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
for (i=0;i<num_windows;i++)
|
||||
{
|
||||
GxidWindow *w = windows[i];
|
||||
|
||||
if (w->xwindow == winid)
|
||||
for (j=0;j<w->num_devices;j++)
|
||||
if (w->devices[j]->id == devid)
|
||||
{
|
||||
if (j<w->num_devices-1)
|
||||
w->devices[j] = w->devices[w->num_devices-1];
|
||||
w->num_devices--;
|
||||
|
||||
if (w->num_devices == 0)
|
||||
{
|
||||
if (i<num_windows-1)
|
||||
windows[i] = windows[num_windows-1];
|
||||
num_windows--;
|
||||
|
||||
free((void *)w);
|
||||
/* FIXME: should we deselect input? But what
|
||||
what if window is already destroyed */
|
||||
}
|
||||
|
||||
if (device->exclusive)
|
||||
{
|
||||
device->exclusive = 0;
|
||||
enable_device(device);
|
||||
}
|
||||
return GXID_RETURN_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/* device/window combination not found */
|
||||
fprintf(stderr,
|
||||
"%s: Device %ld not claimed for window 0x%lx\n",
|
||||
program_name,devid,winid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
void
|
||||
handle_connection()
|
||||
{
|
||||
GxidMessage msg;
|
||||
GxidU32 type;
|
||||
int length;
|
||||
GxidI32 retval;
|
||||
|
||||
int conn_fd;
|
||||
struct sockaddr_in sin;
|
||||
int sin_length;
|
||||
int count;
|
||||
|
||||
sin_length = sizeof(struct sockaddr_in);
|
||||
conn_fd = accept(socket_fd,(struct sockaddr *)&sin,&sin_length);
|
||||
if (conn_fd < 0)
|
||||
{
|
||||
fprintf(stderr,"%s: Error accepting connection\n",
|
||||
program_name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* read type and length of message */
|
||||
|
||||
count = read(conn_fd,(char *)&msg,2*sizeof(GxidU32));
|
||||
if (count != 2*sizeof(GxidU32))
|
||||
{
|
||||
fprintf(stderr,"%s: Error reading message header\n",
|
||||
program_name);
|
||||
close(conn_fd);
|
||||
return;
|
||||
}
|
||||
type = ntohl(msg.any.type);
|
||||
length = ntohl(msg.any.length);
|
||||
|
||||
/* read rest of message */
|
||||
|
||||
if (length > sizeof(GxidMessage))
|
||||
{
|
||||
fprintf(stderr,"%s: Bad message length\n",
|
||||
program_name);
|
||||
close(conn_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
count = read(conn_fd,2*sizeof(GxidU32) + (char *)&msg,
|
||||
length - 2*sizeof(GxidU32));
|
||||
if (count != length - 2*sizeof(GxidU32))
|
||||
{
|
||||
fprintf(stderr,"%s: Error reading message body\n",
|
||||
program_name);
|
||||
close(conn_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GXID_CLAIM_DEVICE:
|
||||
retval = handle_claim_device((GxidClaimDevice *)&msg);
|
||||
break;
|
||||
case GXID_RELEASE_DEVICE:
|
||||
retval = handle_release_device((GxidReleaseDevice *)&msg);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"%s: Unknown message type: %ld (ignoring)\n",
|
||||
program_name,type);
|
||||
close(conn_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
count = write(conn_fd,&retval,sizeof(GxidI32));
|
||||
if (count != sizeof(GxidI32))
|
||||
{
|
||||
fprintf(stderr,"%s: Error writing return code\n",
|
||||
program_name);
|
||||
}
|
||||
|
||||
close(conn_fd);
|
||||
}
|
||||
|
||||
void
|
||||
handle_motion_notify(XDeviceMotionEvent *event)
|
||||
{
|
||||
int i,j;
|
||||
GxidDevice *old_device = NULL;
|
||||
GxidDevice *new_device = NULL;
|
||||
Window w, root, child;
|
||||
int root_x, root_y, x, y, mask;
|
||||
|
||||
for (j=0;j<num_devices;j++)
|
||||
{
|
||||
if (devices[j]->ispointer)
|
||||
old_device = devices[j];
|
||||
if (devices[j]->id == event->deviceid)
|
||||
new_device = devices[j];
|
||||
}
|
||||
|
||||
if (new_device && !new_device->exclusive && !new_device->ispointer)
|
||||
{
|
||||
/* make sure we aren't stealing the pointer back from a slow
|
||||
client */
|
||||
child = root_window;
|
||||
do
|
||||
{
|
||||
w = child;
|
||||
/* FIXME: this fails disasterously if child vanishes between
|
||||
calls. (Which is prone to happening since we get events
|
||||
on root just as the client exits) */
|
||||
|
||||
XQueryPointer(dpy,w,&root,&child,&root_x,&root_y,
|
||||
&x,&y,&mask);
|
||||
}
|
||||
while (child != None);
|
||||
|
||||
for (i=0;i<num_windows;i++)
|
||||
if (windows[i]->xwindow == w)
|
||||
for (j=0;j<windows[i]->num_devices;j++)
|
||||
if (windows[i]->devices[j] == new_device)
|
||||
return;
|
||||
|
||||
/* FIXME: do something smarter with axes */
|
||||
XChangePointerDevice(dpy,new_device->xdevice, 0, 1);
|
||||
new_device->ispointer = 1;
|
||||
|
||||
old_device->ispointer = 0;
|
||||
if (!old_device->xdevice)
|
||||
enable_device(old_device);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_change_notify(XChangeDeviceNotifyEvent *event)
|
||||
{
|
||||
int j;
|
||||
GxidDevice *old_device = NULL;
|
||||
GxidDevice *new_device = NULL;
|
||||
|
||||
|
||||
for (j=0;j<num_devices;j++)
|
||||
{
|
||||
if (devices[j]->ispointer)
|
||||
old_device = devices[j];
|
||||
if (devices[j]->id == event->deviceid)
|
||||
new_device = devices[j];
|
||||
}
|
||||
|
||||
#ifdef DEBUG_EVENTS
|
||||
fprintf(stderr,"gxid: ChangeNotify event; old = %ld; new = %ld\n",
|
||||
old_device->id, new_device->id);
|
||||
#endif
|
||||
|
||||
if (old_device != new_device)
|
||||
{
|
||||
new_device->ispointer = 1;
|
||||
|
||||
old_device->ispointer = 0;
|
||||
if (!old_device->xdevice)
|
||||
enable_device(old_device);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_enter_notify(XEnterWindowEvent *event, GxidWindow *window)
|
||||
{
|
||||
int i;
|
||||
GxidDevice *old_pointer = NULL;
|
||||
for (i=0;i<num_devices;i++)
|
||||
{
|
||||
if (devices[i]->ispointer)
|
||||
{
|
||||
old_pointer = devices[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_EVENTS
|
||||
fprintf(stderr,"gxid: Enter event; oldpointer = %ld\n",
|
||||
old_pointer->id);
|
||||
#endif
|
||||
|
||||
if (old_pointer)
|
||||
for (i=0;i<window->num_devices;i++)
|
||||
{
|
||||
if (window->devices[i] == old_pointer)
|
||||
{
|
||||
switch_core_pointer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_destroy_notify(XDestroyWindowEvent *event)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
for (i=0;i<num_windows;i++)
|
||||
if (windows[i]->xwindow == event->window)
|
||||
{
|
||||
GxidWindow *w = windows[i];
|
||||
|
||||
for (j=0;j<w->num_devices;j++)
|
||||
{
|
||||
#ifdef DEBUG_CLIENTS
|
||||
fprintf(stderr,"device %ld released on destruction of window 0x%lx.\n",
|
||||
w->devices[j]->id,w->xwindow);
|
||||
#endif
|
||||
|
||||
if (w->devices[j]->exclusive)
|
||||
{
|
||||
w->devices[j]->exclusive = 0;
|
||||
enable_device(devices[j]);
|
||||
}
|
||||
}
|
||||
|
||||
if (i<num_windows-1)
|
||||
windows[i] = windows[num_windows-1];
|
||||
num_windows--;
|
||||
|
||||
if (w->devices)
|
||||
free((void *)w->devices);
|
||||
free((void *)w);
|
||||
/* FIXME: should we deselect input? But what
|
||||
what if window is already destroyed */
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_xevent()
|
||||
{
|
||||
int i;
|
||||
XEvent event;
|
||||
|
||||
XNextEvent (dpy, &event);
|
||||
|
||||
#ifdef DEBUG_EVENTS
|
||||
fprintf(stderr,"Event - type = %d; window = 0x%lx\n",
|
||||
event.type,event.xany.window);
|
||||
#endif
|
||||
|
||||
if (event.type == ConfigureNotify)
|
||||
{
|
||||
#ifdef DEBUG_EVENTS
|
||||
XConfigureEvent *xce = (XConfigureEvent *)&event;
|
||||
fprintf(stderr," configureNotify: window = 0x%lx\n",xce->window);
|
||||
#endif
|
||||
}
|
||||
else if (event.type == EnterNotify)
|
||||
{
|
||||
/* pointer entered a claimed window */
|
||||
for (i=0;i<num_windows;i++)
|
||||
{
|
||||
if (event.xany.window == windows[i]->xwindow)
|
||||
handle_enter_notify((XEnterWindowEvent *)&event,windows[i]);
|
||||
}
|
||||
}
|
||||
else if (event.type == DestroyNotify)
|
||||
{
|
||||
/* A claimed window was destroyed */
|
||||
for (i=0;i<num_windows;i++)
|
||||
{
|
||||
if (event.xany.window == windows[i]->xwindow)
|
||||
handle_destroy_notify((XDestroyWindowEvent *)&event);
|
||||
}
|
||||
}
|
||||
else
|
||||
for (i=0;i<num_devices;i++)
|
||||
{
|
||||
if (event.type == devices[i]->motionnotify_type)
|
||||
{
|
||||
handle_motion_notify((XDeviceMotionEvent *)&event);
|
||||
break;
|
||||
}
|
||||
else if (event.type == devices[i]->changenotify_type)
|
||||
{
|
||||
handle_change_notify((XChangeDeviceNotifyEvent *)&event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr,"Usage: %s [-d display] [-p --gxid-port port]\n",
|
||||
program_name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char *display_name = NULL;
|
||||
fd_set readfds;
|
||||
|
||||
program_name = argv[0];
|
||||
|
||||
for (i=1;i<argc;i++)
|
||||
{
|
||||
if (!strcmp(argv[i],"-d"))
|
||||
{
|
||||
if (++i >= argc) usage();
|
||||
display_name = argv[i];
|
||||
}
|
||||
else if (!strcmp(argv[i],"--gxid-port") ||
|
||||
!strcmp(argv[i],"-p"))
|
||||
{
|
||||
if (++i >= argc) usage();
|
||||
port = atoi(argv[i]);
|
||||
break;
|
||||
}
|
||||
else
|
||||
usage();
|
||||
}
|
||||
|
||||
if (!port)
|
||||
{
|
||||
char *t = getenv("GXID_PORT");
|
||||
if (t)
|
||||
port = atoi(t);
|
||||
else
|
||||
port = 6951;
|
||||
}
|
||||
/* set up a signal handler so we can clean up if killed */
|
||||
|
||||
signal(SIGTERM,handler);
|
||||
signal(SIGINT,handler);
|
||||
|
||||
/* initialize the X connection */
|
||||
|
||||
dpy = XOpenDisplay (display_name);
|
||||
if (!dpy)
|
||||
{
|
||||
fprintf (stderr, "%s: unable to open display '%s'\n",
|
||||
program_name, XDisplayName (display_name));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
root_window = DefaultRootWindow(dpy);
|
||||
|
||||
/* We'll want to do this in the future if we are to support
|
||||
gxid monitoring visibility information for clients */
|
||||
#if 0
|
||||
XSelectInput(dpy,root_window,SubstructureNotifyMask);
|
||||
#endif
|
||||
init_xinput();
|
||||
|
||||
/* set up our server connection */
|
||||
|
||||
init_socket();
|
||||
|
||||
/* main loop */
|
||||
|
||||
if (XPending(dpy)) /* this seems necessary to get things
|
||||
in sync */
|
||||
handle_xevent();
|
||||
while (1)
|
||||
{
|
||||
|
||||
FD_ZERO(&readfds);
|
||||
FD_SET(ConnectionNumber(dpy),&readfds);
|
||||
FD_SET(socket_fd,&readfds);
|
||||
|
||||
if (select(8*sizeof(readfds),&readfds,
|
||||
(fd_set *)0,(fd_set *)0, (struct timeval *)0) < 0)
|
||||
{
|
||||
fprintf(stderr,"Error in select\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (FD_ISSET(socket_fd,&readfds))
|
||||
handle_connection(socket_fd);
|
||||
|
||||
while (XPending(dpy))
|
||||
handle_xevent();
|
||||
}
|
||||
|
||||
XCloseDisplay (dpy);
|
||||
exit (0);
|
||||
}
|
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
* gxid version 0.3
|
||||
*
|
||||
* Copyright 1997 Owen Taylor <owt1@cornell.edu>
|
||||
*/
|
||||
|
||||
#include "../config.h"
|
||||
#include "gxid_lib.h"
|
||||
|
||||
#ifdef XINPUT_GXI
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
|
||||
/* handles mechanics of communicating with a client */
|
||||
static int
|
||||
gxid_send_message(char *host, int port, GxidMessage *msg)
|
||||
{
|
||||
int socket_fd;
|
||||
struct sockaddr_in sin;
|
||||
int count;
|
||||
GxidI32 retval;
|
||||
struct hostent *he;
|
||||
|
||||
if (!port) port = 6951;
|
||||
|
||||
if (!host || strcmp(host,"localhost") )
|
||||
{
|
||||
/* looking it up as localhost can be _SLOW_ on ppp systems */
|
||||
/* FIXME: Could localhost be anything other than loopback? */
|
||||
host = "127.0.0.1";
|
||||
}
|
||||
|
||||
he = gethostbyname(host);
|
||||
if (!he)
|
||||
{
|
||||
fprintf(stderr,"gxid_lib: error looking up %s\n",host);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
sin.sin_family = he->h_addrtype;
|
||||
sin.sin_port = htons(port);
|
||||
memcpy(&sin.sin_addr,he->h_addr_list[0],he->h_length);
|
||||
|
||||
socket_fd = socket(AF_INET,SOCK_STREAM,0);
|
||||
if (socket_fd < 0)
|
||||
{
|
||||
fprintf(stderr,"gxid_lib: can't get socket");
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (connect(socket_fd, (struct sockaddr *)&sin,
|
||||
sizeof sin) < 0)
|
||||
{
|
||||
fprintf(stderr,"gxid_lib: can't connect to %s:%d\n",host,port);
|
||||
close(socket_fd);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
count = write(socket_fd,(char *)msg,ntohl(msg->any.length));
|
||||
if (count != ntohl(msg->any.length))
|
||||
{
|
||||
fprintf(stderr,"gxid_lib: error writing");
|
||||
close(socket_fd);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
/* now read the return code */
|
||||
count = read(socket_fd,(char *)&retval,sizeof(GxidI32));
|
||||
if (count != sizeof(GxidI32))
|
||||
{
|
||||
fprintf(stderr,"gxid_lib: error reading return code");
|
||||
close(socket_fd);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
close (socket_fd);
|
||||
return ntohl(retval);
|
||||
}
|
||||
|
||||
/* claim a device. If exclusive, device is claimed exclusively */
|
||||
int
|
||||
gxid_claim_device(char *host, int port, GxidU32 device, GxidU32 window,
|
||||
int exclusive)
|
||||
{
|
||||
GxidClaimDevice msg;
|
||||
msg.type = htonl(GXID_CLAIM_DEVICE);
|
||||
msg.length = htonl(sizeof(GxidClaimDevice));
|
||||
msg.device = htonl(device);
|
||||
msg.window = htonl(window);
|
||||
msg.exclusive = htonl(exclusive);
|
||||
|
||||
return gxid_send_message(host,port,(GxidMessage *)&msg);
|
||||
}
|
||||
|
||||
/* release a device/window pair */
|
||||
int
|
||||
gxid_release_device(char *host, int port, GxidU32 device, GxidU32 window)
|
||||
{
|
||||
GxidReleaseDevice msg;
|
||||
msg.type = htonl(GXID_RELEASE_DEVICE);
|
||||
msg.length = htonl(sizeof(GxidReleaseDevice));
|
||||
msg.device = htonl(device);
|
||||
msg.window = htonl(window);
|
||||
|
||||
return gxid_send_message(host,port,(GxidMessage *)&msg);
|
||||
}
|
||||
|
||||
#else /* !XINPUT_GXI */
|
||||
|
||||
/* Some compilers don't like empty source files */
|
||||
int
|
||||
gxid_claim_device(char *host, int port, GxidU32 device, GxidU32 window,
|
||||
int exclusive)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* XINPUT_GXI */
|
||||
|
@@ -1,6 +0,0 @@
|
||||
#include "gxid_proto.h"
|
||||
|
||||
int gxid_claim_device(char *host, int port,
|
||||
GxidU32 device, GxidU32 window, int exclusive);
|
||||
int gxid_release_device(char *host, int port, GxidU32 device,
|
||||
GxidU32 window);
|
@@ -1,39 +0,0 @@
|
||||
#define GXID_CLAIM_DEVICE 1
|
||||
#define GXID_RELEASE_DEVICE 2
|
||||
|
||||
#define GXID_RETURN_OK 0
|
||||
#define GXID_RETURN_ERROR -1
|
||||
|
||||
typedef struct GxidClaimDevice_ GxidClaimDevice;
|
||||
typedef struct GxidReleaseDevice_ GxidReleaseDevice;
|
||||
typedef struct GxidMessageAny_ GxidMessageAny;
|
||||
typedef union GxidMessage_ GxidMessage;
|
||||
|
||||
typedef unsigned long GxidU32;
|
||||
typedef long GxidI32;
|
||||
|
||||
struct GxidClaimDevice_ {
|
||||
GxidU32 type;
|
||||
GxidU32 length;
|
||||
GxidU32 device;
|
||||
GxidU32 window;
|
||||
GxidU32 exclusive;
|
||||
};
|
||||
|
||||
struct GxidReleaseDevice_ {
|
||||
GxidU32 type;
|
||||
GxidU32 length;
|
||||
GxidU32 device;
|
||||
GxidU32 window;
|
||||
};
|
||||
|
||||
struct GxidMessageAny_ {
|
||||
GxidU32 type;
|
||||
GxidU32 length;
|
||||
};
|
||||
|
||||
union GxidMessage_ {
|
||||
GxidMessageAny any;
|
||||
GxidClaimDevice claim;
|
||||
GxidReleaseDevice release;
|
||||
};
|
106
glib/ChangeLog
106
glib/ChangeLog
@@ -1,3 +1,109 @@
|
||||
Thu Sep 17 19:13:26 PDT 1998 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* install-sh
|
||||
* missing
|
||||
* mkinstalldirs: updated to latest automake version
|
||||
|
||||
Wed Sep 9 02:28:49 PDT 1998 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* configure.in: added -posix check for NeXTStep
|
||||
|
||||
Sun Sep 6 12:35:13 PDT 1998 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* glib.h: provide proper ATEXIT behavior on NeXTStep by !atexit
|
||||
|
||||
Wed Jul 1 20:14:03 PDT 1998 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* ltconfig: fix for properly detecting shared lib support on
|
||||
SunPro cc (taken from libtool 1.2.a)
|
||||
|
||||
Wed May 20 05:02:26 1998 Tim Janik <timj@gtk.org>
|
||||
|
||||
* glib.h: conditionally define NULL, FALSE and TRUE.
|
||||
added G_GNUC_FORMAT(), G_GNUC_NORETURN and G_GNUC_CONST macros to
|
||||
feature more function arguments.
|
||||
(g_mem_chunk_create): new convenience macro as a short hand for
|
||||
g_mem_chunk_new().
|
||||
(g_chunk_free): new convenience macro to be consistent with g_chunk_new.
|
||||
|
||||
* glist.c: backmerged g_list_nth_data().
|
||||
* gslist.c: backmerged g_slist_nth_data().
|
||||
|
||||
Mon May 18 22:14:39 1998 Owen Taylor <otaylor@gtk.org>
|
||||
(Yasuhiro SHIRASAKI <joke@awa.tohoku.ac.jp> : gtk-joke-980517-0.patch)
|
||||
|
||||
* gutils.c: Restored a missing prototype for g_vsprintf.
|
||||
|
||||
Tue May 12 19:22:58 1998 Owen Taylor <otaylor@gtk.org>
|
||||
|
||||
* glib/glib.h: Added macros G[U]INT_TO_POINTER() and
|
||||
GPOINTER_TO_[U]INT for storing small integers integers
|
||||
inside pointers.
|
||||
|
||||
* glib/testglib.c: Print sizeof() results
|
||||
as g_print("%ld", (glong)sizeof(foo)), to deal with
|
||||
size_t being long on Alpha's.
|
||||
|
||||
Tue May 12 16:54:15 1998 Owen Taylor <otaylor@gtk.org>
|
||||
(James A <jamesa@demon.net> : gtk-jamesa-980511-4.patch)
|
||||
|
||||
* glib.h gstring.c gmessages.c: Added some missing
|
||||
const to arguments.
|
||||
|
||||
* gutils.c (g_strsignal.c): Added missing return statements.
|
||||
|
||||
Mon May 11 21:11:54 1998 Owen Taylor <otaylor@gtk.org>
|
||||
|
||||
* gutils.c gmessages.c: Moved g_error, g_warning, g_message and
|
||||
g_print from gutils.c to new file gmessages.c, to avoid having to
|
||||
include <unistd.h> in gutils.c which was causing problems for the
|
||||
g_strsignal implementation on FreeBSD boxes.
|
||||
|
||||
Mon May 11 07:22:36 1998 Tim Janik <timj@gtk.org>
|
||||
|
||||
* glib.h: provide G_GNUC_FUNCTION and G_GNUC_PRETTY_FUNCTION to
|
||||
avoid conditionals. unconditionally define NULL, TRUE, FALSE, MAX,
|
||||
MIN, ABS and CLAMP, these macros might be screwed from other headers.
|
||||
|
||||
Thu May 7 08:17:28 1998 Tim Janik <timj@gtk.org>
|
||||
[1-1-0-Merge]
|
||||
|
||||
* glib.h (G_GNUC_PRINTF):
|
||||
(G_GNUC_SCANF): macros to facilitate the printf/scanf format argument
|
||||
checking of gcc.
|
||||
|
||||
* gstring.c: const corrections, string!=NULL checks at function entry.
|
||||
(g_string_down): new function for tolower(3) conversion.
|
||||
(g_string_up): new function for toupper(3) conversion.
|
||||
|
||||
* gutils.c: const corrections.
|
||||
(g_strdown): g_string_down() counterpart.
|
||||
(g_strup): g_string_up() counterpart.
|
||||
|
||||
* gslist.c:
|
||||
(g_slist_index): find out about about the position of a
|
||||
certain data pointer.
|
||||
(g_slist_position): find out about about the position of a
|
||||
certain node.
|
||||
|
||||
* glist.c:
|
||||
(g_list_index): find out about about the position of a
|
||||
certain data pointer.
|
||||
(g_list_position): find out about about the position of a
|
||||
certain data pointer.
|
||||
|
||||
Fri May 1 16:36:08 1998 Owen Taylor <otaylor@gtk.org>
|
||||
|
||||
* gutils.c: (g_strcasecmp). Check for isupper before
|
||||
taking tolower, and account for macroized tolower.
|
||||
|
||||
* gutils.c (g_error): Check for recursion.
|
||||
|
||||
Thu Apr 30 21:41:30 1998 Owen Taylor <otaylor@gtk.org>
|
||||
|
||||
* gstring.c : Check arguments more carefully,
|
||||
(gtk-draco-980423-1.patch; ramsey@rhrk.uni-kl.de)
|
||||
|
||||
Tue Apr 7 19:36:48 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gutils.c (g_direct_compare): Removed, because that's what
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user