Commit 8d3af849 authored by Alessandro Elias's avatar Alessandro Elias
Browse files

Merge branch 'issue/365/warnings' into 'master'

Issue/365/warnings

See merge request !17
parents ba14495d 0d761be6
Pipeline #14559 passed with stages
in 8 minutes and 25 seconds
/*
* Copyright (C) 2004-2007 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* This program monitors evdev device nodes passed as parameters to detect the
* F1...F12, ENTER or ESC keys pressed or the left mouse button.
*
* The first argument is the key that we need to check.
* - If between f1 and f12, the argument must be between 1 and 12
* - If it's the left mouse button, the argument is 13
* - If it's enter or esc, the argument is 14
* The other arguments are the device node file paths
*
* The timeout is 20 seconds.
* If "enter" or "esc" is requested, the timeout is 5 seconds.
*
* The output is:
* - "detect=|device/node/path" for f1..f12 and mouse button
* - "detect=|enter" or "detect=|esc" for enter and esc keys (no device path)
*/
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <linux/input.h>
/* No, linux/input.h doesn't have these... */
#define EV_PRESS 1
#define EV_RELEASE 0
void read_node(unsigned char* buffer, int sock, int how_many);
int main(int argc, char* argv[]) {
fd_set rfds;
struct input_event ev;
int retval, i;
int biggest_so_far = 0;
int fd_array[30];
int expected_key;
struct timeval tv;
#ifdef DEBUG
for (i = 0; i < argc; i++)
fprintf(stderr, "argv[%d] = %s\n", i, argv[i]);
#endif
/* Basic checking */
if (argc > 31) {
fprintf(stderr, "read_devices: maximum is 30 arguments\n");
fprintf(stderr, "usage: %s key files...\n",argv[0]);
exit(1);
}
if (argc <= 2) {
fprintf(stderr, "read_devices: few arguments\n");
fprintf(stderr, "usage: %s key files...\n",argv[0]);
exit(1);
}
expected_key = atoi(argv[1]);
/* Timeout is different for ESC/ENTER */
if (expected_key != 14)
tv.tv_sec = 20;
else
tv.tv_sec = 5;
tv.tv_usec = 0;
/* Open the file and store at biggest_so_far the biggest FD between the
* files */
for (i = 2; i < argc; i++) {
fd_array[i] = open(argv[i], O_RDONLY);
if (fd_array[i] == -1) {
perror("select (ERROR)");
exit(1);
}
if (fd_array[i] > biggest_so_far )
biggest_so_far = fd_array[i];
}
while(1) {
/* Zero the FD set */
FD_ZERO(&rfds);
/* Insert each FD in the set */
for (i = 2; i < argc; i++)
FD_SET(fd_array[i], &rfds);
retval = select(biggest_so_far+1, &rfds, 0, 0, &tv); /* no timeout */
/* Verify which FDs are still in the set: which ones have data to be
* read */
if (retval == -1) {
perror("select (ERROR)");
exit(1);
}
else if (retval) {
for (i = 2; i < argc; i++) {
if (FD_ISSET(fd_array[i],&rfds)) {
/* Read from FD */
read_node ((unsigned char*)&ev, fd_array[i],
sizeof(struct input_event));
/* f1..f10 */
if (ev.type == EV_KEY && ev.value == EV_PRESS &&
((ev.code - (KEY_F1) +1) == expected_key)) {
printf("detect=|%s\n", argv[i]);
exit(1);
}
/* f11 or f12 */
if (ev.type == EV_KEY && ev.value == EV_PRESS &&
((ev.code == KEY_F11 && expected_key == 11) ||
(ev.code == KEY_F12 && expected_key == 12)) ) {
printf("detect=|%s\n", argv[i]);
exit(1);
}
/* left button */
if (ev.type == EV_KEY && ev.value == EV_PRESS &&
ev.code == BTN_LEFT && expected_key == 13) {
printf("detect=|%s\n", argv[i]);
exit(1);
}
/* enter */
if (ev.type == EV_KEY && ev.value == EV_PRESS &&
(ev.code == KEY_ENTER || ev.code == KEY_KPENTER) &&
expected_key == 14) {
printf("detect=|enter\n");
exit(1);
}
/* esc */
if (ev.type == EV_KEY && ev.value == EV_PRESS &&
ev.code == KEY_ESC && expected_key == 14) {
printf("detect=|esc\n");
exit(1);
}
}
}
}
else {
printf("detect=|timeout\n");
exit(1);
}
}
return 0;
}
void read_node(unsigned char* buffer, int sock, int how_many)
{
/* Keep calling recv until everything is received */
int pointer = 0;
int maximum = how_many;
int bytes_read;
while (pointer < how_many) {
bytes_read = read(sock,(void*)(buffer+pointer), maximum);
if (bytes_read == -1) {
perror("Error reading the socket.");
exit(1);
}
else if (bytes_read == 0) {
fprintf(stderr, "End of file.\n");
exit(1);
}
pointer += bytes_read; /* Forward pointer */
maximum -= bytes_read;
}
}
/*
* Copyright (C) 2004-2007 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
/* This program creates a "parent window" for xephyr
* and waits forever.
* parameters: widthxheight+x+y, window name.
*/
# include <stdio.h>
# include <stdlib.h>
# include <unistd.h>
# include <X11/Xlib.h>
# include <X11/Xutil.h>
int main(int argc, char *argv[])
{
int screen;
int x, y;
int rc;
unsigned int width, height;
Display *display = XOpenDisplay(NULL);
if (display == NULL)
{
fprintf(stderr, "Cannot open display.\n");
exit(1);
}
screen = DefaultScreen(display);
sscanf(argv[1], "%dx%d+%d+%d", &width, &height, &x, &y);
Window win = XCreateSimpleWindow (display, DefaultRootWindow(display),
x, y, width, height, 0,
WhitePixel(display, screen),
BlackPixel(display, screen));
XTextProperty window_name_property;
rc = XStringListToTextProperty(&argv[2], 1, &window_name_property);
if (rc == 0)
{
fprintf(stderr, "XStringListToTextProperty - out of memory\n");
exit(1);
}
XSetWMName(display, win, &window_name_property);
XMapWindow(display, win);
XFlush(display);
pause();
XCloseDisplay(display);
return 0;
}
/*
* Copyright (C) 2004-2007 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>
#include <cairo.h>
#include <cairo-xlib.h>
int main(int argc, char *argv[])
{
int i;
int screen;
int win_x, win_y;
unsigned int width, height;
unsigned int depth;
unsigned int border_width;
unsigned int win_id;
double y_all_extents = 0.0;
double x, y;
Display *display;
Visual *visual;
Window RootWindow;
Window win;
cairo_text_extents_t extents;
cairo_surface_t *surface;
cairo_t *cr;
display = XOpenDisplay(NULL);
if(display == NULL)
{
fprintf(stderr, "Cannot open display.\n");
exit(1);
}
screen = DefaultScreen(display);
sscanf(argv[1], "%x", &win_id);
win = win_id;
XGetGeometry(display, win, &RootWindow, &win_x, &win_y,
&width, &height, &border_width, &depth );
visual = DefaultVisual(display, screen);
surface = cairo_xlib_surface_create (display,
win,
visual,
width,
height );
cr = cairo_create (surface);
cairo_select_font_face (cr, "Arial",
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 32.0);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
for (i = 2; i < argc ; i++)
{
cairo_text_extents(cr, argv[i], &extents);
y_all_extents += (extents.height/2 + extents.y_bearing*2);
}
y_all_extents = y_all_extents/2.0;
cairo_text_extents(cr, argv[1], &extents);
x = width/2 - (extents.width/2 + extents.x_bearing);
y = height/2 - (extents.height/2 + extents.y_bearing);
y += y_all_extents;
cairo_move_to(cr, x, y );
XClearWindow(display, win);
for (i = 2; i < argc ; i++)
{
cairo_text_extents(cr, argv[i], &extents);
x = width/2 - (extents.width/2 + extents.x_bearing);
cairo_move_to (cr, x, y );
cairo_show_text (cr, argv[i]);
y -= (extents.height/2 + extents.y_bearing*2 );
}
XCloseDisplay(display);
return 0;
}
......@@ -24,13 +24,14 @@
#### Written by: Stephanie Briere Americo - sba16@c3sl.ufpr.br on 2017.
## Macros
DEVICES="/opt/le-multiterminal/devices" # shortcut to devices that have already been paired
CONF="/opt/le-multiterminal/98-xephyr-multi-seat.conf" # lightdm settings file (associates seat to output)
DEVICES="/etc/le-multiterminal/devices" # shortcut to devices that have already been paired
#TODO: This path is correctly??
CONF="/etc/le-multiterminal/98-xephyr-multi-seat.conf" # lightdm settings file (associates seat to output)
## Script/function in other file
READ_DEVICES="read-devices"
DETECT_KEYBOARDS="/opt/le-multiterminal/detect-keyboard.sh"
WRITE_W="write_window" # "window-acess.sh"
READ_DEVICES="/usr/sbin/read-devices"
DETECT_KEYBOARDS="/usr/sbin/detect-keyboard"
WRITE_W="write_window" # "window-acess"
## Variables
declare -a SEATS_LISTED # save the name of the existing seats
......
......@@ -30,7 +30,7 @@ WRITE_MESSAGE="write-message" # it receives as parameter <ID_WINDOW> <Message>
create_window () {
#### Description: Create a window in a specific display.
#### ID_WINDOWS and WINDOW_COUNTER are declared in "multiseat-controller.sh".
#### ID_WINDOWS and WINDOW_COUNTER are declared in "multiseat-controller".
# Try to access Xorg
xdpyinfo -display ${DISPLAY_XORGS[$WINDOW_COUNTER]}
......@@ -69,7 +69,7 @@ create_window () {
write_window() {
#### Description: Writes in a specific window on a particular display.
#### Parameters: $1 - message to be written; $2 - display to be used.
#### DISPLAY_XORGS and ID_WINDOWS are declared in "multiseat-controller.sh".
#### DISPLAY_XORGS and ID_WINDOWS are declared in "multiseat-controller".
export DISPLAY=${DISPLAY_XORGS[$2]}
case $1 in
......
#!/bin/bash
# Script adapted from Laércio de Sousa <laerciosousa@sme-mogidascruzes.sp.gov.br>
#cd ../../
# roda o script que atualiza as configs do xorg
#POSTINST
#update-xorg-conf "Silicon.Motion" /etc/X11/xorg.conf.d/98-proinfo-*.conf
#systemctl enable le-multiterminal
#systemctl enable xorg-daemon.socket
#systemctl daemon-reload
......@@ -26,21 +26,20 @@
set -x
export PATH=$PATH:/opt/le-multiterminal
## Auxiliary scripts
source /opt/le-multiterminal/find-devices.sh
source /opt/le-multiterminal/window-acess.sh
source /usr/lib/find-devices
source /usr/lib/window-acess
## Path constants
MC3SL_DEVICES="/opt/le-multiterminal/devices" # shortcut to devices that have already been paired
MC3SL_CONF="/opt/le-multiterminal/98-xephyr-multi-seat.conf" # lightdm settings file (associates seat to output)
MC3SL_DEVICES="/usr/sbin/devices" # shortcut to devices that have already been paired
#TODO: This path is correctly??
MC3SL_CONF="/etc/le-multiterminal/98-xephyr-multi-seat.conf" # lightdm settings file (associates seat to output)
LIGHTDM_CONF="/etc/xdg/lightdm/lightdm.conf.d/98-xephyr-multi-seat.conf"
## Script/function in other file
FIND_KEYBOARD="find_keyboard" # "find-devices.sh"
CREATE_WINDOW="create_window" # "window-acess.sh"
WRITE_WINDOW="write_window" # "window-acess.sh"
FIND_KEYBOARD="find_keyboard" # "find-devices"
CREATE_WINDOW="create_window" # "window-acess"
WRITE_WINDOW="write_window" # "window-acess"
## Macros
FAKE_DISPLAY=:90 # display to access fake-seat (secondary card)
......@@ -54,7 +53,7 @@ WINDOW_COUNTER=0 # how many windows were created
N_SEATS_LISTED=0 # how many seats are there in the system
ONBOARD=0 # if the onboard is connected
declare -a DISPLAY_XORGS # saves the display of the Xorg launched processes
declare -a ID_WINDOWS # saves the created window ids (used in window-acess.sh)
declare -a ID_WINDOWS # saves the created window ids (used in window-acess)
declare -a PID_FIND_DEVICES # saves the pid from the launched configuration processes
create_onboard_window () {
......@@ -213,7 +212,7 @@ while test $CONFIGURED_SEATS -lt $N_SEATS_LISTED; do
if test $EXIT_CODE -eq 0; then
CONFIGURED_SEATS=$(($CONFIGURED_SEATS+1))
else if test $EXIT_CODE -eq 2; then
echo "[Error] Can not configure output: find-devices.sh failed."
echo "[Error] Can not configure output: find-devices failed."
rm -f $MC3SL_CONF
exit 1
fi
......
......@@ -38,6 +38,6 @@ if test ! -e /etc/le-multiterminal/configurado; then
fi
if test $CONFIG_FLAG -eq 1; then
/opt/le-multiterminal/multiseat-controller.sh >> /var/log/le-multiterminal/controller.log 2>&1
/usr/sbin/multiseat-controller >> /var/log/le-multiterminal/controller.log 2>&1
reboot
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment