Closed
Bug 348724
(BidiKeyboardGtk2)
Opened 19 years ago
Closed 17 years ago
nsBidiKeyboard for GTK2 backend
Categories
(Core :: Widget: Gtk, defect)
Tracking
()
RESOLVED
FIXED
mozilla1.9
People
(Reporter: zwnj, Assigned: zwnj)
References
(Blocks 2 open bugs)
Details
Attachments
(2 files, 5 obsolete files)
4.94 KB,
patch
|
smontagu
:
review+
|
Details | Diff | Splinter Review |
5.01 KB,
patch
|
smontagu
:
review+
roc
:
superreview+
beltzner
:
approval1.9+
|
Details | Diff | Splinter Review |
Add GTK2 backend for nsBidiKeyboard.
As GDK doesn't support this feature, xlib/xkblib must be use directly.
I'm going to attach my patch, which adds xkbfile dependecy to the trunk.
Assignee | ||
Comment 1•19 years ago
|
||
Attachment #233786 -
Flags: review?(smontagu)
Assignee | ||
Comment 2•19 years ago
|
||
Just note that "sy" should be added to the list too.
Assignee | ||
Comment 3•19 years ago
|
||
Feature requested on Gnome Bugzilla: Bug 353805 – Support for keyboard layouts
Assignee | ||
Updated•19 years ago
|
Alias: BidiKeyboardGTK
Assignee | ||
Comment 4•19 years ago
|
||
Implements reading keyboard layouts. Selecting keyboard layout coming soon.
Just needs one GTK+ version check for now, and some other after implementation in GDK.
Attachment #233786 -
Attachment is obsolete: true
Attachment #236504 -
Flags: review?(smontagu)
Attachment #233786 -
Flags: review?(smontagu)
Assignee | ||
Comment 5•19 years ago
|
||
Attachment #236504 -
Attachment is obsolete: true
Attachment #236504 -
Flags: review?(smontagu)
Assignee | ||
Updated•19 years ago
|
Attachment #238905 -
Flags: review?(smontagu)
Assignee | ||
Comment 6•19 years ago
|
||
*** Bug 203671 has been marked as a duplicate of this bug. ***
Assignee | ||
Comment 7•19 years ago
|
||
GTK+ 2.12 will have needed API (gnome-bug 353805) and this patch simply uses that API to determine if bidi keyboard layouts have been set.
As the implementation for old GTK+ need a log of XKB code (which is hard to debug) for caching and updating, and this is just an enhancement, I don't care about old GTK+ versions for this bug.
Note that GTK+ 2.12 will be released sooner than Fx3.0.
[In fact, I want to work on other important bugs, so feel free to port GTK+ code, or write new one, if you have time. But this patch works well for me]
Attachment #238905 -
Attachment is obsolete: true
Attachment #240463 -
Flags: review?(smontagu)
Attachment #238905 -
Flags: review?(smontagu)
Comment 8•19 years ago
|
||
Comment on attachment 240463 [details] [diff] [review]
patch v6, simply use gtk api
>+ if (gtk_check_version (2, 12, 0) || gtk_check_version (2, 10, 1))
>+ *aIsRTL = (gdk_keymap_get_direction(NULL) == PANGO_DIRECTION_RTL);
>+
>+ return NS_OK;
>+#if GTK_CHECK_VERSION (2, 12, 0)
>+ if (gtk_check_version (2, 12, 0))
>+ mHaveBidiKeyboards = gdk_keymap_have_bidi_layouts(NULL);
>+#endif /* GTK_CHECK_VERSION */
These need comments saying what exactly you are testing for and why, and why you have both a compile-time check and a run-time check in SetupBidiKeyboards() and only a runtime check in IsLangRTL(). I would have expected the other way round, since all the code has to be compiled, but the call in IsLangRTL() will never be reached in incompatible versions.
Also, if I understand http://developer.gnome.org/doc/API/gtk/gtk-feature-test-macros.html correctly, gtk_check_version returns NULL when the version is compatible, so shouldn't you be testing |if (!gtk_check_version(...))| ?
Attachment #240463 -
Flags: review?(smontagu)
Assignee | ||
Comment 9•19 years ago
|
||
Thanks Simon.
The first Gtk version checking was non-sence, as the function have been available from Gtk 2.0 or 2.2.
The second on now works well (I forgot to compare the return value to NULL), and now it's fixed.
Simon, to test the patch, I changed the 2.12 to 2.10 and tried it on my system's Gtk 2.8 and my own patched 2.10, and it worked well.
Also I moved the destructor to protected part, as suggested by IDL compiler.
Attachment #240463 -
Attachment is obsolete: true
Attachment #240529 -
Flags: review?(smontagu)
Assignee | ||
Updated•19 years ago
|
Alias: BidiKeyboardGTK → BidiKeyboardGtk2
Assignee | ||
Comment 10•19 years ago
|
||
(In reply to comment #8)
> (From update of attachment 240463 [details] [diff] [review] [edit])
> >+ if (gtk_check_version (2, 12, 0) || gtk_check_version (2, 10, 1))
> >+ *aIsRTL = (gdk_keymap_get_direction(NULL) == PANGO_DIRECTION_RTL);
> >+
> >+ return NS_OK;
Fixed in the best way: I removed the version-checking line.
> >+#if GTK_CHECK_VERSION (2, 12, 0)
> >+ if (gtk_check_version (2, 12, 0))
> >+ mHaveBidiKeyboards = gdk_keymap_have_bidi_layouts(NULL);
> >+#endif /* GTK_CHECK_VERSION */
>
> These need comments saying what exactly you are testing for and why, and why
> you have both a compile-time check and a run-time check in SetupBidiKeyboards()
> and only a runtime check in IsLangRTL(). I would have expected the other way
> round, since all the code has to be compiled, but the call in IsLangRTL() will
> never be reached in incompatible versions.
BTW, the first call have been in the API for years (but had detection problems), so it doesn't need any compile time checking.
The second one is new and will be on GTK 2.12 API, so I need to check if the function exist in the API on compile time. But I need to check it run time, to make it possible to run the app which have been built on a GTK >= 2.12 on older GTK versions.
I can put this comments on the code if you think they're necessary. Also I can add the compile-time check to the first call too, just to make the compiled version (on old systems) a bit smaller.
Status: NEW → ASSIGNED
Comment 11•19 years ago
|
||
> The second one is new and will be on GTK 2.12 API, so I need to check if the
> function exist in the API on compile time. But I need to check it run time, to
> make it possible to run the app which have been built on a GTK >= 2.12 on older
> GTK versions.
That is inherently broken and only works with lazy linking. It's at best a hack, and should be avoided.
Comment 12•18 years ago
|
||
Any update on this?
Assignee | ||
Comment 13•18 years ago
|
||
Well, in Linux Runtime Requirements, the GKT+ version is 2.10.x, but the function I use here was added to 2.12. I'm not sure what we can do now.
There won't be any problem on compile time, but if it's compiled on a system with 2.12 version, it (probably) won't run on a system with 2.10; which I think is not acceptable. Am I right?
We can use the not-so-good code of the 1.8 branch, which doesn't work of Hebrew at all.
Simon, Behdad, any idea?
Why not just use a dlsym trick to call the function only when it's available? We do that all over the place (maybe less lately, but it's still a valid strategy).
Assignee | ||
Comment 15•18 years ago
|
||
(In reply to comment #14)
> Why not just use a dlsym trick to call the function only when it's available?
> We do that all over the place (maybe less lately, but it's still a valid
> strategy).
Sorry, I don't know what dlsym is. I'm going to google it; but would you please show me an example in the cvs?
Here are what I wrote:
+#if GTK_CHECK_VERSION (2, 12, 0)
+ if (gtk_check_version (2, 12, 0) == NULL)
+ mHaveBidiKeyboards = gdk_keymap_have_bidi_layouts(NULL);
+#endif /* GTK_CHECK_VERSION */
The gtk_check_version is the run-time check; which Behdad says is not acceptable, but I'm not sure, as it should work on almost all Linux distros.
Assignee | ||
Comment 16•18 years ago
|
||
Ok, I found what dlsym() does. Seems using gtk_check_version is as risky as dlsym; as for both of them, a lazy linker is necessary.
So, Simon, would you review the last patch please?
Who can does the sr?
Thanks Robert.
http://mxr.mozilla.org/seamonkey/source/widget/src/gtk2/nsSound.cpp#118
Lazy linking is NOT necessary here. It just works.
I can do sr's.
Comment 18•18 years ago
|
||
Behnam, dlsym() is runtime-linking. If the symbol is not available, you just get a NULL returned, no big deal. With normal linking (lazy or not), as soon as the symbol is not found the program is terminated.
Assignee | ||
Comment 19•17 years ago
|
||
Simon, I decided to not call SetHaveBidiKeyboards() on every IsLangRTL() call; instead I used cached mHaveBidiKeyboards. This means if user changes her having-bidi-keyboard-layouts status when mozilla is running, the cursor mode remains the same.
If it's necessary to get that work too, that would be a good idea to call SetHaveBidiKeyboards() on another function with less overall calls.
BTW I changed the additional function name, and it doesn't match the win32 one, as their work is a bit different. Don't you mind?
Attachment #240529 -
Attachment is obsolete: true
Attachment #240529 -
Flags: review?(smontagu)
Updated•17 years ago
|
Target Milestone: mozilla1.9alpha1 → mozilla1.9
Assignee | ||
Updated•17 years ago
|
Attachment #233786 -
Flags: review?(smontagu)
Comment 20•17 years ago
|
||
Did you mean to set the review request on attachment 233786 [details] [diff] [review] instead of the latest version?
Assignee | ||
Comment 21•17 years ago
|
||
(In reply to comment #20)
> Did you mean to set the review request on attachment 233786 [details] [diff] [review] instead of the
> latest version?
No, sorry. I'll fix the review requests now.
Assignee | ||
Updated•17 years ago
|
Attachment #233786 -
Flags: review?(smontagu)
Assignee | ||
Updated•17 years ago
|
Attachment #303718 -
Flags: review?(smontagu)
Comment 22•17 years ago
|
||
Comment on attachment 303718 [details] [diff] [review]
patch v11, use PR_LoadLibrary and PR_FindFunctionSymbol
(In reply to comment #19)
> Simon, I decided to not call SetHaveBidiKeyboards() on every IsLangRTL() call;
> instead I used cached mHaveBidiKeyboards. This means if user changes her
> having-bidi-keyboard-layouts status when mozilla is running, the cursor mode
> remains the same.
Users don't install and remove keyboards all that often, so I guess that's OK.
r=me on the bidi functionality, but you need either addl. review or sr from someone who knows from GTK.
Attachment #303718 -
Flags: review?(smontagu) → review+
Comment 23•17 years ago
|
||
(In reply to comment #22)
> (From update of attachment 303718 [details] [diff] [review])
> (In reply to comment #19)
> > Simon, I decided to not call SetHaveBidiKeyboards() on every IsLangRTL() call;
> > instead I used cached mHaveBidiKeyboards. This means if user changes her
> > having-bidi-keyboard-layouts status when mozilla is running, the cursor mode
> > remains the same.
>
> Users don't install and remove keyboards all that often, so I guess that's OK.
>
> r=me on the bidi functionality, but you need either addl. review or sr from
> someone who knows from GTK.
Looks good except that this line is not multi-screen-safe:
+ *aIsRTL = (gdk_keymap_get_direction(NULL) == PANGO_DIRECTION_RTL);
The NULL is the problem. Not sure if Firefox tries to respect per-screen settings or not.
Assignee | ||
Comment 24•17 years ago
|
||
Thanks Behdad.
(In reply to comment #23)
> Looks good except that this line is not multi-screen-safe:
>
> + *aIsRTL = (gdk_keymap_get_direction(NULL) == PANGO_DIRECTION_RTL);
>
> The NULL is the problem. Not sure if Firefox tries to respect per-screen
> settings or not.
Looking around nsWindow, I found out that there's nothing unsafe for mutli-screen there, as we get the right windows from the widgets all the time.
The problem here is that nsBidiKeyboard isn't designed that way and the widget is not passed to the functions. So there's no way to get the default window.
The best solution would be to get the active window from window-manager, which I *think* should be same as passing NULL to this function.
Simon, can we improve nsIBidiKeyboard? Would it be a waste? It wouldn't be approved for 1.9, right?
Comment 25•17 years ago
|
||
(In reply to comment #24)
> Simon, can we improve nsIBidiKeyboard? Would it be a waste? It wouldn't be
> approved for 1.9, right?
That would be classic post-1.9 material.
Assignee | ||
Comment 26•17 years ago
|
||
Thanks Simon. I will work on the multi-display problem later.
I just updated the patch to use both PR_* functions just once in the constructor. Simon, if it's OK, please obsolete the older one.
So, can we get this patch in 1.9 please? It works fine for more than 99% of users, and *may* show incorrect direction for the rest. This is lot better than not having bidi-keyboard in GTK+ at all.
Attachment #315527 -
Flags: superreview?(roc)
Attachment #315527 -
Flags: review?(smontagu)
Attachment #315527 -
Flags: superreview?(roc) → superreview+
Updated•17 years ago
|
Attachment #315527 -
Flags: review?(smontagu) → review+
Assignee | ||
Comment 27•17 years ago
|
||
Comment on attachment 315527 [details] [diff] [review]
patch v12, use PR_LoadLibrary and PR_FindFunctionSymbol (both just once in constructor)
Asking approval1.9, as we had bidi-caret support in 1.8 (with some bugs for Hebrew) and there's no support on 1.9 right now.
Thanks.
Attachment #315527 -
Flags: approval1.9?
Comment 28•17 years ago
|
||
Comment on attachment 315527 [details] [diff] [review]
patch v12, use PR_LoadLibrary and PR_FindFunctionSymbol (both just once in constructor)
a1.9=beltzner
Attachment #315527 -
Flags: approval1.9? → approval1.9+
Updated•17 years ago
|
Keywords: checkin-needed
Comment 29•17 years ago
|
||
mozilla/widget/src/gtk2/nsBidiKeyboard.cpp 1.9
mozilla/widget/src/gtk2/nsBidiKeyboard.h 1.5
You need to log in
before you can comment on or make changes to this bug.
Description
•