Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Maemo: Developers

Rotation support.. :(

 

 

Maemo developers RSS feed   Index | Next | Previous | View Threaded


anidel at gmail

Nov 7, 2009, 7:19 AM

Post #1 of 6 (152 views)
Permalink
Rotation support.. :(

I am trying to add rotation to Xournal.

I have defined the DBus message sig as follows:

#define MCE_SIGNAL_MATCH "type='signal'," \
"sender='" MCE_SERVICE "'," \
"path='" MCE_SIGNAL_PATH "'," \
"interface='" MCE_SIGNAL_IF "'"

then I've added a DBus filter and handler:

sys_conn = osso_get_sys_dbus_connection(ctx);
if (sys_conn) {
DBusError error;
dbus_error_init (&error);
dbus_bus_add_match (sys_conn, MCE_SIGNAL_MATCH, &error);
if (dbus_error_is_set(&error)){
printf("dbus_bus_add_match failed: %s\n", error.message);
dbus_error_free(&error);
}

if (!dbus_connection_add_filter (sys_conn,
(DBusHandleMessageFunction) mce_filter_func, NULL, NULL)) {
printf("Error dbus_connection_add_filter failed\n");
} else {
printf ("DBUS filter added\n");
}
}

and defined the handler function:

DBusHandlerResult
mce_filter_func (DBusConnection *connection, DBusMessage *message, void *data)
{
DBusMessageIter iter;
const gchar *mode = NULL;

printf ("MCE\n");

if (dbus_message_is_signal(message, MCE_SIGNAL_IF,
MCE_DEVICE_ORIENTATION_SIG)) {
printf ("is a orientation signal\n");
if (dbus_message_iter_init(message, &iter)) {
printf ("getting mode\n");
dbus_message_iter_get_basic(&iter, &mode);

hildon_rotate_ui (mode);
}
}

return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}

It compiles, starts up, the MCE function gets called twice when
Xournal starts (it prints MCE twice) and gets called for several other
DBus messages (like screen lock/unlock), but NOT for rotate messages.

What am I missing?

Thanks!

References:
[1] <http://wiki.maemo.org/Using_Fremantle_Widgets#Listening_To_Hardware_Orientation_Changes>

[2] <http://wiki.maemo.org/Documentation/Maemo_5_Developer_Guide/Porting_Software/Porting_Existing_GTK%2B_Application_to_Maemo_5#Portrait_Mode>

[3] <https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/omweather/src/weather-portrait.c?revision=2951&root=omweather&view=markup>

[4] <https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/omweather/src/weather-dbus.c?revision=3265&root=omweather&view=markup>

--
anidel
Sent from London, Eng, United Kingdom
_______________________________________________
maemo-developers mailing list
maemo-developers[at]maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


hald at icandy

Nov 7, 2009, 7:47 AM

Post #2 of 6 (145 views)
Permalink
Re: Rotation support.. :( [In reply to]

Hi Aniello,

you have to enable the accelerators first. Here's a method copied from
my code:

void
orientation_enable_accelerators()
{
AppData *app_data = app_data_get();

if (app_data->accelerators == TRUE) {
return;
}

/* TODO: Replace string "req_accelerometer_enable" with constant once we switched to final SDK */
if (osso_rpc_run_system(app_data->osso_ctx, MCE_SERVICE, MCE_REQUEST_PATH,
MCE_REQUEST_IF, "req_accelerometer_enable", NULL, DBUS_TYPE_INVALID) == OSSO_OK) {
g_printerr("INFO: Accelerometers enabled\n");
app_data->accelerators = TRUE;
} else {
g_printerr("WARN: Cannot enable accelerometers\n");
}
}

To save energy you should disable them again if your window is not the top most window. The rest of the code can be found here:
https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/conboy/src/orientation.c?revision=514&root=conboy&view=markup

Cheers!
Conny


On Sat, 2009-11-07 at 15:19 +0000, Aniello Del Sorbo wrote:
> I am trying to add rotation to Xournal.
>
> I have defined the DBus message sig as follows:
>
> #define MCE_SIGNAL_MATCH "type='signal'," \
> "sender='" MCE_SERVICE "'," \
> "path='" MCE_SIGNAL_PATH "'," \
> "interface='" MCE_SIGNAL_IF "'"
>
> then I've added a DBus filter and handler:
>
> sys_conn = osso_get_sys_dbus_connection(ctx);
> if (sys_conn) {
> DBusError error;
> dbus_error_init (&error);
> dbus_bus_add_match (sys_conn, MCE_SIGNAL_MATCH, &error);
> if (dbus_error_is_set(&error)){
> printf("dbus_bus_add_match failed: %s\n", error.message);
> dbus_error_free(&error);
> }
>
> if (!dbus_connection_add_filter (sys_conn,
> (DBusHandleMessageFunction) mce_filter_func, NULL, NULL)) {
> printf("Error dbus_connection_add_filter failed\n");
> } else {
> printf ("DBUS filter added\n");
> }
> }
>
> and defined the handler function:
>
> DBusHandlerResult
> mce_filter_func (DBusConnection *connection, DBusMessage *message, void *data)
> {
> DBusMessageIter iter;
> const gchar *mode = NULL;
>
> printf ("MCE\n");
>
> if (dbus_message_is_signal(message, MCE_SIGNAL_IF,
> MCE_DEVICE_ORIENTATION_SIG)) {
> printf ("is a orientation signal\n");
> if (dbus_message_iter_init(message, &iter)) {
> printf ("getting mode\n");
> dbus_message_iter_get_basic(&iter, &mode);
>
> hildon_rotate_ui (mode);
> }
> }
>
> return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
> }
>
> It compiles, starts up, the MCE function gets called twice when
> Xournal starts (it prints MCE twice) and gets called for several other
> DBus messages (like screen lock/unlock), but NOT for rotate messages.
>
> What am I missing?
>
> Thanks!
>
> References:
> [1] <http://wiki.maemo.org/Using_Fremantle_Widgets#Listening_To_Hardware_Orientation_Changes>
>
> [2] <http://wiki.maemo.org/Documentation/Maemo_5_Developer_Guide/Porting_Software/Porting_Existing_GTK%2B_Application_to_Maemo_5#Portrait_Mode>
>
> [3] <https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/omweather/src/weather-portrait.c?revision=2951&root=omweather&view=markup>
>
> [4] <https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/omweather/src/weather-dbus.c?revision=3265&root=omweather&view=markup>
>

_______________________________________________
maemo-developers mailing list
maemo-developers[at]maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


timop.harkonen at gmail

Nov 7, 2009, 7:51 AM

Post #3 of 6 (145 views)
Permalink
Re: Rotation support.. :( [In reply to]

Hi

Do you start the accelerometer? It isn't enabled by default.

Don't know about GTK, but with Qt it goes like this:

QDBusConnection::systemBus().call(QDBusMessage::createMethodCall(MCE_SERVICE,
MCE_REQUEST_PATH,MCE_REQUEST_IF, MCE_ACCELEROMETER_ENABLE_REQ));

And when exiting the application ... MCE_ACCELEROMETER_DISABLE_REQ

Timo


timop.harkonen at gmail

Nov 7, 2009, 7:51 AM

Post #4 of 6 (145 views)
Permalink
Re: Rotation support.. :( [In reply to]

Seems I was too slow :)

Timo


anidel at gmail

Nov 7, 2009, 8:01 AM

Post #5 of 6 (145 views)
Permalink
Re: Rotation support.. :( [In reply to]

ahh righit... forgot about that! :)

--
anidel
Sent from London, Eng, United Kingdom
_______________________________________________
maemo-developers mailing list
maemo-developers[at]maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


anidel at gmail

Nov 7, 2009, 8:07 AM

Post #6 of 6 (144 views)
Permalink
Re: Rotation support.. :( [In reply to]

It works!!

package 15 is on its way :D

thanks guys.. you made my day,

--
anidel
Sent from London, Eng, United Kingdom
_______________________________________________
maemo-developers mailing list
maemo-developers[at]maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers

Maemo developers RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.