After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 629093 - [patch] prefix GDK key names
[patch] prefix GDK key names
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: X11
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2010-09-08 17:47 UTC by Colin Walters
Modified: 2010-09-10 15:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add _KEY (3.94 KB, patch)
2010-09-08 17:47 UTC, Colin Walters
none Details | Review
update keysyms (744 bytes, patch)
2010-09-08 17:48 UTC, Colin Walters
none Details | Review
prefix key names with KEY_ (361.22 KB, patch)
2010-09-08 21:44 UTC, Colin Walters
accepted-commit_now Details | Review

Description Colin Walters 2010-09-08 17:47:11 UTC
See patches
Comment 1 Colin Walters 2010-09-08 17:47:30 UTC
Created attachment 169788 [details] [review]
Add _KEY
Comment 2 Colin Walters 2010-09-08 17:48:11 UTC
Created attachment 169789 [details] [review]
update keysyms
Comment 3 Colin Walters 2010-09-08 19:03:05 UTC
Note the order is backwards, for some reason bugzilla didn't take my first attachment.
Comment 4 Colin Walters 2010-09-08 19:09:45 UTC
Note, i'd like to do a patch which renames all of the constants to GDK_KEY_ in gtk3.  This is a lot cleaner - even in C, #define GDK_<random string> is just asking for namespace conflicts.

For application compatibility, I can fairly easily provide gdkkeysyms-compat.h.  Any thoughts/objections?
Comment 5 Owen Taylor 2010-09-08 19:13:55 UTC
Review of attachment 169788 [details] [review]:

Mostly looks like it works as intended to me, specific comments below.

The general idea needs sign-off from a GTK+ maintainer - this patch is saying that these are "really" Gdk.KEY_Whatever for modern language bindings, and Gdk.Whatever for C and older language bindings is compatibility.

::: gdk/Makefile.am
@@ +20,3 @@
 	gdkconfig.h.win32 	\
 	gdkkeysyms-update.pl	\
+	gdkkeysyms-introspection	\

I think it's pretty confusing to have gdkkeysyms-introspection be a script and gdkkeysyms-introspection.h a header file. I'd call this make-gdkkeysms-introspection.py or something like that (you can claim that .py is an implementation detail, but it's not something you run manually and having the .py makes it more obvious what's going on. Note that existing .sh scripts.)

@@ +173,3 @@
 
+gdkkeysyms-introspection.h: gdkkeysyms.h gdkkeysyms-introspection Makefile
+	python $(srcdir)/gdkkeysyms-introspection $< $@

Can't use python like this without a configure.ac check - /usr/bin/python is something ancient on solaris apparently. Use AM_PATH_PYTHON([2.5]) in configure.ac and $(PYTHON) here

@@ +177,2 @@
 introspection_files = 		\
+	$(filter-out gdkkeysyms.h, $(gdk_public_h_sources))	\

Why can't you add gdkkeysyms-introspection.h here?

::: gdk/gdkkeysyms-introspection
@@ +46,3 @@
+        if not line.startswith(GDK_KEY_START):
+            continue
+        output_f.write('#define GDK_KEY_')

It's strange to have the old version and the new version not a constant
Comment 6 Colin Walters 2010-09-08 21:44:18 UTC
Created attachment 169808 [details] [review]
prefix key names with KEY_

Totally different patch; see commit message for details.
Comment 7 Colin Walters 2010-09-08 21:48:40 UTC
If we go with this, my suggested approach for gtk2 is to also add these #defines to gdkkeysyms.h, so apps can be ported and work with both.  (A patch to do so is pretty easy).
Comment 8 Matthias Clasen 2010-09-08 22:25:22 UTC
Review of attachment 169808 [details] [review]:

This one looks a lot better to me. Thanks for doing all the sed work to port gtk over. Not sure we really want to deprecated all the old keysyms in 2.x; thats a lot of deprecation to do so close to 2.22. Adding the new names to 2.x is a good idea though.
Comment 9 Colin Walters 2010-09-08 22:52:31 UTC
Committed to gtk3, working on gtk2.
Comment 10 Colin Walters 2010-09-08 23:09:49 UTC
Fix committed to gtk2 (with maximal compatiblity, gtkkeysyms.h does #include <gdk/gdkkeysyms-compat.h>).
Comment 11 Christian Persch 2010-09-10 12:09:09 UTC
So, while this is also on 2-x branch, if one wants to support _older_ gtk versions as well as gtk3, one does now have to

#if GTK_CHECK_VERSION (2, 22, 0)
#include <gdk/gdkkeysyms-compat.h>
#else
#include <gdk/gdkkeysyms.h>
#endif

IMHO, it would have been better to put the new keysym names in a NEW header (gdkkeysyms3.h maybe), and leave the compat defines in the header with the old name.
Comment 12 Matthias Clasen 2010-09-10 12:16:28 UTC
I think just including gdk/gdkkeysyms.h is supposed to work in 2.x and 3.

It includes the compat header in 2.x
Comment 13 Christian Dywan 2010-09-10 12:35:49 UTC
Is gdkkeysysm intentionally still not in gdk.h? I'd think now that it has proper names, that shouldn't be a problem.
Comment 14 Colin Walters 2010-09-10 14:04:42 UTC
(In reply to comment #11)
> So, while this is also on 2-x branch, if one wants to support _older_ gtk
> versions as well as gtk3, one does now have to
> 
> #if GTK_CHECK_VERSION (2, 22, 0)
> #include <gdk/gdkkeysyms-compat.h>
> #else
> #include <gdk/gdkkeysyms.h>
> #endif
> 
> IMHO, it would have been better to put the new keysym names in a NEW header
> (gdkkeysyms3.h maybe), and leave the compat defines in the header with the old
> name.

Hmm, well we could just include them in gdk.h as comment #13 suggests.  That would reduce your code to:

#if GTK_CHECK_VERSION (2, 22, 0)
#include <gdk/gdkkeysyms-compat.h>
#endif

Is that too onerous?  If we went with your suggestion of gdkkeysyms3.h, I basically don't think anyone would ever use the new names, and we'd be stuck with namespace conflicts if someone added a key named WINDOW or whatever.
Comment 15 Matthias Clasen 2010-09-10 14:24:07 UTC
Colin: do you need 

#if GTK_CHECK_VERSION (2, 22, 0)
#include <gdk/gdkkeysyms-compat.h>
#endif

? It was my understanding that gdk-keysyms.h includes gdk-keysyms-compat.h in 2.x. Is that not the case ?

As for including in gdk.h, I'm open to doing that in 3.0, but we should probably leave things as they are in 2.x
Comment 16 Matthias Clasen 2010-09-10 15:30:55 UTC
gdk.h includes gdkkeysyms.h in master now
Comment 17 Colin Walters 2010-09-10 15:38:15 UTC
(In reply to comment #15)
> Colin: do you need 
> 
> #if GTK_CHECK_VERSION (2, 22, 0)
> #include <gdk/gdkkeysyms-compat.h>
> #endif
> 
> ? It was my understanding that gdk-keysyms.h includes gdk-keysyms-compat.h in
> 2.x. Is that not the case ?

Ah...right.  So we only want to include it in 3.  So:

#if GTK_CHECK_VERSION (2, 95, 0)
#include <gdk/gdkkeysyms-compat.h>
#endif

right?

> As for including in gdk.h, I'm open to doing that in 3.0, but we should
> probably leave things as they are in 2.x

Sounds fine.
Comment 18 Matthias Clasen 2010-09-10 15:42:27 UTC
(In reply to comment #17)
 
> Ah...right.  So we only want to include it in 3.  So:
> 
> #if GTK_CHECK_VERSION (2, 95, 0)
> #include <gdk/gdkkeysyms-compat.h>
> #endif
> 
> right?

Or just an unconditional 

#include <gdk/gdkkeysyms-compat.h> 

if you don't care about the extra include.