Compare commits

..

No commits in common. "master" and "Keyboard_0-3-1" have entirely different histories.

15 changed files with 127 additions and 567 deletions

View File

@ -8,13 +8,11 @@ This program emulates a physical keyboard by providing a virtual interface on
screen. It currently supports four modes: screen. It currently supports four modes:
* docked, where it will occupy the bottom of the screen; * docked, where it will occupy the bottom of the screen;
* popup, likewise as a popup window; * popup, likewise as a popup window;
* windowed, where it can be found in the system tray (the default) * windowed, where it can be found in the system tray (default)
* embedded, which outputs its window ID for inclusion within another program. * embedded, which outputs its window ID for inclusion within another program.
Additionally, it can be piloted through its companion tool, `desktopctl(1)`. Additionally, it can be piloted through its companion tool, `desktopctl(1)`.
Keyboard is part of the DeforaOS Project, found at https://www.defora.org/.
Compiling Keyboard Compiling Keyboard
------------------ ------------------
@ -29,20 +27,6 @@ on most systems:
$ make $ make
The following command will then install Keyboard:
$ make install
To install (or package) Keyboard in a different location:
$ make clean
$ make PREFIX="/another/prefix" install
Keyboard also supports `DESTDIR`, to be installed in a staging directory; for
instance:
$ make DESTDIR="/staging/directory" PREFIX="/another/prefix" install
On some systems, the Makefiles shipped can be re-generated accordingly thanks to On some systems, the Makefiles shipped can be re-generated accordingly thanks to
the DeforaOS configure tool. the DeforaOS configure tool.

View File

@ -1,4 +1,4 @@
dist=Makefile,org.defora.keyboard.desktop dist=Makefile,deforaos-keyboard.desktop
[org.defora.keyboard.desktop] [deforaos-keyboard.desktop]
install=$(PREFIX)/share/applications install=$(PREFIX)/share/applications

View File

@ -1,14 +1,14 @@
# $Id$ # $Id$
# Copyright (c) 2014-2020 Pierre Pronchery <khorben@defora.org> # Copyright (c) 2014 Pierre Pronchery <khorben@defora.org>
# Spanish translations for Keyboard package. # Spanish translations for Keyboard package.
# This file is distributed under the same license as the Keyboard package. # This file is distributed under the same license as the Keyboard package.
# Pierre Pronchery <khorben@defora.org>, 2014. # Pierre Pronchery <khorben@defora.org>, 2014.
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Keyboard 0.4.0\n" "Project-Id-Version: Keyboard 0.2.1\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-12 07:47+0100\n" "POT-Creation-Date: 2016-09-24 04:16+0200\n"
"PO-Revision-Date: 2014-12-28 20:19+0100\n" "PO-Revision-Date: 2014-12-28 20:19+0100\n"
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n" "Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
"Language-Team: Spanish\n" "Language-Team: Spanish\n"
@ -18,46 +18,45 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: ../src/keyboard.c:145 #: ../src/keyboard.c:117
msgid "_Quit" msgid "_Quit"
msgstr "_Salir" msgstr "_Salir"
#: ../src/keyboard.c:152 #: ../src/keyboard.c:124
msgid "_Hide" msgid "_Hide"
msgstr "_Ocultar" msgstr "_Ocultar"
#: ../src/keyboard.c:160 ../src/keyboard.c:162 #: ../src/keyboard.c:132 ../src/keyboard.c:134
msgid "_About" msgid "_About"
msgstr "_Acerca de" msgstr "_Acerca de"
#: ../src/keyboard.c:169 #: ../src/keyboard.c:141
msgid "_File" msgid "_File"
msgstr "_Archivo" msgstr "_Archivo"
#: ../src/keyboard.c:170 #: ../src/keyboard.c:142
msgid "_View" msgid "_View"
msgstr "_Ver" msgstr "_Ver"
#: ../src/keyboard.c:171 #: ../src/keyboard.c:143
msgid "_Help" msgid "_Help"
msgstr "_Ayuda" msgstr "_Ayuda"
#: ../src/keyboard.c:816 #: ../src/keyboard.c:451
msgid "Virtual keyboard" msgid "Virtual keyboard"
msgstr "" msgstr ""
#: ../src/keyboard.c:936 #: ../src/keyboard.c:571
msgid "Keyboard" msgid "Keyboard"
msgstr "Teclado" msgstr "Teclado"
#: ../src/keyboard.c:1055 #: ../src/keyboard.c:690
msgid "Virtual keyboard for the DeforaOS desktop" msgid "Virtual keyboard for the DeforaOS desktop"
msgstr "Teclado virtual para el escritorio de DeforaOS" msgstr "Teclado virtual para el escritorio de DeforaOS"
#: ../src/keyboardctl.c:87 #: ../src/keyboardctl.c:83
#, c-format
msgid "" msgid ""
"Usage: %s [-H|-S]\n" "Usage: keyboardctl [-H|-S]\n"
" -H\tHide the keyboard\n" " -H\tHide the keyboard\n"
" -S\tShow the keyboard\n" " -S\tShow the keyboard\n"
msgstr "" msgstr ""
@ -65,9 +64,8 @@ msgstr ""
#: ../src/main.c:92 #: ../src/main.c:92
#, c-format #, c-format
msgid "" msgid ""
"Usage: %s [-d|-p|-w|-x][-f font][-l layout][-m monitor][-n]\n" "Usage: %s [-d|-p|-w|-x][-f font][-m monitor][-n]\n"
" -d\tStart in docked mode\n" " -d\tStart in docked mode\n"
" -l\tSelect a different layout\n"
" -p\tStart as a popup window\n" " -p\tStart as a popup window\n"
" -w\tStart in windowed mode\n" " -w\tStart in windowed mode\n"
" -x\tStart in embedded mode\n" " -x\tStart in embedded mode\n"

View File

@ -1,14 +1,14 @@
# $Id$ # $Id$
# Copyright (c) 2012-2020 Pierre Pronchery <khorben@defora.org> # Copyright (c) 2012-2013 Pierre Pronchery <khorben@defora.org>
# French translations for Keyboard package. # French translations for Keyboard package.
# This file is distributed under the same license as the Keyboard package. # This file is distributed under the same license as the Keyboard package.
# Pierre Pronchery <khorben@defora.org>, 2012. # Pierre Pronchery <khorben@defora.org>, 2012.
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Keyboard 0.4.0\n" "Project-Id-Version: Keyboard 0.2.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-12 07:47+0100\n" "POT-Creation-Date: 2016-09-24 04:16+0200\n"
"PO-Revision-Date: 2012-05-20 14:32+0200\n" "PO-Revision-Date: 2012-05-20 14:32+0200\n"
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n" "Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
"Language-Team: French\n" "Language-Team: French\n"
@ -18,59 +18,57 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: ../src/keyboard.c:145 #: ../src/keyboard.c:117
msgid "_Quit" msgid "_Quit"
msgstr "_Quitter" msgstr "_Quitter"
#: ../src/keyboard.c:152 #: ../src/keyboard.c:124
msgid "_Hide" msgid "_Hide"
msgstr "Masquer" msgstr "Masquer"
#: ../src/keyboard.c:160 ../src/keyboard.c:162 #: ../src/keyboard.c:132 ../src/keyboard.c:134
msgid "_About" msgid "_About"
msgstr "À propos" msgstr "À propos"
#: ../src/keyboard.c:169 #: ../src/keyboard.c:141
msgid "_File" msgid "_File"
msgstr "_Fichier" msgstr "_Fichier"
#: ../src/keyboard.c:170 #: ../src/keyboard.c:142
msgid "_View" msgid "_View"
msgstr "_Vue" msgstr "_Vue"
#: ../src/keyboard.c:171 #: ../src/keyboard.c:143
msgid "_Help" msgid "_Help"
msgstr "_Aide" msgstr "_Aide"
#: ../src/keyboard.c:816 #: ../src/keyboard.c:451
msgid "Virtual keyboard" msgid "Virtual keyboard"
msgstr "Clavier virtuel" msgstr "Clavier virtuel"
#: ../src/keyboard.c:936 #: ../src/keyboard.c:571
msgid "Keyboard" msgid "Keyboard"
msgstr "Clavier" msgstr "Clavier"
#: ../src/keyboard.c:1055 #: ../src/keyboard.c:690
msgid "Virtual keyboard for the DeforaOS desktop" msgid "Virtual keyboard for the DeforaOS desktop"
msgstr "Clavier virtuel pour l'environnement DeforaOS" msgstr "Clavier virtuel pour l'environnement DeforaOS"
#: ../src/keyboardctl.c:87 #: ../src/keyboardctl.c:83
#, c-format
msgid "" msgid ""
"Usage: %s [-H|-S]\n" "Usage: keyboardctl [-H|-S]\n"
" -H\tHide the keyboard\n" " -H\tHide the keyboard\n"
" -S\tShow the keyboard\n" " -S\tShow the keyboard\n"
msgstr "" msgstr ""
"Usage: %s [-H|-S]\n" "Usage: keyboardctl [-H|-S]\n"
" -H\tMasquer le clavier\n" " -H\tMasquer le clavier\n"
" -S\tAfficher le clavier\n" " -S\tAfficher le clavier\n"
#: ../src/main.c:92 #: ../src/main.c:92
#, c-format #, c-format
msgid "" msgid ""
"Usage: %s [-d|-p|-w|-x][-f font][-l layout][-m monitor][-n]\n" "Usage: %s [-d|-p|-w|-x][-f font][-m monitor][-n]\n"
" -d\tStart in docked mode\n" " -d\tStart in docked mode\n"
" -l\tSelect a different layout\n"
" -p\tStart as a popup window\n" " -p\tStart as a popup window\n"
" -w\tStart in windowed mode\n" " -w\tStart in windowed mode\n"
" -x\tStart in embedded mode\n" " -x\tStart in embedded mode\n"
@ -78,9 +76,8 @@ msgid ""
" -m\tPlace on a particular monitor (in docked or popup mode)\n" " -m\tPlace on a particular monitor (in docked or popup mode)\n"
" -n\tStart without showing up directly (if not embedded)\n" " -n\tStart without showing up directly (if not embedded)\n"
msgstr "" msgstr ""
"Usage: %s [-d|-p|-w|-x][-f police][-l langue][-m moniteur][-n]\n" "Usage: %s [-d|-p|-w|-x][-f police][-m moniteur][-n]\n"
" -d\tDémarrer comme un dock\n" " -d\tDémarrer comme un dock\n"
" -l\tSpécifier la langue utilisée pour le clavier\n"
" -p\tDémarrer comme une fenêtre popup\n" " -p\tDémarrer comme une fenêtre popup\n"
" -w\tDémarrer comme une fenêtre\n" " -w\tDémarrer comme une fenêtre\n"
" -x\tDémarrer en mode embarqué\n" " -x\tDémarrer en mode embarqué\n"

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2010-2020 Pierre Pronchery <khorben@defora.org> #Copyright (c) 2010-2015 Pierre Pronchery <khorben@defora.org>
# #
#Redistribution and use in source and binary forms, with or without #Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met: #modification, are permitted provided that the following conditions are met:
@ -25,8 +25,8 @@
#variables #variables
CONFIGSH="${0%/gettext.sh}/../config.sh"
PREFIX="/usr/local" PREFIX="/usr/local"
[ -f "../config.sh" ] && . "../config.sh"
LOCALEDIR="$PREFIX/share/locale" LOCALEDIR="$PREFIX/share/locale"
POTFILES="POTFILES" POTFILES="POTFILES"
PROGNAME="gettext.sh" PROGNAME="gettext.sh"
@ -40,8 +40,6 @@ MSGMERGE="msgmerge"
RM="rm -f" RM="rm -f"
XGETTEXT="xgettext --force-po" XGETTEXT="xgettext --force-po"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions #functions
#debug #debug
@ -114,7 +112,7 @@ _gettext_pot()
clean=0 clean=0
install=0 install=0
uninstall=0 uninstall=0
while getopts "ciO:uP:" name; do while getopts "ciuP:" name; do
case "$name" in case "$name" in
c) c)
clean=1 clean=1
@ -123,9 +121,6 @@ while getopts "ciO:uP:" name; do
uninstall=0 uninstall=0
install=1 install=1
;; ;;
O)
export "${OPTARG%%=*}"="${OPTARG#*=}"
;;
u) u)
install=0 install=0
uninstall=1 uninstall=1
@ -140,7 +135,7 @@ while getopts "ciO:uP:" name; do
esac esac
done done
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
if [ $# -lt 1 ]; then if [ $# -eq 0 ]; then
_usage _usage
exit $? exit $?
fi fi

View File

@ -1,14 +1,9 @@
vendor=Desktop
package=Keyboard package=Keyboard
version=0.4.0 version=0.3.1
config=h,sh
subdirs=data,include,po,src,src/widget,tools subdirs=data,include,po,src,src/widget,tools
config=h,sh
dist=COPYING,Makefile,README.md,config.h,config.sh dist=COPYING,Makefile,README.md,config.h,config.sh
#dist
[COPYING]
install=$(PREFIX)/share/doc/$(PACKAGE)
[README.md] [README.md]
install=$(PREFIX)/share/doc/$(PACKAGE) install=$(PREFIX)/share/doc/Keyboard

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
static char const _copyright[] = static char const _copyright[] =
"Copyright © 2011-2020 Pierre Pronchery <khorben@defora.org>"; "Copyright © 2011-2016 Pierre Pronchery <khorben@defora.org>";
/* This file is part of DeforaOS Desktop Keyboard */ /* This file is part of DeforaOS Desktop Keyboard */
static char const _license[] = static char const _license[] =
"All rights reserved.\n" "All rights reserved.\n"
@ -33,11 +33,9 @@ static char const _license[] =
#include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <strings.h>
#include <libintl.h> #include <libintl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
@ -57,10 +55,6 @@ static char const _license[] =
#define _(string) gettext(string) #define _(string) gettext(string)
#define N_(string) (string) #define N_(string) (string)
#ifndef PROGNAME_KEYBOARD
# define PROGNAME_KEYBOARD "keyboard"
#endif
/* Keyboard */ /* Keyboard */
/* private */ /* private */
@ -110,21 +104,6 @@ typedef struct _KeyboardLayoutDefinition
KeyboardKeyDefinition const * keys; KeyboardKeyDefinition const * keys;
} KeyboardLayoutDefinition; } KeyboardLayoutDefinition;
typedef enum _KeyboardLayoutType
{
KLT_QWERTY = 0,
KLT_QWERTZ,
KLT_AZERTY
} KeyboardLayoutType;
#define KLT_LAST KLT_AZERTY
#define KLT_COUNT (KLT_LAST + 1)
typedef struct _KeyboardLayoutTypeName
{
KeyboardLayoutType type;
char const * name;
} KeyboardLayoutTypeName;
/* constants */ /* constants */
static char const * _authors[] = static char const * _authors[] =
@ -133,13 +112,6 @@ static char const * _authors[] =
NULL NULL
}; };
static const KeyboardLayoutTypeName _keyboard_layout_type_name[] =
{
{ KLT_QWERTY, "us" },
{ KLT_QWERTZ, "de" },
{ KLT_AZERTY, "fr" }
};
static const DesktopMenu _keyboard_menu_file[] = static const DesktopMenu _keyboard_menu_file[] =
{ {
{ N_("_Quit"), G_CALLBACK(on_file_quit), GTK_STOCK_QUIT, { N_("_Quit"), G_CALLBACK(on_file_quit), GTK_STOCK_QUIT,
@ -174,7 +146,7 @@ static const DesktopMenubar _keyboard_menubar[] =
/* variables */ /* variables */
static KeyboardKeyDefinition const _keyboard_layout_letters_qwerty[] = static KeyboardKeyDefinition const _keyboard_layout_letters[] =
{ {
{ 0, 2, 0, XK_q, "q" }, { 0, 2, 0, XK_q, "q" },
{ 0, 0, XK_Shift_L, XK_Q, "Q" }, { 0, 0, XK_Shift_L, XK_Q, "Q" },
@ -244,174 +216,6 @@ static KeyboardKeyDefinition const _keyboard_layout_letters_qwerty[] =
{ 0, 0, 0, 0, NULL } { 0, 0, 0, 0, NULL }
}; };
static KeyboardKeyDefinition const _keyboard_layout_letters_qwertz[] =
{
{ 0, 2, 0, XK_q, "q" },
{ 0, 0, XK_Shift_L, XK_Q, "Q" },
{ 0, 2, 0, XK_w, "w" },
{ 0, 0, XK_Shift_L, XK_W, "W" },
{ 0, 2, 0, XK_e, "e" },
{ 0, 0, XK_Shift_L, XK_E, "E" },
{ 0, 2, 0, XK_r, "r" },
{ 0, 0, XK_Shift_L, XK_R, "R" },
{ 0, 2, 0, XK_t, "t" },
{ 0, 0, XK_Shift_L, XK_T, "T" },
{ 0, 2, 0, XK_z, "z" },
{ 0, 0, XK_Shift_L, XK_Z, "Z" },
{ 0, 2, 0, XK_u, "u" },
{ 0, 0, XK_Shift_L, XK_U, "U" },
{ 0, 2, 0, XK_i, "i" },
{ 0, 0, XK_Shift_L, XK_I, "I" },
{ 0, 2, 0, XK_o, "o" },
{ 0, 0, XK_Shift_L, XK_O, "O" },
{ 0, 2, 0, XK_p, "p" },
{ 0, 0, XK_Shift_L, XK_P, "P" },
{ 1, 1, 0, 0, NULL },
{ 1, 2, 0, XK_a, "a" },
{ 1, 0, XK_Shift_L, XK_A, "A" },
{ 1, 2, 0, XK_s, "s" },
{ 1, 0, XK_Shift_L, XK_S, "S" },
{ 1, 2, 0, XK_d, "d" },
{ 1, 0, XK_Shift_L, XK_D, "D" },
{ 1, 2, 0, XK_f, "f" },
{ 1, 0, XK_Shift_L, XK_F, "F" },
{ 1, 2, 0, XK_g, "g" },
{ 1, 0, XK_Shift_L, XK_G, "G" },
{ 1, 2, 0, XK_h, "h" },
{ 1, 0, XK_Shift_L, XK_H, "H" },
{ 1, 2, 0, XK_j, "j" },
{ 1, 0, XK_Shift_L, XK_J, "J" },
{ 1, 2, 0, XK_k, "k" },
{ 1, 0, XK_Shift_L, XK_K, "K" },
{ 1, 2, 0, XK_l, "l" },
{ 1, 0, XK_Shift_L, XK_L, "L" },
{ 2, 2, 0, XK_Shift_L, "\xe2\x87\xa7" },
{ 2, 2, 0, XK_y, "y" },
{ 2, 0, XK_Shift_L, XK_Y, "Y" },
{ 2, 2, 0, XK_x, "x" },
{ 2, 0, XK_Shift_L, XK_X, "X" },
{ 2, 2, 0, XK_c, "c" },
{ 2, 0, XK_Shift_L, XK_C, "C" },
{ 2, 2, 0, XK_v, "v" },
{ 2, 0, XK_Shift_L, XK_V, "V" },
{ 2, 2, 0, XK_b, "b" },
{ 2, 0, XK_Shift_L, XK_B, "B" },
{ 2, 2, 0, XK_n, "n" },
{ 2, 0, XK_Shift_L, XK_N, "N" },
{ 2, 2, 0, XK_m, "m" },
{ 2, 0, XK_Shift_L, XK_M, "M" },
{ 2, 2, 0, XK_comma, "," },
{ 2, 0, XK_Shift_L, XK_comma, "<" },
{ 2, 2, 0, XK_period, "." },
{ 2, 0, XK_Shift_L, XK_period, ">" },
{ 3, 3, 0, 0, NULL },
{ 3, 3, 0, XK_Control_L, "Ctrl" },
{ 3, 3, 0, XK_Alt_L, "Alt" },
{ 3, 5, 0, XK_space, " " },
{ 3, 0, XK_Shift_L, XK_space, " " },
{ 3, 3, 0, XK_Return, "\xe2\x86\xb2" },
{ 3, 3, 0, XK_BackSpace, "\xe2\x8c\xab" },
{ 0, 0, 0, 0, NULL }
};
static KeyboardKeyDefinition const _keyboard_layout_letters_azerty[] =
{
{ 0, 2, 0, XK_a, "a" },
{ 0, 0, XK_Shift_L, XK_A, "A" },
{ 0, 2, 0, XK_z, "z" },
{ 0, 0, XK_Shift_L, XK_Z, "Z" },
{ 0, 2, 0, XK_e, "e" },
{ 0, 0, XK_Shift_L, XK_E, "E" },
#if 0 /* def XK_CURRENCY */
{ 0, 0, XK_Alt_R, XK_EuroSign, "" },
#else
{ 0, 0, XK_Alt_R, XK_E, "" },
#endif
{ 0, 2, 0, XK_r, "r" },
{ 0, 0, XK_Shift_L, XK_R, "R" },
{ 0, 2, 0, XK_t, "t" },
{ 0, 0, XK_Shift_L, XK_T, "T" },
{ 0, 2, 0, XK_y, "y" },
{ 0, 0, XK_Shift_L, XK_Y, "Y" },
{ 0, 2, 0, XK_u, "u" },
{ 0, 0, XK_Shift_L, XK_U, "U" },
{ 0, 2, 0, XK_i, "i" },
{ 0, 0, XK_Shift_L, XK_I, "I" },
{ 0, 2, 0, XK_o, "o" },
{ 0, 0, XK_Shift_L, XK_O, "O" },
{ 0, 2, 0, XK_p, "p" },
{ 0, 0, XK_Shift_L, XK_P, "P" },
{ 0, 2, 0, XK_asciicircum, "^" },
{ 0, 0, XK_Shift_L, XK_quotedbl, "\"" },
{ 0, 2, 0, XK_dollar, "$" },
{ 0, 0, XK_Shift_L, XK_sterling, "£" },
{ 1, 1, 0, 0, NULL },
{ 1, 2, 0, XK_q, "q" },
{ 1, 0, XK_Shift_L, XK_Q, "Q" },
{ 1, 2, 0, XK_s, "s" },
{ 1, 0, XK_Shift_L, XK_S, "S" },
{ 1, 2, 0, XK_d, "d" },
{ 1, 0, XK_Shift_L, XK_D, "D" },
{ 1, 2, 0, XK_f, "f" },
{ 1, 0, XK_Shift_L, XK_F, "F" },
{ 1, 2, 0, XK_g, "g" },
{ 1, 0, XK_Shift_L, XK_G, "G" },
{ 1, 2, 0, XK_h, "h" },
{ 1, 0, XK_Shift_L, XK_H, "H" },
{ 1, 2, 0, XK_j, "j" },
{ 1, 0, XK_Shift_L, XK_J, "J" },
{ 1, 2, 0, XK_k, "k" },
{ 1, 0, XK_Shift_L, XK_K, "K" },
{ 1, 2, 0, XK_l, "l" },
{ 1, 0, XK_Shift_L, XK_L, "L" },
{ 1, 2, 0, XK_m, "m" },
{ 1, 0, XK_Shift_L, XK_M, "M" },
{ 1, 2, 0, XK_ugrave, "ù" },
{ 1, 0, XK_Shift_L, XK_percent, "%" },
{ 1, 2, 0, XK_asterisk, "*" },
{ 1, 0, XK_Shift_L, XK_mu, "µ" },
{ 2, 2, 0, XK_Shift_L, "\xe2\x87\xa7" },
{ 2, 2, 0, XK_less, "<" },
{ 2, 0, XK_Shift_L, XK_less, ">" },
{ 2, 2, 0, XK_w, "w" },
{ 2, 0, XK_Shift_L, XK_W, "W" },
{ 2, 2, 0, XK_x, "x" },
{ 2, 0, XK_Shift_L, XK_X, "X" },
{ 2, 2, 0, XK_c, "c" },
{ 2, 0, XK_Shift_L, XK_C, "C" },
{ 2, 2, 0, XK_v, "v" },
{ 2, 0, XK_Shift_L, XK_V, "V" },
{ 2, 2, 0, XK_b, "b" },
{ 2, 0, XK_Shift_L, XK_B, "B" },
{ 2, 2, 0, XK_n, "n" },
{ 2, 0, XK_Shift_L, XK_N, "N" },
{ 2, 2, 0, XK_comma, "," },
{ 2, 0, XK_Shift_L, XK_question, "?" },
{ 2, 2, 0, XK_semicolon, ";" },
{ 2, 0, XK_Shift_L, XK_period, "." },
{ 2, 2, 0, XK_colon, ":" },
{ 2, 0, XK_Shift_L, XK_slash, "/" },
{ 2, 2, 0, XK_exclam, "!" },
{ 2, 0, XK_Shift_L, XK_paragraph, "§" },
{ 3, 3, 0, 0, NULL },
{ 3, 3, 0, XK_Control_L, "Ctrl" },
{ 3, 3, 0, XK_Alt_L, "Alt" },
{ 3, 7, 0, XK_space, " " },
{ 3, 0, XK_Shift_L, XK_space, " " },
{ 3, 3, 0, XK_Alt_R, "Alt Gr" },
{ 3, 0, XK_Shift_L, XK_Alt_R, "Alt Gr" },
{ 3, 3, 0, XK_Return, "\xe2\x86\xb2" },
{ 3, 3, 0, XK_BackSpace, "\xe2\x8c\xab" },
{ 0, 0, 0, 0, NULL }
};
static KeyboardKeyDefinition const * _keyboard_layout_letters_definition[KLT_COUNT] =
{
_keyboard_layout_letters_qwerty,
_keyboard_layout_letters_qwertz,
_keyboard_layout_letters_azerty
};
static KeyboardKeyDefinition const _keyboard_layout_keypad[] = static KeyboardKeyDefinition const _keyboard_layout_keypad[] =
{ {
{ 0, 3, 0, XK_Num_Lock, "Num" }, { 0, 3, 0, XK_Num_Lock, "Num" },
@ -455,17 +259,13 @@ static KeyboardKeyDefinition const _keyboard_layout_keypad[] =
{ 0, 0, 0, 0, NULL } { 0, 0, 0, 0, NULL }
}; };
static KeyboardKeyDefinition const _keyboard_layout_special_qwerty[] = static KeyboardKeyDefinition const _keyboard_layout_special[] =
{ {
{ 0, 3, 0, XK_Escape, "Esc" }, { 0, 3, 0, XK_Escape, "Esc" },
{ 0, 2, 0, XK_F1, "F1" }, { 0, 2, 0, XK_F1, "F1" },
{ 0, 0, XK_Shift_L, XK_F5, "F5" },
{ 0, 2, 0, XK_F2, "F2" }, { 0, 2, 0, XK_F2, "F2" },
{ 0, 0, XK_Shift_L, XK_F6, "F6" },
{ 0, 2, 0, XK_F3, "F3" }, { 0, 2, 0, XK_F3, "F3" },
{ 0, 0, XK_Shift_L, XK_F7, "F7" },
{ 0, 2, 0, XK_F4, "F4" }, { 0, 2, 0, XK_F4, "F4" },
{ 0, 0, XK_Shift_L, XK_F8, "F8" },
{ 0, 1, 0, 0, NULL }, { 0, 1, 0, 0, NULL },
{ 0, 2, 0, XK_F5, "F5" }, { 0, 2, 0, XK_F5, "F5" },
{ 0, 0, XK_Shift_L, XK_F9, "F9" }, { 0, 0, XK_Shift_L, XK_F9, "F9" },
@ -476,28 +276,28 @@ static KeyboardKeyDefinition const _keyboard_layout_special_qwerty[] =
{ 0, 2, 0, XK_F8, "F8" }, { 0, 2, 0, XK_F8, "F8" },
{ 0, 0, XK_Shift_L, XK_F12, "F12" }, { 0, 0, XK_Shift_L, XK_F12, "F12" },
{ 1, 2, 0, XK_1, "1" }, { 1, 2, 0, XK_1, "1" },
{ 1, 0, XK_Shift_L, XK_exclam, "!" }, { 1, 0, XK_Shift_L, XK_1, "!" },
{ 1, 2, 0, XK_2, "2" }, { 1, 2, 0, XK_2, "2" },
{ 1, 0, XK_Shift_L, XK_at, "@" }, { 1, 0, XK_Shift_L, XK_2, "@" },
{ 1, 2, 0, XK_3, "3" }, { 1, 2, 0, XK_3, "3" },
{ 1, 0, XK_Shift_L, XK_numbersign, "#" }, { 1, 0, XK_Shift_L, XK_3, "#" },
{ 1, 2, 0, XK_4, "4" }, { 1, 2, 0, XK_4, "4" },
{ 1, 0, XK_Shift_L, XK_dollar, "$" }, { 1, 0, XK_Shift_L, XK_4, "$" },
{ 1, 2, 0, XK_5, "5" }, { 1, 2, 0, XK_5, "5" },
{ 1, 0, XK_Shift_L, XK_percent, "%" }, { 1, 0, XK_Shift_L, XK_5, "%" },
{ 1, 2, 0, XK_6, "6" }, { 1, 2, 0, XK_6, "6" },
{ 1, 0, XK_Shift_L, XK_asciicircum, "^" }, { 1, 0, XK_Shift_L, XK_6, "^" },
{ 1, 2, 0, XK_7, "7" }, { 1, 2, 0, XK_7, "7" },
{ 1, 0, XK_Shift_L, XK_ampersand, "&" }, { 1, 0, XK_Shift_L, XK_7, "&" },
{ 1, 2, 0, XK_8, "8" }, { 1, 2, 0, XK_8, "8" },
{ 1, 0, XK_Shift_L, XK_asterisk, "*" }, { 1, 0, XK_Shift_L, XK_8, "*" },
{ 1, 2, 0, XK_9, "9" }, { 1, 2, 0, XK_9, "9" },
{ 1, 0, XK_Shift_L, XK_parenleft, "(" }, { 1, 0, XK_Shift_L, XK_9, "(" },
{ 1, 2, 0, XK_0, "0" }, { 1, 2, 0, XK_0, "0" },
{ 1, 0, XK_Shift_L, XK_parenright, ")" }, { 1, 0, XK_Shift_L, XK_0, ")" },
{ 2, 3, 0, XK_Tab, "\xe2\x86\xb9" }, { 2, 3, 0, XK_Tab, "\xe2\x86\xb9" },
{ 2, 2, 0, XK_grave, "`" }, { 2, 2, 0, XK_grave, "`" },
{ 2, 0, XK_Shift_L, XK_asciitilde, "~" }, { 2, 0, XK_Shift_L, XK_grave, "~" },
{ 2, 2, 0, XK_minus, "-" }, { 2, 2, 0, XK_minus, "-" },
{ 2, 0, XK_Shift_L, XK_minus, "_" }, { 2, 0, XK_Shift_L, XK_minus, "_" },
{ 2, 2, 0, XK_equal, "=" }, { 2, 2, 0, XK_equal, "=" },
@ -527,148 +327,11 @@ static KeyboardKeyDefinition const _keyboard_layout_special_qwerty[] =
{ 0, 0, 0, 0, NULL } { 0, 0, 0, 0, NULL }
}; };
static KeyboardKeyDefinition const _keyboard_layout_special_qwertz[] = static KeyboardLayoutDefinition _keyboard_layout[KLS_COUNT] =
{ {
{ 0, 3, 0, XK_Escape, "Esc" }, { "Abc", _keyboard_layout_letters },
{ 0, 2, 0, XK_F1, "F1" }, { "123", _keyboard_layout_keypad },
{ 0, 0, XK_Shift_L, XK_F5, "F5" }, { ",./", _keyboard_layout_special }
{ 0, 2, 0, XK_F2, "F2" },
{ 0, 0, XK_Shift_L, XK_F6, "F6" },
{ 0, 2, 0, XK_F3, "F3" },
{ 0, 0, XK_Shift_L, XK_F7, "F7" },
{ 0, 2, 0, XK_F4, "F4" },
{ 0, 0, XK_Shift_L, XK_F8, "F8" },
{ 0, 1, 0, 0, NULL },
{ 0, 2, 0, XK_F5, "F5" },
{ 0, 0, XK_Shift_L, XK_F9, "F9" },
{ 0, 2, 0, XK_F6, "F6" },
{ 0, 0, XK_Shift_L, XK_F10, "F10" },
{ 0, 2, 0, XK_F7, "F7" },
{ 0, 0, XK_Shift_L, XK_F11, "F11" },
{ 0, 2, 0, XK_F8, "F8" },
{ 0, 0, XK_Shift_L, XK_F12, "F12" },
{ 1, 2, 0, XK_1, "1" },
{ 1, 0, XK_Shift_L, XK_exclam, "!" },
{ 1, 2, 0, XK_2, "2" },
{ 1, 0, XK_Shift_L, XK_at, "@" },
{ 1, 2, 0, XK_3, "3" },
{ 1, 0, XK_Shift_L, XK_numbersign, "#" },
{ 1, 2, 0, XK_4, "4" },
{ 1, 0, XK_Shift_L, XK_dollar, "$" },
{ 1, 2, 0, XK_5, "5" },
{ 1, 0, XK_Shift_L, XK_percent, "%" },
{ 1, 2, 0, XK_6, "6" },
{ 1, 0, XK_Shift_L, XK_asciicircum, "^" },
{ 1, 2, 0, XK_7, "7" },
{ 1, 0, XK_Shift_L, XK_ampersand, "&" },
{ 1, 2, 0, XK_8, "8" },
{ 1, 0, XK_Shift_L, XK_asterisk, "*" },
{ 1, 2, 0, XK_9, "9" },
{ 1, 0, XK_Shift_L, XK_parenleft, "(" },
{ 1, 2, 0, XK_0, "0" },
{ 1, 0, XK_Shift_L, XK_parenright, ")" },
{ 2, 3, 0, XK_Tab, "\xe2\x86\xb9" },
{ 2, 2, 0, XK_grave, "`" },
{ 2, 0, XK_Shift_L, XK_asciitilde, "~" },
{ 2, 2, 0, XK_minus, "-" },
{ 2, 0, XK_Shift_L, XK_minus, "_" },
{ 2, 2, 0, XK_equal, "=" },
{ 2, 0, XK_Shift_L, XK_equal, "+" },
{ 2, 2, 0, XK_backslash, "\\" },
{ 2, 0, XK_Shift_L, XK_backslash, "|" },
{ 2, 2, 0, XK_bracketleft, "[" },
{ 2, 0, XK_Shift_L, XK_bracketleft, "{" },
{ 2, 2, 0, XK_bracketright, "]" },
{ 2, 0, XK_Shift_L, XK_bracketright, "}" },
{ 2, 2, 0, XK_semicolon, ";" },
{ 2, 0, XK_Shift_L, XK_semicolon, ":" },
{ 2, 2, 0, XK_apostrophe, "'" },
{ 2, 0, XK_Shift_L, XK_apostrophe, "\"" },
{ 3, 3, 0, 0, NULL },
{ 3, 2, 0, XK_Shift_L, "\xe2\x87\xa7" },
{ 3, 3, 0, XK_space, " " },
{ 3, 0, XK_Shift_L, XK_space, " " },
{ 3, 2, 0, XK_comma, "," },
{ 3, 0, XK_Shift_L, XK_comma, "<" },
{ 3, 2, 0, XK_period, "." },
{ 2, 0, XK_Shift_L, XK_period, ">" },
{ 3, 2, 0, XK_slash, "/" },
{ 3, 0, XK_Shift_L, XK_slash, "?" },
{ 3, 3, 0, XK_Return, "\xe2\x86\xb2" },
{ 3, 3, 0, XK_BackSpace, "\xe2\x8c\xab" },
{ 0, 0, 0, 0, NULL }
};
static KeyboardKeyDefinition const _keyboard_layout_special_azerty[] =
{
{ 0, 3, 0, XK_Escape, "Esc" },
{ 0, 1, 0, 0, NULL },
{ 0, 2, 0, XK_F1, "F1" },
{ 0, 0, XK_Shift_L, XK_F5, "F5" },
{ 0, 2, 0, XK_F2, "F2" },
{ 0, 0, XK_Shift_L, XK_F6, "F6" },
{ 0, 2, 0, XK_F3, "F3" },
{ 0, 0, XK_Shift_L, XK_F7, "F7" },
{ 0, 2, 0, XK_F4, "F4" },
{ 0, 0, XK_Shift_L, XK_F8, "F8" },
{ 0, 2, 0, XK_F5, "F5" },
{ 0, 0, XK_Shift_L, XK_F9, "F9" },
{ 0, 2, 0, XK_F6, "F6" },
{ 0, 0, XK_Shift_L, XK_F10, "F10" },
{ 0, 2, 0, XK_F7, "F7" },
{ 0, 0, XK_Shift_L, XK_F11, "F11" },
{ 0, 2, 0, XK_F8, "F8" },
{ 0, 0, XK_Shift_L, XK_F12, "F12" },
{ 1, 1, 0, 0, NULL },
{ 1, 2, 0, XK_ampersand, "&" },
{ 1, 0, XK_Shift_L, XK_1, "1" },
{ 1, 2, 0, XK_eacute, "é" },
{ 1, 0, XK_Shift_L, XK_2, "2" },
{ 1, 2, 0, XK_quotedbl, "\"" },
{ 1, 0, XK_Shift_L, XK_3, "3" },
{ 1, 2, 0, XK_apostrophe, "'" },
{ 1, 0, XK_Shift_L, XK_4, "4" },
{ 1, 2, 0, XK_parenleft, "(" },
{ 1, 0, XK_Shift_L, XK_5, "5" },
{ 1, 2, 0, XK_minus, "-" },
{ 1, 0, XK_Shift_L, XK_6, "6" },
{ 1, 2, 0, XK_egrave, "è" },
{ 1, 0, XK_Shift_L, XK_7, "7" },
{ 1, 2, 0, XK_underscore, "_" },
{ 1, 0, XK_Shift_L, XK_8, "8" },
{ 1, 2, 0, XK_ccedilla, "ç" },
{ 1, 0, XK_Shift_L, XK_9, "9" },
{ 1, 2, 0, XK_aacute, "à" },
{ 1, 0, XK_Shift_L, XK_0, "0" },
{ 2, 2, 0, XK_Tab, "\xe2\x86\xb9" },
{ 2, 2, 0, XK_twosuperior, "²" },
{ 2, 2, 0, XK_asciitilde, "~" },
{ 2, 2, 0, XK_numbersign, "#" },
{ 2, 2, 0, XK_braceleft, "{" },
{ 2, 2, 0, XK_bracketleft, "[" },
{ 2, 2, 0, XK_bracketright, "]" },
{ 2, 2, 0, XK_braceright, "}" },
{ 2, 2, 0, XK_parenright, ")" },
{ 2, 0, XK_Shift_L, XK_degree, "°" },
{ 2, 2, 0, XK_equal, "=" },
{ 2, 0, XK_Shift_L, XK_plus, "+" },
{ 3, 3, 0, 0, NULL },
{ 3, 2, 0, XK_Shift_L, "\xe2\x87\xa7" },
{ 3, 2, 0, XK_bracketleft, "|" },
{ 3, 2, 0, XK_grave, "`" },
{ 3, 2, 0, XK_backslash, "\\" },
{ 3, 2, 0, XK_asciicircum, "^" },
{ 3, 2, 0, XK_at, "@" },
{ 3, 3, 0, XK_Return, "\xe2\x86\xb2" },
{ 3, 3, 0, XK_BackSpace, "\xe2\x8c\xab" },
{ 0, 0, 0, 0, NULL }
};
static KeyboardKeyDefinition const * _keyboard_layout_special_definition[KLT_COUNT] =
{
_keyboard_layout_special_qwerty,
_keyboard_layout_special_qwertz,
_keyboard_layout_special_azerty
}; };
@ -677,8 +340,6 @@ static GtkWidget * _keyboard_add_layout(Keyboard * keyboard,
KeyboardLayoutDefinition * definitions, KeyboardLayoutDefinition * definitions,
size_t definitions_cnt, KeyboardLayoutSection section); size_t definitions_cnt, KeyboardLayoutSection section);
static void _keyboard_error(Keyboard * keyboard, char const * format, ...);
/* public */ /* public */
/* functions */ /* functions */
@ -704,14 +365,6 @@ Keyboard * keyboard_new(KeyboardPrefs * prefs)
GdkColor gray = { 0x90909090, 0x9090, 0x9090, 0x9090 }; GdkColor gray = { 0x90909090, 0x9090, 0x9090, 0x9090 };
#endif #endif
unsigned long id; unsigned long id;
KeyboardLayoutDefinition layout[KLS_COUNT] =
{
{ "Abc", _keyboard_layout_letters_qwerty },
{ "123", _keyboard_layout_keypad },
{ ",./", _keyboard_layout_special_qwerty }
};
size_t i;
KeyboardLayoutTypeName const * typename;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s()\n", __func__); fprintf(stderr, "DEBUG: %s()\n", __func__);
@ -770,32 +423,14 @@ Keyboard * keyboard_new(KeyboardPrefs * prefs)
vbox = widget; vbox = widget;
} }
/* layouts */ /* layouts */
if(prefs->layout != NULL) if((widget = _keyboard_add_layout(keyboard, _keyboard_layout,
{ KLS_COUNT, KLS_LETTERS)) != NULL)
for(i = 0; i < sizeof(_keyboard_layout_type_name)
/ sizeof(*_keyboard_layout_type_name); i++)
{
typename = &_keyboard_layout_type_name[i];
if(strcasecmp(prefs->layout, typename->name) == 0)
{
layout[KLS_LETTERS].keys = _keyboard_layout_letters_definition[typename->type];
layout[KLS_SPECIAL].keys = _keyboard_layout_special_definition[typename->type];
break;
}
typename = NULL;
}
if(typename == NULL)
_keyboard_error(NULL, "%s: Unsupported layout",
prefs->layout);
}
if((widget = _keyboard_add_layout(keyboard, layout, KLS_COUNT,
KLS_LETTERS)) != NULL)
gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 0);
if((widget = _keyboard_add_layout(keyboard, layout, KLS_COUNT, if((widget = _keyboard_add_layout(keyboard, _keyboard_layout,
KLS_KEYPAD)) != NULL) KLS_COUNT, KLS_KEYPAD)) != NULL)
gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 0);
if((widget = _keyboard_add_layout(keyboard, layout, KLS_COUNT, if((widget = _keyboard_add_layout(keyboard, _keyboard_layout,
KLS_SPECIAL)) != NULL) KLS_COUNT, KLS_SPECIAL)) != NULL)
gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 0);
gtk_widget_show(vbox); gtk_widget_show(vbox);
if(prefs->mode == KEYBOARD_MODE_EMBEDDED) if(prefs->mode == KEYBOARD_MODE_EMBEDDED)
@ -1060,7 +695,7 @@ void keyboard_show_about(Keyboard * keyboard)
desktop_about_dialog_set_name(keyboard->ab_window, PACKAGE); desktop_about_dialog_set_name(keyboard->ab_window, PACKAGE);
desktop_about_dialog_set_version(keyboard->ab_window, VERSION); desktop_about_dialog_set_version(keyboard->ab_window, VERSION);
desktop_about_dialog_set_website(keyboard->ab_window, desktop_about_dialog_set_website(keyboard->ab_window,
"https://www.defora.org/"); "http://www.defora.org/");
g_signal_connect_swapped(keyboard->ab_window, "delete-event", g_signal_connect_swapped(keyboard->ab_window, "delete-event",
G_CALLBACK(_about_on_closex), keyboard); G_CALLBACK(_about_on_closex), keyboard);
gtk_widget_show(keyboard->ab_window); gtk_widget_show(keyboard->ab_window);
@ -1079,10 +714,6 @@ static gboolean _about_on_closex(gpointer data)
/* private */ /* private */
/* keyboard_add_layout */ /* keyboard_add_layout */
static void _layout_clicked(GtkWidget * widget, gpointer data); static void _layout_clicked(GtkWidget * widget, gpointer data);
static void _layout_selector(Keyboard * keyboard, KeyboardLayout * layout,
KeyboardLayoutDefinition * definitions,
size_t definitions_cnt, KeyboardLayoutSection section,
unsigned int row, unsigned int column, unsigned width);
static GtkWidget * _keyboard_add_layout(Keyboard * keyboard, static GtkWidget * _keyboard_add_layout(Keyboard * keyboard,
KeyboardLayoutDefinition * definitions, KeyboardLayoutDefinition * definitions,
@ -1093,11 +724,17 @@ static GtkWidget * _keyboard_add_layout(Keyboard * keyboard,
KeyboardKeyDefinition const * keys; KeyboardKeyDefinition const * keys;
size_t i; size_t i;
KeyboardKey * key; KeyboardKey * key;
GtkWidget * label;
GtkWidget * widget; GtkWidget * widget;
#if !GTK_CHECK_VERSION(3, 0, 0) unsigned long l;
const GdkColor black = { 0x00000000, 0x0000, 0x0000, 0x0000 }; #if GTK_CHECK_VERSION(3, 0, 0)
const GdkColor white = { 0xffffffff, 0xffff, 0xffff, 0xffff }; gboolean dark = FALSE;
const GdkColor gray = { 0xd0d0d0d0, 0xd0d0, 0xd0d0, 0xd0d0 }; GdkRGBA black = { 0.0, 0.0, 0.0, 1.0 };
GdkRGBA white = { 1.0, 1.0, 1.0, 1.0 };
#else
GdkColor black = { 0x00000000, 0x0000, 0x0000, 0x0000 };
GdkColor white = { 0xffffffff, 0xffff, 0xffff, 0xffff };
GdkColor gray = { 0xd0d0d0d0, 0xd0d0, 0xd0d0, 0xd0d0 };
#endif #endif
if((p = realloc(keyboard->layouts, sizeof(*p) * (keyboard->layouts_cnt if((p = realloc(keyboard->layouts, sizeof(*p) * (keyboard->layouts_cnt
@ -1106,6 +743,10 @@ static GtkWidget * _keyboard_add_layout(Keyboard * keyboard,
keyboard->layouts = p; keyboard->layouts = p;
if((layout = keyboard_layout_new()) == NULL) if((layout = keyboard_layout_new()) == NULL)
return NULL; return NULL;
#if GTK_CHECK_VERSION(3, 0, 0)
g_object_get(gtk_settings_get_default(),
"gtk-application-prefer-dark-theme", &dark, NULL);
#endif
keyboard->layouts[keyboard->layouts_cnt++] = layout; keyboard->layouts[keyboard->layouts_cnt++] = layout;
keys = definitions[section].keys; keys = definitions[section].keys;
for(i = 0; keys[i].width != 0; i++) for(i = 0; keys[i].width != 0; i++)
@ -1128,8 +769,27 @@ static GtkWidget * _keyboard_add_layout(Keyboard * keyboard,
keys[i + 1].keysym, keys[i + 1].label); keys[i + 1].keysym, keys[i + 1].label);
} }
} }
_layout_selector(keyboard, layout, definitions, definitions_cnt, l = (section + 1) % definitions_cnt;
section, 3, 0, 3); label = gtk_label_new(definitions[l].label);
#if GTK_CHECK_VERSION(3, 0, 0)
gtk_widget_override_color(label, GTK_STATE_FLAG_NORMAL,
dark ? &white : &black);
#else
gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &black);
#endif
gtk_widget_override_font(label, keyboard->font);
widget = gtk_button_new();
#if GTK_CHECK_VERSION(3, 0, 0)
gtk_widget_override_background_color(widget, GTK_STATE_FLAG_NORMAL,
dark ? &black : &white);
#else
gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &white);
#endif
gtk_container_add(GTK_CONTAINER(widget), label);
g_object_set_data(G_OBJECT(widget), "layout", (void *)l);
g_signal_connect(widget, "clicked", G_CALLBACK(_layout_clicked),
keyboard);
keyboard_layout_add_widget(layout, 3, 0, 3, widget);
widget = keyboard_layout_get_widget(layout); widget = keyboard_layout_get_widget(layout);
gtk_widget_show_all(widget); gtk_widget_show_all(widget);
gtk_widget_set_no_show_all(widget, TRUE); gtk_widget_set_no_show_all(widget, TRUE);
@ -1154,61 +814,3 @@ static void _layout_clicked(GtkWidget * widget, gpointer data)
break; break;
} }
} }
static void _layout_selector(Keyboard * keyboard, KeyboardLayout * layout,
KeyboardLayoutDefinition * definitions,
size_t definitions_cnt, KeyboardLayoutSection section,
unsigned int row, unsigned int column, unsigned int width)
{
unsigned long l;
GtkWidget * label;
GtkWidget * widget;
#if GTK_CHECK_VERSION(3, 0, 0)
gboolean dark = FALSE;
const GdkRGBA black = { 0.0, 0.0, 0.0, 1.0 };
const GdkRGBA white = { 1.0, 1.0, 1.0, 1.0 };
#else
const GdkColor black = { 0x00000000, 0x0000, 0x0000, 0x0000 };
const GdkColor white = { 0xffffffff, 0xffff, 0xffff, 0xffff };
#endif
#if GTK_CHECK_VERSION(3, 0, 0)
g_object_get(gtk_settings_get_default(),
"gtk-application-prefer-dark-theme", &dark, NULL);
#endif
l = (section + 1) % definitions_cnt;
label = gtk_label_new(definitions[l].label);
#if GTK_CHECK_VERSION(3, 0, 0)
gtk_widget_override_color(label, GTK_STATE_FLAG_NORMAL,
dark ? &white : &black);
#else
gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &black);
#endif
gtk_widget_override_font(label, keyboard->font);
widget = gtk_button_new();
#if GTK_CHECK_VERSION(3, 0, 0)
gtk_widget_override_background_color(widget, GTK_STATE_FLAG_NORMAL,
dark ? &black : &white);
#else
gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &white);
#endif
gtk_container_add(GTK_CONTAINER(widget), label);
g_object_set_data(G_OBJECT(widget), "layout", (void *)l);
g_signal_connect(widget, "clicked", G_CALLBACK(_layout_clicked),
keyboard);
keyboard_layout_add_widget(layout, row, column, width, widget);
}
/* keyboard_error */
static void _keyboard_error(Keyboard * keyboard, char const * format, ...)
{
va_list ap;
/* TODO add support for error dialog messages */
va_start(ap, format);
fprintf(stderr, "%s: ", PROGNAME_KEYBOARD);
vfprintf(stderr, format, ap);
fprintf(stderr, "\n");
va_end(ap);
}

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2010-2020 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2010-2016 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Keyboard */ /* This file is part of DeforaOS Desktop Keyboard */
/* All rights reserved. /* All rights reserved.
* *
@ -53,7 +53,6 @@ typedef struct _KeyboardPrefs
{ {
int monitor; int monitor;
char const * font; char const * font;
char const * layout;
KeyboardMode mode; KeyboardMode mode;
int wait; int wait;
} KeyboardPrefs; } KeyboardPrefs;

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2012-2020 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2012-2016 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Keyboard */ /* This file is part of DeforaOS Desktop Keyboard */
/* All rights reserved. /* All rights reserved.
* *
@ -50,10 +50,6 @@
# define LOCALEDIR DATADIR "/locale" # define LOCALEDIR DATADIR "/locale"
#endif #endif
#ifndef PROGNAME_KEYBOARDCTL
# define PROGNAME_KEYBOARDCTL "keyboardctl"
#endif
/* keyboardctl */ /* keyboardctl */
/* private */ /* private */
@ -75,7 +71,7 @@ static int _keyboardctl(KeyboardMessage message, unsigned int arg1)
/* error */ /* error */
static int _error(char const * message, int ret) static int _error(char const * message, int ret)
{ {
fputs(PROGNAME_KEYBOARDCTL ": ", stderr); fputs("keyboardctl: ", stderr);
perror(message); perror(message);
return ret; return ret;
} }
@ -84,9 +80,9 @@ static int _error(char const * message, int ret)
/* usage */ /* usage */
static int _usage(void) static int _usage(void)
{ {
fprintf(stderr, _("Usage: %s [-H|-S]\n" fputs(_("Usage: keyboardctl [-H|-S]\n"
" -H Hide the keyboard\n" " -H Hide the keyboard\n"
" -S Show the keyboard\n"), PROGNAME_KEYBOARDCTL); " -S Show the keyboard\n"), stderr);
return 1; return 1;
} }

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2010-2020 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2010-2016 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Keyboard */ /* This file is part of DeforaOS Desktop Keyboard */
/* All rights reserved. /* All rights reserved.
* *
@ -146,7 +146,7 @@ KeyboardKey * keyboard_layout_add(KeyboardLayout * layout, unsigned int row,
options, 2, 2); options, 2, 2);
p->keys[p->keys_cnt++] = ret; p->keys[p->keys_cnt++] = ret;
} }
p->width += width; p->width+=width;
return ret; return ret;
} }

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2010-2020 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2010-2016 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Keyboard */ /* This file is part of DeforaOS Desktop Keyboard */
/* All rights reserved. /* All rights reserved.
* *
@ -40,17 +40,17 @@
#define _(string) gettext(string) #define _(string) gettext(string)
/* constants */ /* constants */
#ifndef PROGNAME_KEYBOARD #ifndef PROGNAME
# define PROGNAME_KEYBOARD "keyboard" # define PROGNAME "keyboard"
#endif #endif
#ifndef PREFIX #ifndef PREFIX
# define PREFIX "/usr/local" # define PREFIX "/usr/local"
#endif #endif
#ifndef DATADIR #ifndef DATADIR
# define DATADIR PREFIX "/share" # define DATADIR PREFIX "/share"
#endif #endif
#ifndef LOCALEDIR #ifndef LOCALEDIR
# define LOCALEDIR DATADIR "/locale" # define LOCALEDIR DATADIR "/locale"
#endif #endif
@ -80,7 +80,7 @@ static int _keyboard(KeyboardPrefs * prefs)
/* error */ /* error */
static int _error(char const * message, int ret) static int _error(char const * message, int ret)
{ {
fputs(PROGNAME_KEYBOARD ": ", stderr); fputs(PROGNAME ": ", stderr);
perror(message); perror(message);
return ret; return ret;
} }
@ -89,17 +89,14 @@ static int _error(char const * message, int ret)
/* usage */ /* usage */
static int _usage(void) static int _usage(void)
{ {
fprintf(stderr, _("Usage: %s [-d|-p|-w|-x][-f font][-l layout]" fprintf(stderr, _("Usage: %s [-d|-p|-w|-x][-f font][-m monitor][-n]\n"
"[-m monitor][-n]\n"
" -d Start in docked mode\n" " -d Start in docked mode\n"
" -l Select a different layout\n"
" -p Start as a popup window\n" " -p Start as a popup window\n"
" -w Start in windowed mode\n" " -w Start in windowed mode\n"
" -x Start in embedded mode\n" " -x Start in embedded mode\n"
" -f Set the font used for the keys\n" " -f Set the font used for the keys\n"
" -m Place on a particular monitor (in docked or popup mode)\n" " -m Place on a particular monitor (in docked or popup mode)\n"
" -n Start without showing up directly (if not embedded)\n"), " -n Start without showing up directly (if not embedded)\n"), PROGNAME);
PROGNAME_KEYBOARD);
return 1; return 1;
} }
@ -119,7 +116,7 @@ int main(int argc, char * argv[])
textdomain(PACKAGE); textdomain(PACKAGE);
memset(&prefs, 0, sizeof(prefs)); memset(&prefs, 0, sizeof(prefs));
gtk_init(&argc, &argv); gtk_init(&argc, &argv);
while((o = getopt(argc, argv, "df:l:m:npwx")) != -1) while((o = getopt(argc, argv, "df:m:npwx")) != -1)
switch(o) switch(o)
{ {
case 'd': case 'd':
@ -128,9 +125,6 @@ int main(int argc, char * argv[])
case 'f': case 'f':
prefs.font = optarg; prefs.font = optarg;
break; break;
case 'l':
prefs.layout = optarg;
break;
case 'm': case 'm':
prefs.monitor = strtol(optarg, &p, 10); prefs.monitor = strtol(optarg, &p, 10);
if(optarg[0] == '\0' || *p != '\0') if(optarg[0] == '\0' || *p != '\0')

View File

@ -1,6 +1,6 @@
targets=keyboard,keyboardctl targets=keyboard,keyboardctl
cflags_force=`pkg-config --cflags libDesktop` cflags_force=`pkg-config --cflags libDesktop`
cflags=-W -Wall -g -O2 -pedantic -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector cflags=-W -Wall -g -O2 -pedantic -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector-all
ldflags_force=`pkg-config --libs libDesktop` ldflags_force=`pkg-config --libs libDesktop`
ldflags=-pie -Wl,-z,relro -Wl,-z,now ldflags=-pie -Wl,-z,relro -Wl,-z,now
dist=Makefile,callbacks.h,common.h,key.h,keyboard.h,layout.h dist=Makefile,callbacks.h,common.h,key.h,keyboard.h,layout.h

View File

@ -1,6 +1,6 @@
targets=keyboard targets=keyboard
cflags_force=`pkg-config --cflags libDesktop x11` -fPIC cflags_force=-W `pkg-config --cflags libDesktop x11` -fPIC
cflags=-W -Wall -g -O2 -pedantic -D_FORTIFY_SOURCE=2 -fstack-protector cflags=-Wall -g -O2 -pedantic -D_FORTIFY_SOURCE=2 -fstack-protector-all
ldflags_force=`pkg-config --libs libDesktop x11` -lXtst ldflags_force=`pkg-config --libs libDesktop x11` -lXtst
ldflags=-Wl,-z,relro -Wl,-z,now ldflags=-Wl,-z,relro -Wl,-z,now
dist=Makefile dist=Makefile

View File

@ -1,12 +1,12 @@
targets=plug,snooper,xkey targets=plug,snooper,xkey
cflags=-W -Wall -g -O2 -pedantic -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector cflags=-W -Wall -g -O2 -pedantic -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector-all
ldflags=-pie -Wl,-z,relro -Wl,-z,now ldflags=-pie -Wl,-z,relro -Wl,-z,now
#for Gtk+ 2 #for Gtk+ 2
#cflags_force=`pkg-config --cflags gtk+-2.0` cflags_force=`pkg-config --cflags gtk+-2.0`
#ldflags_force=`pkg-config --libs gtk+-2.0` ldflags_force=`pkg-config --libs gtk+-2.0`
#for Gtk+ 3 #for Gtk+ 3
cflags_force=`pkg-config --cflags gtk+-3.0` #cflags_force=`pkg-config --cflags gtk+-3.0`
ldflags_force=`pkg-config --libs gtk+-3.0` #ldflags_force=`pkg-config --libs gtk+-3.0`
dist=Makefile dist=Makefile
[plug] [plug]