[maemo-commits] [maemo-commits] r8717 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildonwm
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon Dec 11 17:28:57 EET 2006
- Previous message: [maemo-commits] r8716 - in projects/haf/trunk/osso-application-installer: . debian
- Next message: [maemo-commits] r8718 - projects/haf/trunk/osso-application-installer
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: moimart
Date: 2006-12-11 17:28:55 +0200 (Mon, 11 Dec 2006)
New Revision: 8717
Modified:
projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog
projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-entry-info.c
projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-keys.c
projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-keys.h
projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.c
projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.h
Log:
* libhildonwm/hd-keys.[ch]: Refactoring to GObject.
* libhildonwm/hd-wm.[ch]: Using a public a hd-keys config handler.
* libhildonwm/hd-entry-info.[ch]: Code cleanup
* ChangeLog updated.
Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog
===================================================================
--- projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog 2006-12-11 14:51:05 UTC (rev 8716)
+++ projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog 2006-12-11 15:28:55 UTC (rev 8717)
@@ -1,3 +1,9 @@
+2006-12-12 Moises Martinez <moises.martinez at nokia.com>
+
+ * libhildonwm/hd-keys.[ch]: Refactoring to GObject.
+ * libhildonwm/hd-wm.[ch]: Using a public a hd-keys config handler.
+ * libhildonwm/hd-entry-info.[ch]: Code cleanup
+
2006-12-11 Johan Bilien <johan.bilien at nokia.com>
* libhildonwm/hd-wm.[ch]:
Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-entry-info.c
===================================================================
--- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-entry-info.c 2006-12-11 14:51:05 UTC (rev 8716)
+++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-entry-info.c 2006-12-11 15:28:55 UTC (rev 8717)
@@ -124,9 +124,9 @@
real = REAL_ENTRY_INFO (entry_info);
switch (real->type)
- {
+ {
case HD_ENTRY_WATCHED_APP:
- break;
+ break;
case HD_ENTRY_WATCHED_WINDOW:
break;
case HD_ENTRY_WATCHED_VIEW:
@@ -135,7 +135,7 @@
default:
g_assert_not_reached ();
return;
- }
+ }
g_list_free (real->children);
@@ -165,7 +165,7 @@
real = REAL_ENTRY_INFO (entry_info);
switch (real->type)
- {
+ {
case HD_ENTRY_WATCHED_APP:
return REAL_ENTRY_INFO (entry_info)->d.app;
break;
@@ -180,7 +180,7 @@
default:
g_assert_not_reached ();
break;
- }
+ }
return hd_wm_watched_window_get_app(win);
}
@@ -201,16 +201,15 @@
HDWMWatchedWindowView *view;
g_return_val_if_fail (entry_info != NULL, NULL);
- switch(entry_info->type)
- {
+ switch (entry_info->type)
+ {
case HD_ENTRY_WATCHED_WINDOW:
return REAL_ENTRY_INFO (entry_info)->d.window;
case HD_ENTRY_WATCHED_VIEW:
- view = hd_entry_info_get_view(entry_info);
- return hd_wm_watched_window_view_get_parent(view);
+ view = hd_entry_info_get_view (entry_info);
+ return hd_wm_watched_window_view_get_parent (view);
default:
- return hd_wm_watchable_app_get_active_window(
- hd_entry_info_get_app(entry_info));
+ return hd_wm_watchable_app_get_active_window (hd_entry_info_get_app (entry_info));
}
}
@@ -268,7 +267,7 @@
real = REAL_ENTRY_INFO (entry_info);
switch (real->type)
- {
+ {
case HD_ENTRY_WATCHED_APP:
retval = hd_wm_watchable_app_get_name (real->d.app);
break;
@@ -286,7 +285,7 @@
g_assert_not_reached ();
retval = NULL;
break;
- }
+ }
return retval;
}
@@ -300,33 +299,38 @@
real = REAL_ENTRY_INFO (entry_info);
switch (real->type)
- {
+ {
case HD_ENTRY_WATCHED_APP:
{
- HDWMWatchedWindow *win;
+ HDWMWatchedWindow *win;
- win = hd_wm_watchable_app_get_active_window (real->d.app);
- if (win)
- retval = hd_wm_watched_window_get_name (win);
- else
- retval = hd_wm_watchable_app_get_name (real->d.app);
+ win = hd_wm_watchable_app_get_active_window (real->d.app);
+
+ if (win)
+ retval = hd_wm_watched_window_get_name (win);
+ else
+ retval = hd_wm_watchable_app_get_name (real->d.app);
}
break;
+
case HD_ENTRY_WATCHED_WINDOW:
retval = hd_wm_watched_window_get_name (real->d.window);
break;
+
case HD_ENTRY_WATCHED_VIEW:
retval = hd_wm_watched_window_view_get_name (real->d.view);
break;
+
case HD_ENTRY_DESKTOP:
retval = _("tana_fi_home");
break;
+
case HD_ENTRY_INVALID:
default:
g_assert_not_reached ();
retval = NULL;
break;
- }
+ }
return retval;
}
@@ -353,16 +357,16 @@
sep = strstr (title, " - ");
if (sep)
- {
- gchar *retval;
+ {
+ gchar *retval;
- *sep = 0;
- retval = g_strdup (title);
+ *sep = 0;
+ retval = g_strdup (title);
- g_free (title);
+ g_free (title);
- return retval;
- }
+ return retval;
+ }
else
return title;
}
@@ -383,16 +387,16 @@
sep = strstr (title, " - ");
if (sep)
- {
- gchar *retval;
+ {
+ gchar *retval;
- *sep = 0;
- retval = g_strdup (sep + 3);
+ *sep = 0;
+ retval = g_strdup (sep + 3);
- g_free (title);
+ g_free (title);
- return retval;
- }
+ return retval;
+ }
else
return NULL;
}
@@ -408,21 +412,24 @@
real = REAL_ENTRY_INFO (entry_info);
switch (real->type)
- {
+ {
case HD_ENTRY_WATCHED_APP:
/* TODO */
break;
+
case HD_ENTRY_WATCHED_WINDOW:
hd_wm_watched_window_set_name (real->d.window, title);
break;
+
case HD_ENTRY_WATCHED_VIEW:
hd_wm_watched_window_view_set_name (real->d.view, title);
break;
+
case HD_ENTRY_INVALID:
default:
g_assert_not_reached ();
break;
- }
+ }
}
GdkPixbuf *
@@ -436,7 +443,7 @@
real = REAL_ENTRY_INFO (entry_info);
switch (real->type)
- {
+ {
case HD_ENTRY_WATCHED_APP:
/* TODO */
break;
@@ -453,7 +460,7 @@
default:
g_assert_not_reached ();
break;
- }
+ }
return retval;
}
@@ -469,7 +476,7 @@
real = REAL_ENTRY_INFO (entry_info);
switch (real->type)
- {
+ {
case HD_ENTRY_WATCHED_APP:
/* TODO */
break;
@@ -481,7 +488,7 @@
default:
g_assert_not_reached ();
break;
- }
+ }
}
void
@@ -493,21 +500,24 @@
real = REAL_ENTRY_INFO (info);
switch (real->type)
- {
+ {
case HD_ENTRY_WATCHED_APP:
/* TODO */
break;
+
case HD_ENTRY_WATCHED_WINDOW:
hd_wm_watched_window_close (real->d.window);
break;
+
case HD_ENTRY_WATCHED_VIEW:
hd_wm_watched_window_view_close_window (real->d.view);
break;
+
case HD_ENTRY_INVALID:
default:
g_assert_not_reached ();
break;
- }
+ }
}
const gchar *
@@ -521,7 +531,7 @@
real = REAL_ENTRY_INFO (info);
switch (real->type)
- {
+ {
case HD_ENTRY_WATCHED_APP:
app = hd_entry_info_get_app (info);
break;
@@ -537,18 +547,18 @@
default:
g_assert_not_reached ();
break;
- }
+ }
if (!app)
- {
- if (!win)
- return NULL;
+ {
+ if (!win)
+ return NULL;
- app = hd_wm_watched_window_get_app (win);
+ app = hd_wm_watched_window_get_app (win);
- if (!app)
- return NULL;
- }
+ if (!app)
+ return NULL;
+ }
return hd_wm_watchable_app_get_icon_name (app);
}
@@ -581,11 +591,10 @@
GTK_ICON_LOOKUP_NO_SVG,
&load_error);
if (load_error)
- {
- g_propagate_error (error, load_error);
-
- return NULL;
- }
+ {
+ g_propagate_error (error, load_error);
+ return NULL;
+ }
g_debug (G_STRLOC ": adding cache entry (size:%d)", size);
g_hash_table_insert (real_info->icon_cache,
@@ -692,26 +701,30 @@
real = REAL_ENTRY_INFO (info);
switch (info->type)
- {
- case HD_ENTRY_WATCHED_APP:
- {
- GList *l;
+ {
+ case HD_ENTRY_WATCHED_APP:
+ {
+ GList *l;
- for (l = real->children; l != NULL; l = l->next)
- if (hd_entry_info_is_active (l->data))
- return TRUE;
- }
- return FALSE;
- case HD_ENTRY_WATCHED_WINDOW:
- return hd_wm_watched_window_is_active(real->d.window);
- case HD_ENTRY_WATCHED_VIEW:
- return hd_wm_watched_window_view_is_active(real->d.view);
- case HD_ENTRY_DESKTOP:
- return TRUE;
- case HD_ENTRY_INVALID:
- default:
- g_critical("Invalid Entry type");
- }
+ for (l = real->children; l != NULL; l = l->next)
+ if (hd_entry_info_is_active (l->data))
+ return TRUE;
+ }
+ return FALSE;
+
+ case HD_ENTRY_WATCHED_WINDOW:
+ return hd_wm_watched_window_is_active(real->d.window);
+
+ case HD_ENTRY_WATCHED_VIEW:
+ return hd_wm_watched_window_view_is_active(real->d.view);
+
+ case HD_ENTRY_DESKTOP:
+ return TRUE;
+
+ case HD_ENTRY_INVALID:
+ default:
+ g_critical("Invalid Entry type");
+ }
return FALSE;
}
@@ -733,16 +746,16 @@
g_return_val_if_fail (info, NULL);
switch (info->type)
- {
- case HD_ENTRY_WATCHED_APP:
- return hd_wm_watchable_app_get_extra_icon(hd_entry_info_get_app(info));
+ {
+ case HD_ENTRY_WATCHED_APP:
+ return hd_wm_watchable_app_get_extra_icon(hd_entry_info_get_app(info));
- case HD_ENTRY_WATCHED_WINDOW:
- case HD_ENTRY_WATCHED_VIEW:
- case HD_ENTRY_INVALID:
- default:
- g_critical("Invalid Entry type");
- }
+ case HD_ENTRY_WATCHED_WINDOW:
+ case HD_ENTRY_WATCHED_VIEW:
+ case HD_ENTRY_INVALID:
+ default:
+ g_critical("Invalid Entry type");
+ }
return NULL;
}
@@ -754,3 +767,4 @@
return (NULL != hd_entry_info_get_extra_icon (info));
}
+
Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-keys.c
===================================================================
--- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-keys.c 2006-12-11 14:51:05 UTC (rev 8716)
+++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-keys.c 2006-12-11 15:28:55 UTC (rev 8717)
@@ -44,22 +44,68 @@
#define MCE_TRIGGER_POWERKEY_EVENT_REQ "req_trigger_powerkey_event"
+G_DEFINE_TYPE (HDKeysConfig, hd_keys_config, G_TYPE_OBJECT);
+
+static void hd_keys_config_finalize (GObject *object);
+
+static void gconf_key_changed_callback (GConfClient *client,
+ guint connection_id,
+ GConfEntry *entry,gpointer
+ user_data);
+
+static void hd_keys_set_modifiers (HDKeysConfig *keys);
+
+static void hd_keys_load_and_grab_all_shortcuts (HDKeysConfig *keys);
+
static void
+hd_keys_config_class_init (HDKeysConfigClass *keys_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (keys_class);
+
+ object_class->finalize = hd_keys_config_finalize;
+}
+
+static void
+hd_keys_config_init (HDKeysConfig *keys)
+{
+ keys->gconf_client = gconf_client_get_default();
+
+ gconf_client_add_dir (keys->gconf_client,
+ HD_KEYS_GCONF_PATH,
+ GCONF_CLIENT_PRELOAD_NONE,
+ NULL);
+
+ gconf_client_notify_add (keys->gconf_client,
+ HD_KEYS_GCONF_PATH,
+ gconf_key_changed_callback,
+ keys,
+ NULL,
+ NULL);
+
+ hd_keys_set_modifiers (keys);
+
+ hd_keys_load_and_grab_all_shortcuts (keys);
+
+ g_debug ("**** Shortcuts loaded and grabbed ****");
+}
+
+static void
+hd_keys_config_finalize (GObject *object)
+{
+ HDKeysConfig *keys = HD_KEYS_CONFIG (object);
+
+ g_slist_free (keys->shortcuts);
+
+ g_object_unref (keys->gconf_client);
+}
+
+static void
hd_keys_action_send_key (HDKeysConfig *keys,
gpointer *user_data)
{
- KeyCode keycode = 0;
KeySym keysym = (KeySym)user_data;
-
- HN_DBG("Faking keysym %li", keysym);
- if ((keycode = XKeysymToKeycode (GDK_DISPLAY(), keysym)) != 0)
- {
- XTestFakeKeyEvent (GDK_DISPLAY(), keycode, TRUE, CurrentTime);
- XTestFakeKeyEvent (GDK_DISPLAY(), keycode, FALSE, CurrentTime);
-
- XSync(GDK_DISPLAY(), False);
- }
+ hd_keys_send_key_by_keysym (keys,keysym);
}
static void
@@ -69,13 +115,9 @@
HDWMWatchedWindow * win = hd_wm_get_active_window();
if (win)
- {
- hd_wm_watched_window_close (win);
- }
+ hd_wm_watched_window_close (win);
else
- {
- g_warning ("No active window set");
- }
+ g_warning ("No active window set");
}
static void
@@ -86,25 +128,22 @@
HDWMWatchedWindow * win = hd_wm_get_active_window();
if (win)
- {
- XWindowAttributes attrs;
- Window xid = hd_wm_watched_window_get_x_win (win);
- XGetWindowAttributes (GDK_DISPLAY(), xid, &attrs);
+ {
+ XWindowAttributes attrs;
+ Window xid = hd_wm_watched_window_get_x_win (win);
+ XGetWindowAttributes (GDK_DISPLAY(), xid, &attrs);
- XIconifyWindow (GDK_DISPLAY(), xid,
- XScreenNumberOfScreen (attrs.screen));
- }
+ XIconifyWindow (GDK_DISPLAY(), xid, XScreenNumberOfScreen (attrs.screen));
+ }
else
- {
- g_warning ("No active window set");
- }
+ g_warning ("No active window set");
}
static void
hd_keys_action_tn_activate (HDKeysConfig *keys,
gpointer *user_data)
{
- hd_wm_activate(GPOINTER_TO_INT (user_data));
+ hd_wm_activate (GPOINTER_TO_INT (user_data));
}
static void
@@ -120,26 +159,26 @@
gpointer *user_data)
{
osso_rpc_t retval;
- osso_context_t * osso_context
- = get_context(osso_manager_singleton_get_instance());
+
+ osso_context_t * osso_context =
+ get_context(osso_manager_singleton_get_instance());
+
gboolean long_press = GPOINTER_TO_INT(user_data);
if (!osso_context ||
- OSSO_OK != osso_rpc_run_system (osso_context,
- MCE_SERVICE,
- MCE_REQUEST_PATH,
- MCE_REQUEST_IF,
- MCE_TRIGGER_POWERKEY_EVENT_REQ,
- &retval,
- DBUS_TYPE_BOOLEAN, long_press,
- DBUS_TYPE_INVALID))
- {
- g_warning("Unable to toggle Power menu");
- }
+ OSSO_OK != osso_rpc_run_system (osso_context,
+ MCE_SERVICE,
+ MCE_REQUEST_PATH,
+ MCE_REQUEST_IF,
+ MCE_TRIGGER_POWERKEY_EVENT_REQ,
+ &retval,
+ DBUS_TYPE_BOOLEAN, long_press,
+ DBUS_TYPE_INVALID))
+ {
+ g_warning ("Unable to toggle Power menu");
+ }
}
-/* ==================================================================== */
-
struct
{
char *gkey;
@@ -232,45 +271,52 @@
kpm = mod_map->max_keypermod;
for (mod_idx = 0; mod_idx < 8; mod_idx++)
+ {
for (mod_key = 0; mod_key < kpm; mod_key++)
+ {
+ KeySym last_sym = 0;
+ for (col = 0; col < 4; col += 2)
{
- KeySym last_sym = 0;
- for (col = 0; col < 4; col += 2)
- {
- KeyCode code = mod_map->modifiermap[mod_idx * kpm + mod_key];
- KeySym sym = (code ? XKeycodeToKeysym(GDK_DISPLAY(), code, col) : 0);
+ KeyCode code = mod_map->modifiermap[mod_idx * kpm + mod_key];
+ KeySym sym = (code ? XKeycodeToKeysym (GDK_DISPLAY(), code, col) : 0);
- if (sym == last_sym) continue;
- last_sym = sym;
+ if (sym == last_sym) continue;
+
+ last_sym = sym;
- switch (sym)
- {
- case XK_Meta_L:
- case XK_Meta_R:
- keys->meta_mask |= (1 << mod_idx);
- break;
- case XK_Super_L:
- case XK_Super_R:
- keys->super_mask |= (1 << mod_idx);
- break;
- case XK_Hyper_L:
- case XK_Hyper_R:
- keys->hyper_mask |= (1 << mod_idx);
- break;
- case XK_Alt_L:
- case XK_Alt_R:
- keys->alt_mask |= (1 << mod_idx);
- break;
- case XK_Num_Lock:
- keys->numlock_mask |= (1 << mod_idx);
- break;
- case XK_Scroll_Lock:
- keys->scrolllock_mask |= (1 << mod_idx);
- break;
- }
- }
+ switch (sym)
+ {
+ case XK_Meta_L:
+ case XK_Meta_R:
+ keys->meta_mask |= (1 << mod_idx);
+ break;
+
+ case XK_Super_L:
+ case XK_Super_R:
+ keys->super_mask |= (1 << mod_idx);
+ break;
+
+ case XK_Hyper_L:
+ case XK_Hyper_R:
+ keys->hyper_mask |= (1 << mod_idx);
+ break;
+
+ case XK_Alt_L:
+ case XK_Alt_R:
+ keys->alt_mask |= (1 << mod_idx);
+ break;
+
+ case XK_Num_Lock:
+ keys->numlock_mask |= (1 << mod_idx);
+ break;
+
+ case XK_Scroll_Lock:
+ keys->scrolllock_mask |= (1 << mod_idx);
+ break;
+ }
}
-
+ }
+ }
/* Assume alt <=> meta if only either set */
if (!keys->alt_mask) keys->alt_mask = keys->meta_mask;
if (!keys->meta_mask) keys->meta_mask = keys->alt_mask;
@@ -310,134 +356,135 @@
};
while (*p != '\0')
+ {
+ Bool found = False;
+
+ /* Parse <modifier> and look up its mask
+ */
+ if (*p == '<' && *(p+1) != '\0')
{
- Bool found = False;
-
- /* Parse <modifier> and look up its mask
- */
- if (*p == '<' && *(p+1) != '\0')
- {
- q = ++p;
- while (*q != '\0' && *q != '>') q++;
- if (*q == '\0')
- return NULL;
+ q = ++p;
+ while (*q != '\0' && *q != '>') q++;
+ if (*q == '\0')
+ return NULL;
- i = 0;
+ i = 0;
- while (mod_lookup[i].def != NULL && !found)
- {
- if (!g_ascii_strncasecmp (p, mod_lookup[i].def, q-p))
- {
- if (mod_lookup[i].mask)
- {
- mask |= mod_lookup[i].mask;
- found = True;
- }
- }
- i++;
- }
+ while (mod_lookup[i].def != NULL && !found)
+ {
+ if (!g_ascii_strncasecmp (p, mod_lookup[i].def, q-p))
+ {
+ if (mod_lookup[i].mask)
+ {
+ mask |= mod_lookup[i].mask;
+ found = True;
+ }
+ }
+
+ i++;
+ }
- if (found)
- {
- p = q; /* found the modifier skip index over tag */
- }
- else
- {
- /* Check if its <shift> */
- if (!g_ascii_strncasecmp (p, "shift", 5))
- {
- want_shift = True;
- p = q;
- }
- else return NULL; /* Unknown modifier string */
- }
-
- }
- /* Now parse the actual Key */
- else if (!g_ascii_isspace(*p))
+ if (found)
+ {
+ p = q; /* found the modifier skip index over tag */
+ }
+ else
+ {
+ /* Check if its <shift> */
+ if (!g_ascii_strncasecmp (p, "shift", 5))
{
- keydef = p;
- break;
+ want_shift = True;
+ p = q;
}
- p++;
+ else
+ return NULL; /* Unknown modifier string */
+ }
+
+ }
+ /* Now parse the actual Key */
+ else
+ if (!g_ascii_isspace(*p))
+ {
+ keydef = p;
+ break;
}
+
+ p++;
+ }
if (!keydef)
return NULL;
if ((ks = XStringToKeysym(keydef)) == (KeySym)NULL)
- {
- if ( g_ascii_islower(keydef[0])) /* Try again, changing case */
- keydef[0] = g_ascii_toupper(keydef[0]);
- else
- keydef[0] = g_ascii_tolower(keydef[0]);
+ {
+ if (g_ascii_islower(keydef[0])) /* Try again, changing case */
+ keydef[0] = g_ascii_toupper(keydef[0]);
+ else
+ keydef[0] = g_ascii_tolower(keydef[0]);
- if ((ks = XStringToKeysym(keydef)) == (KeySym)NULL)
- return NULL; /* Couldn't find a keysym */
- }
+ if ((ks = XStringToKeysym(keydef)) == (KeySym)NULL)
+ return NULL; /* Couldn't find a keysym */
+ }
/* Cannot install grab for keys that we are supposed to fake */
switch (ks)
- {
- case XK_F4:
- case XK_F6:
- case XK_F7:
- case XK_F8:
- HN_DBG ("Illegal shortcut symbol -- ignoring");
- return NULL;
-
- default:
- ;
+ {
+ case XK_F4:
+ case XK_F6:
+ case XK_F7:
+ case XK_F8:
+ g_debug ("Illegal shortcut symbol -- ignoring");
+ return NULL;
+ default:
+ g_debug ("%s: %d, should never be reached",__FILE__,__LINE__);
}
if (hd_keys_keysym_needs_shift(ks))
+ {
+ mask |= ShiftMask;
+ index = 1;
+ }
+ else
+ if (want_shift)
+ {
+ KeySym shifted;
+
+ /* Change the keysym for case of '<shift>lowerchar' where we
+ * actually want to grab the shifted version of the keysym.
+ */
+ if ((shifted = hd_keys_keysym_get_shifted (ks)) != NoSymbol)
{
- mask |= ShiftMask;
+ ks = shifted;
index = 1;
}
- else if (want_shift)
- {
- KeySym shifted;
-
- /* Change the keysym for case of '<shift>lowerchar' where we
- * actually want to grab the shifted version of the keysym.
- */
- if ((shifted = hd_keys_keysym_get_shifted (ks)) != NoSymbol)
- {
- ks = shifted;
- index = 1;
- }
- /* Set the mask even if no shifted version - <shift>up key for
- * example.
- */
- mask |= ShiftMask;
- }
+ /* Set the mask even if no shifted version - <shift>up key for
+ * example.
+ */
+ mask |= ShiftMask;
+ }
/* If F5 is assigned to "Home", don't do anything or we will be
* conflicting with MCE's handling of the key */
- if (ks == XK_F5 &&
- HDKeysActionConfLookup[conf_index].action == HD_KEY_ACTION_HOME)
- return NULL;
+ if (ks == XK_F5 && HDKeysActionConfLookup[conf_index].action == HD_KEY_ACTION_HOME)
+ return NULL;
/* If we grab keycode 0, we end up grabbing the entire keyboard :\ */
if (XKeysymToKeycode(GDK_DISPLAY(), ks) == 0)
- return NULL;
+ return NULL;
shortcut = g_new0(HDKeyShortcut, 1);
- shortcut->action
- = HDKeysActionConfLookup[conf_index].action;
- shortcut->action_func
- = HDKeysActionConfLookup[conf_index].action_func;
- shortcut->action_func_data
- = HDKeysActionConfLookup[conf_index].action_func_data;
+
+ shortcut->action = HDKeysActionConfLookup[conf_index].action;
+ shortcut->action_func = HDKeysActionConfLookup[conf_index].action_func;
+ shortcut->action_func_data = HDKeysActionConfLookup[conf_index].action_func_data;
+
shortcut->mod_mask = mask;
shortcut->keysym = ks;
shortcut->keycode = XKeysymToKeycode(GDK_DISPLAY(), ks);
shortcut->index = index;
- HN_DBG("'%s' to new shortcut with ks:%li, mask:%i",
- keystr, ks, mask);
+ g_debug("'%s' to new shortcut with ks:%li, mask:%i", keystr, ks, mask);
return shortcut;
}
@@ -448,66 +495,62 @@
HDKeyShortcut *shortcut,
gboolean ungrab)
{
- int ignored_mask = 0;
+ gint ignored_mask = 0;
/* Needed to grab all ignored combo's too if num of scroll lock are on */
while (ignored_mask < (int) keys->lock_mask)
- {
- if (ignored_mask & ~(keys->lock_mask))
- {
- ++ignored_mask;
- continue;
- }
+ {
+ if (ignored_mask & ~(keys->lock_mask))
+ {
+ ++ignored_mask;
+ continue;
+ }
- if (ungrab)
- {
- XUngrabKey(GDK_DISPLAY(),
- shortcut->keycode,
- shortcut->mod_mask | ignored_mask,
- GDK_ROOT_WINDOW());
- }
- else
- {
- int result;
+ if (ungrab)
+ {
+ XUngrabKey (GDK_DISPLAY(),
+ shortcut->keycode,
+ shortcut->mod_mask | ignored_mask,
+ GDK_ROOT_WINDOW());
+ }
+ else
+ {
+ gint result;
- gdk_error_trap_push();
+ gdk_error_trap_push();
- XGrabKey (GDK_DISPLAY(),
- shortcut->keycode,
- shortcut->mod_mask | ignored_mask,
- GDK_ROOT_WINDOW(),
- False,
- GrabModeAsync,
- GrabModeAsync);
+ XGrabKey (GDK_DISPLAY(),
+ shortcut->keycode,
+ shortcut->mod_mask | ignored_mask,
+ GDK_ROOT_WINDOW(),
+ False,
+ GrabModeAsync,
+ GrabModeAsync);
- XSync(GDK_DISPLAY(), False);
- result = gdk_error_trap_pop();
+ XSync(GDK_DISPLAY(), False);
- if (result)
- {
- /* FIXME: Log below somewhere */
- if (result == BadAccess)
- {
- fprintf(stderr,
- "Some other program is already using the key %s "
- "with modifiers %x as a binding\n",
- (XKeysymToString (shortcut->keysym)) ?
- XKeysymToString (shortcut->keysym) : "unknown",
- shortcut->mod_mask | ignored_mask );
- }
- else
- {
- fprintf(stderr,
- "Unable to grab the key %s with modifiers %x"
- "as a binding\n",
- (XKeysymToString (shortcut->keysym)) ?
- XKeysymToString (shortcut->keysym) : "unknown",
- shortcut->mod_mask | ignored_mask );
- }
- }
+ result = gdk_error_trap_pop();
+
+ if (result)
+ {
+ /* FIXME: Log below somewhere */
+ if (result == BadAccess)
+ {
+ g_debug ("Some other program is already using the key %s "
+ "with modifiers %x as a binding\n",
+ (XKeysymToString (shortcut->keysym)) ? XKeysymToString (shortcut->keysym) : "unknown",
+ shortcut->mod_mask | ignored_mask );
}
- ++ignored_mask;
- }
+ else
+ {
+ g_debug ("Unable to grab the key %s with modifiers %x as a binding\n",
+ (XKeysymToString (shortcut->keysym)) ? XKeysymToString (shortcut->keysym) : "unknown",
+ shortcut->mod_mask | ignored_mask);
+ }
+ }
+ }
+ ++ignored_mask;
+ }
return TRUE;
}
@@ -519,25 +562,25 @@
char *key_def_str = NULL;
while (HDKeysActionConfLookup[i].gkey != NULL)
+ {
+ key_def_str =
+ gconf_client_get_string (keys->gconf_client,
+ HDKeysActionConfLookup[i].gkey,
+ NULL);
+
+ if (key_def_str && g_ascii_strncasecmp(key_def_str, "disabled", 8))
{
- key_def_str = gconf_client_get_string(keys->gconf_client,
- HDKeysActionConfLookup[i].gkey,
- NULL);
-
- if (key_def_str && g_ascii_strncasecmp(key_def_str, "disabled", 8))
- {
- HDKeyShortcut *shortcut;
+ HDKeyShortcut *shortcut;
- if ((shortcut = hd_keys_shortcut_new (keys, key_def_str, i)) != NULL)
- {
- HN_DBG("Grabbing '%s'", key_def_str);
- hn_key_shortcut_grab (keys, shortcut, FALSE);
- keys->shortcuts = g_slist_append (keys->shortcuts, shortcut);
- }
- }
-
- i++;
+ if ((shortcut = hd_keys_shortcut_new (keys, key_def_str, i)) != NULL)
+ {
+ g_debug ("Grabbing '%s'", key_def_str);
+ hn_key_shortcut_grab (keys, shortcut, FALSE);
+ keys->shortcuts = g_slist_append (keys->shortcuts, shortcut);
+ }
}
+ i++;
+ }
}
static void
@@ -551,98 +594,80 @@
gvalue = gconf_entry_get_value(entry);
- HN_DBG("called");
+ g_debug ("called");
if (gconf_entry_get_key(entry))
- {
- /* Parse, find entry, ungrab, replace, regrab */
- HDKeyShortcut *shortcut;
- gint i = 0;
- GSList *item;
- const gchar *value;
+ {
+ /* Parse, find entry, ungrab, replace, regrab */
+ HDKeyShortcut *shortcut;
+ gint i = 0;
+ GSList *item;
+ const gchar *value;
- HN_DBG("Looking up '%s'", gconf_entry_get_key(entry));
+ g_debug ("Looking up '%s'", gconf_entry_get_key(entry));
/* Find what this keys matches in lookup */
- while (HDKeysActionConfLookup[i].gkey != NULL)
- {
- if (g_str_equal(gconf_entry_get_key(entry),
- HDKeysActionConfLookup[i].gkey))
- break;
- i++;
- }
+ while (HDKeysActionConfLookup[i].gkey != NULL)
+ {
+ if (g_str_equal(gconf_entry_get_key(entry), HDKeysActionConfLookup[i].gkey))
+ break;
+ i++;
+ }
- if (HDKeysActionConfLookup[i].gkey == NULL)
- {
- HN_DBG("Unable to find '%s'", gconf_entry_get_key(entry));
- return; /* key not found */
- }
+ if (HDKeysActionConfLookup[i].gkey == NULL)
+ {
+ g_debug ("Unable to find '%s'", gconf_entry_get_key(entry));
+ return; /* key not found */
+ }
- item = keys->shortcuts;
+ item = keys->shortcuts;
/* Remove a potential existing grab and shortcut for this action */
- while (item)
- {
- HDKeyShortcut *sc = (HDKeyShortcut *)item->data;
+ while (item)
+ {
+ HDKeyShortcut *sc = (HDKeyShortcut *)item->data;
- if (sc->action == HDKeysActionConfLookup[i].action)
- {
- HN_DBG("removing exisiting action %i", sc->action);
- hn_key_shortcut_grab (keys, sc, TRUE);
- keys->shortcuts = g_slist_remove (keys->shortcuts, item->data);
- g_free (sc);
- break;
- }
- item = g_slist_next(item);
- }
+ if (sc->action == HDKeysActionConfLookup[i].action)
+ {
+ g_debug ("removing exisiting action %i", sc->action);
+ hn_key_shortcut_grab (keys, sc, TRUE);
+ keys->shortcuts = g_slist_remove (keys->shortcuts, item->data);
+ g_free (sc);
+ break;
+ }
+ item = g_slist_next(item);
+ }
/* If value is not NULL to handle removing of key */
- if (gvalue && gvalue->type == GCONF_VALUE_STRING)
- {
- value = gconf_value_get_string (gvalue);
+ if (gvalue && gvalue->type == GCONF_VALUE_STRING)
+ {
+ value = gconf_value_get_string (gvalue);
- HN_DBG("attempting to grab '%s'", value);
+ g_debug ("attempting to grab '%s'", value);
- /* Grab the new shortcut and addd to our list */
- if (value && g_ascii_strncasecmp(value, "disabled", 8))
- if ((shortcut = hd_keys_shortcut_new (keys, value, i)) != NULL)
- {
- HN_DBG("now grabbing '%s'", value);
- hn_key_shortcut_grab (keys, shortcut, FALSE);
- keys->shortcuts = g_slist_append (keys->shortcuts, shortcut);
- }
- }
- }
+ /* Grab the new shortcut and addd to our list */
+ if (value && g_ascii_strncasecmp(value, "disabled", 8))
+ {
+ if ((shortcut = hd_keys_shortcut_new (keys, value, i)) != NULL)
+ {
+ g_debug ("now grabbing '%s'", value);
+ hn_key_shortcut_grab (keys, shortcut, FALSE);
+ keys->shortcuts = g_slist_append (keys->shortcuts, shortcut);
+ }
+ }
+ }
+ }
}
HDKeysConfig*
-hd_keys_init (void)
+hd_keys_config_get_singleton (void)
{
- HDKeysConfig *keys;
+ static HDKeysConfig *singleton = NULL;
- keys = g_new0 (HDKeysConfig, 1);
+ if (!singleton)
+ singleton = HD_KEYS_CONFIG (g_object_new (HD_TYPE_KEYS_CONFIG,NULL));
- keys->gconf_client = gconf_client_get_default();
-
- gconf_client_add_dir (keys->gconf_client,
- HD_KEYS_GCONF_PATH,
- GCONF_CLIENT_PRELOAD_NONE,
- NULL);
-
- gconf_client_notify_add (keys->gconf_client,
- HD_KEYS_GCONF_PATH,
- gconf_key_changed_callback,
- keys,
- NULL,
- NULL);
-
- hd_keys_set_modifiers (keys);
-
- hd_keys_load_and_grab_all_shortcuts (keys);
-
- HN_DBG("**** Shortcuts loaded and grabbed ****");
-
- return keys;
+ return singleton;
}
void
@@ -653,12 +678,12 @@
shortcut = keys->shortcuts;
while (shortcut != NULL)
- {
- gpointer data = shortcut->data;
- hn_key_shortcut_grab (keys, shortcut->data, TRUE);
- shortcut = g_slist_remove (shortcut, shortcut->data);
- g_free (data);
- }
+ {
+ gpointer data = shortcut->data;
+ hn_key_shortcut_grab (keys, shortcut->data, TRUE);
+ shortcut = g_slist_remove (shortcut, shortcut->data);
+ g_free (data);
+ }
keys->shortcuts = NULL;
@@ -676,23 +701,43 @@
item = keys->shortcuts;
while (item)
- {
- HDKeyShortcut *shortcut = (HDKeyShortcut *)item->data;
+ {
+ HDKeyShortcut *shortcut = (HDKeyShortcut *)item->data;
- HN_DBG("%i vs %i, %li vs %li",
+ g_debug ("%i vs %i, %li vs %li",
shortcut->mod_mask, mod_mask,
shortcut->keysym, XKeycodeToKeysym(GDK_DISPLAY(), keycode, 0));
- if (shortcut->mod_mask == mod_mask &&
- shortcut->keysym == XKeycodeToKeysym(GDK_DISPLAY(),
- keycode,
- shortcut->index))
- {
- return shortcut;
- }
- item = g_slist_next(item);
+ if (shortcut->mod_mask == mod_mask &&
+ shortcut->keysym == XKeycodeToKeysym(GDK_DISPLAY(),keycode,shortcut->index))
+ {
+ return shortcut;
}
+
+ item = g_slist_next(item);
+ }
return NULL;
}
+void
+hd_keys_send_key_by_keysym (HDKeysConfig *keys, KeySym keysym)
+{
+ g_debug ("Faking keysym %li", keysym);
+
+ hd_keys_send_key_by_keycode (keys,XKeysymToKeycode (GDK_DISPLAY(), keysym));
+}
+
+void
+hd_keys_send_key_by_keycode (HDKeysConfig *keys, KeyCode keycode)
+{
+ g_debug ("Faking keycode %d", keycode);
+
+ if (keycode != 0)
+ {
+ XTestFakeKeyEvent (GDK_DISPLAY(), keycode, TRUE, CurrentTime);
+ XTestFakeKeyEvent (GDK_DISPLAY(), keycode, FALSE, CurrentTime);
+
+ XSync(GDK_DISPLAY(), False);
+ }
+}
Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-keys.h
===================================================================
--- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-keys.h 2006-12-11 14:51:05 UTC (rev 8716)
+++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-keys.h 2006-12-11 15:28:55 UTC (rev 8717)
@@ -27,9 +27,20 @@
#ifndef __HD_KEYS_H__
#define __HD_KEYS_H__
+#include <glib-object.h>
#include <gconf/gconf-client.h>
#include <gdk/gdkx.h>
+#define HD_TYPE_KEYS_CONFIG (hd_keys_config_get_type ())
+#define HD_KEYS_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), HD_TYPE_KEYS_CONFIG, HDKeysConfig))
+#define HD_KEYS_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), HD_TYPE_KEYS_CONFIG, HDKeysConfigClass))
+#define HD_IS_KEYS_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HD_TYPE_KEYS_CONFIG))
+#define HD_IS_KEYS_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HD_TYPE_KEYS_CONFIG))
+#define HD_KEYS_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), HD_TYPE_KEYS_CONFIG, HDKeysConfigClass))
+
+typedef struct _HDKeysConfig HDKeysConfig;
+typedef struct _HDKeysConfigClass HDKeysConfigClass;
+
typedef enum HDKeyAction
{
HD_KEY_ACTION_UNKOWN = 0,
@@ -46,16 +57,24 @@
}
HDKeyAction;
-typedef struct HDKeysConfig
+struct _HDKeysConfig
{
+ GObject parent;
+
GConfClient *gconf_client;
gint32 meta_mask, hyper_mask, super_mask, alt_mask,
mode_mask, numlock_mask, scrolllock_mask, lock_mask;
GSList *shortcuts;
-}
-HDKeysConfig;
+};
+struct _HDKeysConfigClass
+{
+ GObjectClass parent_class;
+
+ /**/
+};
+
typedef void (*HDKeysActionFunc) (HDKeysConfig *keys, gpointer *user_data);
typedef struct HDKeyShortcut
@@ -72,8 +91,11 @@
#define HD_KEYS_GCONF_PATH "/system/osso/af/keybindings"
+GType
+hd_keys_config_get_type (void);
+
HDKeysConfig*
-hd_keys_init (void);
+hd_keys_config_get_singleton (void);
void
hd_keys_reload (GdkKeymap *keymap, HDKeysConfig *keys);
@@ -82,5 +104,12 @@
hd_keys_handle_keypress (HDKeysConfig *keys,
KeyCode keycode,
guint32 mod_mask);
+
+void
+hd_keys_send_key_by_keysym (HDKeysConfig *keys, KeySym keysym);
+
+void
+hd_keys_send_key_by_keycode (HDKeysConfig *keys, KeyCode keycode);
+
#endif/*__HD_KEYS_H__*/
Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.c
===================================================================
--- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.c 2006-12-11 14:51:05 UTC (rev 8716)
+++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.c 2006-12-11 15:28:55 UTC (rev 8717)
@@ -53,7 +53,6 @@
#include "hd-wm-memory.h"
#include "hd-entry-info.h"
#include "osso-manager.h"
-#include "hd-keys.h"
#define SAVE_METHOD "save"
#define KILL_APPS_METHOD "kill_app"
@@ -655,19 +654,21 @@
/* Setup shortcuts */
- hdwm->priv->keys = hd_keys_init ();
+ hdwm->keys = hd_keys_config_get_singleton ();
/* Track changes in the keymap */
keymap = gdk_keymap_get_default ();
- g_signal_connect (G_OBJECT (keymap), "keys-changed",
- G_CALLBACK (hd_keys_reload), hdwm->priv->keys);
+ g_signal_connect (G_OBJECT (keymap),
+ "keys-changed",
+ G_CALLBACK (hd_keys_reload),
+ hdwm->keys);
/* Get on the DBus */
dbus_error_init (&error);
- connection = dbus_bus_get( DBUS_BUS_SESSION, &error );
+ connection = dbus_bus_get (DBUS_BUS_SESSION, &error);
if (!connection)
{
@@ -1699,7 +1700,7 @@
if (hdwm->priv->shortcut != NULL &&
hdwm->priv->shortcut->action == HD_KEY_ACTION_POWER)
{
- hdwm->priv->shortcut->action_func (hdwm->priv->keys, GINT_TO_POINTER(TRUE));
+ hdwm->priv->shortcut->action_func (hdwm->keys, GINT_TO_POINTER(TRUE));
hdwm->priv->shortcut = NULL;
}
@@ -1757,7 +1758,7 @@
if (((XEvent*)xevent)->type == KeyPress)
{
XKeyEvent *kev = (XKeyEvent *)xevent;
- hdwm->priv->shortcut = hd_keys_handle_keypress (hdwm->priv->keys, kev->keycode, kev->state);
+ hdwm->priv->shortcut = hd_keys_handle_keypress (hdwm->keys, kev->keycode, kev->state);
if (hdwm->priv->shortcut != NULL &&
hdwm->priv->shortcut->action == HD_KEY_ACTION_POWER &&
@@ -1781,7 +1782,7 @@
if (hdwm->priv->shortcut != NULL)
{
if (!hd_wm_modal_windows_present())
- hdwm->priv->shortcut->action_func (hdwm->priv->keys, hdwm->priv->shortcut->action_func_data);
+ hdwm->priv->shortcut->action_func (hdwm->keys, hdwm->priv->shortcut->action_func_data);
hdwm->priv->shortcut = NULL;
}
Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.h
===================================================================
--- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.h 2006-12-11 14:51:05 UTC (rev 8716)
+++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-wm.h 2006-12-11 15:28:55 UTC (rev 8717)
@@ -38,6 +38,7 @@
#include <libhildonwm/hd-wm-types.h>
#include <libhildonwm/hd-entry-info.h>
#include <libhildonwm/hd-wm-watchable-app.h>
+#include <libhildonwm/hd-keys.h>
#define HN_WANT_DEBUG 0 /* Set to 1 for more verbose hn */
@@ -130,6 +131,8 @@
{
GObject parent;
+ HDKeysConfig *keys;
+
HDWMPrivate *priv;
};
- Previous message: [maemo-commits] r8716 - in projects/haf/trunk/osso-application-installer: . debian
- Next message: [maemo-commits] r8718 - projects/haf/trunk/osso-application-installer
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
