Quote:
Originally Posted by twobob
the toggle keyboards is/was bafs.
|
You could also try something like this, using my openlipc.h:
Code:
#include <openlipc.h>
int is_keyboard_visible(){
char publisher[]="com.lab126.keyboard";
char property[]="show";
int ivalue, lipc_handle, lipc_error;
lipc_handle = LipcOpenNoName();
if (!lipc_handle) {
return -1;
}
lipc_error = LipcGetIntProperty(lipc_handle, publisher, property, &ivalue);
LipcClose(lipc_handle);
if (lipc_error) {
return -1;
}
return ivalue;
}
int open_keyboard(){
int lipc_handle, lipc_error;
char publisher[]="com.lab126.keyboard";
char property[]="open";
char value[100];
int p = getpid();
snprintf(value, sizeof value, "com.lab126.gtkInputMethod%d:abc:0", p);
lipc_handle = LipcOpenNoName();
if (!lipc_handle) {
return FALSE;
}
lipc_error = LipcSetStringProperty(lipc_handle, publisher, property, value);
LipcClose(lipc_handle);
if (lipc_error) {
return FALSE;
}
return TRUE;
}
int close_keyboard(){
int lipc_handle, lipc_error;
char publisher[]="com.lab126.keyboard";
char property[]="close";
char value[100];
int p = getpid();
snprintf(value, sizeof value, "com.lab126.gtkInputMethod%d", p);
lipc_handle = LipcOpenNoName();
if (!lipc_handle) {
return FALSE;
}
lipc_error = LipcSetStringProperty(lipc_handle, publisher, property, value);
LipcClose(lipc_handle);
if (lipc_error) {
return FALSE;
}
return TRUE;
}
void toggle_keyboard() {
if (is_keyboard_visible()) {
close_keyboard();
} else {
open_keyboard();
}
}
BTW you need to include gtkInputMethod+pid in the keyboard name only if there is a chance that keyboard was opened automatically by system. If you control keyboard only from your app you may choose whatever name you want.