r1158 - in trunk/src/target/OM-2007/applications/openmoko-keyboard: layouts src

caowai_song at sita.openmoko.org caowai_song at sita.openmoko.org
Wed Feb 28 09:20:11 CET 2007


Author: caowai_song
Date: 2007-02-28 09:20:02 +0100 (Wed, 28 Feb 2007)
New Revision: 1158

Modified:
   trunk/src/target/OM-2007/applications/openmoko-keyboard/layouts/keyboard.xml
   trunk/src/target/OM-2007/applications/openmoko-keyboard/src/config-parser.c
   trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard-key.c
   trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard-layout.c
   trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard-ui-xft-backend.c
   trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard-ui.c
   trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard.c
   trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard.h
Log:
1. Add background picture to the keyboard
2. Display normal picture or pushed picture for each keys


Modified: trunk/src/target/OM-2007/applications/openmoko-keyboard/layouts/keyboard.xml
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-keyboard/layouts/keyboard.xml	2007-02-28 07:26:23 UTC (rev 1157)
+++ trunk/src/target/OM-2007/applications/openmoko-keyboard/layouts/keyboard.xml	2007-02-28 08:20:02 UTC (rev 1158)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <keyboard>
 
 <options>
@@ -6,367 +6,172 @@
 </options>
 
 <layout id="defualt keyboard">
+  <background image="bg_keypad.png" />
 
-<!--
   <row>
-     <key>
-	  <default display="ヂ" />                
-    </key>
-    <key>
-	  <default display="Ӫ" />                
-    </key>
-    <key width="1500">
-	  <default display="Ω" />                
-    </key>
-    <space width="1500" />
-    <key fill="true">
-	  <default display="⠿" />                
-    </key>
-  </row>
--->
 
-  <row>
-
-    <space width="500" extended="true"/>
-
-    <key fill="true">
-	  <default display="Esc" action="escape" />
-	  <background image="testkey.png"/>
-    </key>
-<!--
     <key>
-      <default display="image:/usr/share/pixmaps/sync_icon.png" action="a"/>
-    </key>  
--->
-    <key>
-	  <default display="`" />
-	  <background image="testkey.png"/>
+      <default display="Q" />
+      <normalimage image="key_cap_Q.png"/>
+      <pushimage image="key_cap_Q_p.png"/>
     </key>
     <key>
-	  <default display="1" />                
-	  <shifted display="!" />
-	  <background image="testkey.png"/>
+      <default display="W" />
+      <normalimage image="key_cap_W.png"/>
+      <pushimage image="key_cap_W_p.png"/>
     </key>
     <key>
-	  <default display="2" />                
-	  <shifted display='"' />
-          <mod1    display="½" />
-	  <background image="testkey.png"/>
+      <default display="E" />
+      <normalimage image="key_cap_E.png"/>
+      <pushimage image="key_cap_E_p.png"/>
     </key>
     <key>
-	  <default display="3" />
-	  <shifted display="£" />
-          <mod1    display="¾" />               
-	  <background image="testkey.png"/>
+      <default display="R" />
+      <normalimage image="key_cap_R.png"/>
+      <pushimage image="key_cap_R_p.png"/>
     </key>
     <key>
-	  <default display="4" />
-	  <shifted display="$" />                
-	  <background image="testkey.png"/>
+      <default display="T" />
+      <normalimage image="key_cap_T.png"/>
+      <pushimage image="key_cap_T_p.png"/>
     </key>
     <key>
-	  <default display="5" />
-	  <shifted display="%" />                
-	  <background image="testkey.png"/>
+      <default display="Y" />
+      <normalimage image="key_cap_Y.png"/>
+      <pushimage image="key_cap_Y_p.png"/>
     </key>
     <key>
-	  <default display="6" />
-	  <shifted display="^" />                
-	  <background image="testkey.png"/>
+      <default display="U" />
+      <normalimage image="key_cap_U.png"/>
+      <pushimage image="key_cap_U_p.png"/>
     </key>
     <key>
-	  <default display="7" />
-	  <shifted display="&amp;" />                
-	  <background image="testkey.png"/>
+      <default display="I" />
+      <normalimage image="key_cap_I.png"/>
+      <pushimage image="key_cap_I_p.png"/>
     </key>
     <key>
-	  <default display="8" />
-	  <shifted display="*" />                
-	  <background image="testkey.png"/>
+      <default display="O" />
+      <normalimage image="key_cap_O.png"/>
+      <pushimage image="key_cap_O_p.png"/>
     </key>
     <key>
-	  <default display="9" />
-	  <shifted display="(" />                
-	  <background image="testkey.png"/>
+      <default display="P" />
+      <normalimage image="key_cap_P.png"/>
+      <pushimage image="key_cap_P_p.png"/>
     </key>
-    <key>
-	  <default display="0" />
-	  <shifted display=")" />                
-	  <background image="testkey.png"/>
-    </key>
-    <key>
-	  <default display="-" />
-	  <shifted display="_" />                
-	  <background image="testkey.png"/>
-    </key>
-    <key>
-	  <default display="=" />
-	  <shifted display="+" />                
-	  <background image="testkey.png"/>
-    </key>
 
-    <key fill="true">
-	  <default display="Bksp" action="backspace"/>
-    </key>
-
   </row>
 
   <row>
 
-    <space width="500" extended="true"/>
-
-    <key fill="true">
-	  <default display="Tab" action="tab"/>                
+    <key>
+      <default display="A" />
+      <normalimage image="key_cap_A.png"/>
+      <pushimage image="key_cap_A_p.png"/>
     </key>
-    <key obey-caps='true'>
-	  <default display="q" />                
-	  <shifted display="Q" />
-	  <background image="testkey.png"/>
+    <key>
+      <default display="S" />
+      <normalimage image="key_cap_S.png"/>
+      <pushimage image="key_cap_S_p.png"/>
     </key>
-    <key obey-caps='true'>
-	  <default display="w" />                
-	  <shifted display="W" />
-	  <background image="testkey.png"/>
+    <key>
+      <default display="D" />
+      <normalimage image="key_cap_D.png"/>
+      <pushimage image="key_cap_D_p.png"/>
     </key>
-    <key obey-caps='true'>
-	  <mod1 display="ë" />
-	  <default    display="e" />                
-	  <shifted display="E" />
-	  <background image="testkey.png"/>
+    <key>
+      <default display="F" />
+      <normalimage image="key_cap_F.png"/>
+      <pushimage image="key_cap_F_p.png"/>
     </key>
-    <key obey-caps='true'>
-	  <default display="r" />                
-	  <shifted display="R" />
-	  <background image="testkey.png"/>
+    <key>
+      <default display="G" />
+      <normalimage image="key_cap_G.png"/>
+      <pushimage image="key_cap_G_p.png"/>
     </key>
-    <key obey-caps='true'>
-	  <default display="t" />                
-	  <shifted display="T" />
-	  <background image="testkey.png"/>
+    <key>
+      <default display="H" />
+      <normalimage image="key_cap_H.png"/>
+      <pushimage image="key_cap_H_p.png"/>
     </key>
-    <key obey-caps='true'>
-	  <default display="y" />                
-	  <shifted display="Y" />
-	  <background image="testkey.png"/>
+    <key>
+      <default display="J" />
+      <normalimage image="key_cap_J.png"/>
+      <pushimage image="key_cap_J_p.png"/>
     </key>
-    <key obey-caps='true'>
-	  <default display="u" />                
-	  <shifted display="U" />
-	  <background image="testkey.png"/>
-    </key>
-    <key obey-caps='true'>
-	  <default display="i" />                
-	  <shifted display="I" />
-	  <background image="testkey.png"/>
-    </key>
-    <key obey-caps='true'>
-	  <default display="o" />                
-	  <shifted display="O" />
-	  <background image="testkey.png"/>
-    </key>
-    <key obey-caps='true'>
-	  <default display="p" />                
-	  <shifted display="P" />
-	  <background image="testkey.png"/>
-    </key>
     <key>
-	  <default display="{" />                
-	  <shifted display="[" />
-	  <background image="testkey.png"/>
+      <default display="K" />
+      <normalimage image="key_cap_K.png"/>
+      <pushimage image="key_cap_K_p.png"/>
     </key>
     <key>
-	  <default display="}" />                
-	  <shifted display="]" />
-	  <background image="testkey.png"/>
+      <default display="L" />
+      <normalimage image="key_cap_L.png"/>
+      <pushimage image="key_cap_L_p.png"/>
     </key>
-    <key fill="true">
-	  <default display="\" />                
-	  <shifted display="|" />
-	  <background image="testkey.png"/>
-    </key>
 
   </row>
   <row>
 
-    <space width="500" extended="true"/>
-
-    <key fill="true">
-	  <default display="Caps" action="modifier:caps"/>                
-    </key>
-    <key obey-caps='true'>
-	  <default display="a" />                
-	  <shifted display="A" />
-	  <background image="testkey.png"/>
-    </key>
-    <key obey-caps='true'>
-	  <default display="s" />                
-	  <shifted display="S" />
-	  <background image="testkey.png"/>
-    </key>
-    <key obey-caps='true'>
-	  <default display="d" />                
-	  <shifted display="D" />
-	  <background image="testkey.png"/>
-    </key>
-    <key obey-caps='true'>
-	  <default display="f" />                
-	  <shifted display="F" />
-	  <background image="testkey.png"/>
-    </key>
-    <key obey-caps='true'>
-	  <default display="g" />                
-	  <shifted display="G" />
-	  <background image="testkey.png"/>
-    </key>
-    <key obey-caps='true'>
-	  <default display="h" />                
-	  <shifted display="H" />
-	  <background image="testkey.png"/>
-    </key>
-    <key obey-caps='true'>
-	  <default display="j" />                
-	  <shifted display="J" />
-	  <background image="testkey.png"/>
-    </key>
-    <key obey-caps='true'>
-	  <default display="k" />                
-	  <shifted display="K" />
-	  <background image="testkey.png"/>
-    </key>
-    <key obey-caps='true'>
-	  <default display="l" />                
-	  <shifted display="L" />
-	  <background image="testkey.png"/>
-    </key>
     <key>
-	  <default display=";" />                
-	  <shifted display=":" />
-	  <background image="testkey.png"/>
+      <default display="Z" />
+      <normalimage image="key_cap_Z.png"/>
+      <pushimage image="key_cap_Z_p.png"/>
     </key>
     <key>
-	  <default display="#" />                
-	  <shifted display="~" />
-	  <background image="testkey.png"/>
+      <default display="X" />
+      <normalimage image="key_cap_X.png"/>
+      <pushimage image="key_cap_X_p.png"/>
     </key>
-    <key fill="true">
-	  <default display="Ret" action="return"/>
-    </key>
-
-  </row>
-  <row>
-
-    <space width="500" extended="true"/>
-
-    <key fill="true">
-	  <default display="Shift" action="modifier:shift"/>                
-    </key>
-
-    <key obey-caps='true'>
-	  <default display="z" />                
-	  <shifted display="Z" />
-	  <background image="testkey.png"/>
-    </key>
-
-    <key obey-caps='true'>
-	  <default display="x" />                
-	  <shifted display="X" />
-	  <background image="testkey.png"/>
-    </key>
-
-    <key obey-caps='true'>
-	  <default display="c" />                
-	  <shifted display="C" />
-	  <background image="testkey.png"/>
-    </key>
-
-    <key obey-caps='true'>
-	  <default display="v" />                
-	  <shifted display="V" />
-	  <background image="testkey.png"/>
-    </key>
-
-    <key obey-caps='true'>
-	  <default display="b" />                
-	  <shifted display="B" />
-	  <background image="testkey.png"/>
-    </key>
-
-    <key obey-caps='true'>
-	  <default display="n" />                
-	  <shifted display="N" />
-	  <background image="testkey.png"/>
-    </key>
-
-    <key obey-caps='true'>
-	  <default display="m" />                
-	  <shifted display="M" />
-	  <background image="testkey.png"/>
-    </key>
-
     <key>
-	  <default display="," />                
-	  <shifted display="&lt;" />
-	  <background image="testkey.png"/>
+      <default display="C" />
+      <normalimage image="key_cap_C.png"/>
+      <pushimage image="key_cap_C_p.png"/>
     </key>
     <key>
-	  <default display="." />                
-	  <shifted display="&gt;" />
-	  <background image="testkey.png"/>
+      <default display="V" />
+      <normalimage image="key_cap_V.png"/>
+      <pushimage image="key_cap_V_p.png"/>
     </key>
     <key>
-	  <default display="/" />                
-	  <shifted display="?" />
-	  <background image="testkey.png"/>
+      <default display="B" />
+      <normalimage image="key_cap_B.png"/>
+      <pushimage image="key_cap_B_p.png"/>
     </key>
-
-
-    <key fill="true">
-	  <default display="Shift" action="modifier:shift"/>                
-    </key>
-
- </row>
-  <row>
-
-    <space width="500" extended="true"/>
-
     <key>
-	  <default display="äëö" action="modifier:mod1"/>                
+      <default display="N" />
+      <normalimage image="key_cap_N.png"/>
+      <pushimage image="key_cap_N_p.png"/>
     </key>
-
-    <key fill="true">
-	  <default display="Ctrl" action="modifier:ctrl"/>                
-    </key>
-
     <key>
-	  <default display="Alt" action="modifier:alt"/>                
+      <default display="M" />
+      <normalimage image="key_cap_M.png"/>
+      <pushimage image="key_cap_M_p.png"/>
     </key>
 
+  </row>
 
-    <key>
-	  <default display=" " action="space" />                
-	  <background image="spacekey.png"/>
-    </key>
+  <row>
 
-    <key>
-	  <default display="@" />                
-	  <shifted display="'" />
-    </key>
 
     <key>
-	  <default display="^" action="up" />                
+      <default display=" " action="space" />
+      <normalimage image="key_comm_space.png"/>
+      <pushimage image="key_comm_space_p.png"/>
     </key>
     <key>
-	  <default display="V" action="down" />                
+      <default display=" " action="backspace" />
+      <normalimage image="key_comm_backspace.png"/>
+      <pushimage image="key_comm_backspace_p.png"/>
     </key>
     <key>
-	  <default display="&lt;" action="left" />                
+      <default display=" " action="return" />
+      <normalimage image="key_comm_enter.png"/>
+      <pushimage image="key_comm_enter_p.png"/>
     </key>
-    <key>
-	  <default display="&gt;" action="right" />                
-    </key>
+  </row>
 
-</row>
-
 </layout>
 
 

Modified: trunk/src/target/OM-2007/applications/openmoko-keyboard/src/config-parser.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-keyboard/src/config-parser.c	2007-02-28 07:26:23 UTC (rev 1157)
+++ trunk/src/target/OM-2007/applications/openmoko-keyboard/src/config-parser.c	2007-02-28 08:20:02 UTC (rev 1158)
@@ -315,10 +315,24 @@
   MBKeyboardImage *img;
   const char *val;
   char  buf[512];
+  Bool  pushimage;
 
+  if (streq(tag, "normalimage"))
+    {
+      pushimage = False;
+    }
+  else if (streq(tag, "pushimage"))
+    {
+      pushimage = True;
+    }
+  else
+    {
+      set_error(state, "Unknown background image");
+      return;
+    }
+
   if ((val = attr_get_val("image", attr)) == NULL)
     {
-      fprintf(stderr, "image=%s\n", val);
       set_error(state, "Attribute 'image' is required");
       return;
     }
@@ -339,7 +353,10 @@
   if (img == NULL)
     fprintf(stderr, "load img fail\n");
 
-  mb_kbd_key_set_back_image(state->current_key, img);
+  if (pushimage)
+    mb_kbd_key_set_normal_image(state->current_key, img);
+  else
+    mb_kbd_key_set_push_image(state->current_key, img);
 }
 
 static void
@@ -556,15 +573,44 @@
 	mb_kbd_key_set_fill(state->current_key, True);
     }
 
-  /*FIXME: It is only temporary code */
-  //img = mb_kbd_image_new(state->keyboard, "/root/.matchbox/match.png");
-  //if(!img)
-    //fprintf(stderr, "can not find /root/.matchbox/match.png\n");
-  //mb_kbd_key_set_back_image(state->current_key, img);
-
   mb_kbd_row_append_key(state->current_row, state->current_key);
 }
 
+static void
+config_handle_layout_background(MBKeyboardConfigState *state,
+                                const char **attr)
+{
+  MBKeyboardImage *img;
+  const char *val;
+  char  buf[512];
+
+  if ((val = attr_get_val("image", attr)) == NULL)
+    {
+      set_error(state, "Backgroud Attribute 'image' is required");
+      return;
+    }
+
+  if (val[0] != '/')
+    {
+      snprintf(buf, 512, "%s/%s", PKGDATADIR, val);
+
+      if (!util_file_readable(buf))
+        snprintf(buf, 512, "%s/.matchbox/%s", getenv("HOME"), val);
+
+      img = mb_kbd_image_new (state->keyboard, buf);
+    }
+  else
+    {
+      img = mb_kbd_image_new (state->keyboard, val);
+    }
+
+  if (img == NULL)
+    fprintf(stderr, "load img fail\n");
+
+  mb_kbd_layout_set_background(state->current_layout, img);
+
+}
+
 static void 
 config_xml_start_cb(void *data, const char *tag, const char **attr)
 {
@@ -587,7 +633,8 @@
       config_handle_key_tag(state, attr);
       mb_kbd_key_set_blank(state->current_key, True);
     }
-  else  if (streq(tag, "background"))
+  else  if (streq(tag, "normalimage")
+	   || streq(tag, "pushimage"))
     {
       config_handle_key_background_tag(state, tag, attr);
     }
@@ -600,6 +647,10 @@
     {
       config_handle_key_subtag(state, tag, attr);
     }
+  else if (streq(tag, "background"))
+    {
+      config_handle_layout_background(state, attr);
+    }
 
   if (state->error)
     {

Modified: trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard-key.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard-key.c	2007-02-28 07:26:23 UTC (rev 1157)
+++ trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard-key.c	2007-02-28 08:20:02 UTC (rev 1158)
@@ -72,7 +72,8 @@
   boolean                is_blank;   /* 'blank' keys are spacers */
   boolean                extended;   /* only show in landscape */
 
-  MBKeyboardImage        *back_image;   /* The background image */
+  MBKeyboardImage        *normal_image;   /* The normal image */
+  MBKeyboardImage        *push_image;   /* The push down image */
 
   MBKeyboardStateType    sets_kbdstate; /* needed */
 };
@@ -100,18 +101,30 @@
 }
 
 void
-mb_kbd_key_set_back_image(MBKeyboardKey *key, MBKeyboardImage *image)
+mb_kbd_key_set_normal_image(MBKeyboardKey *key, MBKeyboardImage *image)
 {
-  key->back_image = image;
+  key->normal_image = image;
 }
 
 MBKeyboardImage *
-mb_kbd_key_get_back_image(MBKeyboardKey *key)
+mb_kbd_key_get_normal_image(MBKeyboardKey *key)
 {
-  return key->back_image;
+  return key->normal_image;
 }
 
 void
+mb_kbd_key_set_push_image(MBKeyboardKey *key, MBKeyboardImage *image)
+{
+  key->push_image = image;
+}
+
+MBKeyboardImage *
+mb_kbd_key_get_push_image(MBKeyboardKey *key)
+{
+  return key->push_image;
+}
+
+void
 mb_kbd_key_set_obey_caps(MBKeyboardKey  *key, boolean obey)
 {
   key->obeys_caps = obey;

Modified: trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard-layout.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard-layout.c	2007-02-28 07:26:23 UTC (rev 1157)
+++ trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard-layout.c	2007-02-28 08:20:02 UTC (rev 1158)
@@ -23,6 +23,7 @@
 {
   MBKeyboard       *kbd;  
   char             *id;
+  MBKeyboardImage  *background;
   List             *rows;
 };
 
@@ -41,6 +42,19 @@
 }
 
 void
+mb_kbd_layout_set_background(MBKeyboardLayout *layout,
+                             MBKeyboardImage  *background)
+{
+  layout->background = background;
+}
+
+MBKeyboardImage *
+mb_kbd_layout_get_background(MBKeyboardLayout *layout)
+{
+  return layout->background;
+}
+
+void
 mb_kbd_layout_append_row(MBKeyboardLayout *layout,
 			 MBKeyboardRow    *row)
 {

Modified: trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard-ui-xft-backend.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard-ui-xft-backend.c	2007-02-28 07:26:23 UTC (rev 1157)
+++ trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard-ui-xft-backend.c	2007-02-28 08:20:02 UTC (rev 1158)
@@ -147,13 +147,10 @@
   if (rect.y + rect.height >= mb_kbd_ui_x_win_height(ui)) 
     rect.height  = mb_kbd_ui_x_win_height(ui) - rect.y - 1;
 
-  /* clear it */
-
-  XSetForeground(xdpy, xft_backend->xgc, WhitePixel(xdpy, xscreen));
-
-  XFillRectangles(xdpy, backbuffer, xft_backend->xgc, &rect, 1);
-
-  image = mb_kbd_key_get_back_image(key);
+  if (mb_kbd_key_is_held(kbd, key))
+    image = mb_kbd_key_get_push_image(key);
+  else
+    image = mb_kbd_key_get_normal_image(key);
   if(image)
     {
       int w, h;
@@ -169,6 +166,12 @@
     }
   else                   
     {
+      /* clear it */
+
+      XSetForeground(xdpy, xft_backend->xgc, WhitePixel(xdpy, xscreen));
+
+      XFillRectangles(xdpy, backbuffer, xft_backend->xgc, &rect, 1);
+
       /* draw 'main border' */
       
       XSetForeground(xdpy, xft_backend->xgc, xft_backend->xcol_c5c5c5.pixel);
@@ -245,6 +248,7 @@
         state = MBKeyboardKeyStateNormal;
     }
 
+/*
   if (mb_kbd_key_get_face_type(key, state) == MBKeyboardKeyFaceGlyph)
     {
       const char *face_str = mb_kbd_key_get_glyph_face(key, state);
@@ -293,32 +297,52 @@
 		       XftDrawPicture (xft_backend->xft_backbuffer), 
 		       0, 0, 0, 0, x, y, w, h);
     }
+*/
 }
 
 void
 mb_kbd_ui_xft_pre_redraw(MBKeyboardUI  *ui)
 {
   MBKeyboardUIBackendXft *xft_backend = NULL;
+  MBKeyboardImage        *image;
 
   xft_backend = (MBKeyboardUIBackendXft*)mb_kbd_ui_backend(ui);
 
+  image = mb_kbd_layout_get_background(mb_kbd_get_selected_layout(mb_kbd_ui_kbd(ui)));
+
   /* Background */
-  XSetForeground(mb_kbd_ui_x_display(ui), 
-		 xft_backend->xgc, xft_backend->xcol_f4f4f4.pixel);
+  if (image == NULL)
+    {
+      XSetForeground(mb_kbd_ui_x_display(ui), 
+                     xft_backend->xgc, xft_backend->xcol_f4f4f4.pixel);
 
-  XFillRectangle(mb_kbd_ui_x_display(ui), 
-		 mb_kbd_ui_backbuffer(ui), 
-		 xft_backend->xgc,
-		 0, 0, 
-		 mb_kbd_ui_x_win_width(ui),
-		 mb_kbd_ui_x_win_height(ui));
+      XFillRectangle(mb_kbd_ui_x_display(ui), 
+                     mb_kbd_ui_backbuffer(ui), 
+                     xft_backend->xgc,
+                     0, 0, 
+                     mb_kbd_ui_x_win_width(ui),
+                     mb_kbd_ui_x_win_height(ui));
 
-  XSetForeground(mb_kbd_ui_x_display(ui), 
-		 xft_backend->xgc, 
-		 BlackPixel(mb_kbd_ui_x_display(ui), 
-			    mb_kbd_ui_x_screen(ui)));
+      XSetForeground(mb_kbd_ui_x_display(ui), 
+                     xft_backend->xgc, 
+                     BlackPixel(mb_kbd_ui_x_display(ui), 
+                                mb_kbd_ui_x_screen(ui)));
+    }
+  else
+    {
+      int w, h;
 
+      w = mb_kbd_image_width (image);
+      h = mb_kbd_image_height (image);
 
+      XRenderComposite(mb_kbd_ui_x_display(ui),
+                       PictOpOver,
+                       mb_kbd_image_render_picture(image),
+                       None,
+                       XftDrawPicture(xft_backend->xft_backbuffer),
+                       0, 0, 0, 0, 0, 0, w, h);
+    }
+
 }
 
 static int

Modified: trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard-ui.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard-ui.c	2007-02-28 07:26:23 UTC (rev 1157)
+++ trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard-ui.c	2007-02-28 08:20:02 UTC (rev 1158)
@@ -134,7 +134,6 @@
   if (y) *y           = geometry[1];
   if (width)  *width  = geometry[2];
   if (height) *height = geometry[3];
-  fprintf(stderr, "x=%d,y=%d,w=%d,h=%d\n",geometry[0],geometry[1],geometry[2],geometry[3]);
   
   XFree(geometry);
 
@@ -341,9 +340,9 @@
 	    max_h = mb_kbd_image_height (img);
 	}
     }
-  if (mb_kbd_key_get_back_image(key))
+  if (mb_kbd_key_get_normal_image(key))
     {
-      MBKeyboardImage *img = mb_kbd_key_get_back_image(key);
+      MBKeyboardImage *img = mb_kbd_key_get_normal_image(key);
 
       if (mb_kbd_image_width (img) > max_w)
         max_w = mb_kbd_image_width (img);
@@ -437,9 +436,7 @@
       row_y += max_row_key_height + mb_kbd_row_spacing(ui->kbd);
 
       row_item = util_list_next(row_item);
-      fprintf(stderr, "the key_x=%d,key_y=%d\n", key_x, key_y);
     }
-  fprintf(stderr, "max_row_key_height=%d,max_row_width=%d\n", max_row_key_height, max_row_width);
 
   *height = row_y; 
 
@@ -468,7 +465,6 @@
 	goto next_row;
 
       free_space = max_row_width - mb_kbd_row_width(row);
-      fprintf(stderr, "free_space=%d, max_row_width=%d, mb_kbd_row_width(row)=%d\n", free_space, max_row_width, mb_kbd_row_width(row));
 
       mb_kbd_row_for_each_key(row, key_item)
 	{
@@ -524,6 +520,23 @@
     }
   
   *width = max_row_width;
+
+  if (mb_kbd_layout_get_background(layout) != NULL)
+    {
+      MBKeyboardImage *img;
+      int             img_wid;
+      int             img_hei;
+
+      img = mb_kbd_layout_get_background(layout);
+      img_wid = mb_kbd_image_width(img);
+      img_hei = mb_kbd_image_height(img);
+
+      if (img_wid > *width)
+        *width = img_wid;
+
+      if (img_hei > *height)
+        *height = img_hei;
+    }
 }
 
 void
@@ -667,8 +680,8 @@
 	have_matchbox_wm = True;
     }
 
-  win_attr.override_redirect = True; /* Set to true for extreme case */
-  /*win_attr.override_redirect = False;*/ /* Set to true for extreme case */
+  /*win_attr.override_redirect = True;*/ /* Set to true for extreme case */
+  win_attr.override_redirect = False; /* Set to true for extreme case */
   win_attr.event_mask 
     = ButtonPressMask|ButtonReleaseMask|Button1MotionMask|StructureNotifyMask;
 
@@ -680,7 +693,6 @@
 			   CopyFromParent, CopyFromParent, CopyFromParent,
 			   CWOverrideRedirect|CWEventMask,
 			   &win_attr);
-  fprintf(stderr, "ui->xwin_width=%d,ui->xwin_height=%d\n", ui->xwin_width, ui->xwin_height);
 
 
   wm_hints = XAllocWMHints();
@@ -1038,7 +1050,6 @@
   old_state = mb_kbd_is_extended(ui->kbd);
   new_state = want_extended(ui);
    
-  fprintf(stderr, "########################################################\n");
   if (new_state == old_state) 	/* Not a rotation */
     {
       mb_kbd_ui_resize(ui, width, height); 
@@ -1249,7 +1260,6 @@
   */
   mb_kbd_ui_allocate_ui_layout(ui, 
 			       &ui->base_alloc_width, &ui->base_alloc_height);
-  fprintf(stderr, "ui->base_alloc_width=%d, ui->base_alloc_height=%d\n",ui->base_alloc_width, ui->base_alloc_height);
 
   ui->xwin_width  = ui->base_alloc_width;
   ui->xwin_height = ui->base_alloc_height;

Modified: trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard.c	2007-02-28 07:26:23 UTC (rev 1157)
+++ trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard.c	2007-02-28 08:20:02 UTC (rev 1158)
@@ -89,11 +89,11 @@
 
   if (want_small)
     {
-      kb->key_border   = 1;
+      kb->key_border   = 0;
       kb->key_pad      = 0;
       kb->col_spacing  = 0;
       kb->row_spacing  = 0;
-      kb->font_pt_size = 10;
+      kb->font_pt_size = 12;
     }
 
   if (!mb_kbd_config_load(kb, variant))

Modified: trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard.h	2007-02-28 07:26:23 UTC (rev 1157)
+++ trunk/src/target/OM-2007/applications/openmoko-keyboard/src/matchbox-keyboard.h	2007-02-28 08:20:02 UTC (rev 1158)
@@ -341,6 +341,13 @@
 mb_kbd_layout_new(MBKeyboard *kbd, const char *id);
 
 void
+mb_kbd_layout_set_background(MBKeyboardLayout *layout,
+                             MBKeyboardImage  *background);
+
+MBKeyboardImage *
+mb_kbd_layout_get_background(MBKeyboardLayout *layout);
+
+void
 mb_kbd_layout_append_row(MBKeyboardLayout *layout,
 			 MBKeyboardRow    *row);
 
@@ -392,12 +399,18 @@
 mb_kbd_key_new(MBKeyboard *kbd);
 
 void
-mb_kbd_key_set_back_image(MBKeyboardKey *key, MBKeyboardImage *image);
+mb_kbd_key_set_normal_image(MBKeyboardKey *key, MBKeyboardImage *image);
 
 MBKeyboardImage *
-mb_kbd_key_get_back_image(MBKeyboardKey *key);
+mb_kbd_key_get_normal_image(MBKeyboardKey *key);
 
 void
+mb_kbd_key_set_push_image(MBKeyboardKey *key, MBKeyboardImage *image);
+
+MBKeyboardImage *
+mb_kbd_key_get_push_image(MBKeyboardKey *key);
+
+void
 mb_kbd_key_set_obey_caps(MBKeyboardKey  *key, boolean obey);
 
 boolean





More information about the commitlog mailing list