Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > More E-Book Readers > iRex > iRex Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 12-22-2010, 04:36 PM   #1
heyneman
Member
heyneman began at the beginning.
 
Posts: 15
Karma: 10
Join Date: Sep 2010
Device: IREX DR800SG
program in new tab

Quick question for folks:

I've got a DR800, but I'm running DR800+ to get the tab functionality, etc, from the DR1000. How does a program get put in a new tab, vs running in the main (explorer) tab?

I ask because, for example, rxvt shows up in the explorer tab. If I don't explicitly exit the terminal, it is still running in the background when I try to switch back to the home screen (I know because the on-screen keyboard doesn't disappear, and when I start rxvt up again I see all my previous commands). I've looked a bit into the source for rxvt and the xournal port (which does end up in its own tab), and the only thing I've noticed so far is that the xournal port uses the IPC stuff. Is that the key?

Thanks,

-heyneman
heyneman is offline   Reply With Quote
Old 12-22-2010, 05:44 PM   #2
dima_tr
Groupie
dima_tr has learned how to read e-booksdima_tr has learned how to read e-booksdima_tr has learned how to read e-booksdima_tr has learned how to read e-booksdima_tr has learned how to read e-booksdima_tr has learned how to read e-booksdima_tr has learned how to read e-books
 
Posts: 175
Karma: 863
Join Date: Oct 2009
Location: Germany, Karlsruhe
Device: Iliad v2, DR800S (inlove)
indeed, ipc is required.

The main call is

Code:
	// iRex DR: report "application started"
	const int xid = GDK_WINDOW_XID(window->window); // window->window seems to be a good candidate
        eripc_sysd_startup_complete(eripcClient, getpid(), FALSE, xid); // TRUE only when the app handles openFile and closeFile

Below is the complete sequence of all calls around this one (taken from the port of StarDict). Note, that GDK/GTK is used here, and I'm not sure you can do this in rxvt. I had the same kind of problems of how to make a tab when porting xMahjongg (= non GTK app). Still do not know the solution, so if/when you have one please share


Code:
#include <liberipc/eripc.h>
#include <liberipc/eripc_support.h>

// IPC application
// TODO: set DBUS_APPL_NAME to your application name, use lower-case and digits only
//       or set to PACKAGENAME when this is lower-case and digits only
#define DBUS_APPL_NAME                  "stardict"            // lower-case and digits only
#define DBUS_SERVICE                     "com.irexnet." DBUS_APPL_NAME
#define DBUS_PATH                       "/com/irexnet/" DBUS_APPL_NAME
#define DBUS_INTERFACE                   "com.irexnet." DBUS_APPL_NAME

// IPC system control
#define DBUS_SERVICE_SYSTEM_CONTROL     "com.irexnet.sysd"

// IPC popup menu
#define DBUS_SERVICE_POPUP_MENU         "com.irexnet.popupmenu"

#define DBUS_SERVICE_CTB        "com.irexnet.ctb"
#define DBUS_SERVICE_MENU       "com.irexnet.popupmenu"
#define DBUS_SERVICE_CONN_WIFI  "com.irexnet.connwifi"
#define DBUS_SERVICE_CONN_BLUE  "com.irexnet.connblue"
#define DBUS_SERVICE_CONN_3G    "com.irexnet.conn3g"


//----------------------------------------------------------------------------
// Static Variables
//----------------------------------------------------------------------------

static eripc_client_context_t *eripcClient = NULL;

// Exported DBUS API list
static eripc_callback_function_t service_functions[] = { {NULL} };
........

///////////////////
AppCore::AppCore()
{
......
	// iRex DR, init ipc
        eripcClient = eripc_client_context_new(
                        DBUS_APPL_NAME, 
                        "1.0",
                        DBUS_SERVICE, 
                        DBUS_PATH,
                        DBUS_INTERFACE,
                        service_functions);
}

AppCore::~AppCore()
{
......	
	// iRex DR, un-init
	eripc_client_context_free(eripcClient, service_functions);
}


void someMethodWhenIKnowAppIsReady()
{
	// iRex DR: report "application started"
	const int xid = GDK_WINDOW_XID(window->window); // window->window seems to be a good candidate
        eripc_sysd_startup_complete(eripcClient, getpid(), FALSE, xid); // TRUE only when the app handles openFile and closeFile
	
	// rename
	eripc_send_varargs(eripcClient->context,
                               NULL,
                               NULL,
                               ERIPC_BUS_SESSION,
                               DBUS_SERVICE_MENU,
                               "renameTask",
                               ERIPC_TYPE_INT, xid,
                               ERIPC_TYPE_STRING, _("NameToBeSeenInTab"),
                               ERIPC_TYPE_INVALID);							

}

Last edited by dima_tr; 12-22-2010 at 05:47 PM.
dima_tr is offline   Reply With Quote
Advert
Old 12-22-2010, 06:11 PM   #3
dima_tr
Groupie
dima_tr has learned how to read e-booksdima_tr has learned how to read e-booksdima_tr has learned how to read e-booksdima_tr has learned how to read e-booksdima_tr has learned how to read e-booksdima_tr has learned how to read e-booksdima_tr has learned how to read e-books
 
Posts: 175
Karma: 863
Join Date: Oct 2009
Location: Germany, Karlsruhe
Device: Iliad v2, DR800S (inlove)
Hm, has just found one thing that may serve as a substitute for
..............const int xid = GDK_WINDOW_XID(window->window);

Guys, can you please check if this helps rxvt to have a tab?
Code:
	Window focusWindow;
	Display *focusDisplay = XOpenDisplay(NULL);
	int param = 0;
	int xid = XGetInputFocus(focusDisplay,&focusWindow,&param);
dima_tr is offline   Reply With Quote
Old 12-22-2010, 11:15 PM   #4
heyneman
Member
heyneman began at the beginning.
 
Posts: 15
Karma: 10
Join Date: Sep 2010
Device: IREX DR800SG
Hmm, thanks for the info Dima. I'm still getting up to speed on a lot of this stuff (I don't know GTK/GDK very well), so I don't know if I'm going to be able to test that out for you any time soon.

I will play around with rxvt (as a test case) and let you know what, if anything, I come up with.
heyneman is offline   Reply With Quote
Old 12-23-2010, 04:41 AM   #5
Iņigo
Guru
Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.
 
Posts: 730
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, iRex DR800S. K4NT. Kobo Aura, Aura One, Libra 2.
Quote:
Originally Posted by heyneman View Post
Quick question for folks:

I've got a DR800, but I'm running DR800+ to get the tab functionality, etc, from the DR1000. How does a program get put in a new tab, vs running in the main (explorer) tab?

I ask because, for example, rxvt shows up in the explorer tab. If I don't explicitly exit the terminal, it is still running in the background when I try to switch back to the home screen (I know because the on-screen keyboard doesn't disappear, and when I start rxvt up again I see all my previous commands). I've looked a bit into the source for rxvt and the xournal port (which does end up in its own tab), and the only thing I've noticed so far is that the xournal port uses the IPC stuff. Is that the key?

Thanks,

-heyneman
You could also take a look at how we do it in FBReader: https://bitbucket.org/inigoserna/fbr...t/8c0f3a67c11a

1. while initating FBreader we store application GTK+ window as a global variable for later use.

ipc_sys_set_window(GTK_WIDGET(myMainWindow)) in zlibrary/ui/src/gtk/application-desktop/ZLGtkApplicationWindow.cpp:70

This function is in ipc.c file (renamed to dr-ipc.cpp in a later release).


2. after all the initization is done we call ipc_sys_startup_complete(), located at the end of ipc.c file.
This function gets Xwindow ID from the GTK+ window stored before and calls the DR machinery to associate xwindow ID and application process ID and set as a tab if firmware supports tabs, that is, in DR1000 and DR800+.

Code:
void ipc_sys_startup_complete ( void )
{
    eripc_error_t   result;
    // parameters for ipc message
    const int       my_pid = getpid();
    const int       my_xid = GDK_WINDOW_XID(g_window->window);
    const gboolean  is_multidoc = FALSE;        // TODO: set TRUE/FALSE depending on your application
    const gboolean  show_taskbar = TRUE;

    // broadcast signal over session bus
    result = eripc_send_signal_varargs( eripcContext,
                                        ERIPC_BUS_SESSION,
                                        DBUS_PATH,
                                        DBUS_SERVICE_SYSTEM_CONTROL,
                                        "startupComplete",
                                        ERIPC_TYPE_STRING, DBUS_APPL_NAME,
                                        ERIPC_TYPE_INT,    my_pid,
                                        ERIPC_TYPE_BOOL,   is_multidoc,
                                        ERIPC_TYPE_STRING, DBUS_SERVICE,
                                        ERIPC_TYPE_INT,    my_xid,
                                        ERIPC_TYPE_BOOL,   show_taskbar,
                                        ERIPC_TYPE_INVALID );

    if (result != ERIPC_ERROR_SUCCESS) {
        printf("eripc_send_varargs returns [%d]", result);
    } 
}
See the "show_taskbar" argument passed to the eripc_...?

Note this is not the last version, as code evolved to gain DR-like menus, but it's simpler to show and comment.

Hope it helps,
Iņigo

Last edited by Iņigo; 12-23-2010 at 04:45 AM.
Iņigo is offline   Reply With Quote
Advert
Old 12-30-2010, 08:56 AM   #6
Mackx
Guru
Mackx is a splendid one to beholdMackx is a splendid one to beholdMackx is a splendid one to beholdMackx is a splendid one to beholdMackx is a splendid one to beholdMackx is a splendid one to beholdMackx is a splendid one to beholdMackx is a splendid one to beholdMackx is a splendid one to beholdMackx is a splendid one to beholdMackx is a splendid one to behold
 
Posts: 999
Karma: 19985
Join Date: Dec 2008
Location: Netherlands
Device: iRex DR1000S
Quote:
Originally Posted by dima_tr View Post
Hm, has just found one thing that may serve as a substitute for
..............const int xid = GDK_WINDOW_XID(window->window);

Guys, can you please check if this helps rxvt to have a tab?
Code:
	Window focusWindow;
	Display *focusDisplay = XOpenDisplay(NULL);
	int param = 0;
	int xid = XGetInputFocus(focusDisplay,&focusWindow,&param);
Hi dima,

Thanks for 'inspiring' me, to fix this issue that also annoyed me for some time. The xid is already available, my main function now contains:
Code:
    // make sure that rxvt is shown in a tab
    ipc_set_services();
    ipc_sys_startup_complete(rxvt_vars->TermWin.parent[0]);

    rxvt_main_loop(rxvt_vars);	/* main processing loop */
The keyboard is still displayed when switching to other applications, but that will not be a big problem I hope. To make this work I also had to change the code to remove the keyboard. When calling eripc_sysd_startup_complete() to show the application in the taskbar, sysd checks to see if the process-id that is given as parameter is equal to one of the processes that is started from the UI. The original code was using a shell-script to start the real rxvt-program, so the pid of the program started, did not match with the pid of the process calling startup_complete().
I modified the code slightly to close the keyboard when the program exits, so I do not need the shell-script anymore.

I see if I can make a proper 'installation package' and post it in the original rxvt message thread.
Mackx is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Review: Samsung Galaxy Tab mgmueller Android Devices 57 02-10-2011 01:06 PM
Samsung Galaxy Tab mgmueller Android Devices 96 11-16-2010 08:19 AM
Preferences Miscellaneous Tab adun EPUBReader 2 07-28-2010 06:06 AM
Links opening in the same tab and other issues. BookCat Feedback 25 01-22-2009 03:15 PM


All times are GMT -4. The time now is 04:55 AM.


MobileRead.com is a privately owned, operated and funded community.