diff options
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | AUTHORS | 7 | ||||
-rw-r--r-- | COPYING | 339 | ||||
-rw-r--r-- | MAINTAINERS | 3 | ||||
-rw-r--r-- | Makefile | 15 | ||||
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | TODO | 1 | ||||
-rwxr-xr-x | bin/change-prefix.sh | 28 | ||||
-rwxr-xr-x | bin/create-xorg-conf | 44 | ||||
-rwxr-xr-x | bin/discover-devices | 178 | ||||
-rwxr-xr-x | bin/mdm | 57 | ||||
-rw-r--r-- | bin/mdm-bin | 137 | ||||
-rw-r--r-- | bin/mdm-common | 81 | ||||
-rw-r--r-- | bin/mdm-start-seat | 229 | ||||
-rw-r--r-- | bin/mdm.conf | 60 | ||||
-rw-r--r-- | bin/modes/template | 59 | ||||
-rw-r--r-- | bin/modes/xephyr-xdmcp | 123 | ||||
-rw-r--r-- | bin/read-devices.c | 191 | ||||
-rw-r--r-- | bin/write-message.c | 145 | ||||
-rw-r--r-- | distro/targz/xephyr-geometry.patch.diff | 138 | ||||
-rw-r--r-- | distro/ubuntu-8.04/Makefile | 4 | ||||
-rw-r--r-- | distro/ubuntu-8.04/make-xephyr.sh | 22 | ||||
-rw-r--r-- | distro/ubuntu-8.04/xephyr-geometry.patch.diff | 138 | ||||
-rw-r--r-- | doc/mdm.notes | 69 | ||||
-rw-r--r-- | misc/background.png | bin | 0 -> 4962 bytes | |||
-rwxr-xr-x | misc/make-tree.sh | 67 |
26 files changed, 2142 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2a3ada --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.swp +*~ +bin/read-devices +bin/write-message +mdm.tar.gz +tmp @@ -0,0 +1,7 @@ +People who somehow contributed with the script, in lexicographic order: + +Aramis Stach Haiduski Fernandes +Eros Moreira de Carvalho +Loirto Alves dos Santos +Lucas Nascimento Ferreira +Paulo Ricardo Zanoni @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/MAINTAINERS b/MAINTAINERS new file mode 100644 index 0000000..05c55bb --- /dev/null +++ b/MAINTAINERS @@ -0,0 +1,3 @@ +Paulo Ricardo Zanoni (paulo@c3sl.ufpr.br) +Aramis Stach Haiduski Fernandes (ashf03@c3sl.ufpr.br) +Lucas Nascimento Ferreira (lnf07@c3sl.ufpr.br) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..955dd10 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +targz: binaries + @echo "Creating file tree in temporary folder tmp/" + misc/make-tree.sh + @echo "Creating .tar.gz file" + tar cvzf mdm.tar.gz tmp/* + +binaries: bin/read-devices.c + gcc -Wall -O2 bin/read-devices.c -o bin/read-devices + gcc -Wall -O2 bin/write-message.c -o bin/write-message + +clean: + rm -f bin/read-devices + rm -f bin/write-message + rm -rf tmp + rm -rf mdm.tar.gz @@ -0,0 +1 @@ +For documentation, see the "doc" directory. @@ -0,0 +1 @@ +egrep -r "(TODO|XXX|FIXME)" * diff --git a/bin/change-prefix.sh b/bin/change-prefix.sh new file mode 100755 index 0000000..c42e212 --- /dev/null +++ b/bin/change-prefix.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# 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. + +# XXX: this is ugly... + +NEW_OPT=/ + +for i in `rgrep -I '^MDM_OPT=.*$' * | cut -d':' -f1`; do + sed -i "s%^MDM_OPT=.*$%MDM_OPT=${NEW_OPT}%g" $i + +done diff --git a/bin/create-xorg-conf b/bin/create-xorg-conf new file mode 100755 index 0000000..cc08a63 --- /dev/null +++ b/bin/create-xorg-conf @@ -0,0 +1,44 @@ +#!/bin/bash + +# 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. + +MDM_OPT=/home/paulo/teste +MDM_SCRIPTS=${MDM_OPT}/usr/sbin +MDM_INCLUDE=${MDM_SCRIPTS}/mdm-common +source $MDM_INCLUDE + +NEW_FILE=$(X -configure 2>&1 | grep "^Your xorg.conf file is " | cut -d' ' -f5) + +mv $NEW_FILE $MDM_XORG_CONF + +# As far as I've tested, openchrome still doesn't work with multiple screens +# (definition of "far": tested with via 0x3344 in June 2008) +sed -i s/openchrome/vesa/g $MDM_XORG_CONF + +echo ' +Section "ServerFlags" + Option "DontVTSwitch" "yes" + Option "DontZoom" "yes" + Option "DontZap" "yes" + Option "AllowMouseOpenFail" "yes" + # Option "BlankTime" "0" + # Option "StandbyTime" "0" + # Option "SuspendTime" "0" + # Option "OffTime" "0" +EndSection' >> $MDM_XORG_CONF diff --git a/bin/discover-devices b/bin/discover-devices new file mode 100755 index 0000000..f711150 --- /dev/null +++ b/bin/discover-devices @@ -0,0 +1,178 @@ +#!/bin/bash + +# 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 script discover evdev mice and keyboards and also discovers video cards +# on the machine. +# For input devices, it uses /proc/bus/input/devices +# For video cardes, it uses the "discover" package. + +# TODO: we should stop using /proc and "discover". We should use HAL and X! + +PROC_DEVICES=/proc/bus/input/devices +DISCOVER=/sbin/discover + +# This function prints the physical addresses of the mice found +function discover_input () { + + # The elements of the list should contain a whole line of the file, so to + # make the attribution work, the line can't contain spaces + # Also, there are lines like "^P: $", and if we just grep them and cut -f2, + # they will become empty, and will mess with our lists + + NUMBER_OF_DEVICES=$(grep '^I:' $PROC_DEVICES | wc -l) + for(( i = 1; i <= ${NUMBER_OF_DEVICES}; i++ )); do + PHYS_ADDRS[i]=$(cat $PROC_DEVICES | grep '^P:' | \ + head -n $i | tail -n 1 | cut -d'=' -f2) + HANDLERS[i]=$( cat $PROC_DEVICES | grep '^H:' | \ + head -n $i | tail -n 1 | cut -d'=' -f2) + NAMES[i]=$( cat $PROC_DEVICES | grep '^N:' | \ + head -n $i | tail -n 1 | cut -d'=' -f2) + done + + for (( i = 1; i <= ${#PHYS_ADDRS[@]}; i++ )); do + + #echo "PHYS_ADDR: ${PHYS_ADDRS[i]}" + #echo "HANDLER: ${HANDLERS[i]}" + #echo "NAME: ${NAMES[i]}" + #echo "--" + + EVDEV_NODE="/dev/input/`echo ${HANDLERS[i]}| tr ' ' '\n'| grep "event"`" + + # XXX: "Speaker" should be the "PCSpeaker" device and "Button" should be + # all those power buttons and machintosh buttons (not mice!) + + # A mouse has the physical address ending in "0" and its handler + # contains "mouse". + if echo ${HANDLERS[i]} | grep -q "mouse" && \ + echo ${PHYS_ADDRS[i]} | grep -q ".*0$" && \ + echo ${NAMES[i]} | egrep -q -v "(Speaker|Button)"; then + + echo -e "mouse\t${PHYS_ADDRS[i]}" + echo -e "mevdev\t${EVDEV_NODE}" + fi + + # A keyboard has a "kbd" handler, its physical address ends in 0 and it + # doesn't have the "Speaker" or "Button" words on its name. + if echo ${HANDLERS[i]} | grep -q "kbd" && \ + echo ${PHYS_ADDRS[i]} | grep -q ".*0$" && \ + echo ${NAMES[i]} | egrep -q -v "(Speaker|Button)"; then + + echo -e "kbd\t${PHYS_ADDRS[i]}" + echo -e "kevdev\t${EVDEV_NODE}" + + fi + done + + # if no mouse found, put a serial mouse as default + #if [[ ${#PHYS_ADDRS[@]} == 0 ]]; then + # echo -e "mouse\tserial0" + #fi +} + +# Prints bus address and drivers of the video cards. +function video_cards (){ + + DRIVERS=(`$DISCOVER -t --data-path=xfree86/server/device/driver display`) + BUS_IDS=(`lspci | grep "VGA" | cut -f1 -d' '`) + + for (( i=0 ; i < ${#BUS_IDS[@]}; i++ )) ; do + if [[ "${DRIVERS[$i]}" = "" ]]; then + DRIVERS[$i]=vesa # VESA=default + fi + # busid from lspci is in format 00:00.00 + # below we split in 00 and 00.00 + NUMS=(`echo ${BUS_IDS[$i]} | \ + awk 'BEGIN {FS=":"}{print toupper($1), toupper($2)}'`) + # now, we split 00.00 in 00 and 00 + SEC_NUMS=(`echo ${NUMS[1]} | \ + awk 'BEGIN {FS="."}{print toupper($1), toupper($2)}'`) + # now, we convert the numbers from hexa to decimal base + echo -e "bus\t`echo "obase=10;ibase=16;${NUMS[0]};${SEC_NUMS[0]};${SEC_NUMS[1]};" | bc | paste -s -d":"`" + + done + + for i in ${DRIVERS[@]}; do + echo -e "driver\t$i" + done +} # video_cards + +# ******************** MAIN ************************* + +if [[ "$#" = 0 ]] +then + ARG=all +else + ARG=$1 +fi + +INPUT=`discover_input` +CARDS=`video_cards` + +case $ARG in + all) + echo "$INPUT" | grep mouse + echo "$INPUT" | grep mevdev + echo "$INPUT" | grep kbd + echo "$INPUT" | grep kevdev + echo "$CARDS" + ;; + all2) + echo "$INPUT" + echo "$CARDS" + ;; + + mouse) + echo "$INPUT" | grep mouse + ;; + mevdev) + echo "$INPUT" | grep mevdev + ;; + kbd) + echo "$INPUT" | grep kbd + ;; + kevdev) + echo "$INPUT" | grep kevdev + ;; + + bus) + echo "$CARDS" | grep bus + ;; + driver) + echo "$CARDS" | grep driver + ;; + cards) + echo "$CARDS" + ;; + + #debug) + # echo "$INPUT" | egrep "(PHYS|HANDLER|NAME|--)" + # ;; + *) + echo "$1: unrecognized argument" + echo "Valid parameters: " + echo "mouse: prints physical addresses of the mice" + echo "mevdev: prints the evdev mouse events" + echo "kbd: prints physical addresses of the keyboards" + echo "kevdev: prints the evdev keyboard events" + echo "driver: prints the video card drivers" + echo "cards: prints the video card bus IDs" + echo "all: prints everything" + ;; +esac @@ -0,0 +1,57 @@ +#!/bin/sh + +# 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. + +. /lib/lsb/init-functions + +MDM_OPT=/home/paulo/teste +MDM_SCRIPTS=${MDM_OPT}/usr/sbin + +PATH=/sbin:/bin:/usr/sbin:/usr/bin +export PATH +MDM_BIN=${MDM_SCRIPTS}/mdm-bin + +case "$1" in + start) + log_daemon_msg "Starting the Muliseat Display Manager..." + $MDM_BIN start + log_end_msg $? + ;; + stop) + log_daemon_msg "Stopping the Multiseat Display Manager..." + $MDM_BIN stop + log_end_msg $? + ;; + restart) + log_daemon_msg "Restarting the Multiseat Display Manager..." + $MDM_BIN restart + log_end_msg $? + ;; + reconfigure) + log_daemon_msg "Reconfiguring the Multiseat Display Manager..." + $MDM_BIN reconfigure + log_end_msg $? + ;; + *) + log_success_msg "Usage: /etc/init.d/mdm {start|stop|restart|reconfigure}" + exit 1 + ;; +esac + +exit 0 diff --git a/bin/mdm-bin b/bin/mdm-bin new file mode 100644 index 0000000..1161637 --- /dev/null +++ b/bin/mdm-bin @@ -0,0 +1,137 @@ +#!/bin/bash + +# 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 is the script that is called by init.d/mdm, it is the one that actually +# starts the "hard work". + +# Do this first: +MDM_OPT=/home/paulo/teste +MDM_SCRIPTS=${MDM_OPT}/usr/sbin +MDM_INCLUDE=${MDM_SCRIPTS}/mdm-common +source $MDM_INCLUDE + +MY_LOG=${MDM_LOGS}/mdm.log + +CREATE_XORG_CONF=${MDM_SCRIPTS}/create-xorg-conf +START_SEAT=${MDM_SCRIPTS}/mdm-start-seat + +function exec_start() { + + log --log-file-only "Multiseat Display Manager version $MDM_VERSION" + log --log-file-only "Today is `date`." + + if ([ "$RECREATE_XORG_CONF" = 'yes' ] || [ ! -f "$MDM_XORG_CONF" ]); then + $CREATE_XORG_CONF + fi + + if [ "$RECONFIGURE_INPUT" = 'yes' ]; then + # Removing links AND locks + for i in `ls $MDM_DEVICES`; do + rm -f $MDM_DEVICES/$i + done + fi + + KEYBOARDS=`$DISCOVER_DEVICES kevdev | wc -l` + MICE=`$DISCOVER_DEVICES mevdev | wc -l` + VIDEO_CARDS=`$DISCOVER_DEVICES driver | wc -l` + + log "$KEYBOARDS keyboards detected" + log "$MICE mice detected" + log "$VIDEO_CARDS video cards detected" + + if [ "$USE_MONOSEAT" = 'yes' ]; then + SEATS=1 + else + SEATS=$VIDEO_CARDS + fi + + # Other scripts assume we do this: + export DISPLAY=:0 + + # erase links, locks, logs, close stuff, whatever needed + display_manager_init + + if [ "$SEATS" = "1" ]; then + log "Only 1 video card: not using multiseat" + display_manager_start_monoseat >> $MY_LOG 2>&1 + + else + display_manager_start_underneath_xserver >> $MY_LOG 2>&1 + + for ((i = 0; i < $SEATS; i++)); do + export DISPLAY=:0.$i + + # display :0.$i must press key $(i+1) + log --log-file-only "Starting seat $((i+1))" + START_SEAT_LOG="${MDM_LOGS}/mdm-start-seat.$((i+1)).log" + rotate_log ${START_SEAT_LOG} + ${START_SEAT} $((i+1)) &> ${START_SEAT_LOG} & + PID=$! + echo $PID > ${MDM_PIDS}/start-seat.$((i+1)).pid + done + fi +} + +function exec_stop() { + + display_manager_stop + + for i in `ls $MDM_PIDS/*.pid 2> /dev/null`; do + kill `cat $i` 2> /dev/null + rm -f $i + done +} + +function exec_reconfigure() { + RECREATE_XORG_CONF='yes' + RECONFIGURE_INPUT='yes' + exec_stop + exec_start +} + +##### + +rotate_log $MY_LOG + +# Check if we're root +if [ ! "`id -u`" -eq "0" ]; then + log "ERROR: not running as root user" + exit 1 +fi + +case "$1" in + start) + exec_start + ;; + stop) + exec_stop + ;; + restart) + exec_stop + exec_start + ;; + reconfigure) + exec_reconfigure + ;; + *) + ;; +esac + +exit 0 diff --git a/bin/mdm-common b/bin/mdm-common new file mode 100644 index 0000000..fe6cd95 --- /dev/null +++ b/bin/mdm-common @@ -0,0 +1,81 @@ +#!/bin/bash + +# 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 is the file that is included by everyone. It should cointain all the +# variables that are common to every function. + +MDM_VERSION='0.0.1' + +MDM_OPT=/home/paulo/teste + +MDM_LOGS=$MDM_OPT/var/log/mdm/ +MDM_RUN=$MDM_OPT/var/run/mdm/ +MDM_ETC=$MDM_OPT/etc/mdm/ +MDM_SHARE=$MDM_OPT/usr/share/mdm/ +MDM_SCRIPTS=$MDM_OPT/usr/sbin/ + +CONFIG_FILE=$MDM_ETC/mdm.conf + +MDM_DEVICES=$MDM_ETC/devices/ +MDM_MODES=$MDM_SHARE/modes/ +MDM_PIDS=$MDM_RUN/ + +MDM_XORG_CONF=$MDM_ETC/xorg.conf.mdm +DISCOVER_DEVICES=$MDM_SCRIPTS/discover-devices + +function log() { + # Whoever calls this must set the $MY_LOG variable! + ME=`basename $0` + + #echo "MY_LOG = $MY_LOG $1 $2" + if [ "$1" == '--log-file-only' ]; then + echo "$ME: $2" >> $MY_LOG + else + echo "$ME: $1" >> $MY_LOG + echo "$ME: $1" + fi +} + +function debug() { + if [[ "$DEBUG" -eq "1" ]]; then + echo "$1" + fi +} + +function load_config() { + # TODO: we should check for the file integrity and for missing variables + source $CONFIG_FILE +} + +function rotate_log () { + # Whoever calls this must set the $MY_LOG variable + if [ -f $1 ]; then + mv $1 $1.old + fi +} + +function select_display_manager () { + source $MDM_MODES/$DISPLAY_MANAGER +} + +##### + +load_config +select_display_manager diff --git a/bin/mdm-start-seat b/bin/mdm-start-seat new file mode 100644 index 0000000..d3b4a4f --- /dev/null +++ b/bin/mdm-start-seat @@ -0,0 +1,229 @@ +#!/bin/bash + +# 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 script starts a seat. +# The argument is the number of the seat, starting from zero. +# We assume $DISPLAY is already set here + + +MDM_OPT=/home/paulo/teste +MDM_SCRIPTS=${MDM_OPT}/usr/sbin +MDM_INCLUDE=${MDM_SCRIPTS}/mdm-common +source $MDM_INCLUDE + +READ_DEVICES=${MDM_SCRIPTS}/read-devices +WRITE_MESSAGE=${MDM_SCRIPTS}/write-message +IMAGE_FILE=${MDM_SHARE}/background.png +PUT_IMAGE="xsetbg -fullscreen" + +SEAT_NUMBER=$1 + +#MY_LOG=$MDM_LOGS/mdm-start-seat.${SEAT_NUMBER}.log + +function display_message () { + case $1 in + key_press) + $WRITE_MESSAGE "Press the F$2 key" 1>&2 + ;; + button_press) + $WRITE_MESSAGE "Click left button" 1>&2 + ;; + wait) + $WRITE_MESSAGE "Please wait" 1>&2 + ;; + reconfigure) + $WRITE_MESSAGE "Press ESC to reconfigure" 1>&2 + ;; + esac + +} + +function select_keyboard () { + if [ -e "${MDM_DEVICES}/keyboard${SEAT_NUMBER}" ]; then + return + fi + + display_message key_press $SEAT_NUMBER + + CREATED=0 + while (( ! CREATED )); do + # Who are the keyboards? + KEYBOARDS=$($DISCOVER_DEVICES kevdev | cut -f2) + echo " Keyboards = $KEYBOARDS" 1>&2 + + # Remove used keyboards + REMOVE=$(stat -c %N $MDM_DEVICES/keyboard* 2> /dev/null| + cut -d'`' -f3 | cut -d"'" -f1) + for i in ${REMOVE}; do + KEYBOARDS=`sed "s#$i# #g" <<< $KEYBOARDS` + done + echo " ... after removing: Keyboards = $KEYBOARDS" 1>&2 + + if [ -z "$KEYBOARDS" ]; then + # No keyboards. Hopefully someone will connect one. + sleep 1 # Don't use 100% CPU + continue + fi + + # See if someone presses the key: + PRESSED=$($READ_DEVICES $SEAT_NUMBER $KEYBOARDS | grep '^detect' | cut -d'|' -f2) + + if [ -z "$PRESSED" ]; then + # if $READ_DEVICES gets killed the script won't do bad stuff + continue + fi + if [ "$PRESSED" = 'timeout' ]; then + continue + fi + + # Ok, someone pressed the key + ln -sf $PRESSED $MDM_DEVICES/keyboard${SEAT_NUMBER} + CREATED=1 + + # Verify is there is already another link in $MDM_DEVICES/keyboard* that + # points to the device. If there is, erase the one I created and + # continue looping + for i in `ls $MDM_DEVICES | grep "\<keyboard"`; do + if [ "$i" != "keyboard${SEAT_NUMBER}" ]; then + AUX=$(stat -c %N $MDM_DEVICES/$i| cut -d'`' -f3| cut -d"'" -f1) + if [ "$AUX" = "$PRESSED" ]; then + # Keyboard link already exists... + rm -f $MDM_DEVICES/keyboard${SEAT_NUMBER} + CREATED=0 + fi + fi + done + done + + KEYBOARD="$MDM_DEVICES/keyboard${SEAT_NUMBER}" + +} + +function select_mouse () { + if [ -e "${MDM_DEVICES}/mouse${SEAT_NUMBER}" ]; then + return + fi + + CREATED=0 + while (( ! CREATED )); do + # Who are the mice? + MICE=$($DISCOVER_DEVICES mevdev | cut -f2) + + REMOVE=$(stat -c %N ${MDM_DEVICES}/mouse* 2> /dev/null| + cut -d'`' -f3 | cut -d"'" -f1) + for i in ${REMOVE}; do + MICE=`sed "s#$i# #g" <<< $MICE` + done + + if [ -z "$MICE" ]; then + # No mice. Hopefully someone will connect one. + sleep 1 # Don't use 100% CPU + continue + fi + + # Create the lock + LOCK_EXISTS=1 + while (( LOCK_EXISTS )); do + touch ${MDM_DEVICES}/lock${SEAT_NUMBER} + LOCK_EXISTS=0 + for i in `ls $MDM_DEVICES | grep "\<lock"`; do + if [ "$i" != "lock${SEAT_NUMBER}" ]; then + LOCK_EXISTS=1 + fi + done + if (( LOCK_EXISTS )); then + # Yes, we'll call this lots of times... + display_message wait + rm -f ${MDM_DEVICES}/lock${SEAT_NUMBER} + sleep 1; + fi + done + + # Now we have the lock! + display_message button_press + + # See if someone presses the button: + PRESSED=$($READ_DEVICES 13 $MICE | grep '^detect' | cut -d'|' -f2) + + if [ -z "$PRESSED" ]; then + # If $READ_DEVICES gets killed, don't do unwanted stuff + rm -f ${MDM_DEVICES}/lock${SEAT_NUMBER} + continue + fi + if [ "$PRESSED" = 'timeout' ]; then + # Wait 5 seconds to give other machines the opportunity to enter the + # lock + display_message wait + rm -f ${MDM_DEVICES}/lock${SEAT_NUMBER} + sleep 5 + continue + fi + + # Ok, someone pressed the key + ln -sf $PRESSED ${MDM_DEVICES}/mouse${SEAT_NUMBER} + CREATED=1 + + # Verify is there is already another link in $MDM_DEVICES/mouse* that + # points to the device. If there is, erase the one I created and + # continue looping + for i in `ls $MDM_DEVICES | grep "\<mouse"`; do + if [ "$i" != "mouse${SEAT_NUMBER}" ]; then + AUX=$(stat -c %N ${MDM_DEVICES}/$i| cut -d'`' -f3|cut -d"'" -f1) + if [ "$AUX" = "$PRESSED" ]; then + # Mouse link already exists... + rm -f ${MDM_DEVICES}/mouse${SEAT_NUMBER} + CREATED=0 + fi + fi + done + rm -f ${MDM_DEVICES}/lock${SEAT_NUMBER} + done + + MOUSE="${MDM_DEVICES}/mouse${SEAT_NUMBER}" +} + +KEYBOARD= +MOUSE= +while (( 1 )); do + + #log --log-file-only "Configuring devices..." + echo -e "\n--" + echo "Configuring seat:" + + # Put image on the background + $PUT_IMAGE $IMAGE_FILE + + echo " selecting keyboard" + select_keyboard + echo " selecting mouse" + select_mouse + + echo " starting seat" + display_manager_start_seat + + display_message reconfigure + + PRESSED=$($READ_DEVICES 14 $KEYBOARD | grep '^detect' | cut -d'|' -f2) + if [ "$PRESSED" = 'esc' ]; then + rm -f $KEYBOARD + rm -f $MOUSE + fi + +done diff --git a/bin/mdm.conf b/bin/mdm.conf new file mode 100644 index 0000000..989c392 --- /dev/null +++ b/bin/mdm.conf @@ -0,0 +1,60 @@ +#!/bin/bash + +# This is the mdm configuration file. + +####################################### +# create_xorg_conf script options: + +# Recreate xorg.conf every time (used by create_xorg_conf) +# Values: 'yes', 'no'. +RECREATE_XORG_CONF='no' + +# Screen resolution for all screens: +# Values: as added in xorg.conf +DEFAULT_MODE='1024x768' +# Mode for specific head, ignores DEFAULT_MODES +# (normal array, first position is 1) +#MODE[1]="'1280x768'" + +### XXX: not used +# Monitor frequency: +# Values: as added in xorg.conf or 'none' for X auto-detection +DEFAULT_HORIZ_SYNC="28-49" +DEFAULT_VERT_REFRESH="43-72" +# Specific heads +#HORIZ_SYNC[1]='none' +#VERT_REFRESH[1]='none' + +# Keyboard options: +# Values: same as in xorg.conf. +DEFAULT_XKB_MODEL='abnt2' +DEFAULT_XKB_LAYOUT='br' +# Specific heads +#XKB_MODEL[1]='abnt2' +#XKB_LAYOUT[1]='br' + +####################################### +# mdm and sub-scripts options: + +# Enable this option to disable multiseat if you have multiple video cards +# (xorg.conf will be used instead of xorg.conf.mdm) +# Values: 'yes', 'no' +USE_MONOSEAT='no' + +# Reconfigure the input devices every time (re-creating the links) +# Values: 'yes', 'no'. +RECONFIGURE_INPUT='yes' + +# Display manager +# Values: `ls /usr/share/mdm/modes` (you probably want 'xephyr-gdm') +DISPLAY_MANAGER='xephyr-xdmcp' + +#################################### +# xephyr-gdm options: + +# Connection type: +# Values: 'indirect' or 'query' +CONNECTION_TYPE='query' +# Connection target: +# Values: your xdmcp server. +CONNECTION_TARGET='guinness' diff --git a/bin/modes/template b/bin/modes/template new file mode 100644 index 0000000..35a2488 --- /dev/null +++ b/bin/modes/template @@ -0,0 +1,59 @@ +#!/bin/bash + +# 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 is the template file for the mdm modes + +function display_manager_init () { + # This function should stop running processes, remove logs, links, locks, or + # anything your display manager might need. + # Consider calling display_manager_stop here if you don't need anything + # else. +} + +function display_manager_start_monoseat () { + # This function is called when the computer has only 1 video card. + # You should open only 1 xserver and that's it: normal usage, not multiseat + # Do NOT configure devices or stuff like that + # We assume $DISPLAY is already set here. +} + +function display_manager_start_underneath_xserver () { + # In case we're using nested xservers (like Xephyr), we'll need to start an + # xserver to run the nested servers on top of it + # Don't put login screen on this server! + # We assume $DISPLAY is already set here. +} + +function display_manager_start_seat () { + # This is where we start the xserver that will have a login screen + # In case of multiseat with Xephyr, this function starts the Xephyrs and + # put the login screens on them. + # We assume $DISPLAY is already set here. + # This function is called by mdm-start-seat, which gives you 2 variables: + # $KEYBOARD and $MOUSE, which point to evdev device nodes. + # $SEAT_NUMBER variable corresponds to the number that the user will have to + # press on the keyboard. Might be useful to use. +} + +function display_manager_stop () { + # This function should kill everything it has to kill, so that we REALLY + # stop all the seats, kill all the Xephyrs, remove locks, links and stuff + # like that. +} diff --git a/bin/modes/xephyr-xdmcp b/bin/modes/xephyr-xdmcp new file mode 100644 index 0000000..e6641e3 --- /dev/null +++ b/bin/modes/xephyr-xdmcp @@ -0,0 +1,123 @@ +#!/bin/bash + +# 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 configuration runs Xephyr on XDMCP + +# TODO: use XAUTHORITY correctly, we MUST have a secure environment + +XAUTH_FILE=${MDM_RUN}/Xauth + +function display_manager_init () { + # This function should stop running processes, remove logs, links, locks, or + # anything your display manager might need. + # Consider calling display_manager_stop here if you don't need anything + # else. + display_manager_stop +} + +function display_manager_start_monoseat () { + # This function is called when the computer has only 1 video card. + # You should open only 1 xserver and that's it: normal usage, not multiseat + # Do NOT configure devices or stuff like that + # We assume $DISPLAY is already set here. + + X -config $MDM_XORG_CONF \ + -${CONNECTION_TYPE} ${CONNECTION_TARGET} & + + PID=$! + echo $PID > $MDM_PIDS/xephyr-xdmcp-X.pid + wait $PID + rm -f $MDM_PIDS/xephyr-xdmcp-X.pid +} + +function display_manager_start_underneath_xserver () { + # In case we're using nested xservers (like Xephyr), we'll need to start an + # xserver to run the nested servers on top of it + # Don't put login screen on this server! + # We assume $DISPLAY is already set here. + + # Without -noreset the configuration process doesn't work properly + X -noreset -config $MDM_XORG_CONF & + PID=$! + echo $PID > $MDM_PIDS/xephyr-xdmcp-X.pid + + # XXX Wait for sigusr1, that X will send when it gets ready + sleep 5 + + xauth -f ${XAUTH_FILE} generate :0 +} + +function display_manager_start_seat () { + # This is where we start the xserver that will have a login screen + # In case of multiseat with Xephyr, this function starts the Xephyrs and + # puts the login screens on them. + # We assume $DISPLAY is already set here. + # This function is called by mdm-start-seat, which gives you 2 variables: + # $KEYBOARD and $MOUSE, which point to evdev device nodes. + # $SEAT_NUMBER variable corresponds to the number that the user will have to + # press on the keyboard. Might be useful here. + + if [ ! -z ${XKB_MODEL[SEAT_NUMBER]} ]; then + XKBMODEL=${XKB_MODEL[SEAT_NUMBER]} + else + XKBMODEL=$DEFAULT_XKB_MODEL + fi + if [ ! -z ${XKB_LAYOUT[SEAT_NUMBER]} ]; then + XKBLAYOUT=${XKB_LAYOUT[SEAT_NUMBER]} + else + XKBLAYOUT=$DEFAULT_XKB_LAYOUT + fi + if [ ! -z ${MODE[SEAT_NUBMER]} ]; then + SCREEN_SIZE=${MODE[SEAT_NUMBER]} + else + SCREEN_SIZE=$DEFAULT_MODE + fi + +# echo "Xephyr :${SEAT_NUMBER} -br \ +# -geometry ${SCREEN_SIZE}+0+0 \ +# -mouse evdev,,device=$MOUSE \ +# -keybd \ +# evdev,,device=$KEYBOARD,xkbmodel=$XKBMODEL,xkblayout=$XKBLAYOUT \ +# -${CONNECTION_TYPE} ${CONNECTION_TARGET} &" + + Xephyr :${SEAT_NUMBER} -br \ + -geometry ${SCREEN_SIZE}+0+0 \ + -mouse evdev,,device=$MOUSE \ + -keybd \ + evdev,,device=$KEYBOARD,xkbmodel=$XKBMODEL,xkblayout=$XKBLAYOUT \ + -${CONNECTION_TYPE} ${CONNECTION_TARGET} & + + PID=$! + echo $PID > $MDM_PIDS/Xephyr.${SEAT_NUMBER}.pid + wait $PID + rm -f $MDM_PIDS/xephyr-xdmcp-Xephyr.${SEAT_NUMBER}.pid +} + +function display_manager_stop () { + # This function should kill everything it has to kill, so that we REALLY + # stop all the seats, kill all the Xephyrs, remove locks, links and stuff + # like that. + for i in `ls $MDM_PIDS/xephyr-xdmcp*.pid 2> /dev/null`; do + kill `cat $i` 2> /dev/null + rm -f $i + done + + rm -f $XAUTH_FILE +} diff --git a/bin/read-devices.c b/bin/read-devices.c new file mode 100644 index 0000000..a5b28df --- /dev/null +++ b/bin/read-devices.c @@ -0,0 +1,191 @@ +/* + * 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; + } +} diff --git a/bin/write-message.c b/bin/write-message.c new file mode 100644 index 0000000..2e498e0 --- /dev/null +++ b/bin/write-message.c @@ -0,0 +1,145 @@ +/* XXX: THIS IS JUST A PRELIMINARY SCRIPT, USED FOR TESTING */ + +/* + * 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. + * + + +/* compiling with: + * gcc -Wall -g3 -O0 ttwrite1.c -o ttwrite `pkg-config --libs --cflags freetype2 x11 xft */ + +# include <stdlib.h> +# include <stdio.h> +# include <X11/Xlib.h> +# include <cairo.h> + +int main (int argc, char *argv[] ) +{ + Display *display = XOpenDisplay(NULL); + Visual *visual; + Window win; + XEvent event; + + cairo_surface_t *surface; + cairo_text_extents_t extents; + cairo_t *cr; + + int i; + int screen_num = DefaultScreen(display); + int display_width = DisplayWidth(display, screen_num); + int display_height = DisplayHeight(display, screen_num); + double x,y; + unsigned int width, height; + unsigned int win_x, win_y; + unsigned int win_border_width; + + width = (display_width); + height = (display_height); + + win_x = 0; + win_y = 0; + + win_border_width = 3; + + /*win = XCreateSimpleWindow(display, + RootWindow(display, screen_num), + win_x, + win_y, + width, + height, + win_border_width, + BlackPixel(display, screen_num), + WhitePixel(display, screen_num) ); */ + win = RootWindow(display, screen_num); + +// XSelectInput(display, win, ExposureMask | ButtonPressMask | KeyPressMask); + + visual = DefaultVisual(display, screen_num); + + surface = cairo_xlib_surface_create (display, + win, + visual, + width, + height ); + cr = cairo_create (surface); + + //XMapWindow(display, win); + + 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, 0.0, 0.0, 0.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); + + cairo_move_to (cr, x, y ); + + for (i = argc; i > 0; i--) + { + cairo_text_extents(cr, argv[i], &extents); + cairo_move_to (cr, x, y ); + cairo_show_text (cr, argv[i]); + + y = y + (extents.height/2 + extents.y_bearing*2 ); + } + +/* while (1) + { + XNextEvent(display, &event); + switch (event.type) + { + case Expose: + 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); + + cairo_move_to (cr, x, y ); + + for (i = argc; i > 0; i--) + { + cairo_text_extents(cr, argv[i], &extents); + cairo_move_to (cr, x, y ); + cairo_show_text (cr, argv[i]); + + y = y + (extents.height/2 + extents.y_bearing*2 ); + } + + break; + + case ButtonPress: + exit(0); + + case KeyPress: + exit(0); + } + + } +*/ + + XFlush(display); + XCloseDisplay(display); + + + return 0; + +} diff --git a/distro/targz/xephyr-geometry.patch.diff b/distro/targz/xephyr-geometry.patch.diff new file mode 100644 index 0000000..515bf25 --- /dev/null +++ b/distro/targz/xephyr-geometry.patch.diff @@ -0,0 +1,138 @@ +diff -Nru xorg-server-1.4.1.sem-patch/hw/kdrive/ephyr/ephyr.c xorg-server-1.4.1.com-patch-sem-compilar/hw/kdrive/ephyr/ephyr.c +--- xorg-server-1.4.1.sem-patch/hw/kdrive/ephyr/ephyr.c 2008-06-26 16:42:54.000000000 -0300 ++++ xorg-server-1.4.1.com-patch-sem-compilar/hw/kdrive/ephyr/ephyr.c 2008-06-26 16:58:29.000000000 -0300 +@@ -437,7 +437,8 @@ + *rotations = RR_Rotate_All|RR_Reflect_All; + + if (!hostx_want_preexisting_window() +- && !hostx_want_fullscreen()) /* only if no -parent switch */ ++ && !hostx_want_fullscreen() /* only if no -parent switch */ ++ && !hostx_want_user_geometry()) + { + while (sizes[n].width != 0 && sizes[n].height != 0) + { +diff -Nru xorg-server-1.4.1.sem-patch/hw/kdrive/ephyr/ephyrinit.c xorg-server-1.4.1.com-patch-sem-compilar/hw/kdrive/ephyr/ephyrinit.c +--- xorg-server-1.4.1.sem-patch/hw/kdrive/ephyr/ephyrinit.c 2008-06-26 16:42:54.000000000 -0300 ++++ xorg-server-1.4.1.com-patch-sem-compilar/hw/kdrive/ephyr/ephyrinit.c 2008-06-26 16:58:29.000000000 -0300 +@@ -98,6 +98,7 @@ + ErrorF("-fullscreen Attempt to run Xephyr fullscreen\n"); + ErrorF("-grayscale Simulate 8bit grayscale\n"); + ErrorF("-fakexa Simulate acceleration using software rendering\n"); ++ ErrorF("-geometry geometry Use specified geometry\n"); + ErrorF("\n"); + + exit(1); +@@ -142,6 +143,14 @@ + ephyrFuncs.finiAccel = ephyrDrawFini; + return 1; + } ++ else if (!strcmp (argv[i], "-geometry")) ++ { ++ if (i+1 < argc) ++ { ++ hostx_use_user_geometry(argv[i+1]); ++ return 2; ++ } ++ } + else if (argv[i][0] == ':') + { + hostx_set_display_name(argv[i]); +diff -Nru xorg-server-1.4.1.sem-patch/hw/kdrive/ephyr/hostx.c xorg-server-1.4.1.com-patch-sem-compilar/hw/kdrive/ephyr/hostx.c +--- xorg-server-1.4.1.sem-patch/hw/kdrive/ephyr/hostx.c 2008-06-26 16:42:54.000000000 -0300 ++++ xorg-server-1.4.1.com-patch-sem-compilar/hw/kdrive/ephyr/hostx.c 2008-06-26 16:58:29.000000000 -0300 +@@ -59,9 +59,10 @@ + int depth; + int server_depth; + XImage *ximg; +- int win_width, win_height; ++ int win_width, win_height, win_x, win_y; + Bool use_host_cursor; + Bool use_fullscreen; ++ Bool use_user_geometry; + Bool have_shm; + + long damage_debug_msec; +@@ -73,7 +74,7 @@ + }; + + /* memset ( missing> ) instead of below */ +-static EphyrHostXVars HostX = { "?", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; ++static EphyrHostXVars HostX = { "?", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + + static int HostXWantDamageDebug = 0; + +@@ -118,7 +119,8 @@ + hostx_want_screen_size(int *width, int *height) + { + if (HostX.win_pre_existing != None +- || HostX.use_fullscreen == True) ++ || HostX.use_fullscreen == True ++ || HostX.use_user_geometry == True) + { + *width = HostX.win_width; + *height = HostX.win_height; +@@ -168,6 +170,20 @@ + } + + void ++hostx_use_user_geometry(char *geometry) ++{ ++ if (XParseGeometry (geometry, &HostX.win_x, &HostX.win_y, ++ &HostX.win_width, &HostX.win_height)) ++ HostX.use_user_geometry = True; ++} ++ ++int ++hostx_want_user_geometry(void) ++{ ++ return HostX.use_user_geometry; ++} ++ ++void + hostx_use_fullscreen(void) + { + HostX.use_fullscreen = True; +@@ -447,9 +463,10 @@ + void* + hostx_screen_init (int width, int height, int buffer_height) + { +- int bitmap_pad; +- Bool shm_success = False; +- XSizeHints *size_hints; ++ int bitmap_pad; ++ Bool shm_success = False; ++ XSizeHints *size_hints; ++ XWindowChanges values; + + EPHYR_DBG("mark"); + +@@ -525,6 +542,13 @@ + + XResizeWindow(HostX.dpy, HostX.win, width, height); + ++ if (HostX.use_user_geometry) ++ { ++ values.x = HostX.win_x; ++ values.y = HostX.win_y; ++ XConfigureWindow(HostX.dpy, HostX.win, CWX | CWY, &values); ++ } ++ + /* Ask the WM to keep our size static */ + size_hints = XAllocSizeHints(); + size_hints->max_width = size_hints->min_width = width; +diff -Nru xorg-server-1.4.1.sem-patch/hw/kdrive/ephyr/hostx.h xorg-server-1.4.1.com-patch-sem-compilar/hw/kdrive/ephyr/hostx.h +--- xorg-server-1.4.1.sem-patch/hw/kdrive/ephyr/hostx.h 2008-06-26 16:42:54.000000000 -0300 ++++ xorg-server-1.4.1.com-patch-sem-compilar/hw/kdrive/ephyr/hostx.h 2008-06-26 16:58:29.000000000 -0300 +@@ -101,6 +101,12 @@ + hostx_use_host_cursor(void); + + void ++hostx_use_user_geometry(char *); ++ ++int ++hostx_want_user_geometry(void); ++ ++void + hostx_use_fullscreen(void); + + int diff --git a/distro/ubuntu-8.04/Makefile b/distro/ubuntu-8.04/Makefile new file mode 100644 index 0000000..1eda98b --- /dev/null +++ b/distro/ubuntu-8.04/Makefile @@ -0,0 +1,4 @@ +all: xephyr + +xephyr: + make-xephyr.sh diff --git a/distro/ubuntu-8.04/make-xephyr.sh b/distro/ubuntu-8.04/make-xephyr.sh new file mode 100644 index 0000000..60259b0 --- /dev/null +++ b/distro/ubuntu-8.04/make-xephyr.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# 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. + +# XXX: this script should "apt-get source xserver-xephyr", apply the patch and +# compile it diff --git a/distro/ubuntu-8.04/xephyr-geometry.patch.diff b/distro/ubuntu-8.04/xephyr-geometry.patch.diff new file mode 100644 index 0000000..515bf25 --- /dev/null +++ b/distro/ubuntu-8.04/xephyr-geometry.patch.diff @@ -0,0 +1,138 @@ +diff -Nru xorg-server-1.4.1.sem-patch/hw/kdrive/ephyr/ephyr.c xorg-server-1.4.1.com-patch-sem-compilar/hw/kdrive/ephyr/ephyr.c +--- xorg-server-1.4.1.sem-patch/hw/kdrive/ephyr/ephyr.c 2008-06-26 16:42:54.000000000 -0300 ++++ xorg-server-1.4.1.com-patch-sem-compilar/hw/kdrive/ephyr/ephyr.c 2008-06-26 16:58:29.000000000 -0300 +@@ -437,7 +437,8 @@ + *rotations = RR_Rotate_All|RR_Reflect_All; + + if (!hostx_want_preexisting_window() +- && !hostx_want_fullscreen()) /* only if no -parent switch */ ++ && !hostx_want_fullscreen() /* only if no -parent switch */ ++ && !hostx_want_user_geometry()) + { + while (sizes[n].width != 0 && sizes[n].height != 0) + { +diff -Nru xorg-server-1.4.1.sem-patch/hw/kdrive/ephyr/ephyrinit.c xorg-server-1.4.1.com-patch-sem-compilar/hw/kdrive/ephyr/ephyrinit.c +--- xorg-server-1.4.1.sem-patch/hw/kdrive/ephyr/ephyrinit.c 2008-06-26 16:42:54.000000000 -0300 ++++ xorg-server-1.4.1.com-patch-sem-compilar/hw/kdrive/ephyr/ephyrinit.c 2008-06-26 16:58:29.000000000 -0300 +@@ -98,6 +98,7 @@ + ErrorF("-fullscreen Attempt to run Xephyr fullscreen\n"); + ErrorF("-grayscale Simulate 8bit grayscale\n"); + ErrorF("-fakexa Simulate acceleration using software rendering\n"); ++ ErrorF("-geometry geometry Use specified geometry\n"); + ErrorF("\n"); + + exit(1); +@@ -142,6 +143,14 @@ + ephyrFuncs.finiAccel = ephyrDrawFini; + return 1; + } ++ else if (!strcmp (argv[i], "-geometry")) ++ { ++ if (i+1 < argc) ++ { ++ hostx_use_user_geometry(argv[i+1]); ++ return 2; ++ } ++ } + else if (argv[i][0] == ':') + { + hostx_set_display_name(argv[i]); +diff -Nru xorg-server-1.4.1.sem-patch/hw/kdrive/ephyr/hostx.c xorg-server-1.4.1.com-patch-sem-compilar/hw/kdrive/ephyr/hostx.c +--- xorg-server-1.4.1.sem-patch/hw/kdrive/ephyr/hostx.c 2008-06-26 16:42:54.000000000 -0300 ++++ xorg-server-1.4.1.com-patch-sem-compilar/hw/kdrive/ephyr/hostx.c 2008-06-26 16:58:29.000000000 -0300 +@@ -59,9 +59,10 @@ + int depth; + int server_depth; + XImage *ximg; +- int win_width, win_height; ++ int win_width, win_height, win_x, win_y; + Bool use_host_cursor; + Bool use_fullscreen; ++ Bool use_user_geometry; + Bool have_shm; + + long damage_debug_msec; +@@ -73,7 +74,7 @@ + }; + + /* memset ( missing> ) instead of below */ +-static EphyrHostXVars HostX = { "?", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; ++static EphyrHostXVars HostX = { "?", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + + static int HostXWantDamageDebug = 0; + +@@ -118,7 +119,8 @@ + hostx_want_screen_size(int *width, int *height) + { + if (HostX.win_pre_existing != None +- || HostX.use_fullscreen == True) ++ || HostX.use_fullscreen == True ++ || HostX.use_user_geometry == True) + { + *width = HostX.win_width; + *height = HostX.win_height; +@@ -168,6 +170,20 @@ + } + + void ++hostx_use_user_geometry(char *geometry) ++{ ++ if (XParseGeometry (geometry, &HostX.win_x, &HostX.win_y, ++ &HostX.win_width, &HostX.win_height)) ++ HostX.use_user_geometry = True; ++} ++ ++int ++hostx_want_user_geometry(void) ++{ ++ return HostX.use_user_geometry; ++} ++ ++void + hostx_use_fullscreen(void) + { + HostX.use_fullscreen = True; +@@ -447,9 +463,10 @@ + void* + hostx_screen_init (int width, int height, int buffer_height) + { +- int bitmap_pad; +- Bool shm_success = False; +- XSizeHints *size_hints; ++ int bitmap_pad; ++ Bool shm_success = False; ++ XSizeHints *size_hints; ++ XWindowChanges values; + + EPHYR_DBG("mark"); + +@@ -525,6 +542,13 @@ + + XResizeWindow(HostX.dpy, HostX.win, width, height); + ++ if (HostX.use_user_geometry) ++ { ++ values.x = HostX.win_x; ++ values.y = HostX.win_y; ++ XConfigureWindow(HostX.dpy, HostX.win, CWX | CWY, &values); ++ } ++ + /* Ask the WM to keep our size static */ + size_hints = XAllocSizeHints(); + size_hints->max_width = size_hints->min_width = width; +diff -Nru xorg-server-1.4.1.sem-patch/hw/kdrive/ephyr/hostx.h xorg-server-1.4.1.com-patch-sem-compilar/hw/kdrive/ephyr/hostx.h +--- xorg-server-1.4.1.sem-patch/hw/kdrive/ephyr/hostx.h 2008-06-26 16:42:54.000000000 -0300 ++++ xorg-server-1.4.1.com-patch-sem-compilar/hw/kdrive/ephyr/hostx.h 2008-06-26 16:58:29.000000000 -0300 +@@ -101,6 +101,12 @@ + hostx_use_host_cursor(void); + + void ++hostx_use_user_geometry(char *); ++ ++int ++hostx_want_user_geometry(void); ++ ++void + hostx_use_fullscreen(void); + + int diff --git a/doc/mdm.notes b/doc/mdm.notes new file mode 100644 index 0000000..e9f9b87 --- /dev/null +++ b/doc/mdm.notes @@ -0,0 +1,69 @@ +============================== +MDM: Multiseat Display Manager +============================= + +Although it is called a "Display Manager", mdm is actually a wrapper on the +display manager: it just arranges displays and pair the input and output devices +so the display manager will be able to start the seats properly. + +============ +How it works +============ + +- mdm: +The mdm script is the "init.d" script. It must be called with the +start/stop/restart/reconfigure arguments. It just prints some information on the +screen and then calls the mdm-bin script. + +- mdm-bin: +Here the real task starts. mdm-bin sets up the system to start a multiseat, +detect video cards, calls create-xorg-conf if needed and then calls the scripts. +If it detects a single-seat environment, it will just call the +"display_manager_start_monoseat" function. If it detects a multiseat +environment, it will call the other "display_manager*" functions and then call +the mdm-start-seat script in background, one for each seat. + +- mdm-start-seat: +This script is called once for each seat. It should "source" the correct display +manager mode script and then then call the proper functions to associate the +devices to the seat and then start the session (calling gdm, xdmcp or whatever). + +- mdm-common: +This script has common functions and definitions and can be included by +everyone. It also loads the config-file and includes the correct display +manager mode. + +- mdm.conf: +This is the config file. It is just a bash script that is sourced by the +mdm-common script. + +- read-devices: +Binary responsible for reading devices and detect key/button pressing. It is +used to help associating devices to seats. + +- write-message: +Binary that receives text as arguments and displays them on the screen. + +- modes/*: +Scripts that should be sourced to start the xserver according to what needs to +be called. MDM was designed to work with any kind of multiseat environment +(multiple xservers, nested xservers, using gdm, kdm, xdm, xdmcp, vnc or anything +else). To addapt mdm to your environment, you just need to write your "mode" +script and configure mdm.conf to use it. See the "template" mode or the existing +files to see what you'll need to implement and how. + +- create-xorg-conf: +Script that creates the xorg-conf. As xserver evolves, this script should be +updated (and simplified!). It can also take parameters from mdm.conf. + +- discover-devices: +This script parses /proc/bus/input/devices to discover the existing mice and +keyboard and report their evdev events. It also uses discover to find out the +correct video drivers for the video cards. Other kinds of implementation could +be considered (udev? hal? d-bus? mpx?). + +============ +Useful stuff +============ + +TODO diff --git a/misc/background.png b/misc/background.png Binary files differnew file mode 100644 index 0000000..388c60e --- /dev/null +++ b/misc/background.png diff --git a/misc/make-tree.sh b/misc/make-tree.sh new file mode 100755 index 0000000..a0bf536 --- /dev/null +++ b/misc/make-tree.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# 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. + +set -e + +# XXX: update these from mdm-common + +TARGET=tmp/ +BASE_DIR=/ + +MDM_LOGS=$BASE_DIR/var/log/mdm/ +MDM_RUN=$BASE_DIR/var/run/mdm/ +MDM_ETC=$BASE_DIR/etc/mdm/ +MDM_SHARE=$BASE_DIR/usr/share/mdm/ +MDM_SCRIPTS=$BASE_DIR/usr/sbin/ + +CONFIG_FILE=$MDM_ETC/mdm.conf + +MDM_DEVICES=$MDM_ETC/devices/ +MDM_MODES=$MDM_SHARE/modes/ +MDM_PIDS=$MDM_RUN/ + +INITD=/etc/init.d + +rm -rf $TARGET +mkdir -p $TARGET + +mkdir -p $TARGET/$MDM_LOGS +mkdir -p $TARGET/$MDM_RUN +mkdir -p $TARGET/$MDM_ETC +mkdir -p $TARGET/$MDM_SHARE +mkdir -p $TARGET/$MDM_SCRIPTS + +mkdir -p $TARGET/$MDM_DEVICES +mkdir -p $TARGET/$MDM_PIDS + +mkdir -p $TARGET/$INITD +cp bin/mdm $TARGET/$INITD + +cp bin/mdm-bin $TARGET/$MDM_SCRIPTS/mdm-bin +cp bin/mdm-common $TARGET/$MDM_SCRIPTS/mdm-common +cp bin/mdm-start-seat $TARGET/$MDM_SCRIPTS/mdm-start-seat +cp bin/create-xorg-conf $TARGET/$MDM_SCRIPTS/create-xorg-conf +cp bin/write-message $TARGET/$MDM_SCRIPTS/write-message +cp bin/read-devices $TARGET/$MDM_SCRIPTS/read-devices +cp bin/discover-devices $TARGET/$MDM_SCRIPTS/discover-devices +cp misc/background.png $TARGET/$MDM_SHARE/background.png +cp -r bin/modes $TARGET/$MDM_SHARE/modes +cp bin/mdm.conf $TARGET/$MDM_ETC/mdm.conf + |