Skip to content

Commit

Permalink
Make keyboard intelligently handle layout on screen orientation and r…
Browse files Browse the repository at this point in the history
…otation

git-svn-id: https://svn.o-hand.com/repos/matchbox/trunk/matchbox-keyboard@1132 b067294f-1dea-0310-9683-c47a78595994
  • Loading branch information
mallum committed Apr 27, 2005
1 parent 07591f4 commit 6c66568
Show file tree
Hide file tree
Showing 8 changed files with 323 additions and 71 deletions.
25 changes: 25 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
2005-04-27 mallum,,, <[email protected]>


* layouts/keyboard.xml:
New layout with extended keys.

* src/config-parser.c: (config_handle_key_tag):
* src/matchbox-keyboard-key.c: (mb_kbd_key_get_extra_width_pad):
* src/matchbox-keyboard-row.c: (mb_kbd_row_height),
(mb_kbd_row_width), (mb_kbd_row_base_width):
* src/matchbox-keyboard-ui.c: (get_desktop_area),
(mb_kbd_ui_send_keysym_press), (mb_kbd_ui_send_release),
(mb_kdb_ui_unit_key_size), (mb_kbd_ui_min_key_size),
(mb_kbd_ui_allocate_ui_layout), (mb_kbd_ui_redraw_key),
(mb_kbd_ui_redraw_row), (mb_kbd_ui_resources_create),
(mb_kbd_ui_resize), (mb_kbd_ui_handle_configure),
(mb_kbd_ui_events_iteration), (mb_kbd_ui_load_font),
(mb_kbd_ui_init), (mb_kbd_ui_display_width),
(mb_kbd_ui_display_height), (mb_kbd_ui_realize):
* src/matchbox-keyboard.c: (mb_kbd_locate_key),
(mb_kbd_get_held_key):
* src/matchbox-keyboard.h:
Make keyboard 'adapt' with extended keys to screen rotation
and screen orientation.

2005-04-26 mallum,,, <[email protected]>

* configure.ac:
Expand Down
59 changes: 59 additions & 0 deletions layouts/keyboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
-->

<row>

<space width="500" extended="true"/>

<key fill="true">
<default display="Esc" action="escape" />
</key>
Expand Down Expand Up @@ -87,10 +90,24 @@
<default display="Bksp" action="backspace"/>
</key>

<space width="500" extended="true"/>

<key width="4000" extended="true">
<default display="Home" />
</key>
<key width="4000" extended="true">
<default display="PgUp" />
</key>

<space width="500" extended="true"/>


</row>

<row>

<space width="500" extended="true"/>

<key fill="true">
<default display="Tab" action="tab"/>
</key>
Expand Down Expand Up @@ -148,9 +165,22 @@
<shifted display="|" />
</key>

<space width="500" extended="true"/>

<key width="4000" extended="true">
<default display="End" />
</key>
<key width="4000" extended="true">
<default display="PgDn" />
</key>

<space width="500" extended="true"/>

</row>
<row>

<space width="500" extended="true"/>

<key fill="true">
<default display="Caps" action="modifier:caps"/>
</key>
Expand Down Expand Up @@ -202,10 +232,20 @@
<default display="Ret" action="return"/>
</key>

<space width="500" extended="true"/>

<space width="4000" extended="true" />

<space width="4000" extended="true" />

<space width="500" extended="true"/>


</row>
<row>

<space width="500" extended="true"/>

<key fill="true">
<default display="Shift" action="modifier:shift"/>
</key>
Expand Down Expand Up @@ -263,10 +303,21 @@
<default display="Shift" action="modifier:shift"/>
</key>

<space width="500" extended="true"/>

<space width="4000" extended="true" />

<space width="4000" extended="true" />

<space width="500" extended="true"/>



</row>
<row>

<space width="500" extended="true"/>

<key>
<default display="äëö" action="modifier:mod1"/>
</key>
Expand Down Expand Up @@ -302,6 +353,14 @@
<default display="&gt;" action="right" />
</key>

<space width="500" extended="true"/>

<space width="4000" extended="true" />

<space width="4000" extended="true" />

<space width="500" extended="true"/>

</row>

</layout>
Expand Down
6 changes: 6 additions & 0 deletions src/config-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,12 @@ config_handle_key_tag(MBKeyboardConfigState *state, const char **attr)
mb_kbd_key_set_obey_caps(state->current_key, True);
}

if ((val = attr_get_val("extended", attr)) != NULL)
{
if (strcaseeq(val, "true"))
mb_kbd_key_set_extended(state->current_key, True);
}

if ((val = attr_get_val("width", attr)) != NULL)
{
if (atoi(val) > 0)
Expand Down
13 changes: 13 additions & 0 deletions src/matchbox-keyboard-key.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct MBKeyboardKey
boolean fill; /* width fills avialble space */
int req_uwidth; /* unit width in 1/1000's */
boolean is_blank; /* 'blank' keys are spacers */
boolean extended; /* only show in landscape */

MBKeyboardStateType sets_kbdstate; /* needed */
};
Expand Down Expand Up @@ -211,6 +212,18 @@ mb_kbd_key_get_extra_width_pad(MBKeyboardKey *key)
return key->extra_width_pad;
}

void
mb_kbd_key_set_extended(MBKeyboardKey *key, boolean extend)
{
key->extended = extend;
}

boolean
mb_kbd_key_get_extended(MBKeyboardKey *key)
{
return key->extended;
}


/* URG Nasty - some stuf should be public-ish */
void
Expand Down
46 changes: 29 additions & 17 deletions src/matchbox-keyboard-row.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,31 @@ mb_kbd_row_x (MBKeyboardRow *row)

int
mb_kbd_row_y(MBKeyboardRow *row)
{
{
return row->alloc_y;
}

int
mb_kbd_row_height(MBKeyboardRow *row)
{
List *key_item = mb_kdb_row_keys(row);
MBKeyboardKey *key;
List *key_item;

/* XX this is a little crazed */
/* XX this is a little crazed
* We avoid keys with 0 height - spacers or non allocated extended ones
*/

mb_kbd_row_for_each_key(row, key_item)
{
if (!mb_kbd_is_extended(row->kbd)
&& mb_kbd_key_get_extended(key_item->data))
continue;

key = key_item->data;

return mb_kbd_key_height(key);
if (mb_kbd_key_height(key_item->data) > 0)
return mb_kbd_key_height(key_item->data);
}

return 0;
}

int
Expand All @@ -66,15 +76,16 @@ mb_kbd_row_width(MBKeyboardRow *row)

result = mb_kbd_col_spacing(row->kbd);

key_item = mb_kdb_row_keys(row);

while (key_item != NULL)
{

mb_kbd_row_for_each_key(row, key_item)
{
MBKeyboardKey *key = key_item->data;

result += (mb_kbd_key_width(key) + mb_kbd_col_spacing(row->kbd));
if (!mb_kbd_is_extended(row->kbd)
&& mb_kbd_key_get_extended(key))
continue;

key_item = util_list_next(key_item);
result += (mb_kbd_key_width(key) + mb_kbd_col_spacing(row->kbd));
}

return result;
Expand All @@ -88,17 +99,18 @@ mb_kbd_row_base_width(MBKeyboardRow *row)

result = mb_kbd_col_spacing(row->kbd);

key_item = mb_kdb_row_keys(row);

while (key_item != NULL)
mb_kbd_row_for_each_key(row, key_item)
{
MBKeyboardKey *key = key_item->data;

if (!mb_kbd_is_extended(row->kbd)
&& mb_kbd_key_get_extended(key))
continue;

result += (mb_kbd_key_width(key)
+ mb_kbd_col_spacing(row->kbd)
- mb_kbd_key_get_extra_width_pad(key));

key_item = util_list_next(key_item);

}

return result;
Expand Down
Loading

0 comments on commit 6c66568

Please sign in to comment.