Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 41240

Summary: GTK-BIDI: RTL support in Scale
Product: [Eclipse Project] Platform Reporter: Semion Chichelnitsky <semion>
Component: SWTAssignee: Bogdan Gheorghe <gheorghe>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: billy.biggs, eclipse.felipe, ericwill, markus.kell.r, matial, salexb
Version: 3.0Keywords: helpwanted, triaged
Target Milestone: ---   
Hardware: PC   
OS: Linux-GTK   
Whiteboard: stalebug
Attachments:
Description Flags
OS.java from build N20030729 with proposed changes.
none
os.c from build N20030729
none
Scale.java from build N20030729
none
os.c from build I20040210 with proposed changes.
none
OS.java from build I20040210 with proposed changes.
none
Scale.java from build I20040210 with proposed changes. none

Description Semion Chichelnitsky CLA 2003-08-07 04:48:48 EDT
When keyboard is used to changed value of rtl-oriented Scale, Up and Down, Ctrl-
Up and Ctrl-Down, PgUp and PgDown keys change this value in the opposite 
direction. Keys in each of this pairs should be swapped.
Comment 1 Semion Chichelnitsky CLA 2003-08-07 04:51:19 EDT
Created attachment 5665 [details]
OS.java from build N20030729 with proposed changes.

Our changes are marked with tag "bidi for scale".
Comment 2 Semion Chichelnitsky CLA 2003-08-07 04:53:19 EDT
Created attachment 5666 [details]
os.c from build N20030729

Our changes are marked with tag "bidi for scale".
Comment 3 Semion Chichelnitsky CLA 2003-08-07 04:55:08 EDT
Created attachment 5667 [details]
Scale.java from build N20030729
Comment 4 Semion Chichelnitsky CLA 2004-02-12 04:29:48 EST
Created attachment 7825 [details]
os.c from build I20040210 with proposed changes.

Our changes are marked with tag b41240.
Comment 5 Semion Chichelnitsky CLA 2004-02-12 04:30:46 EST
Created attachment 7826 [details]
OS.java from build I20040210 with proposed changes.

Our changes are marked with tag b41240.
Comment 6 Semion Chichelnitsky CLA 2004-02-12 04:36:56 EST
Created attachment 7827 [details]
Scale.java from build I20040210 with proposed changes.

Our suggestion (about using of *Up and *Down keys) for some reason was declined
by GTK team. Therefore workaround is needed here.
It is supposed, that general problem, which is described in the bug 41184,
is solved by the newly suggested way.
Our changes are marked with tag b41240.
Comment 7 Felipe Heidrich CLA 2005-02-23 18:48:33 EST
The patch is not quite right, it has custom c code, it leaks memory, and it
doesn't honour the group and the level of the event (not sure this last item
matters).
For me, when the scale is vertical RTL the left/arrow key don't move the thumb
in the right direction.
I also changed the code to do the work right before return to the OS, swapping
the keys before running translate mnemonic and sending the event to the
application is wrong in my opnion (test on windows).

Here is the code I'm working on:
int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
	int /*long*/ result = super.gtk_key_press_event (widget, event);
	if (result != 0) return result;
	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
		GdkEventKey keyEvent = new GdkEventKey ();
		OS.memmove (keyEvent, event, GdkEventKey.sizeof);
		int key = keyEvent.keyval;
		if ((style & SWT.HORIZONTAL) != 0) {
			switch (key) {
				case OS.GDK_Up: key = OS.GDK_Down; break; 
				case OS.GDK_KP_Up: key = OS.GDK_KP_Down; break;
				case OS.GDK_Down: key = OS.GDK_Up; break; 
				case OS.GDK_KP_Down: key = OS.GDK_KP_Up; break;					
				case OS.GDK_Page_Up: key = OS.GDK_Page_Down; break; 
				case OS.GDK_Page_Down: key = OS.GDK_Page_Up; break;					
			}			
		} else {
			switch (key) {
				case OS.GDK_Right: key = OS.GDK_Left; break; 
				case OS.GDK_KP_Right: key = OS.GDK_KP_Left; break;
				case OS.GDK_Left: key = OS.GDK_Right; break; 
				case OS.GDK_KP_Left: key = OS.GDK_KP_Right; break;		
			}
		}
		if (key != keyEvent.keyval) {
			int keymap = OS.gdk_keymap_get_default ();
			int /*long*/[] keys = new int /*long*/[1];
			int /*long*/[] n_keys = new int /*long*/[1]; 
			if (OS.gdk_keymap_get_entries_for_keyval (keymap, key, keys, n_keys)) {
				int [] keymapKey = new int [3];
				int level = (keyEvent.state & OS.GDK_SHIFT_MASK) != 0 ? 1 : 0;
				for (int i = 0; i < n_keys [0]; i++) {
					OS.memmove(keymapKey, keys [0] + (i*3*4), 3*4);
					if (keymapKey [1] == keyEvent.group && keymapKey [2] == level) {
						keyEvent.hardware_keycode = (short) keymapKey [0];
						keyEvent.keyval = key;
						OS.memmove (event, keyEvent, GdkEventKey.sizeof);
						break;
					}
				}
				OS.g_free (keys [0]);
			}
		}
	}
	return 0;
}
Comment 8 Felipe Heidrich CLA 2005-02-23 18:50:14 EST
This kind of code is very bad, I wish we could find a different solution for the
problem... Billy, you who masters gtk, any advise ?
Comment 9 Eclipse Genie CLA 2020-11-20 03:37:01 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.