x2gokdriveclient-0.0.0.1/AUTHORS0000644000000000000000000000005614441666201013074 0ustar Oleksandr Shneyder x2gokdriveclient-0.0.0.1/ChangeLog0000644000000000000000000001512714441666201013603 0ustar x2gokdriveclient (0.0.0.1-0x2go1) unstable; urgency=medium [ Oleksandr Shneyder ] * Initial release: - Add floating tool bar. - disable kbd input for toolbar. - set default window geometry to 800x600. - force client to send geometry event if the size of the display area is not changed after intiation for server to send initial image. - identify screen, when user hovering the action in the multiple monitors menu. - not use QClipboard class on Linux. It has problems mit INCR properties. Using XCB API instead. - add xcb and xcb-fixes to deps. - add command line argument --selection (both|none|server|client) to specify selection mode. - send a recive feature versions. - give server some time for initialization before sending version. - support sending and recieving selections on demand. Support reading and writing INCR properties. - include xcb/xproto.h header - use zlib library to decompress compressed strings instead of built in QT function. - reiniting of frame and cursors caches if cache is corrupted. - support for --debug command line argument. - wait for server version before requesting main image. - use QTextStream(stderr) instead of qDebug. - use Qt::endl and Qt::hex in Qt >= 5.15 and endl and hex otherwise. - use KDR_ENDL in destructor. - revert to sprintf function for correct background in menuframe.cpp. - output some important messages if not running in debug mode. - fix building on Windows. - rootless mode for x2gokdrive. - improve WM updates procedure. - sending KEYRELEASE immediately after KEYPRESS to avoid the "key sticking". - replace QByteArray::compare with operator ==. - include in extwin.h to fix build on leap423 and co - fix server version checking - reduce window updates when moving windows in rootless mode - remove resizeWinFromServer code - bring rootless window on top if server requesting - rootless mode: if updated window not found, considering it as a new one. - rootless mode: update window on focus events. - normal mode: update window on focus events (MS Windows). - rootles mode for Windows: disable resize animation, change background of display area, don't show window content and don't send geometry events while moving/resizing. - add --noresize option to disable size changing of the window for user. - support for sending frames over UDP. Some improvements in detecting of unchanged regions. - repaint window in rootless mode after move/resize to avoid repaint errors on Windows. - hide normal windows with visibility == 2 from taskbar. [ Mike Gabriel ] * Initial release: - client.{cpp|h}: Don't hide Client::slotSelectionChanged on Linux. Older Qt5 version (as found in Debian stretch) choke on the ifdef'ed out code portions when parsing auto-generated moc_client.cpp. [ Mihai Moldovan ] * Initial release: - x2gokdriveclient.pro: we require C++11, so set this via CONFIG. Mostly for documentation purposes, since this feature should be enabled by default. - x2gokdriveclient.pro: whitespace only. - client.cpp: allow building with Qt 5.8-, which does not support QWidget::setWindowFlag (). Use QWidget::setWindowFlags () with QWidget::windowFlags () and an additional call to show () instead on older platforms. - LICENSE: add GPL 3.0 file. - rpm/: add directory and new file x2gokdriveclient-rpmlint, copied from X2Go Client. - LICENSE: rename to COPYING. - LICENSE: copy from X2Go Client and adapt. - AUTHORS: copy from X2Go Client and adapt. - *.{h,cpp}: move to src directory. - Makefile: copy from X2Go Client. - Makefile.man2html: copy from X2Go Client. - Makefile.docupload: copy from X2Go Client. - Makefile.docupload: adapt to this package. - res/txt: create and add .placeholder file. - Makefile: adapt to this package. - Makefile: install VERSION file into SHAREDIR/x2go/versions/. - resources.qrc: move to res/. - res/resources.qrc: remove res/ prefix. - src/{client,extwin,menuframe}.cpp: remove res/ prefix from resource locations. - res/: move image files to res/img/. - src/{client,extwin,menuframe}.cpp: add img/ prefix to image files. - x2gokdriveclient.pro: adapt to new layout. - res/img/: create svg and img subdirectories, move files to them. - src/{client,extwin,menuframe}.cpp: reference image files via subdirectories. - res/resource.qrc: reference subdirectories. - AUTHORS: actually add file, whoops. - .gitignore: copy from X2Go Client, adapt to this project. - misc: pre-release date update. - x2gokdriveclient.pro: add VERSION variable, currently unused, but might become handy at a later point in time. - x2gokdriveclient.pro: add translations support. - res/: add i18n directory and x2gokdriveclient_de.ts translation file with the initial German translation. * debian/rules: + Let qmake add general Qt {C{,XX},L}FLAGS instead of overriding them. Especially needed for C++11 support. + Switch to most of what X2Go Client uses, minus the Qt switching mechanism. We would need a lot more work for that. + Don't install x2gokdriveclient binary manually, the Makefile does that for us. + Try to export PREFIX to not install in the default prefix. We might have to pass it down further, though. * debian/copyright: + Change the source license to GPL-3+. + Change license for debian/* to GPL-3+ as well, after asking Mike Gabriel to relicense and drop GPL-2+ portions. * debian/control: + Add BD: man2html. * debian/x2gokdriveclient.install: + Remove, we'll handle this differently. * x2gokdriveclient.spec: + Add for RPM support, copied from X2Go Client. + Thin out, mostly adapt to current source, switch between Qt 5 and Qt 6 (although Qt 6 is currently untested and only defined for fake versions of distributions that don't exist yet). + Fix man page install permissions. + No need to explicitly install the man pages any longer, drop. + Add Enhances: x2goclient. + Add version file to list of installed files. + Fix package name, whoops. + Move make_call macro invocation to correct location. It previously only triggered for non-existent Qt6 builds. + Add PREFIX to make call. + Add BR: pkgconfig(zlib). + Don't use Enhances: tag on CentOS 7 (but all other platforms). -- X2Go Release Manager Fri, 09 Jun 2023 22:38:06 +0200 x2gokdriveclient-0.0.0.1/COPYING0000644000000000000000000010451514441666201013064 0ustar GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. 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 them 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 prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. 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. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. 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. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 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 state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 3 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program 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, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU 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. But first, please read . x2gokdriveclient-0.0.0.1/LICENSE0000644000000000000000000000135314441666201013032 0ustar 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 3 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, see . Copyright (C) 2018-2023 Oleksandr Shneyder Copyright (C) 2018-2023 X2Go Project x2gokdriveclient-0.0.0.1/Makefile0000755000000000000000000001057514441666201013476 0ustar #!/usr/bin/make -f TOP_DIR=$(CURDIR) CLIENT_DIR=$(TOP_DIR)/client_build CLIENT_BINARY=$(CLIENT_DIR)/x2gokdriveclient SHELL=/bin/bash # Default to Qt 5. # We'll change this to Qt 6 as soon as Qt-5-based platforms go EOL. QT_VERSION ?= 5 INSTALL_DIR ?= install -d -o root -g root -m 755 INSTALL_FILE ?= install -o root -g root -m 644 INSTALL_SYMLINK ?= ln -s -f INSTALL_PROGRAM ?= install -o root -g root -m 755 RM_FILE ?= rm -f RM_DIR ?= rmdir -p --ignore-fail-on-non-empty DESTDIR ?= PREFIX ?= /usr/local ETCDIR ?= /etc/x2go BINDIR ?= $(PREFIX)/bin SHAREDIR ?= $(PREFIX)/share MANDIR ?= $(SHAREDIR)/man ifeq ($(QT_VERSION),5) QMAKE_BINARY ?= qmake LRELEASE_BINARY ?= lrelease else ifeq ($(QT_VERSION),6) QMAKE_BINARY ?= qmake-qt6 LRELEASE_BINARY ?= lrelease-qt6 else $(error Unsupported Qt version "$(QT_VERSION)" passed.) endif endif QMAKE_OPTS ?= LDFLAGS ?= LIBS ?= ##################################################################### # Make sure that variables passed via the command line are not # automatically exported. # # By default, such variables are exported and passed on to child # (make) processes, which means that we will run into trouble if we # pass CXXFLAGS="some value" as an argument to the top-level # make call. Whatever qmake generates will be overridden by this # definition, leading to build failures (since the code expects # macro values to be set in some cases - which won't be the case # for "generic" CXXFLAGS values.) # # Doing that turns out to be somewhat difficult, though. # # While preventing make from passing down *options* is possible via # giving the new make call an empty MAKEFLAGS value and even though # variables defined on the command line are part of MAKEFLAGS, this # doesn't affect implicit exporting of variables (for most # implementations.) # # Even worse, the correct way to this stuff differs from make # implementation to make implementation. # GNU make way. MAKEOVERRIDES = SHELL QT_VERSION INSTALL_DIR INSTALL_FILE INSTALL_SYMLINK INSTALL_PROGRAM RM_FILE RM_DIR DESTDIR PREFIX ETCDIR BINDIR SHAREDIR MANDIR QMAKE_BINARY LRELEASE_BINARY QMAKE_OPTS LDFLAGS LIBS # FreeBSD and NetBSD way. .MAKEOVERRIDES = SHELL QT_VERSION INSTALL_DIR INSTALL_FILE INSTALL_SYMLINK INSTALL_PROGRAM RM_FILE RM_DIR DESTDIR PREFIX ETCDIR BINDIR SHAREDIR MANDIR QMAKE_BINARY LRELEASE_BINARY QMAKE_OPTS LDFLAGS LIBS # OpenBSD way. .MAKEFLAGS = SHELL QT_VERSION INSTALL_DIR INSTALL_FILE INSTALL_SYMLINK INSTALL_PROGRAM RM_FILE RM_DIR DESTDIR PREFIX ETCDIR BINDIR SHAREDIR MANDIR QMAKE_BINARY LRELEASE_BINARY QMAKE_OPTS LDFLAGS LIBS all: build build: build_man $(MAKE) build_client build_client: $(LRELEASE_BINARY) x2gokdriveclient.pro mkdir -p $(CLIENT_DIR) && cd $(CLIENT_DIR) && $(QMAKE_BINARY) QMAKE_CFLAGS="${CPPFLAGS} ${CFLAGS}" QMAKE_CXXFLAGS="${CPPFLAGS} ${CXXFLAGS}" QMAKE_LFLAGS="${LDFLAGS}" QMAKE_LIBS="${LIBS}" $(QMAKE_OPTS) ../x2gokdriveclient.pro cd $(CLIENT_DIR) && $(MAKE) build_man: ${MAKE} -f Makefile.man2html build clean: clean_client clean_man find . -maxdepth 3 -name '*.o' -exec rm -vf {} + -type f find . -maxdepth 3 -name 'moc_*.cpp' -exec rm -vf {} + -type f find . -maxdepth 3 -name 'ui_*.h' -exec rm -vf {} + -type f find . -maxdepth 3 -name 'qrc_*.cpp' -exec rm -vf {} + -type f find . -maxdepth 3 -name 'x2gokdriveclient_*.qm' -exec rm -vf {} + -type f rm -f x2gokdriveclient rm -f x2gokdriveclient.tag rm -f res/txt/changelog rm -f res/txt/git-info clean_client: rm -fr $(CLIENT_DIR) clean_man: $(MAKE) -f Makefile.man2html clean install: install_client install_data install_man install_client: $(INSTALL_DIR) $(DESTDIR)$(BINDIR)/ $(INSTALL_PROGRAM) $(CLIENT_DIR)/x2gokdriveclient $(DESTDIR)$(BINDIR)/x2gokdriveclient install_data: $(INSTALL_DIR) $(DESTDIR)$(SHAREDIR)/x2go/versions $(INSTALL_FILE) VERSION.x2gokdriveclient $(DESTDIR)$(SHAREDIR)/x2go/versions/ install_man: $(INSTALL_DIR) $(DESTDIR)$(MANDIR)/ $(INSTALL_DIR) $(DESTDIR)$(MANDIR)/man1 $(INSTALL_FILE) man/man1/x2gokdriveclient.1 $(DESTDIR)$(MANDIR)/man1/x2gokdriveclient.1 gzip -f $(DESTDIR)$(MANDIR)/man1/x2gokdriveclient.1 uninstall: uninstall_client uninstall_data uninstall_man uninstall_client: $(RM_FILE) $(BINDIR)/x2gokdriveclient uninstall_data: $(RM_FILE) $(SHAREDIR)/x2go/versions/VERSION.x2gokdriveclient $(RM_DIR) $(SHAREDIR)/x2go/versions $(RM_DIR) $(SHAREDIR)/x2go uninstall_man: $(RM_FILE) $(MANDIR)/man1/x2gokdriveclient.1.gz $(RM_DIR) $(MANDIR)/man1 x2gokdriveclient-0.0.0.1/Makefile.docupload0000644000000000000000000000113314441666201015432 0ustar #!/usr/bin/make -f # Makefile.docupload file - for x2goclient # Copyright (C) 2010-2023 by Mike Gabriel , GPLv3 applies to this file VERSION=$(head -n1 debian/changelog | sed 's,.*(\(.*\)).*,\1,' | cut -d"-" -f1) DOC_HOST="code.x2go.org" DOC_PATH="/srv/sites/x2go.org/packages/doc/x2gokdriveclient/man/" DOC_USER="x2go-admin" doc: docbuild docupload docbuild: make -f Makefile.man2html build_man2html docupload: ssh -l${DOC_USER} ${DOC_HOST} "{ mkdir -p ${DOC_PATH}; rm -Rfv ${DOC_PATH}/*; }" scp -r .build_man2html/html/* ${DOC_USER}@${DOC_HOST}:${DOC_PATH}/ x2gokdriveclient-0.0.0.1/Makefile.man2html0000644000000000000000000000112314441666201015201 0ustar #!/usr/bin/make -f MAN2HTML_BIN = $(shell which man2html) MAN2HTML_SRC = man BUILD_DIR = .build_man2html MAN2HTML_DEST = $(BUILD_DIR)/html man_pages = $(cd $(MAN2HTML_SRC) && find * -type f) all: build build: build_man2html build_man2html: if [ -n "$(MAN2HTML_BIN)" ]; then \ mkdir -p $(MAN2HTML_DEST); \ for man_page in $(man_pages); do mkdir -p $$(dirname $(MAN2HTML_DEST)/$$man_page); done; \ for man_page in $(man_pages); do $(MAN2HTML_BIN) $(MAN2HTML_SRC)/$$man_page > $(MAN2HTML_DEST)/$$man_page.html; done; \ fi clean: clean_man2html clean_man2html: rm -Rf $(BUILD_DIR) x2gokdriveclient-0.0.0.1/man/man1/x2gokdriveclient.10000644000000000000000000000152314441666201017000 0ustar '\" -*- coding: utf-8 -*- .if \n(.g .ds T< \\FC .if \n(.g .ds T> \\F[\n[.fam]] .de URL \\$2 \(la\\$1\(ra\\$3 .. .if \n(.g .mso www.tmac .TH x2gokdriveclient 1 "May 2023" "Version 0.0.0.1" "X2Go Application" .SH NAME x2gokdriveclient \- Graphical client-side backend for X2Go Server's KDrive-based X-Server backend .SH SYNOPSIS 'nh .fi .ad l \fBx2gokdriveclient\fR \fI[options]\fR .SH DESCRIPTION \fBx2gokdriveclient\fR is X2Go Client's graphical backend for displaying KDrive based X2Go Server sessions. .PP You should not run this application standalone. It is evoked from within X2Go Client. .PP .SH OPTIONS \fBx2gokdriveclient\fR accepts all known options known by \fInxproxy\fR (and ignores most of them). .PP .SH AUTHOR This manual has been written by Mike Gabriel for the X2Go project (http://www.x2go.org). x2gokdriveclient-0.0.0.1/res/i18n/x2gokdriveclient_de.ts0000644000000000000000000001217514441666201017704 0ustar Client &Connection &Verbindung &View &Ansicht Multiple monitors Mehrere Bildschirme Monitor Bildschirm All monitors Alle Bildschirme Restore Wiederherstellen Disconnect Verbindung trennen Monitor Bildschirm Enter new window title Neuen Fenstertitel eingeben New window title: Neuer Fenstertitel: X2GoKDrive Client X2GoKDrive Client Monitor 1 Bildschirm 1 Fullscreen Vollbild Wrong cookie Ungültiger X11-Auth-Cookie Error! Can't open options File for reading Fehler! Kann options-Datei nicht zum Lesen öffnen Cursor not found in cache Mauszeiger nicht im Cache gefunden Unsupported header type Nicht-unterstützter Header-Typ This function not ready yet Diese Funktion ist noch nicht bereit Wrong cookie length Ungültige X11-Auth-Cookie-Länge Failed to send auth cookie to server Senden des X11-Auth-Cookies an den Server ist fehlgeschlagen MenuFrame Pin menu bar Menüzeile festsetzen View Ansicht Double click to change window title Drag to change position Doppelklick, um den Fenstertitel zu ändern Drücken und ziehen um die Position zu verändern Disconnect Verbindung trennen Minimize Minimieren x2gokdriveclient-0.0.0.1/res/img/png/x2goclient.png0000644000000000000000000004532614441666201016752 0ustar PNG  IHDR>asBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org<tEXtAuthorHeinz-M. GraesingQBtEXtCreation Time12.06.20071¢"tEXtSourcehttp://www.x2go.org/artworkrPtEXtCopyrightCC Attribution-NoDerivs http://creativecommons.org/licenses/by-nd/3.0/e, IDATxIeٙ;o7 /RoOWx{Oe{D:7ZP=^}^<ϣfНlSUC|+Z߼opOgtW_Vp+_|seaz?B?N ڗC0(Nj#!xz,/3cT ?[\X'K="S7[՗VwO_.*a ϗųYn,3^3y`F0Af9HdҚ3?o~'w/fk4+"  f(UGӓDF?W b}Ȉ^fhgX@9~#H3b; fdwo6k k} WVTJەFbsg)@N~/y@ .R0QQ5W)y#ē )%'}8X+B?s]_$aj9wα$9ϑxGtzS)y4aS7F c?j ΓETŃY_zH"~ 66B |j$$Ir!G=*R $&Qv_)C *A A+2c M%A={'iw,^BEk.{;bg ? ,J)A i4LNMh @ H>r||CE%l05cbq218IӧEQJQ{Qcm#M+TPZ"AڬLaI\'ғx%c燄''.>S ()l0R"'P29;E^gſZi|l}ٙ: R8omS._| 1{{{#ethOxh7pF~w=7׷XZZ^Bfk׮v|>$ IHM?VDQIbE; U:qB %aNZ5$'SƠAiH4xDiɥ vi4$Ir޿|4J$qbXiXNֆDZk`S ОF!A,}ʡ^ XZh!y>x>F@{jV#=܌R4r 9><$Sm;j-w>޽e899ժq-|߻0s(a":ol\fIqth (mPHRQkk9f^-mvR%(UAk D`ocvW2 ׯv|.WzEVmӝFeDRsMO_Korxdo|~B7zjez6ss3J _z~L[k~7Tjk;RXiKhKKt߽Gg㶉NAf^AkҧT39[31Zs|tgO_"z:{*_3@V## F8hwz4[mNPI!33Wf;>3Ox[\@ۦ\.>-\g.4Co8Q*q=)8Nn8QqLkV(`dp'^ =3sF}x}6ן25H-pEJD6A`֠\kɻ_~nx|}+hNhR 0!0xZJD)>^õs`kk?Ooc#DzaAkj+/ћ^;3 exǬ=gn\ pp"6&KU1Hq>'S^QH)B T\)?$_o󕯼:ABKVō7&Vlj"OR?!IqHkTH6"e`t~ b<)3=Y<|CJ/%~G=fwA=Eޢ=5/xPd6D'=i N9ܹN~a% >VZ6nTԁ33ư`=ES:lHٗQvJXk@P XT7HgaO=╗'~hpt|B?N()_9"ꗺl2Eq1q>{zw?}ё&SS=J^HicRso e@g69k߆} 1H[FɌǂgD9FHGơ>(mv֊(lmptQk6iv& +u{Osk67Sew{cJ:!JO II [O1?s,jNُerzzl5N[ٜ{*;>ul_d! TnGcݣ\%VrTcHP*y`f*)3|#^=5C [Rh#5eAܢ4G'll03=q{?!ZO4}qX^2[[ۜ:z}QDoEQL$qLRh5 eSl2Efw)SkYY.V},I|_Inbx׿X<8'ROhu/q.JHU ^P}e3@ݻ\(~DяbpF`Tl .%2!4<鎝/%)\sY_yLeKXoўY_]~U*%(MElnl#o:''|耯h4fH0@:JCx)⤏B2"FH#&Ho e €%h,*Fz6E,(aJ!̑' ^'3/_tR?xgÛ;SLLr}r|(U:2S#h`ŭcD+X~L399h{|xməiRό?mi  ÐvyҏCĉnF@i_cPHCDN]' $X\tХm@YZ()Pi=/ O7Pdc}2(Sp$OW(g rr`MkH* 2N ũ[hߛ԰M$I9IoM4^xW:|*%J*Rz:F;ݿΓxxg1| H@cssC`<4@ ~ U*ߜfIV ZQrD;C=a.#q[  ?ad9H:̾T",hL'xK|NmxJ+XyiD}7ci0t8y]޻(J"[0˘g3`{ҳHO=Yq! 8КF=ź7=g[>H!Yӵ53sR  ![<}_>9{{<| ހ?)p `=2Nm$v~Icbql B Aƴ8,1ڢ;aR8zLN D||B>9,ńG;'M&?ݺJFz>zR pe^^ V}]=9em !jqmIu˽N/,33fQyDqQE BsîL+Bsc0 XNʅ;" :F6X v J! qKU-798Ӝ] ^N~J7CiKS6=c#zc{<ْ|yjg[UesB#PJI\T8qǙ.7Yn@)COgܐ̓AJCC(,hNЉUbGcbu@k12'yݏsvRK޿[ar zÆ J%xߨR)]tf/1D%` Q:v bg [ck g,>XAY;Pq{ WTW1q,߈axi܌vL!ϘN%ֳ5v޷nȗ?@xo.9B `!vwyS{&+f8NYIHb뫫8q% 0cZ K{y>oq?yg4]硢qΛ?[Q7X\&c@t3LT TkuffUNNwIA TB$1XgF!+Wh!\; ȼz^{ws϶A`.K+=lpzOPmQd<ǽtc/OљY@J-?櫯MM~cf ~׾}̕h{ ?c Is8_`~?I?YWL`nYJ>tO2&)ES b %n'9N1K9FHҠmP| o!=f-J8^)/yo޻ll>p}yyh7fU룈x>=~.0?fee]N\$=A &`G+PX`g9 8 VT󥤔GKf=I۸.0˿Djkr{>GjQn`jenM+;3ݷ1{s4=#@5䆉 C Lj. ؈㄃VWWXY]~YO Q5v]l \@X_J,IZiHyGV*+O 'z<֯^3ܯ <\cWY',Hӽ5Sz]{}JFҕk4=QlE2~W<(8qb? ;q}u; IDATL4*zBJWb @B Hci~!2O o $gafg%/ B$B׿0>IVjT:||fN#33?;}0u 4Z5k/s36@ o:+ GpϏ@t~jǹ c/Ë@ Q),<`KZ }E HM$ԚudGpb|ʛ/^@7h3|vo}caz~!xFH1e BB#< s|e_2.Ts9:( :C 0FCm2 URW :qJc@NL©ќCMr Tқ>G=~gk_ִEEX87D¤?s\c1@=6~rrǧ}k " D]8I .$Q%,(! 9m,`V ו#A;=hIi}A oCˁ/}A(Juc?[414mre}̑a sf>h ɓ'lnp|r( 6#~B_j jVH- 5 Z/R|FL{X{y`PF`o?Wzs|>7?^{KT-rCLi?Q(es)YG$;fƸ\7%@[zdt-sR~^l5 NsDSO?[al_*#\<}QWao/0Vk7nқ4pMq׃A2*HϝE:eEډu $ms@RWa߷͜y.CKf$am+TBr=@PP\o}_?X"x"f,=R_ c6)jU8D~Sw!Gs[brTpCY^ s j 5:)QmkFwcgghrmDH?X|KJi HcMH m+~, y "F83챈5w TBº(IsYF0(Q!Bgg+mF#F"POcg=F5w~O0kz{g 痉q%#v88v 1TZAfX4IKX_>0fe>U@XhĪ ( $E~Gxg/qN7w>|oޘl3]3ڽI >@{o1;;<|gP[ ڷ !8Ilf-V(1`>=˥K)Ȭ-L\gk,5xyw9:f,|믎ڗ_ajv՞ĜT d?C̣iK?~\o_787/\/"Wa {M`/VzZ:<{[ӟʴ?Ӯ<ns;=b``y84f tFJVqN=ąqIq~*e;1EJ-ÓƩ'ľL$ ]ũs|v^TSͷ=j|,n*첵ce~c4Dž<Ƶz;U2\gb2(.$ OHvA giUvUv`lZJQP2?+Apj!=->=|=~v4r6*P$Q)܁$ CZ2T6ԏl(V}3v MB~Mbsn^v8) EMpә'Tߠ`TzjCߘJJf7'_$50 -н,A@JL-@$| $} lYaKt"Np3P9o1" PdPW@*:W :OGI^<ڑ Dl=NNR)H a1 ~7q6RVVf߿ܦ=`h+Hh@H\`3=g=$+Յ,Z !;{¶ӹ4AD3Gk4脓5ꃳkDoD= c֟0@V?MA_ F\fx^ `Vq;Bm@b2ë 䙫X.G0f|*9emɊC2RCEoAi뗀tLtf+>{L7x4܌c:s/8zy!{nr)3{0"vylq>& m ۔o(a$(+Zb]jqpVLm_H{O can~%|?$lTv[~TR3JxR ޻k.,PPQ  3f]=*mblOWi|Ad=`f10qޯَ8,=pYvVOX #:W8fy|OQgvvRZYa0#)n̎]8I[+]RZk4_Qi5U5ԗ~ӧ3yFM*]8ZֆfI֭[M41;wHV B! >aff979>{ϕRJaHӥR1wTp(FҰiD OA+)IDeF_IIVsOmA& t IlhP);As*a:k#fsK&ڔeIWxޣ]]JktmVkz#X\0aafEa#+o5N[b!h qmcDDY܀rFcZ)LOkH ptyL$CeXur:U*9&fSoOaT̉Z4v;tܢٛ!,JA{f-L#r^4|OOo0=3Mb{ $!}荣ӓS]yxV:TS$2>\h1L{TP(Ϊwy뗕b(m MtIb06N M\@ M(_?}DwHk#HЙ]:<]^a [<"Q_H n7[\~No2+ On4c2i'1I]/7p& IIP-4H*H,HTBgՉ>G[+(WfivR: 3Oc[Obrxȓw5&{ 3_€vMVcQ7K1y#QA5y[8cFҮνE `h)T)ӼD{RkF~iJo~ZI6T^R35Mg>D8ܺړW_V+#Ex#- ۨ)l\*Kj2H$O9BB'<){ iH]t|-l,q+KE@(R_PҜZS7WQFvO{nݤٛT*el;/c&:],%%'q5z6j`أ@kMcN$ΙVL71V2lPvd[O;!},(b 9ʵ'9bo`e(-W/RkL#3\QVkO𽋄B6V>-gW?1en;<~''gE E ".ۧvk:|@4d~F RB!, po+>(Ug^;nv 'l<ŗ%W$u?fsU&"t5J@kM+k apEE9*(6&]A>#GN4?qxӯh=+hC_Ik7&l_Q_)$FYL<30c^b~nj9<#_ϣa̕Coܸ4JrS˿,#"@$JYy.=Bw+$VM3w:ԀOJ$!)]gQ+AP,?X%:\ \ mtAOբV._2&*Yt }%c2GbGKH+6pi_~ɗ1:bKJ4J!O~`u$ʣ< MR4.̳ܾoE ೏ufgzV ™?w)L`AvŭXYe}mIAb+GǠ5YQY 1ٺRtJCYo@/0n pb R ۷vFX2ћ9@$>9`ch}OtzVӗRAR;=GchOp͉穂qDž6R#999ɖl=l:аgDF2m ݒ5J%ĺu:q~Cm)/&?0T]ͿHx°C&2:v!OgiZ-ͱ>HapȽOrUTJR ObrG㓾z4DĶeL I2,^ -4CHNΡ ǙNiS3).`t88K/%gO?{?Lf~?lDTff~# .+˯p߽/ 0th07?mrpӏX}F<88`ggcw>lTLwu90W *@e^II-NmC_9# VK,(v6x3?{z u(`#J!S=޼%5NV n-iՑ.0c,/{qpI84J.'IQ9@}ߑP:bw.QIͶO8\{F88ҵ+t'')C$d9x<*H$D,n?W27ӥVznCV^qD 8tس.,-KĬ6j %ºEX^[K*{ :)OzK|zW?e !ULt&>~Uoo=8M^\.P܋{;W*<L: M dP\4$PPA c($\ߵvѮ0AXbդ;D[<[~w4nrcqNK\DFaMwL V,.rLwo͛sz -(}>UpIH[[[If)/q<`4  ,V ;$Q%j((p(ƁH3(r_,\! <''l='R ŸiRW f_60ԨטPx TsK]K8E}Gg') 0j3; (+ % z MS)1Ig+<.~6Ky']`r3'FAPWiLt/4 yoss]KK˥RRJ2n)%!bǙzPiHܚnV[ tP4[@N t[(wIM.Toz gRaHmE=v6ָG;mﰵ,E6#@4D ڝ6Az5l9SNxλ|2˻Οx-տm_eztnZR/ I?JHOӲiTQ)T,M kOyisH!RנR!:=b>z}?dg@lP /!]>yk{Ohi\y[GL|Jbyp1[{v(88?5Zׯ// LAEр]KiEqUGcMO'|,\^4jr۴U-GG}ZV6sp\VWW9::"\(B©ahE Q/:ڦC3NFI11Έ>F'x˂7#8# x(wDyć1Bf+Wn3Up% W2'D]h. ̣ d,4t=RUn'/ ǵnn5 C/g$@ɗtyQAfɯmA+/jMY8.enK^^5NV0@X:y(40&KOR)>nL8{/ȁx"c >vi* 'g,*o|58`px1@Ǩ!T LOO(hbl`> :7|m tY.V;r9<Ϙ@gL6mV )&'{qeF#*E|Q`gEtc3ȤF _JGƀ'OVVt-wagv+. ʡH@ %LCCw Q]E{ $J$ L9˅DDر{ٙbcq<$.ɉ|ez_;3k!! #_ !}8}(q?N#F/)tXYY! QyҰu-VX,r*yB8|7@wF38DpcAX0ڲhIK6TQg6j(&P>ٌ4 aG'x8xˉe 0:D%9cB46vUTˏ3 *k&84^ۥdWQ˹w !NF˟/(0 xqϾf!A ;{wRBC I ̔UR6<+?uK36L:G7ň`( ;l?#oqܞ6|B͡p.Zha{v,Hz}O|f|QkEWi?՚>nߛВ{W+Vazjt*? zID/Pj:& \&ȷ76m얪oʛ&v JmVt3x3:V??_Os)~' 7; goHy^ӂ\fchc\.{k=H-qLTE!E'bn$9kLW-'0 K}z!>߭{LRxS3쨿ځ:,vf$|$}u]9*J`QK X>LDV2t'4æ>2Lv gq S@XQ7~MۨL<]! "|'2-o IVZ0+?pI!ͤ>k\Lt bIENDB`x2gokdriveclient-0.0.0.1/res/img/svg/application-menu.svg0000644000000000000000000000070014441666201020152 0ustar x2gokdriveclient-0.0.0.1/res/img/svg/minimize.svg0000644000000000000000000000065614441666201016540 0ustar x2gokdriveclient-0.0.0.1/res/img/svg/network-disconnect.svg0000644000000000000000000000214514441666201020532 0ustar x2gokdriveclient-0.0.0.1/res/img/svg/pin.svg0000644000000000000000000000164014441666201015477 0ustar x2gokdriveclient-0.0.0.1/res/img/svg/randr.svg0000644000000000000000000000104214441666201016013 0ustar x2gokdriveclient-0.0.0.1/res/img/svg/view-fullscreen.svg0000644000000000000000000000105714441666201020025 0ustar x2gokdriveclient-0.0.0.1/res/img/svg/view-restore.svg0000644000000000000000000000106714441666201017347 0ustar x2gokdriveclient-0.0.0.1/res/img/svg/view.svg0000644000000000000000000000103014441666201015654 0ustar x2gokdriveclient-0.0.0.1/res/img/svg/x2gobg.svg0000644000000000000000000002402514441666201016103 0ustar image/svg+xml x2gokdriveclient-0.0.0.1/res/img/svg/x2gologo.svg0000644000000000000000000002220414441666201016450 0ustar image/svg+xml x2gokdriveclient-0.0.0.1/res/resources.qrc0000644000000000000000000000072714441666201015343 0ustar img/png/x2goclient.png img/svg/x2gobg.svg img/svg/application-menu.svg img/svg/network-disconnect.svg img/svg/randr.svg img/svg/minimize.svg img/svg/view.svg img/svg/pin.svg img/svg/view-fullscreen.svg img/svg/view-restore.svg x2gokdriveclient-0.0.0.1/res/txt/.placeholder0000644000000000000000000000000014441666201015704 0ustar x2gokdriveclient-0.0.0.1/rpm/x2gokdriveclient-rpmlintrc0000644000000000000000000000004114441666201020032 0ustar addFilter("non-standard-group"); x2gokdriveclient-0.0.0.1/src/client.cpp0000644000000000000000000023352714441666201014610 0ustar /* * QT Client for X2GoKDrive * Copyright (C) 2018-2023 Oleksandr Shneyder * Copyright (C) 2018-2023 phoca-GmbH * * 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 3 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, see . * */ #include #include #include #include "client.h" #include "displayarea.h" #include #include #include #include #include #include #include #include #include #include #include #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) #include #endif #include "menuframe.h" #include #include #include #include #include #include #include #include #include #include #include #include "screenidentifier.h" #include "extwin.h" #ifdef Q_OS_LINUX #include #endif #include //stderr DgramPacket::DgramPacket(uint16_t seq, uint16_t numOfDatagrams) { datagrams.resize(numOfDatagrams); packetSeq=seq; } //return vector with numbers of missing datagrams //return true if the packet is complete after adding datagram bool DgramPacket::addDgram(QByteArray dgram) { uint16_t dgSeq=*((uint16_t*)dgram.constData()+4); //never should happen if(dgSeq>=datagrams.size()) { KDRStdErr()<<"Wrong DGRAM seq number "<width=width; this->height=height; this->xhot=xhot; this->yhot=yhot; this->serialNumber=serialNumber; this->dataSize=dataSize; } X2GoCursor::~X2GoCursor() { } FrameRegion::FrameRegion(uint32_t source_crc, int32_t source_x, int32_t source_y, int32_t x, int32_t y, uint32_t width, uint32_t height, uint32_t dataSize) { this->source_crc=source_crc; this->source_x=source_x; this->source_y=source_y; this->x=x; this->y=y; this->width=width; this->height=height; this->dataSize=dataSize; } FrameRegion::~FrameRegion() { } Frame::Frame(uint32_t width, uint32_t height, int32_t x, int32_t y, uint32_t numOfRegions, uint32_t crc, uint32_t winId) { this->crc=crc; this->x=x; this->y=y; this->width=width; this->height=height; this->winId=winId; this->numOfRegions=numOfRegions; } Frame::~Frame() { while (!regions.isEmpty()) delete regions.takeFirst(); } OutputChunk::OutputChunk(SelectionType selection, SelectionMime mime) { this->selection=selection; mimeData=mime; totalSize=0; firstChunk=lastChunk=false; } QString Client::QRectToStr(const QRect& rec) { QString str; QTextStream(&str) << rec.x()<<","<setSingleShot(true); geometryDelay->setInterval(500); connect(geometryDelay, SIGNAL(timeout()), this, SLOT(geometryChanged())); QGuiApplication* app=(QGuiApplication*)QGuiApplication::instance(); connect(app, SIGNAL(screenAdded(QScreen *)), this, SLOT(slotScreenAdded(QScreen*))); connect(app, SIGNAL(screenRemoved(QScreen *)), this, SLOT(slotScreenRemoved(QScreen*))); connect(app, SIGNAL(primaryScreenChanged(QScreen *)), this, SLOT(geometryChanged())); QList screens=app->screens(); foreach(QScreen* screen, screens) { slotScreenAdded(screen); } QTimer::singleShot(10,this,SLOT(connectToServer())); if(rootless) { hide(); ((QGuiApplication*)QGuiApplication::instance())->setQuitOnLastWindowClosed(false); } } Client::~Client() { KDRStdErr()<<"Client destructor"<setObjectName("DisplayArea"); displayArea->setStyleSheet("QFrame#DisplayArea{background-color:black;border-image:url(:/img/svg/x2gobg.svg) 0 0 0 0 stretch stretch;}"); displayArea->show(); setCentralWidget(displayArea); setWindowIcon(QIcon(":/img/png/x2goclient.png")); QMenu* menuCon=menuBar()->addMenu(tr("&Connection")); menu=menuBar()->addMenu(tr("&View")); FSMenuBar=new MenuFrame(this, menu); menuBar()->hide(); connect(FSMenuBar, SIGNAL(editCaption()), this, SLOT(editWindowTitle())); connect(this, SIGNAL(windowTitleChanged(const QString &)), FSMenuBar, SLOT(setCaption(const QString &))); actRandr=menu->addAction(QIcon(":/img/svg/randr.svg"), tr("Multiple monitors"),this, SLOT(slotEnableRandr())); actRandr->setCheckable(true); menu->addSeparator(); for(int i=0;i<4;++i) { actDisp[i]=menu->addAction(QIcon(":/img/svg/view-fullscreen.svg"), tr("Monitor ")+QString::number(i+1) ,this, SLOT(slotDisplayFS())); connect(actDisp[i], SIGNAL(hovered()), this, SLOT (slotIdentifyScreen())); } actFS=menu->addAction(QIcon(":/img/svg/view-fullscreen.svg"), tr("All monitors"),this, SLOT(slotFS())); menu->addSeparator(); actRestore=menu->addAction(QIcon(":/img/svg/view-restore.svg"), tr("Restore") ,this, SLOT(slotRestore())); menuBar()->addSeparator(); actDisconnect=menuCon->addAction( tr("Disconnect"),this, SLOT(slotDisconnect())); actDisconnect->setIcon(QIcon(":/img/svg/network-disconnect.svg")); actDisconnect->setToolTip(tr("Disconnect")); connect(menu,SIGNAL(aboutToShow()), this, SLOT(slotSetupMenu())); setWindowTitle(mainWndTitle); FSMenuBar->enableViewMenu(!noresize); if(noresize) { setFixedSize(QSize(width,height)); #if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) setWindowFlag(Qt::MSWindowsFixedSizeDialogHint); #else setWindowFlags(windowFlags () | Qt::MSWindowsFixedSizeDialogHint); show (); #endif } } void Client::slotIdentifyScreen() { if(!menu->isVisible() || !menu->underMouse()) { if(screenIdentifier) screenIdentifier->hide(); return; } QAction* hoveredAction=menu->actionAt( menu->mapFromGlobal(QCursor::pos())); if(!hoveredAction) { if(screenIdentifier) screenIdentifier->hide(); return; } int number=-1; for(int i=0;i<4;++i) { if(hoveredAction == actDisp[i]) { number=i; break; } } if(number<0) { if(screenIdentifier) screenIdentifier->hide(); return; } if(number >= QGuiApplication::screens().size()) { KDRStdErr()<<"screen not connected"; if(screenIdentifier) screenIdentifier->hide(); return; } QRect geom=QGuiApplication::screens()[number]->geometry(); if(!screenIdentifier) { screenIdentifier=new ScreenIdentifier(this, Qt::FramelessWindowHint|Qt::X11BypassWindowManagerHint|Qt::WindowStaysOnTopHint); } screenIdentifier->setText(tr("Monitor")+" "+QString::number(number+1)); int x_pos=geom.width()/2-300; int y_pos=geom.height()/2-150; screenIdentifier->setFixedSize(600,300); screenIdentifier ->move(geom.x()+x_pos, geom.y()+y_pos); screenIdentifier->show(); menu->show(); //hide the identifier, when no screen actions are hovered QTimer::singleShot(100,this, SLOT(slotIdentifyScreen())); } void Client::editWindowTitle() { bool ok; QString title=QInputDialog::getText(this,tr("Enter new window title"),tr("New window title:"),QLineEdit::Normal, windowTitle(),&ok); if(ok) { if(title.length()==0) { setWindowTitle(tr("X2GoKDrive Client")); return; } setWindowTitle(title); } } void Client::slotEnableRandr() { setUseRandr(!useRandr); } void Client::slotDisconnect() { if(serverVersion >=8) {//sending disconnect event to server char evmsg[EVLENGTH]{}; uint32_t etype; etype=DISCONNECTCLIENT; memcpy(evmsg,(char*)&etype,4); sendEvent(evmsg); } clientSocket->close(); if(udpSocket->isOpen()) udpSocket->close(); } void Client::slotDisplayFS() { for(int i=0;i<4;++i) { if(QObject::sender() == actDisp[i]) { setFS(i); return; } } setFS(dispNumber); } void Client::slotFS() { setFS(-1); } void Client::slotRestore() { if(FSScreen==-1 || wasInRealFs) { setWindowFlags(Qt::Window); setWindowState(Qt::WindowFullScreen); showFullScreen(); QTimer::singleShot(100,this, &Client::resizeToSaved); } wasInRealFs=false; isFs=false; FSScreen=-1; showNormal(); resize(savedSize); move(savedPosition); } void Client::resizeToSaved() { #ifdef Q_OS_WIN setWindowFlags(Qt::Window); QTimer::singleShot(100,this, SLOT(showNormal())); #endif #ifdef Q_OS_LINUX setWindowState(Qt::WindowNoState); setWindowState(windowState() & ~Qt::WindowMaximized); #endif KDRStdErr()<<"restore to "<screens()[0]->virtualGeometry(); QSize sz=geometry.size(); resize(sz); setVisible(true); raise(); activateWindow(); QTimer::singleShot(1000,this, SLOT(slotEnableRandr())); } void Client::resizeToFS() { QRect geometry=((QGuiApplication*)QGuiApplication::instance())->screens()[0]->virtualGeometry(); #ifdef Q_OS_LINUX setWindowState(windowState() & ~Qt::WindowMaximized); setWindowState(Qt::WindowFullScreen); move(geometry.topLeft()); QTimer::singleShot(100,this, SLOT(slotEnableRandr())); QTimer::singleShot(250,this, SLOT(slotResizeFSFinal())); #endif #ifdef Q_OS_WIN QSize sz=geometry.size(); resize(sz); setVisible(true); raise(); activateWindow(); #endif } void Client::slotRealFs() { wasInRealFs=true; savedFlags=windowFlags(); #ifdef Q_OS_LINUX setWindowFlags(windowFlags()|Qt::X11BypassWindowManagerHint); QTimer::singleShot(100,this, &Client::resizeToFS); #endif #ifdef Q_OS_WIN QTimer::singleShot(100,this,SLOT(showFullScreen())); QTimer::singleShot(200,this, &Client::resizeToFS); #endif } void Client::setFS(int screenNumber) { if(!isFs) { savedSize=geometry().size(); savedPosition=pos(); } else { showNormal(); } KDRStdErr()<<"setting FS on screen"<screens()[0]->virtualGeometry(); move(geometry.topLeft()); #ifdef Q_OS_LINUX setWindowState(Qt::WindowFullScreen); #endif QTimer::singleShot(100,this, &Client::slotRealFs); } else { QListscreens=((QGuiApplication*)QGuiApplication::instance())->screens(); if(screenNumbergeometry().width()-50, screens[screenNumber]->geometry().height()-50); move(screens[screenNumber]->geometry().topLeft()); QTimer::singleShot(100,this,SLOT(showFullScreen())); } } } void Client::slotSetupMenu() { menu->setEnabled(clientSocket->isOpen()); if(useRandr) { actRandr->setChecked(true); } else { actRandr->setChecked(false); } actRestore->setVisible(isFs); actFS->setVisible((!isFs)); actDisp[0]->setText(tr("Monitor 1")); if(((QGuiApplication*)QGuiApplication::instance())->screens().count()==1) { actFS->setVisible(false); actDisp[0]->setText(tr("Fullscreen")); } for(int i=0;i<4;++i) { if(i<((QGuiApplication*)QGuiApplication::instance())->screens().count()) { actDisp[i]->setVisible(true); if(isFs && (FSScreen==i || FSScreen==-1)) { actDisp[i]->setVisible(false); } } else { actDisp[i]->setVisible(false); } } } bool Client::isDisplayPointer(QMouseEvent* event) { if(rootless) return true; if(event->x() > FSMenuBar->x() && event->x() < FSMenuBar->x() + FSMenuBar->width() && event->y() > FSMenuBar->y() && event->y() < FSMenuBar->y() + FSMenuBar->height() && event->button()== Qt::NoButton && event->buttons() == 0) { FSMenuBar->setHasPointer(true); return false; } else { FSMenuBar->setHasPointer(false); return true; } } void Client::freeMessageBuffer() { if(messageBuffer) delete []messageBuffer; messageBuffer=0l; } void Client::parseOptions() { mainWndTitle=tr("X2GoKDrive Client"); QStringList args=QCoreApplication::arguments(); QString optFile; for(int i=0;iconnectToHost(host, port); } QPixmap Client::getPixmapFromCache(uint32_t crc) { if(!frameCache.contains(crc)) { KDRStdErr()<<"GETPIXMAP: frame "<crc) { //we got a whole display copy if(currentFrame->x==-1||currentFrame->y==-1) { KDRStdErr()<<"got initial Image: "<width<<"x"<height<<" "<regions[0]->pix.size())<resize(currentFrame->width, currentFrame->height); this->resize(currentFrame->width, currentFrame->height); } displayImage=QImage(currentFrame->width, currentFrame->height, QImage::Format_RGB32); } } else { if(currentFrame->numOfRegions) { QPainter painter; //We have new Image. We need to create a Pixmap and add to cache QPixmap pix(currentFrame->width, currentFrame->height); if(pix.isNull()) { KDRStdErr()<<"Error allocating new pixmap: "<width<<"x"<height<width<<"x"<height<regions.size();++i) { FrameRegion* reg=currentFrame->regions[i]; if(reg->source_crc) { if(!frameCache.contains(reg->source_crc)) { KDRStdErr()<<"Region "<source_crc<<" not found in cache, fill with display image"<x,reg->y,displayImage, reg->x+currentFrame->x,reg->y+currentFrame->y,reg->width, reg->height); } else { // KDRStdErr()<<"Got region from cache "<source_crc<x<y<width<< reg->height<<"SOURCE:"<source_x<source_y; painter.drawPixmap(reg->x,reg->y,reg->width, reg->height, frameCache[reg->source_crc], reg->source_x, reg->source_y, reg->width, reg->height); } else { //KDRStdErr()<<"REG:"<x<y<width<< reg->height; painter.drawPixmap(reg->x,reg->y, reg->pix); } } painter.end(); frameCache.insert(currentFrame->crc, pix); // KDRStdErr()<<"Add to cache: "<crc<repaint(currentFrame->x, currentFrame->y, currentFrame->width, currentFrame->height); else { if(currentFrame->winId) { // KDRStdErr()<<"Paint currentFrame: "<x<<":"<y<<" "<< currentFrame->width<<"x"<< currentFrame->height<winId<winId); if(win) { QPoint kdrPos=win->virtualToKdrivePosition(win->geometry().topLeft()); win->getDisplayArea()->repaint(currentFrame->x-kdrPos.x(), currentFrame->y-kdrPos.y(), currentFrame->width, currentFrame->height); } else { KDRStdErr()<<"Window not found: "<winId<virtualToKdrivePosition(win->geometry().topLeft()); win->getDisplayArea()->repaint(currentFrame->x-kdrPos.x(), currentFrame->y-kdrPos.y(), currentFrame->width, currentFrame->height); } } } setUptodate(); setDisplayImage(); } void Client::setDisplayImage() { Frame* currentFrame=this->getCurrentFrame(); QPixmap pix; if(!currentFrame->crc) { // Client::KDRStdErr()<<"Draw DISPLAY PIX "<regions[0]->pix; // disp=true; } else { // Client::KDRStdErr()<<"Draw PIX from cache"<getPixmapFromCache(currentFrame->crc); } if(currentFrame->x==-1 || currentFrame->y==-1) { currentFrame->x=currentFrame->y=0; } QPainter painter; painter.begin(this->getDisplayImage()); painter.drawPixmap(currentFrame->x,currentFrame->y,pix); painter.end(); } void Client::setUptodate() { wantRepaint=false; hasUpdates=true; } void Client::getImageFrameFromDGPacket(QByteArray data) { uint32_t winId=0; const char* messageBuffer=data.constData(); if(*((uint32_t*)messageBuffer) == CACHEFRAME) { uint32_t crc=*((uint32_t*)messageBuffer+1); KDRStdErr()<<"Server resent frame with crc "<numOfRegions;++i) { FrameRegion* region=new FrameRegion(*((uint32_t*)messageBuffer), *((uint32_t*)messageBuffer+1),*((uint32_t*)messageBuffer+2), *((uint32_t*)messageBuffer+3), *((uint32_t*)messageBuffer+4), *((uint32_t*)messageBuffer+5), *((uint32_t*)messageBuffer+6),*((uint32_t*)messageBuffer+7)); messageBuffer+=8*4; currentFrame->regions.append(region); if(!region->source_crc) { if(currentFrame->regions.last()->pix.loadFromData((uchar*)messageBuffer, currentFrame->regions.last()->dataSize)) { } else { KDRStdErr()<<"=============================Image loading failed: "<crc<<" Replacing with display image"<pix=QPixmap(region->width, region->height); QPainter painter; painter.begin(®ion->pix); painter.drawImage(region->x,region->y,displayImage, region->x+currentFrame->x,region->y+currentFrame->y,region->width, region->height); painter.end(); } messageBuffer+=currentFrame->regions.last()->dataSize; } } renderFrame(); } void Client::getImageFrame() { if(currentFrame) delete currentFrame; uint32_t winId=0; if(rootless) winId=*((uint32_t*)messageBuffer+7); currentFrame=new Frame(*((uint32_t*)messageBuffer+1), *((uint32_t*)messageBuffer+2),*((uint32_t*)messageBuffer+3), *((uint32_t*)messageBuffer+4), *((uint32_t*)messageBuffer+5), *((uint32_t*)messageBuffer+6), winId); // KDRStdErr()<<"got frame "<crc<numOfRegions; if(!currentFrame->numOfRegions) { //we have no regions, render frame renderFrame(); } else { //read first region bytesReady=0; bytesLeftToRead=REGION_HEADER; currentDataType=FRAMEREGION; } } void Client::getCursorImage() { //get cursor image from buffer // KDRStdErr()<<"got cursor image"; QCursor* cursor; if(currentCursor->dataSize == (uint32_t) currentCursor->width*currentCursor->height*4) { // KDRStdErr()<<"get ARGB cursor"; QImage img((uchar*)messageBuffer, currentCursor->width, currentCursor->height, QImage::Format_ARGB32); cursor=new QCursor(QPixmap::fromImage(img), currentCursor->xhot, currentCursor->yhot); } else { cursor=new QCursor(); } cursorCache.insert(currentCursor->serialNumber, cursor); freeMessageBuffer(); if(!rootless) displayArea->setCursor(*cursor); else { for(int i=0;igetDisplayArea()->setCursor(*cursor); } } } void Client::setCursor() { } void Client::getServerversion() { serverVersion=*((uint16_t*)messageBuffer+2); serverExtSelection = (serverVersion>1); KDRStdErr(false)<<"server version: "<requestSelectionData(selection); #else sendSelectionToServer(selection); #endif } void Client::getCursor() { if(currentCursor) delete currentCursor; currentCursor=new X2GoCursor(*((uint16_t*)messageBuffer+5), *((uint16_t*)messageBuffer+6), *((uint16_t*)messageBuffer+7), *((uint16_t*)messageBuffer+8), *((uint32_t*)messageBuffer+5),*((uint32_t*)messageBuffer+6)); // KDRStdErr()<<"got cursor with serial"<serialNumber<<" size: "<dataSize; if(!currentCursor->dataSize) { //we don't have data, set cursor if(!cursorCache.contains(currentCursor->serialNumber)) { KDRStdErr()<<"cursor not found: "<serialNumber<setCursor(*cursorCache[currentCursor->serialNumber]); else { for(int i=0;igetDisplayArea()->setCursor(*cursorCache[currentCursor->serialNumber]); } } } else { //getCursor image bytesReady=0; bytesLeftToRead=currentCursor->dataSize; currentDataType=CURSORDATA; freeMessageBuffer(); } } void Client::getSelectionBuffer() { #ifndef Q_OS_LINUX //if using qt class, not supporting on demand load of data setInputSelectionData(selectionClipboard, selectionFormat, firstChunk, lastChunk, compressed_size, selectionSize, messageBuffer); #else clipboard->setInputSelectionData(selectionClipboard, selectionFormat, firstChunk, lastChunk, compressed_size, selectionSize, messageBuffer); #endif freeMessageBuffer(); } QByteArray Client::zuncompress(const char* data, uint compressed_size, uint size) { unsigned char* out=new unsigned char [size]; z_stream stream; stream.zalloc = Z_NULL; stream.zfree = Z_NULL; stream.opaque = Z_NULL; stream.avail_in = compressed_size; stream.next_in = (unsigned char*)data; stream.avail_out = size; stream.next_out = out; inflateInit(&stream); inflate(&stream, Z_NO_FLUSH); inflateEnd(&stream); if(!stream.total_out || stream.total_out != size) { KDRStdErr()<<"zlib decompression error, "<<"output size: "<setText(QString::fromLocal8Bit(selData), mode); break; case UTF_STRING: clipboard->setText(QString::fromUtf8(selData), mode);break; case PIXMAP: { QPixmap pix; pix.loadFromData(selData); clipboard->setImage(pix.toImage(), mode); break; } } } } } #endif void Client::getDeletedCursorsList() { //process list from messageBuffer // KDRStdErr()<<"get deleted cursors: "<5) { requestCacheRebuild(); return; } else continue; } delete cursorCache[serial]; cursorCache.remove(serial); } freeMessageBuffer(); } ExtWin* Client::findExtWinById(uint32_t extWinId) { for(QList::iterator j=extWindows.begin(); j!=extWindows.end(); ++j) { if((*j)->getExtWinId()== extWinId) { return (*j); } } return NULL; } void Client::repaintAllWindows() { foreach(ExtWin* w, extWindows) { QTimer::singleShot(10, w->getDisplayArea(), SLOT(repaint())); } } void Client::getWinUpdateBuffer() { //process window updates from messageBuffer // KDRStdErr()<<"get winupdate buffer size: "<close(); delete win; repaintAllWindows(); } else { int16_t x, y; uint16_t w,h,minw,minh,bw; uint8_t visibility; uint8_t winType; uint16_t nameSize; uint32_t icon_size; QPixmap icon; QString name; uint32_t parId=*((uint32_t*)(messageBuffer+readFromBuf)); readFromBuf+=sizeof(uint32_t); uint32_t nextSibId=*((uint32_t*)(messageBuffer+readFromBuf)); readFromBuf+=sizeof(uint32_t); uint32_t transWinId=*((uint32_t*)(messageBuffer+readFromBuf)); readFromBuf+=sizeof(uint32_t); x=*((int16_t*)(messageBuffer+readFromBuf)); readFromBuf+=sizeof(uint16_t); y=*((int16_t*)(messageBuffer+readFromBuf)); readFromBuf+=sizeof(uint16_t); w=*((uint16_t*)(messageBuffer+readFromBuf)); readFromBuf+=sizeof(uint16_t); h=*((uint16_t*)(messageBuffer+readFromBuf)); readFromBuf+=sizeof(uint16_t); minw=*((uint16_t*)(messageBuffer+readFromBuf)); readFromBuf+=sizeof(uint16_t); minh=*((uint16_t*)(messageBuffer+readFromBuf)); readFromBuf+=sizeof(uint16_t); bw=*((uint16_t*)(messageBuffer+readFromBuf)); readFromBuf+=sizeof(uint16_t); visibility=*((uint8_t*)(messageBuffer+readFromBuf)); readFromBuf+=sizeof(uint8_t); winType=*((uint8_t*)(messageBuffer+readFromBuf)); readFromBuf+=sizeof(uint8_t); nameSize=*((uint16_t*)(messageBuffer+readFromBuf)); readFromBuf+=sizeof(uint16_t); if(nameSize) { name=QString::fromUtf8(messageBuffer+readFromBuf, nameSize); readFromBuf+=nameSize; } icon_size=*((uint32_t*)(messageBuffer+readFromBuf)); readFromBuf+=sizeof(uint32_t); if(icon_size) { if(!icon.loadFromData((const uchar*)(messageBuffer+readFromBuf), icon_size)) { KDRStdErr()<<"Failed load icon from bytes: "<setParent(0); } else { ExtWin* parentWin=findExtWinById(parId); // KDRStdErr()<<"win has parent!!!!!: "<setParent(0); } if(transWinId) { ExtWin* transWin=findExtWinById(transWinId); if(!transWin) { // KDRStdErr()<<"trans Win not found in list: "<setParent(transWin); win->setTransWinId(transWinId); if(winType==WINDOW_TYPE_DIALOG) { win->setModality(ExtWin::MOD_SINGLE); win->setWindowIcon(transWin->windowIcon()); } } } // KDRStdErr()<<"my Geometry: "<geometry()); win->setParentId(parId); // KDRStdErr()<<"Place above"<setNextSibId(nextSibId); extWindows.append(win); if(minh&&minw) { win->setMinimumWidth(minw); win->setMinimumHeight(minh); } win->resize(w,h); win->moveWinFromServer(win->kdriveToVirtualPosition(QPoint(x,y))); // Client::KDRStdErr()<<"new win pos: "<kdriveToVirtualPosition(QPoint(x,y)).x()<<":"<kdriveToVirtualPosition(QPoint(x,y)).y()<showNormal(); win->raise(); win->activateWindow(); repaintAllWindows(); if(!icon.isNull()) { win->setWindowIcon(icon); } //hide windows with visibility==2 from taskbar if(winType == WINDOW_TYPE_NORMAL) { if(visibility==2) { flags=Qt::SubWindow; win->setWindowFlags(flags); Client::KDRStdErr()<<"Window with visibility == 2, hiding from taskbar"<update(); } QPoint adjustedWinPos=win->kdriveToVirtualPosition(QPoint(x,y)); // KDRStdErr()<geometry().width() != w || win->geometry().height() != h) win->resize(w,h); if(win->geometry().x()!=adjustedWinPos.x() || win->geometry().y()!=adjustedWinPos.y()) win->moveWinFromServer(adjustedWinPos); if(win->windowTitle()!=name) win->setWindowTitle(name); // win->raise(); if(win->getParentId()!=parId) { //set new parent and remap window win->setParentId(parId); KDRStdErr()<<"Reparent window"<getNextSibId()!=nextSibId) { // set sib and restack windows if(!win->getNextSibId() && nextSibId && winType == WINDOW_TYPE_NORMAL) { win->activateWindow(); win->raise(); win->showNormal(); } win->setNextSibId(nextSibId); // KDRStdErr()<<"Check if need to Restack window???"; } } } freeMessageBuffer(); } void Client::getDeletedFramesList() { //process list from messageBuffer // KDRStdErr()<<"get deleted frames: "< Client::getSiblings(ExtWin* win) { QList siblings; for(int i=0;igetParentId() == extWindows[i]->getParentId())) { siblings<setInputSelectionData(selectionClipboard, selectionFormat, true, true, 0, 0, 0, true); #else setInputSelectionData(selectionClipboard, selectionFormat, true, true, 0, 0, 0, true); #endif } else if(serverSupportsExtSelection() && lastChunk && (selectionSize==0)) { //it's last chunk of incr selection with size 0 #ifdef Q_OS_LINUX clipboard->setInputSelectionData(selectionClipboard, selectionFormat, firstChunk, lastChunk, 0, 0, 0); #else setInputSelectionData(selectionClipboard, selectionFormat, firstChunk, lastChunk, 0, 0, 0); #endif } } else { //if server doesn't support extended selection it'll send data in one chunk, uncompressed firstChunk=true; lastChunk=true; compressed_size=0; } currentDataType=SELECTIONBUFFER; //if data is compressed, read the "compressed_size" bytes if(compressed_size) { bytesLeftToRead=compressed_size; } else bytesLeftToRead=selectionSize; // KDRStdErr()<<"Get Selection, is Clipboard "<regions.count()-1<<"from"<numOfRegions; if(currentFrame->regions.last()->pix.loadFromData((uchar*)messageBuffer, currentFrame->regions.last()->dataSize)) { // QString fname; // fname.sprintf("/tmp/client/%05d.JPG",++frame_ctr); // currentFrame->regions.last()->pix->save(fname); } else { KDRStdErr()<<"Image loading failed: "<crc; /* KDRStdErr()<regions.last()->dataSize; QFile fl("/tmp/client/failed.jpg"); fl.open(QFile::WriteOnly); fl.write((const char*)messageBuffer, currentFrame->regions.last()->dataSize); fl.close(); exit(-1);*/ if(serverVersion<5) exitOnError("Image loading failed"); else requestCacheRebuild(); } if(currentFrame->numOfRegions == (uint)currentFrame->regions.size()) { //all regions are ready, render image; renderFrame(); } else { //read next region bytesReady=0; bytesLeftToRead=REGION_HEADER; currentDataType=FRAMEREGION; } } void Client::getFrameRegion() { FrameRegion* region=new FrameRegion(*((uint32_t*)messageBuffer), *((uint32_t*)messageBuffer+1),*((uint32_t*)messageBuffer+2), *((uint32_t*)messageBuffer+3), *((uint32_t*)messageBuffer+4), *((uint32_t*)messageBuffer+5), *((uint32_t*)messageBuffer+6),*((uint32_t*)messageBuffer+7)); currentFrame->regions.append(region); // KDRStdErr()<<"got region "<regions.count()-1<<"from" // <numOfRegions<<"source: "<source_crc<<"size: "<dataSize; if(!region->source_crc) { //we need to read the image data of region bytesReady=0; bytesLeftToRead=region->dataSize; currentDataType=REGIONDATA; freeMessageBuffer(); } else { if(currentFrame->numOfRegions == (uint)currentFrame->regions.size()) { //all regions are ready, render image; renderFrame(); } else { //read next region bytesReady=0; bytesLeftToRead=REGION_HEADER; currentDataType=FRAMEREGION; } } } void Client::readDataHeader() { uint32_t data_type=*((uint32_t*)messageBuffer); switch(data_type) { case FRAME: { // KDRStdErr()<<"frame"; getImageFrame(); break; } case CURSOR: { // KDRStdErr()<<"cursor"; getCursor(); break; } case DELETEDFRAMES: { // KDRStdErr()<<"deleted frames"; getDeletedFrames(); break; } case DELETEDCURSORS: { // KDRStdErr()<<"deleted cursors"; getDeletedCursors(); break; } case SELECTION: { // KDRStdErr()<<"Get Selection"; getSelection(); break; } case SERVER_VERSION: { getServerversion(); break; } case DEMANDCLIENTSELECTION: { getClientSelection(); break; } case REINIT: { reinitCaches(); break; } case WINUPDATE: { getWinUpdate(); break; } case SRVKEEPALIVE: { //keepalive packet, do nothing break; } case SRVDISCONNECT: { KDRStdErr()<<"Server sent disconnect notification"<* list, uint16_t seq) { for(int i=0;isize();++i) { if(list->at(i)->getPacketSeq()==seq) return i; } return -1; } void Client::readDgram() { qint64 available=udpSocket->pendingDatagramSize(); // KDRStdErr()<<"Have available:"<readDatagram(data.data(),available); if(read!=available) { KDRStdErr()<<"Read datagram failed, read "< *list; uint16_t lastSeq; QString stringType; int32_t current_long; int32_t last_long; switch (dgtype) { case ServerFramePacket: lastSeq=serverFrameSeq; stringType="Server frame packet"; list=&serverFramePackets; break; case ServerRepaintPacket: lastSeq=serverRepaintSeq; stringType="Server repaint packet"; list=&serverRepaintPackets; break; } //this is for the case when the seq is going over the max of the uint16 //don't think we can lose more than 1k Packets current_long=packSeq; last_long=lastSeq; if(abs(current_long-last_long)>64535 && (current_long<1000) ) { current_long+=65536; } if(abs(current_long-last_long)>64535 && (last_long<1000) ) { last_long+=65536; } if(current_long<=last_long) { KDRStdErr()<<"Late "<append(packet); packetInd=list->size()-1; } else { // KDRStdErr()<<"packet with seq "<at(packetInd); } //if true, packet is complete if(packet->addDgram(data)) { // KDRStdErr()<<"packet "<getData()); //delete all broken or processed packets while(!list->isEmpty()) { DgramPacket* first=list->takeFirst(); if(first==packet) { delete first; break; } delete first; } } } void Client::slotSynchronize() { //not connected or server not supporting KEEPALIVE event if(!connected || serverVersion<3) return; /*KDRStdErr()<<"Synchronizing: control seq:"<hasPendingDatagrams()) readDgram(); } void Client::dataArrived() { updateServerAlive(); // KDRStdErr()<<"Have available:"<bytesAvailable(); if(!bytesLeftToRead) { bytesLeftToRead=HEADER_SIZE; bytesReady=0; currentDataType=HEADER; freeMessageBuffer(); } if(!messageBuffer) { // KDRStdErr()<<"init message buffer: "<read(messageBuffer+bytesReady, bytesLeftToRead); bytesLeftToRead-=length; bytesReady+=length; if(!bytesLeftToRead) { switch(currentDataType) { case HEADER: { // KDRStdErr()<<"header"; readDataHeader(); break; } case FRAMEREGION: { // KDRStdErr()<<"frame region"; getFrameRegion(); break; } case REGIONDATA: { // KDRStdErr()<<"region data"; getRegionImage(); break; } case CURSORDATA: { // KDRStdErr()<<"cursor data"; getCursorImage(); break; } case SELECTIONBUFFER: { // KDRStdErr()<<"selection"; getSelectionBuffer(); break; } case CURSORLIST: { // KDRStdErr()<<"cursor list"; getDeletedCursorsList(); break; } case FRAMELIST: { // KDRStdErr()<<"frame list"; getDeletedFramesList(); break; } case WINUPDATEBUFFER: { getWinUpdateBuffer(); break; } default: { KDRStdErr()<<"not ready"; exitOnError(tr("This function not ready yet")); } } } if(clientSocket->bytesAvailable()) dataArrived(); } void Client::socketConnected() { if(!rootless) displayArea->setStyleSheet("QFrame#DisplayArea{background-color:black;}"); KDRStdErr(false)<<"Connected to server"<write(cookie.toLatin1().data(), 32)!=32) { KDRStdErr(false)<<"Failed to send auth cookie to server"<=8) { checkSrvAliveTimer=new QTimer(this); connect(checkSrvAliveTimer, SIGNAL(timeout()),this, SLOT(slotCheckIfServerIsAlive())); checkSrvAliveTimer->start(SERVERALIVETIMEOUT*1000); QTimer* t=new QTimer(this); connect(t, SIGNAL(timeout()), this, SLOT(slotSynchronize())); t->start(5000); if(udpFrames) requestUdpFrames(); } } void Client::initGeometry() { if(rootless) { geometryChanged(); return; } if(geometry().width() != width || geometry().height() != height ) resize(width, height); currentGeometry=geometry(); sendGeometryEvent(); if(fullscreen) { QTimer::singleShot(1000, this, SLOT( slotFS())); } else if(multidisp && (dispNumber < QGuiApplication::screens().count())) { QTimer::singleShot(1000, this, SLOT( slotDisplayFS())); } } void Client::socketDisconnected() { connected=false; KDRStdErr(false)<<"Disconnected from Server"<errorString(); KDRStdErr(false)<isOpen()) return; ln=clientSocket->write(event, EVLENGTH); if(ln!=EVLENGTH) { KDRStdErr()<<"Failed to send input event to server, sent "<isActive()) geometryDelay->stop(); geometryDelay->start(); } void Client::resizeEvent(QResizeEvent* ) { if(rootless) return; if(geometryDelay->isActive()) geometryDelay->stop(); geometryDelay->start(); FSMenuBar->adjustPosition(); } void Client::resizeToOldSize() { currentGeometry=restoreGeometry; sendGeometryEvent(); } void Client::slotScreenAdded(QScreen* screen) { KDRStdErr()<<"Add screen: "<geometry())<<" Dimensions(mm) "<physicalSize()); connect(screen, &QScreen::geometryChanged, this, &Client::geometryChanged); geometryChanged(); } void Client::slotScreenRemoved(QScreen* screen) { KDRStdErr()<<"Remove screen: "<geometry()); disconnect(screen, &QScreen::geometryChanged, this, &Client::geometryChanged); geometryChanged(); } void Client::sendGeometryEvent() { char evmsg[EVLENGTH]{}; uint16_t width, height; uint32_t etype; width=currentGeometry.size().width(); height=currentGeometry.size().height(); etype=GEOMETRY; memcpy(evmsg,(char*)&etype,4); memcpy(evmsg+4,(char*)&width,2); memcpy(evmsg+6,(char*)&height,2); //evmsg+8 - 1 byte, index of primary screen //start from evmsg+9 uint8_t i=0; for(;i<4;++i) { bool isPrimary=(i==primaryScreenIndex); QRect* scr=&ephyrScreens[i]; KDRStdErr()<<"X2GoKDrive-"<size().width()<<"x"<size().height()<<" "<topLeft().x()<<":"<topLeft().y()<<" isPrimary: "<size().width(); h=scr->size().height(); x=scr->topLeft().x(); y=scr->topLeft().y(); memcpy(evmsg+9+i*8, (char*)&w,2); memcpy(evmsg+9+i*8+2, (char*)&h,2); memcpy(evmsg+9+i*8+4, (char*)&x,2); memcpy(evmsg+9+i*8+6, (char*)&y,2); } else { KDRStdErr()<<"not supporting more then 4 displays yet, not sending this display to server"; } } sendEvent(evmsg); } void Client::sendClientVersion() { //sending the feature vesrion and OS version to the server char evmsg[EVLENGTH]{}; uint16_t version, os; uint32_t etype; version=FEATURE_VERSION; os=OS_LINUX; #ifdef Q_OS_WIN os=OS_WINDOWS; #endif #ifdef Q_OS_DARWIN os=OS_DARWIN #endif etype=CLIENTVERSION; memcpy(evmsg,(char*)&etype,4); memcpy(evmsg+4,(char*)&version,2); memcpy(evmsg+6,(char*)&os,2); KDRStdErr(false)<<"Sending version: "<getExtWinId(); uint32_t sibId=win->getNextSibId(); uint16_t x,y,w,h; uint8_t focus=win->getHasFocus(); QPoint kdrPoint=win->virtualToKdrivePosition(QPoint(win->geometry().topLeft())); x=kdrPoint.x(); y=kdrPoint.y(); w=win->geometry().width(); h=win->geometry().height(); etype=WINCHANGE; // KDRStdErr()<<"win geom "<screens()[0]->availableVirtualGeometry(); hide(); } else { newGeometry.setTopLeft(geometry().topLeft()); newGeometry.setSize(geometry().size()); } KDRStdErr()<<"geometry changed: "< screens=app->screens(); foreach(QScreen* screen, screens) { // KDRStdErr()<geometry()<geometry().intersects(newGeometry)) { QRect inter=newGeometry.intersected(screen->geometry()); newScreens[screenIndex++]=QRect(inter.topLeft().x()-newGeometry.topLeft().x(), inter.topLeft().y()-newGeometry.topLeft().y(), inter.width(), inter.height()); // KDRStdErr()<<"Virtual screen:"<primaryScreen()==screen) { if ( screenIndex != primaryScreenIndex) screensChanged=true; primaryScreenIndex=screenIndex; } //support max 4 screens now if(screenIndex>3) break; } } } else { newScreens[0].setX(0); newScreens[0].setY(0); newScreens[0].setSize(newGeometry.size()); } for(int i=0;i<4;++i) { if(newScreens[i].size()!=ephyrScreens[i].size()) screensChanged=true; ephyrScreens[i]=newScreens[i]; } bool geometryChanged=false; if(currentGeometry.size() != newGeometry.size()) { geometryChanged=true; } currentGeometry=newGeometry; if(!screensChanged && !geometryChanged) { return; } //Not really happy with this solution //if our size not changed we won't get randr screen changed event even if we change outputs geometry //so we first resize window with width-1 and then resize it to original size if(!geometryChanged) { // KDRStdErr()<<"Screen Changed without geometry, running resize hack!!!!!"; restoreGeometry=currentGeometry; currentGeometry.setWidth(currentGeometry.width()-1); QTimer::singleShot(100,this, &Client::resizeToOldSize); } sendGeometryEvent(); } void Client::setUseRandr(bool use) { if(use!=useRandr) { useRandr=use; geometryChanged(); } } void Client::send_selnotify_to_server(SelectionType selection, SelectionMime mime) { OutputChunk* chunk=new OutputChunk(selection, mime); chunk->firstChunk=chunk->lastChunk=true; //attach empty chunk to the end of output chunk queue addToSelectionOutput(chunk); //send this chunk sendOutputSelChunk(); } void Client::slotSelectionChanged(QClipboard::Mode mode) { #ifndef Q_OS_LINUX //we are not using QT Clipboard Class on Linux, seems that it has problems with INCR properties if(!connected) return; const QClipboard *clipboard = QGuiApplication::clipboard(); if(mode == QClipboard::Clipboard && clipboard->ownsClipboard()) return; if(mode == QClipboard::Selection && clipboard->ownsSelection()) return; const QMimeData *mimeData = clipboard->mimeData(mode); KDRStdErr()<<"selection changed for "<formats().join(", "); SelectionType destination=PRIMARY; if(mode== QClipboard::Clipboard) destination=CLIPBOARD; SelectionMime mime; if(mimeData->hasImage()) { KDRStdErr()<<"Have new Image"; mime=PIXMAP; } else if(mimeData->hasText()) { KDRStdErr()<<"Have new Text"; mime=UTF_STRING; } else { KDRStdErr()<<"Unsupported MIME type in clipboard"; return; } if(serverSupportsExtSelection()) { //send notify to server send_selnotify_to_server(destination,mime); } else { //send data to server sendSelectionToServer(destination); } #endif } #ifndef Q_OS_LINUX void Client::sendSelectionToServer(SelectionType selection) { //sending selection data to server if(!connected) return; const QClipboard *clipboard = QGuiApplication::clipboard(); QClipboard::Mode mode; if(selection==PRIMARY) mode= QClipboard::Selection; else mode =QClipboard::Clipboard; if(mode == QClipboard::Clipboard && clipboard->ownsClipboard()) return; if(mode == QClipboard::Selection && clipboard->ownsSelection()) return; const QMimeData *mimeData = clipboard->mimeData(mode); SelectionMime mime; QByteArray data; if(mimeData->hasImage()) { QBuffer buffer(&data); buffer.open(QIODevice::WriteOnly); QPixmap pix=clipboard->pixmap(mode); pix.save(&buffer, "PNG"); KDRStdErr()<<"Selection image size "<< data.size(); mime=PIXMAP; } else if(mimeData->hasText()) { data=clipboard->text(mode).toUtf8(); KDRStdErr()<<"Selection Text "<< data.size(); mime=UTF_STRING; } else { KDRStdErr()<<"Unsupported MIME type in clipboard"; return; } if(!data.size()) { KDRStdErr(false)<<"no data"<totalSize=data.size(); chunk->data=data; chunk->mimeData=mime; chunk->selection=selection; chunk->firstChunk=true; chunk->lastChunk=true; addToSelectionOutput(chunk); sendOutputSelChunk(); } #endif void Client::sendOutputSelChunk() { //sending the first chunk from output selection queue if(outputSelectionQueue.isEmpty()) return; OutputChunk* chunk=outputSelectionQueue.takeFirst(); if(!serverSupportsExtSelection() && (!chunk->firstChunk || !chunk->lastChunk)) { //selection has multiply chunks, but this server doesn't support ext selection, not sending anything KDRStdErr()<<"Server doesn't support extended selections"; delete chunk; return; } char evmsg[EVLENGTH]{}; uint32_t etype=SELECTIONEVENT; uint32_t size; uint8_t destination=chunk->selection; uint8_t mime=chunk->mimeData; uint8_t firstChunk=chunk->firstChunk; uint8_t lastChunk=chunk->lastChunk; uint32_t compressed_size=0; uint32_t totalSize=chunk->totalSize; size=chunk->data.size(); memcpy(evmsg,(char*)&etype,4); memcpy(evmsg+4,(char*)&size,4); memcpy(evmsg+8,(char*)&destination,1); memcpy(evmsg+9,(char*)&mime,1); //if server supports extended selection, sending extended header if(serverSupportsExtSelection()) { //if server supports it compress the big string data if(chunk->mimeData==UTF_STRING && serverSupportsExtSelection() && size >1024) { chunk->data=qCompress(chunk->data); //Qt puting uncompressed size of data in the first 4 bytes of buffer, we won't send them compressed_size=chunk->data.size()-4; } memcpy(evmsg+10,(char*)&firstChunk,1); memcpy(evmsg+11,(char*)&lastChunk,1); memcpy(evmsg+12,(char*)&compressed_size,4); memcpy(evmsg+16,(char*)&totalSize,4); // KDRStdErr()<<"size of chunk: "<data.data(); if(compressed_size) { //sending data compressed data_ptr+=4;//don't send first 4 bytes size=compressed_size; } uint32_t sentData=(size < EVLENGTH-headerSize)?size:EVLENGTH-headerSize; memcpy(evmsg+headerSize,data_ptr,sentData); sendEvent(evmsg); while(sentDatarepaint(0, 0, displayArea->width(), displayArea->height()); serverFramePackets.clear(); serverRepaintPackets.clear(); KDRStdErr(false)<<"Done"<=lastServerPacketTime) { KDRStdErr()<<"Didn't recive any data from server since "<start(SERVERALIVETIMEOUT*1000); } void Client::requestUdpFrames() { if(udpConnectionAttempts>=3) { KDRStdErr()<<"Failed to establish UDP connection, continue over TCP"<connectToHost(udpHost, udp_port); if(!udpSocket->waitForConnected(3000)) { KDRStdErr(false)<<"Warning, can't establish UDP connection"<write((char*)tmp_cookie,8*4); } } #ifdef Q_OS_WIN bool Client::nativeEvent(const QByteArray &eventType, void *message, long *result) { if(eventType=="windows_generic_MSG" && !rootless) { MSG* ev = static_cast(message); switch((ev->message)) { case WM_SETFOCUS: case WM_KILLFOCUS: //try to repaint the window to avoid update errors on Windows QTimer::singleShot(500, displayArea, SLOT(repaint())); break; } } return QMainWindow::nativeEvent(eventType, message, result); } #endif //Q_OS_WIN x2gokdriveclient-0.0.0.1/src/client.h0000644000000000000000000003043714441666201014250 0ustar /* * QT Client for X2GoKDrive * Copyright (C) 2018-2023 Oleksandr Shneyder * Copyright (C) 2018-2023 phoca-GmbH * * 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 3 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, see . * */ #ifndef CLIENT_H #define CLIENT_H #define KDRStdErr(a) Client::KDRStdErrFunc(a)<<__FILE__<<":"<< __LINE__<<":"<< __func__<<"(): " //FEATURE_VERSION is not cooresponding to actual version of client //it used to tell server which features are supported by client //Changes 1 - 2: supporting extended selection and sending selection on demand //Changes 2 - 3: support UDP protocol, sending keep alive packets #define FEATURE_VERSION 3 //Version of client OS for same reason enum OS_VERSION{OS_LINUX, OS_WINDOWS, OS_DARWIN}; #define EVLENGTH 41 #define Button1Mask (1<<8) #define Button2Mask (1<<9) #define Button3Mask (1<<10) #define Button4Mask (1<<11) #define Button5Mask (1<<12) #define Button1 1 #define Button2 2 #define Button3 3 #define Button4 4 #define Button5 5 //Events #define KEYPRESS 2 #define KEYRELEASE 3 #define MOUSEPRESS 4 #define MOUSERELEASE 5 #define MOUSEMOTION 6 #define GEOMETRY 7 #define UPDATE 8 #define SELECTIONEVENT 9 #define CLIENTVERSION 10 #define DEMANDSELECTION 11 #define KEEPALIVE 12 #define CACHEREBUILD 13 #define WINCHANGE 14 //client is going to disconnect #define DISCONNECTCLIENT 15 //ask to resend particular frame #define RESENDFRAME 16 //client is requesting UDP port for frames #define OPENUDP 17 #define ShiftMask (1<<0) #define LockMask (1<<1) #define ControlMask (1<<2) #define Mod1Mask (1<<3) #define Mod2Mask (1<<4) #define Mod3Mask (1<<5) #define Mod4Mask (1<<6) #define Mod5Mask (1<<7) #ifdef Q_OS_WIN #define WINCAPS 256 #define WINNUM 512 #endif #define HEADER_SIZE 56 #define REGION_HEADER 64 //max size for UDP dgram #define UDPDGRAMSIZE 1200 //UDP Server DGRAM Header - 4B checksum + 2B packet seq number + 2B amount of datagrams + 2B datagram seq number + 1B type #define SRVDGRAMHEADERSIZE (4+2+2+2+1) //check if server is alive every 30 seconds #define SERVERALIVETIMEOUT 30//sec //Types for UDP datagrams enum ServerDgramType{ ServerFramePacket, //dgram belongs to packet representing frame ServerRepaintPacket, // dgram belongs to packet with screen repaint and the loss can be ignored }; enum SelectionMime{STRING,UTF_STRING,PIXMAP}; enum WinState{UNCHANGED, DELETED, ICONIFIED}; enum SelectionType{PRIMARY,CLIPBOARD}; enum ClipboardMode{CLIP_BOTH, CLIP_SERVER, CLIP_CLIENT, CLIP_NONE}; enum WinType{WINDOW_TYPE_DESKTOP, WINDOW_TYPE_DOCK, WINDOW_TYPE_TOOLBAR, WINDOW_TYPE_MENU, WINDOW_TYPE_UTILITY, WINDOW_TYPE_SPLASH, WINDOW_TYPE_DIALOG, WINDOW_TYPE_DROPDOWN_MENU, WINDOW_TYPE_POPUP_MENU, WINDOW_TYPE_TOOLTIP, WINDOW_TYPE_NOTIFICATION, WINDOW_TYPE_COMBO, WINDOW_TYPE_DND, WINDOW_TYPE_NORMAL}; #include #include #include #include #include #include #ifdef Q_OS_LINUX class XCBClip; #endif #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) #define KDR_ENDL Qt::endl>>Qt::dec #define KDR_HEX Qt::hex #define KDR_DEC Qt::dec #else #define KDR_ENDL endl>>dec #define KDR_HEX hex #define KDR_DEC dec #endif class FrameRegion { public: FrameRegion(uint32_t source_crc, int32_t source_x, int32_t source_y, int32_t x, int32_t y, uint32_t width, uint32_t height, uint32_t dataSize); ~FrameRegion(); uint32_t source_crc, width, height, dataSize; int32_t source_x, source_y, x, y; QPixmap pix; }; class Frame { public: Frame(uint32_t width, uint32_t height, int32_t x, int32_t y, uint32_t numOfRegions, uint32_t crc, uint32_t winId); ~Frame(); uint32_t width, height, crc, numOfRegions, winId; int32_t x, y; QVector regions; }; class X2GoCursor { public: X2GoCursor(uint16_t width, uint16_t height, uint16_t xhot, uint16_t yhot,uint32_t serialNumber, uint32_t dataSize); ~X2GoCursor(); uint16_t xhot; uint16_t yhot; uint32_t serialNumber; uint32_t dataSize; uint16_t width; uint16_t height; }; class OutputChunk { public: OutputChunk(SelectionType selection, SelectionMime mimeType); QByteArray data; enum SelectionMime mimeData; bool firstChunk=false; bool lastChunk=false; uint32_t totalSize=0; enum SelectionType selection; }; class DgramPacket { public : DgramPacket(uint16_t seq, uint16_t numOfDatagrams); bool isComplete(){return complete;} bool addDgram(QByteArray dgram); int getNumberOfDatagrams(){return datagrams.size();}; QByteArray getData(){return data;}; uint16_t getPacketSeq(){return packetSeq;}; private: bool complete=false; QVector datagrams; QByteArray data; uint16_t packetSeq; }; class DisplayArea; class QTimer; class MenuFrame; class QMenu; class QAction; class QLabel; class ScreenIdentifier; class ExtWin; class QTcpSocket; class QUdpSocket; class Client : public QMainWindow { Q_OBJECT public: Client(); ~Client(); void sendEvent(char *event); Frame* getCurrentFrame(){return currentFrame;} bool needUpdate(){return wantRepaint;} void setUptodate(); QPixmap getPixmapFromCache(uint32_t crc); QPixmap addPixmapToCache(); bool isDisplayPointer(QMouseEvent* event); void addToSelectionOutput(OutputChunk* chunk); bool serverSupportsExtSelection(){return serverExtSelection;} ClipboardMode clipboardMode(){return clipMode;} void requestSelectionFromServer(SelectionType sel); void send_selnotify_to_server(SelectionType selection, SelectionMime mime); int max_chunk(); static QByteArray zuncompress(const char* data, uint compressed_size, uint size); static QTextStream& KDRStdErrFunc(bool dbg=true); static QString QRectToStr(const QRect& rec); static QString QSizeToStr(const QSizeF& sz); void changeWindow(ExtWin* win, uint8_t newState=UNCHANGED); bool isRootless(){return rootless;} const QList getExtWindows(){return extWindows;} const QList getSiblings(ExtWin* win); ExtWin* findExtWinById(uint32_t extWinId); QImage* getDisplayImage(){return &displayImage;} void repaintAllWindows(); quint16 getPublicServerVersion(){return serverVersion;} public slots: void sendOutputSelChunk(); private slots: void sendClientVersion(); void slotIdentifyScreen(); void connectToServer(); void socketConnected(); void socketDisconnected(); void socketError(QAbstractSocket::SocketError socketError); void dataArrived(); void UDPDataArrived(); void slotSynchronize(); void slotScreenAdded(QScreen* screen); void slotScreenRemoved(QScreen* screen); void geometryChanged(); void resizeToOldSize(); void resizeToFS(); void resizeToSaved(); void slotSetupMenu(); void slotDisconnect(); void slotFS(); void slotRealFs(); void slotRestore(); void slotDisplayFS(); void slotEnableRandr(); void slotResizeFSFinal(); void slotSelectionChanged(QClipboard::Mode mode); void requestCacheRebuild(); void checkServerVersion(); void slotCheckIfServerIsAlive(); public slots: void editWindowTitle(); private: enum{ HEADER, FRAMEREGION, REGIONDATA ,CURSORDATA, CURSORLIST, FRAMELIST, SELECTIONBUFFER, WINUPDATEBUFFER } currentDataType; enum HeaderType{ FRAME, DELETEDFRAMES, CURSOR, DELETEDCURSORS, SELECTION, SERVER_VERSION, DEMANDCLIENTSELECTION, REINIT, WINUPDATE, SRVKEEPALIVE, SRVDISCONNECT, CACHEFRAME, UDPOPEN, UDPFAILED}; void getServerversion(); void getClientSelection(); void setUseRandr(bool use); void exitOnError(const QString& message); void getImageFrame(); void getImageFrameFromDGPacket(QByteArray data); void readDataHeader(); void getFrameRegion(); void getRegionImage(); void getCursor(); void getCursorImage(); void getDeletedFrames(); void getDeletedCursors(); void getDeletedFramesList(); void getDeletedCursorsList(); void getSelection(); void getSelectionBuffer(); void getWinUpdate(); void getWinUpdateBuffer(); void renderFrame(); void requestUdpFrames(); void openUdpConnection(); void freeMessageBuffer(); void setCursor(); void sendGeometryEvent(); void setFS(int screenNumber); void reinitCaches(); void initGeometry(); void setDisplayImage(); void readDgram(); void requestFrame(uint32_t crc); int findPacket(QList* list, uint16_t seq); void updateServerAlive(); bool wantRepaint=false; bool hasUpdates=false; #ifndef Q_OS_LINUX void sendSelectionToServer(SelectionType selection); void setInputSelectionData(SelectionType selection, SelectionMime mime, bool firstChunk, bool lastChunk, uint32_t compressed, uint size, char* data, bool notify=false); #endif void parseOptions(); void initDesktopMode(); QImage displayImage; static bool debug; //initial values int width=800; int height=600; QString host="localhost"; QString udpHost="localhost"; int port=15000; //feature version of server quint16 serverVersion=0; bool fullscreen=false; bool multidisp=false; int dispNumber=1; bool serverExtSelection=false; bool rootless=false; bool udpFrames=false; int udpConnectionAttempts=0; time_t lastServerPacketTime=0; bool noresize=false; QString cookie; QString mainWndTitle; MenuFrame *FSMenuBar; QMenu* menu; QAction* actRandr; QAction* actFS; QAction* actDisp[4]; QAction* actRestore; QAction* actDisconnect; bool wasInRealFs=false; DisplayArea* displayArea=0l; Frame* currentFrame=0; X2GoCursor* currentCursor=0l; int currentRegionNumber=0; bool useRandr=false; bool isFs=false; int FSScreen=-1; QSize savedSize; QPoint savedPosition; Qt::WindowFlags savedFlags; QTcpSocket* clientSocket=0l; QUdpSocket* udpSocket=0l; int bytesLeftToRead=0; int bytesReady=0; char* messageBuffer=0l; bool connected=false; //input selection chunk variables //size of current chunk uint32_t selectionSize; //size of complete selection uint32_t selectionTotalSize; //format of chunk, string or pix SelectionMime selectionFormat; //if true clipboard else primary SelectionType selectionClipboard; //if it's the first chunk in multiply sel bool firstChunk; //if it's the last chunk in multiply sel bool lastChunk; //if the chunk compressed the size is > 0 uint32_t compressed_size; ////////// ClipboardMode clipMode=CLIP_BOTH; //clipboard mode: both, server, client or none uint32_t deletedFramesSize=0; uint32_t deletedCursorsSize=0; int winUpdateSize=0; QHash frameCache; QHash cursorCache; QList outputSelectionQueue; QList extWindows; QList serverFramePackets, serverRepaintPackets; //last succesfully processed frame packet sequence uint16_t serverFrameSeq=0-1; //last succesfully processed repaint packet sequence uint16_t serverRepaintSeq=0-1; int frameCount=0; QTimer* geometryDelay=0l; QTimer* checkSrvAliveTimer=0l; QRect currentGeometry; QRect restoreGeometry; QRect ephyrScreens[4]; int primaryScreenIndex=0; int cacheSize=0; ScreenIdentifier *screenIdentifier=0l; QLabel* fr; //selection #ifdef Q_OS_LINUX XCBClip* clipboard; #else SelectionMime selMime; //mime of selection (string or image) QByteArray selData; //data uint32_t total_compressed=0; #endif protected: void resizeEvent(QResizeEvent*); void moveEvent(QMoveEvent*); void closeEvent(QCloseEvent* ); #ifdef Q_OS_WIN bool nativeEvent(const QByteArray &eventType, void *message, long *result); #endif }; #endif // CLIENT_H x2gokdriveclient-0.0.0.1/src/displayarea.cpp0000644000000000000000000004651414441666201015626 0ustar /* * QT Client for X2GoKDrive * Copyright (C) 2018-2023 Oleksandr Shneyder * Copyright (C) 2018-2023 phoca-GmbH * * 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 3 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, see . * */ #include "displayarea.h" #include "extwin.h" #include #include #include #include #include #include #include #include #include "client.h" #ifdef Q_OS_LINUX #include #include #endif #ifdef Q_OS_WIN static DisplayArea* display=0; LRESULT CALLBACK LowLevelKeyboardProc( _In_ int nCode, _In_ WPARAM wParam, _In_ LPARAM lParam ) { if(!display->hasFocus()) { // Client::KDRStdErr()<<"Not in focus, not processing events"; return CallNextHookEx(0, nCode, wParam,lParam); } if(nCode<0) { // Client::KDRStdErr()<<"Not processing this event"; return CallNextHookEx(0, nCode, wParam,lParam); } uint32_t etype=KEYPRESS; KBDLLHOOKSTRUCT* str= (KBDLLHOOKSTRUCT*) lParam; if((str->flags&LLKHF_ALTDOWN) && (str->vkCode == VK_TAB || str->vkCode == VK_F4)) { uint32_t key= DisplayArea::win2pc105(str->scanCode); uint32_t mods=0; mods|=Mod1Mask; switch(wParam) { case WM_KEYDOWN: case WM_SYSKEYDOWN: etype=KEYPRESS; // Client::KDRStdErr()<<"KEYPRESS: System alt+TAB"<client->sendEvent(evmsg); //send key release immediately after key press to avoid key sticking //server with version > 6 will do it automatically if(etype==KEYPRESS && display->client->getPublicServerVersion()<7) { etype=KEYRELEASE; memcpy(evmsg,(char*)&etype,4); memcpy(evmsg+4,(char*)&mods,4); memcpy(evmsg+8,(char*)&key,4); display->client->sendEvent(evmsg); } return -1; } return CallNextHookEx(0, nCode, wParam, lParam); } #endif DisplayArea::DisplayArea(Client* client, QWidget* parentWidget):QFrame(parentWidget) { this->client=client; this->parentWidget=parentWidget; setMouseTracking(true); setFocusPolicy(Qt::StrongFocus); if(!client->isRootless()) grabKeyboard(); } void DisplayArea::grabKeyboard() { #ifdef Q_OS_LINUX Client::KDRStdErr()<<"Grab X11 Keyboard"<needUpdate()) { Frame* currentFrame=client->getCurrentFrame(); QPixmap pix; if(!currentFrame->crc) { // Client::KDRStdErr()<<"Draw DISPLAY PIX "<regions[0]->pix; // disp=true; } else { // Client::KDRStdErr()<<"Draw PIX from cache"<getPixmapFromCache(currentFrame->crc); if(pix.isNull()) { KDRStdErr()<<"Replacing with display image"<getDisplayImage()); pix=disp.copy(currentFrame->x, currentFrame->y, currentFrame->width, currentFrame->height); } } if(currentFrame->x==-1 || currentFrame->y==-1) { currentFrame->x=currentFrame->y=0; } if(!client->isRootless()) { // if(!disp) { painter.drawPixmap(currentFrame->x,currentFrame->y,pix); } // else // { // painter.drawPixmap(currentFrame->x,currentFrame->y,pix,currentFrame->x,currentFrame->y,currentFrame->width,currentFrame->height); // dispImagePainter.drawPixmap(currentFrame->x,currentFrame->y,pix,currentFrame->x,currentFrame->y,currentFrame->width,currentFrame->height); // } } else { // if(!disp) { ExtWin* parWin=(ExtWin*)parentWidget; QPoint kdrPos=parWin->virtualToKdrivePosition(parWin->geometry().topLeft()); painter.drawPixmap(currentFrame->x-kdrPos.x(),currentFrame->y-kdrPos.y(),pix); // Client::KDRStdErr()<<"DRAW pix on: "<x-kdrPos.x()<<":"<y-kdrPos.y()<x-((ExtWin*)parentWidget)->adjustGeometry().x(),currentFrame->y-((ExtWin*)parentWidget)->adjustGeometry().y(),pix, // currentFrame->x,currentFrame->y,ev->rect().width(),ev->rect().height()); // dispImagePainter.drawPixmap(currentFrame->x-((ExtWin*)parentWidget)->adjustGeometry().x(),currentFrame->y-((ExtWin*)parentWidget)->adjustGeometry().y(),pix, // currentFrame->x,currentFrame->y,ev->rect().width(),ev->rect().height()); // } } } else { if(!client->isRootless()) { // Client::KDRStdErr()<<"WM update: "<rect())<rect(),*(client->getDisplayImage()),ev->rect()); } else { // if(((ExtWin*)parentWidget)->getWindowType()==WINDOW_TYPE_NORMAL) // Client::KDRStdErr()<<"WM update: "<rect())<virtualToKdrivePosition(parWin->geometry().topLeft()); painter.drawImage(ev->rect().x(),ev->rect().y(), *(client->getDisplayImage()), ev->rect().x()+kdrPos.x(), ev->rect().y()+kdrPos.y(), ev->rect().width(), ev->rect().height()); } } painter.end(); } uint32_t DisplayArea::X11MouseButtonsState(Qt::MouseButtons qtMouseButtons) { uint32_t x11Buttons=0; if(qtMouseButtons&Qt::LeftButton) { x11Buttons|=Button1Mask; } if(qtMouseButtons&Qt::RightButton) { x11Buttons|=Button3Mask; } if(qtMouseButtons&Qt::MiddleButton) { x11Buttons|=Button2Mask; } return x11Buttons; } uint32_t DisplayArea::X11MouseButton(Qt::MouseButton qtMouseButton) { switch(qtMouseButton) { case Qt::LeftButton: return Button1; case Qt::RightButton: return Button3; case Qt::MidButton: return Button2; default: return 0; } } void DisplayArea::mouseMoveEvent(QMouseEvent* event) { if(!client->isDisplayPointer(event)) return; char evmsg[EVLENGTH]={}; uint32_t etype, x, y; etype=MOUSEMOTION; // Client::KDRStdErr()<<"kbd mods"<modifiers(); if(!client->isRootless()) { x=event->x(); y=event->y(); } else { ExtWin* w=(ExtWin*) parentWidget; QPoint parTopLeft=w->virtualToKdrivePosition(w->geometry().topLeft()); x=event->x()+parTopLeft.x(); y=event->y()+parTopLeft.y(); } memcpy(evmsg,(char*)&etype,4); memcpy(evmsg+4,(char*)&x,4); memcpy(evmsg+8,(char*)&y,4); client->sendEvent(evmsg); // Client::KDRStdErr()<<"mouse move"<x()<y(); } void DisplayArea::mousePressEvent(QMouseEvent* event) { // Client::KDRStdErr()<<"kbd mods"<modifiers(); char evmsg[EVLENGTH]={}; uint32_t etype, state, button; etype=MOUSEPRESS; state=X11MouseButtonsState(event->buttons()); button=X11MouseButton(event->button()); state|=qtModifiers2pc105(event->modifiers()); memcpy(evmsg,(char*)&etype,4); memcpy(evmsg+4,(char*)&state,4); memcpy(evmsg+8,(char*)&button,4); client->sendEvent(evmsg); // Client::KDRStdErr()<<"mouse press"<button()<buttons()<modifiers(); char evmsg[EVLENGTH]={}; uint32_t etype, state, button; etype=MOUSERELEASE; state=X11MouseButtonsState(event->buttons()); button=X11MouseButton(event->button()); state|=qtModifiers2pc105(event->modifiers()); memcpy(evmsg,(char*)&etype,4); memcpy(evmsg+4,(char*)&state,4); memcpy(evmsg+8,(char*)&button,4); client->sendEvent(evmsg); // Client::KDRStdErr()<<"mouse release"<button()<buttons()<buttons()<angleDelta(); char evmsg[EVLENGTH]={}; uint32_t etype, state, button; if(event->angleDelta().y() > 0) { button=Button4; } else { button=Button5; } etype=MOUSEPRESS; state=0; state|=qtModifiers2pc105(event->modifiers()); memcpy(evmsg,(char*)&etype,4); memcpy(evmsg+4,(char*)&state,4); memcpy(evmsg+8,(char*)&button,4); // Client::KDRStdErr()<sendEvent(evmsg); etype=MOUSERELEASE; state=X11MouseButtonsState(event->buttons()); if(event->angleDelta().y() > 0) { button=Button4; state|=Button4Mask; } else { button=Button5; state|=Button5Mask; } state|=qtModifiers2pc105(event->modifiers()); memcpy(evmsg,(char*)&etype,4); memcpy(evmsg+4,(char*)&state,4); memcpy(evmsg+8,(char*)&button,4); // Client::KDRStdErr()<sendEvent(evmsg); } /* void DisplayArea::debugLinuxMods(uint32_t nativeModifiers) { if(nativeModifiers&ShiftMask) Client::KDRStdErr()<<"shift"; if(nativeModifiers&ControlMask) Client::KDRStdErr()<<"ctrl"; if(nativeModifiers&LockMask) Client::KDRStdErr()<<"lock"; if(nativeModifiers&Mod1Mask) Client::KDRStdErr()<<"mod1"; if(nativeModifiers&Mod2Mask) Client::KDRStdErr()<<"mod2"; if(nativeModifiers&Mod3Mask) Client::KDRStdErr()<<"mod3"; if(nativeModifiers&Mod4Mask) Client::KDRStdErr()<<"mod4"; if(nativeModifiers&Mod5Mask) Client::KDRStdErr()<<"mod5"; if(nativeModifiers&WINCAPS) Client::KDRStdErr()<<"win caps"; if(nativeModifiers&WINNUM) Client::KDRStdErr()<<"win num"; } */ void DisplayArea::keyPressEvent(QKeyEvent* event) { // Client::KDRStdErr()<<"Press key:"<key()<< // "nat scan:"<nativeScanCode()<<"nat vkey:"<nativeVirtualKey()<<"text:"<text(); // debugLinuxMods(event->nativeModifiers()); // Client::KDRStdErr()<nativeScanCode(); state=event->nativeModifiers(); #else key=win2pc105(event->nativeScanCode()); state=qtwinModifiers2pc105(event->nativeModifiers(), event->modifiers()); #endif etype=KEYPRESS; memcpy(evmsg,(char*)&etype,4); memcpy(evmsg+4,(char*)&state,4); memcpy(evmsg+8,(char*)&key,4); client->sendEvent(evmsg); //send key release immediately after key press to avoid key sticking //server with version > 6 will do it automatically if(client->getPublicServerVersion()<7) { etype=KEYRELEASE; memcpy(evmsg,(char*)&etype,4); memcpy(evmsg+4,(char*)&state,4); memcpy(evmsg+8,(char*)&key,4); client->sendEvent(evmsg); } } void DisplayArea::keyReleaseEvent(QKeyEvent* event) { char evmsg[EVLENGTH]={}; uint32_t state, key, etype; #ifdef Q_OS_LINUX key=event->nativeScanCode(); state=event->nativeModifiers(); #else key=win2pc105(event->nativeScanCode()); state=qtwinModifiers2pc105(event->nativeModifiers(), event->modifiers()); #endif //only send additional release event if modifier is set #ifndef Q_OS_WIN if(!state) return; #endif // Client::KDRStdErr()<<"RELEASE key:"<key()<< // "nat scan:"<nativeScanCode()<<"nat vkey:"<nativeVirtualKey()<<"text:"<text(); // debugLinuxMods(event->nativeModifiers()); // Client::KDRStdErr()<sendEvent(evmsg); } uint32_t DisplayArea::qtModifiers2pc105(Qt::KeyboardModifiers qtModifiers) { uint32_t mods=0; if(qtModifiers&Qt::ShiftModifier) { mods|=ShiftMask; } if(qtModifiers&Qt::MetaModifier) { mods|=Mod4Mask; } if(qtModifiers&Qt::GroupSwitchModifier) { mods|=Mod5Mask; } if(qtModifiers&Qt::ControlModifier && qtModifiers&Qt::AltModifier) { mods|=Mod5Mask; } else { if(qtModifiers&Qt::ControlModifier) { mods|=ControlMask; } if(qtModifiers&Qt::AltModifier) { mods|=Mod1Mask; } } return mods; } #ifdef Q_OS_WIN uint32_t DisplayArea::qtwinModifiers2pc105(uint32_t nativeModifiers, Qt::KeyboardModifiers qtModifiers ) { uint32_t mods=0; if(nativeModifiers&WINCAPS) { mods|=LockMask; } if(nativeModifiers&WINNUM) { mods|=Mod2Mask; } return mods|qtModifiers2pc105(qtModifiers); } uint32_t DisplayArea::win2pc105(uint32_t nativeCode) { switch(nativeCode) { case 347: return 133; //WINL case 312: return 108; //ALTR case 348: return 134; //WINR case 349: return 135; //OPT case 285: return 105; //CTRR case 338: return 118; //INS case 327: return 110; //HOME case 329: return 112; //PGUP case 339: return 119; //DEL case 335: return 115; //END case 337: return 117; //PGDN //ARROWS case 328: return 111; //UP case 336: return 116; //DOWN case 331: return 113; //LEFT case 333: return 114; //RIGHT //NUMPAD case 325: return 77; //NLOCK case 309: return 106; // / case 55: return 63; // * case 74: return 82; // - case 71: return 79; // 7 case 72: return 80; // 8 case 73: return 81; // 9 case 75: return 83; // 4 case 76: return 84; // 5 case 77: return 85; // 6 case 78: return 86; // + case 79: return 87; // 1 case 80: return 88; // 2 case 81: return 89; // 3 case 82: return 90; // 0 case 83: return 91; // , case 284: return 104; // ENTER*/ default: return nativeCode+8; } } #endif //Q_OS_WIN /* case 1: return 0; //ESC * case 59: return 0; //F1 * case 60: return 0; //F2 * case 61: return 0; //F3 * case 62: return 0; //F4 * case 63: return 0; //F5 * case 64: return 0; //F6 * case 65: return 0; //F7 * case 66: return 0; //F8 * case 67: return 0; //F9 * case 68: return 0; //F10 * case 87: return 0; //F11 * case 88: return 0; //F12 * * case 1: return 0; //print * case 70: return 0; //scroll * case 1: return 0; //Break * * case 41: return 0; //^ * case 2: return 0; //1 * case 3: return 0; //2 * case 4: return 0; //3 * case 5: return 0; //4 * case 6: return 0; //5 * case 7: return 0; //6 * case 8: return 0; //7 * case 9: return 0; //8 * case 10: return 0; //9 * case 11: return 0; //0 * case 12: return 0; //ß * case 13: return 0; //´ * case 14: return 0; //BSP * * case 15: return 0; //TAB * case 16: return 0; //q * case 17: return 0; //w * case 18: return 0; //e * case 19: return 0; //r * case 20: return 0; //t * case 21: return 0; //z * case 22: return 0; //u * case 23: return 0; //i * case 24: return 0; //o * case 25: return 0; //p * case 26: return 0; //ü * case 27: return 0; //+ * case 28: return 0; //ENTER * * case 58: return 0; //CAPS * case 30: return 0; //a * case 31: return 0; //s * case 32: return 0; //d * case 33: return 0; //f * case 34: return 0; //g * case 35: return 0; //h * case 36: return 0; //j * case 37: return 0; //k * case 38: return 0; //l * case 39: return 0; //ö * case 40: return 0; //ä * case 43: return 0; //# * * case 42: return 0; //SHIFTL * case 86: return 0; //< * case 44: return 0; //y * case 45: return 0; //x * case 46: return 0; //c * case 47: return 0; //v * case 48: return 0; //b * case 49: return 0; //n * case 50: return 0; //m * case 51: return 0; //, * case 52: return 0; //. * case 53: return 0; //- * case 54: return 0; //SHIFTR * * case 29: return 0; //CTRL * case 347: return 0; //WINL * case 56: return 0; //ALTL * case 57: return 0; //SPS * case 312: return 0; //ALTR * case 348: return 0; //WINR * case 349: return 0; //OPT * case 285: return 0; //CTRR * * case 338: return 0; //INS * case 327: return 0; //HOME * case 329: return 0; //PGUP * case 339: return 0; //DEL * case 335: return 0; //END * case 337: return 0; //PGDN * * //ARROWS * case 328: return 0; //UP * case 336: return 0; //DOWN * case 331: return 0; //LEFT * case 333: return 0; //RIGHT * * //NUMPAD * case 325: return 0; //NLOCK * case 309: return 0; // / * case 55: return 0; // * * case 74: return 0; // - * * case 71: return 0; // 7 * case 72: return 0; // 8 * case 73: return 0; // 9 * * case 75: return 0; // 4 * case 76: return 0; // 5 * case 77: return 0; // 6 * case 78: return 0; // + * * case 79: return 0; // 1 * case 80: return 0; // 2 * case 81: return 0; // 3 * * case 82: return 0; // 0 * case 83: return 0; // , * case 284: return 0; // ENTER*/ x2gokdriveclient-0.0.0.1/src/displayarea.h0000644000000000000000000000403214441666201015260 0ustar /* * QT Client for X2GoKDrive * Copyright (C) 2018-2023 Oleksandr Shneyder * Copyright (C) 2018-2023 phoca-GmbH * * 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 3 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, see . * */ #ifndef DISPLAYAREA_H #define DISPLAYAREA_H #include #ifdef Q_OS_WIN #include #endif class Client; class QPainter; class QTimer; class DisplayArea : public QFrame { #ifdef Q_OS_WIN friend LRESULT CALLBACK LowLevelKeyboardProc(_In_ int nCode, _In_ WPARAM wParam, _In_ LPARAM lParam ); #endif Q_OBJECT public: DisplayArea(Client* client, QWidget* parentWidget); ~DisplayArea(); private: Client* client; QWidget* parentWidget; protected: void paintEvent(QPaintEvent *); void mouseMoveEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); void keyPressEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event); void wheelEvent(QWheelEvent *event); private: uint32_t X11MouseButtonsState(Qt::MouseButtons qtMouseButtons); uint32_t X11MouseButton(Qt::MouseButton qtMouseButton); // void debugLinuxMods(uint32_t nativeModifiers); uint32_t qtModifiers2pc105(Qt::KeyboardModifiers qtModifiers ); void grabKeyboard(); #ifdef Q_OS_WIN static uint32_t win2pc105(uint32_t nativeCode); uint32_t qtwinModifiers2pc105(uint32_t nativeModifiers, Qt::KeyboardModifiers qtModifiers ); #endif }; #endif // DISPLAYAREA_H x2gokdriveclient-0.0.0.1/src/extwin.cpp0000644000000000000000000004157314441666201014646 0ustar /* * QT Client for X2GoKDrive * Copyright (C) 2018-2023 Oleksandr Shneyder * Copyright (C) 2018-2023 phoca-GmbH * * 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 3 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, see . * */ #include "extwin.h" #include "displayarea.h" #include "client.h" #include #include #include #include #ifdef Q_OS_WIN #include #endif ExtWin::ExtWin(uint32_t extWinId, Client *client, QWidget* parent, uint8_t wt, Qt::WindowFlags flags): QMainWindow(parent, flags) { changeTimer=new QTimer(this); changeTimer->setSingleShot(true); connect(changeTimer, SIGNAL(timeout()), this, SLOT(slotChangeWin())); displayArea=new DisplayArea((Client*)client,this); displayArea->setObjectName("DisplayArea"); // displayArea->setStyleSheet("QFrame#DisplayArea{background-color:black;}"); displayArea->show(); setCentralWidget(displayArea); setWindowIcon(QIcon(":/img/png/x2goclient.png")); this->extWinId=extWinId; this->client=client; windowType=wt; #ifdef Q_OS_WIN if((windowType!=WINDOW_TYPE_NORMAL) && (windowType!=WINDOW_TYPE_DIALOG)) QTimer::singleShot(10,this,SLOT(slotSetTaskbar())); else QTimer::singleShot(10,this,SLOT(slotSetWinWindow())); #endif #ifdef Q_OS_LINUX switch(windowType) { case WINDOW_TYPE_DROPDOWN_MENU: setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu); break; case WINDOW_TYPE_POPUP_MENU: setAttribute(Qt::WA_X11NetWmWindowTypePopupMenu); break; case WINDOW_TYPE_DIALOG: setAttribute(Qt::WA_X11NetWmWindowTypeDialog); break; case WINDOW_TYPE_TOOLTIP: setAttribute(Qt::WA_X11NetWmWindowTypeToolTip); break; case WINDOW_TYPE_UTILITY: setAttribute(Qt::WA_X11NetWmWindowTypeUtility); break; } #endif setFocusPolicy(Qt::NoFocus); } #ifdef Q_OS_WIN void ExtWin::slotSetTaskbar() { HWND hWnd=(HWND)winId(); // Client::KDRStdErr()<<"HWND "<resize(w,h); } void ExtWin::moveWinFromServer(QPoint p) { ignoreGeometryChangeEvent=true; move(p); ignoreGeometryChangeEvent=false; } void ExtWin::slotChangeWin() { client->changeWindow(this); } void ExtWin::moveEvent(QMoveEvent* ev) { if(((windowType == WINDOW_TYPE_NORMAL)||(windowType == WINDOW_TYPE_DIALOG))&&(!ignoreGeometryChangeEvent && ! isChanging)) { #ifdef Q_OS_WIN slotChangeWin(); #else changeTimer->start(50); #endif } QMainWindow::moveEvent(ev); } void ExtWin::closeEvent(QCloseEvent* ev) { if((windowType == WINDOW_TYPE_NORMAL)||(windowType == WINDOW_TYPE_DIALOG)) { // Client::KDRStdErr()<<"Request window close "; client->changeWindow(this,DELETED); ev->ignore(); } } void ExtWin::resizeEvent(QResizeEvent* ev) { if(((windowType == WINDOW_TYPE_NORMAL)||(windowType == WINDOW_TYPE_DIALOG))&&!isChanging) { #ifdef Q_OS_WIN displayArea->hide(); setWindowOpacity(0.2); #endif slotChangeWin(); slotChangeWin(); #ifdef Q_OS_WIN QTimer::singleShot(200, this, SLOT(slotRestoreWin())); #endif } QMainWindow::resizeEvent(ev); } void ExtWin::showEvent(QShowEvent *ev) { QMainWindow::showEvent(ev); if((windowType == WINDOW_TYPE_NORMAL)||(windowType == WINDOW_TYPE_DIALOG)) { // Client::KDRStdErr()<<"Show "<getExtWindows()) { if(w->transWinId==extWinId) w->raise(); } QTimer::singleShot(5,this,SLOT(slotCheckStackOrder())); } } void ExtWin::hideEvent(QHideEvent *ev) { QMainWindow::hideEvent(ev); if(((windowType == WINDOW_TYPE_NORMAL)||(windowType == WINDOW_TYPE_DIALOG))&&isMinimized()) { // Client::KDRStdErr()<<"Request window minimize"; client->changeWindow(this,ICONIFIED); foreach(ExtWin* w, client->getExtWindows()) { if(w->transWinId==extWinId) w->showMinimized(); if(w->extWinId==transWinId) w->showMinimized(); } } } void ExtWin::focusInEvent(QFocusEvent *ev) { Client::KDRStdErr()<<"Focus In "<root; free(reply); } return root_id; } xcb_window_t getParentNativeId(xcb_window_t winId) { xcb_query_tree_cookie_t cookie; xcb_query_tree_reply_t *reply; xcb_window_t parent_id=0; xcb_connection_t *connection = QX11Info::connection(); cookie = xcb_query_tree(connection, winId); if ((reply = xcb_query_tree_reply(connection, cookie, NULL))) { parent_id=reply->parent; free(reply); } return parent_id; } xcb_window_t getCommonParent(xcb_window_t win1, xcb_window_t win2) { QList win1_preds; xcb_window_t root=getRootNativeId(win1); xcb_window_t w_next_pred=getParentNativeId(win1); while(w_next_pred!=0) { win1_preds< &siblings) { for(int i=0; i< siblings.count(); ++i) { if(siblings[i]->topWinId==topWinId) { return siblings[i]; } } return 0; } #endif //Q_OS_LINUX #ifdef Q_OS_WIN ExtWin* ExtWin::findWinByHWND(HWND hwnd, QList &siblings) { for(int i=0; i< siblings.count(); ++i) { if((HWND)(siblings[i]->winId())==hwnd) { return siblings[i]; } } return 0; } #endif ExtWin* ExtWin::findWinByZInd(int zInd, QList &siblings) { for(int i=0; i< siblings.count(); ++i) { if(siblings[i]->zOrderInd==zInd) { return siblings[i]; } } return 0; } QPoint ExtWin::virtualToKdrivePosition(QPoint virtPos) { QRect avGeom=((QGuiApplication*)QGuiApplication::instance())->screens()[0]->availableVirtualGeometry(); return QPoint(virtPos.x()-avGeom.x(),virtPos.y()-avGeom.y()); } QPoint ExtWin::kdriveToVirtualPosition(QPoint kdrPos) { QRect avGeom=((QGuiApplication*)QGuiApplication::instance())->screens()[0]->availableVirtualGeometry(); return QPoint(kdrPos.x()+avGeom.x(),kdrPos.y()+avGeom.y()); } void ExtWin::slotCheckStackOrder() { #ifdef Q_OS_WIN if(!isVisible()) return; #endif //Q_OS_WIN QList siblings=client->getSiblings(this); // Client::KDRStdErr()<<"Have Siblings: "<winId(), siblings[0]->winId()); // Client::KDRStdErr()<<"common parent: "<topWinId=getTopWinId(siblings[i]->winId(),commonParent); cookie = xcb_query_tree(connection, commonParent); if ((reply = xcb_query_tree_reply(connection, cookie, NULL))) { xcb_window_t *children = xcb_query_tree_children(reply); #endif //Q_OS_LINUX int z=0; int negative_z=0; // Client::KDRStdErr()<<"Current stack for parent: "<isMinimized()) win->zOrderInd=z++; else win->zOrderInd=--negative_z; // Client::KDRStdErr()<zOrderInd<<" - "<extWinId<<" "<windowTitle()<zOrderInd>=0) { siblings[i]->zOrderInd=(z-1)-siblings[i]->zOrderInd; } // Client::KDRStdErr()<zOrderInd<<" - "<extWinId<<" "<windowTitle()<extWinId; } if(nextSibId != newNextSib) { //if some modal windows are not ordered correct, fix it and try again if(!checkModality(siblings)) { QTimer::singleShot(5,this,SLOT(slotCheckStackOrder())); return ; } // Client::KDRStdErr()<<"Need to restack "<repaintAllWindows(); nextSibId=newNextSib; client->changeWindow(this); } } #ifdef Q_OS_LINUX } #endif } bool ExtWin::checkModality(QList &siblings) { if(isMinimized()) return true; bool mod_res=true; for(int i=0;imodality==MOD_SINGLE) { if(w->transWinId) { ExtWin* trwin=client->findExtWinById(w->transWinId); if(!trwin) { Client::KDRStdErr()<<"Error finding trans window "<transWinId<zOrderInd > w->zOrderInd) { Client::KDRStdErr()<<"Transwin "<transWinId<< " on top of modal win "<extWinId<update(); w->raise(); w->activateWindow(); mod_res=false; } } } } } return mod_res; } #ifdef Q_OS_WIN void ExtWin::slotRestoreWin() { displayArea->show(); setWindowOpacity(1); //try to repaint the window to avoid update errors on Windows QTimer::singleShot(200, getDisplayArea(), SLOT(repaint())); } #endif bool ExtWin::nativeEvent(const QByteArray &eventType, void *message, long *result) { #ifdef Q_OS_LINUX if((windowType == WINDOW_TYPE_NORMAL)||(windowType == WINDOW_TYPE_DIALOG)) { if(eventType=="xcb_generic_event_t" && parentId==0) { xcb_generic_event_t* ev = static_cast(message); switch((ev->response_type & ~0x80)) { case XCB_FOCUS_IN: slotCheckStackOrder(); // Client::KDRStdErr()<<"FOCUS IN "<changeWindow(this); } break; case XCB_FOCUS_OUT: slotCheckStackOrder(); // Client::KDRStdErr()<<"FOCUS OUT "<changeWindow(this); } break; } } } #endif //Q_OS_LINUX #ifdef Q_OS_WIN if((windowType == WINDOW_TYPE_NORMAL)||(windowType == WINDOW_TYPE_DIALOG)) { if(eventType=="windows_generic_MSG" && parentId==0) { MSG* ev = static_cast(message); switch((ev->message)) { case WM_ENTERSIZEMOVE: isChanging=true; displayArea->hide(); setWindowOpacity(0.2); break; case WM_EXITSIZEMOVE: isChanging=false; slotChangeWin(); QTimer::singleShot(10, this, SLOT(slotChangeWin())); QTimer::singleShot(200, this, SLOT(slotRestoreWin())); break; case WM_SETFOCUS: slotCheckStackOrder(); // Client::KDRStdErr()<<"FOCUS IN "<changeWindow(this); } //try to repaint the window to avoid update errors on Windows // Client::KDRStdErr()<changeWindow(this); } //try to repaint the window to avoid update errors on Windows // Client::KDRStdErr()< * Copyright (C) 2018-2023 phoca-GmbH * * 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 3 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, see . * */ #ifndef EXTWIN_H #define EXTWIN_H #include #ifdef Q_OS_LINUX #include #include #endif #include "client.h" class DisplayArea; class Client; class ExtWin : public QMainWindow { Q_OBJECT public: enum {MOD_NONE,MOD_SINGLE, MOD_GROUP}; ExtWin(uint32_t extWinId, Client *client, QWidget* parent, uint8_t wt, Qt::WindowFlags flags = Qt::WindowFlags()); uint32_t getPtr(){return extWinId;} void setWinSize(int w, int h); void setParentId(uint32_t id){parentId=id;} void setTransWinId(uint32_t id){transWinId=id;} void setNextSibId(uint32_t id){nextSibId=id;} uint8_t getWindowType(){return windowType;} void setWindowType(uint8_t tp){windowType=tp;} uint64_t getParentId(){return parentId;} uint64_t getNextSibId(){return nextSibId;} uint64_t getExtWinId(){return extWinId;} uint32_t getTransWinId(){return transWinId;} DisplayArea* getDisplayArea(){return displayArea;} void setModality(int mod){modality=mod;} QPoint virtualToKdrivePosition(QPoint virtPos); QPoint kdriveToVirtualPosition(QPoint kdrPos); void setHasFocus( bool f){focus=f;} uint8_t getHasFocus(){return focus;} void moveWinFromServer(QPoint pos); private: #ifdef Q_OS_LINUX ExtWin* findWinByTopWinId(xcb_window_t topWinId, QList &siblings); #endif #ifdef Q_OS_WIN ExtWin* findWinByHWND(HWND hwnd, QList &siblings); #endif ExtWin* findWinByZInd(int zInd, QList &siblings); bool checkModality(QList &siblings); DisplayArea* displayArea; Client* client; uint32_t extWinId; uint32_t parentId=0; uint32_t nextSibId=0; uint32_t transWinId=0; uint8_t windowType=WINDOW_TYPE_NORMAL; #ifdef Q_OS_LINUX xcb_window_t topWinId=0; #endif int zOrderInd; int modality=MOD_NONE; bool focus=0; bool ignoreGeometryChangeEvent=false; bool isChanging=false; QTimer* changeTimer; private slots: void slotChangeWin(); void slotCheckStackOrder(); #ifdef Q_OS_WIN void slotSetTaskbar(); void slotSetWinWindow(); void slotRestoreWin(); #endif protected: void closeEvent(QCloseEvent*); void resizeEvent(QResizeEvent*); void moveEvent(QMoveEvent*); void showEvent(QShowEvent *event); void hideEvent(QHideEvent *event); void focusInEvent(QFocusEvent *event); void focusOutEvent(QFocusEvent *event); bool nativeEvent(const QByteArray &eventType, void *message, long *result); }; #endif //EXTWIN_H x2gokdriveclient-0.0.0.1/src/main.cpp0000644000000000000000000000245314441666201014246 0ustar /* * QT Client for X2GoKDrive * Copyright (C) 2018-2023 Oleksandr Shneyder * Copyright (C) 2018-2023 phoca-GmbH * * 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 3 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, see . * */ #include #include "client.h" #ifdef Q_OS_WIN void winStdOutput(QtMsgType /*type*/, const QMessageLogContext& /*context*/, const QString &msg) { fprintf(stderr, "%s\n", msg.toLocal8Bit().data()); fflush(stderr); } #endif int main(int argc, char** argv ) { #ifdef Q_OS_WIN qInstallMessageHandler(winStdOutput); #endif QApplication* app=new QApplication(argc,argv); Client* cl=new Client(); cl->show(); int exitVal=app->exec(); delete cl; delete app; return exitVal; } x2gokdriveclient-0.0.0.1/src/menuframe.cpp0000644000000000000000000003457314441666201015311 0ustar /* * QT Client for X2GoKDrive * Copyright (C) 2018-2023 Oleksandr Shneyder * Copyright (C) 2018-2023 phoca-GmbH * * 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 3 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, see . * */ #include #include #include #include #include #include #include #include #include #include "client.h" #include RotatedLabel::RotatedLabel(QWidget *parent): QLabel(parent) { } RotatedLabel::RotatedLabel(const QString &text, QWidget *parent): QLabel(text, parent) { } void RotatedLabel::setOrientation(RotatedLabel::orient ort) { orientation=ort; } void RotatedLabel::mouseDoubleClickEvent(QMouseEvent*) { emit doubleClick(); } void RotatedLabel::paintEvent(QPaintEvent* ev) { switch (orientation) { case NORMAL: QLabel::paintEvent(ev); return; case LEFT: { QPainter painter(this); painter.translate(8,2); painter.rotate(90); painter.drawText(0,0,text()); break; } case RIGHT: { QPainter painter(this); painter.translate( sizeHint().height()-4,sizeHint().width()+1); painter.rotate(270); painter.drawText(0,0,text()); break; } } } MenuFrame::MenuFrame(QWidget* parent, QMenu* menu):QFrame(parent) { setMouseTracking(true); setObjectName("FSMenuBar"); bPin=new QToolButton(this); bPin->setIcon(QIcon(":/img/pin.svg")); bPin->setCheckable(true); bPin->setToolTip(tr("Pin menu bar")); connect(bPin, SIGNAL(toggled(bool)), this, SLOT(setPinned(bool))); QHBoxLayout* ml=new QHBoxLayout(this); hLayout=new QHBoxLayout(); vLayout=new QVBoxLayout(); ml->addLayout(hLayout); ml->addLayout(vLayout); defaultMargin=ml->margin(); defaultSpacing=ml->spacing(); ml->setSpacing(0); ml->setMargin(0); viewMenu=new QToolButton(this); viewMenu->setMenu(menu); viewMenu->setPopupMode(QToolButton::InstantPopup); viewMenu->setToolTip(tr("View")); viewMenu->setIcon(QIcon(":/img/svg/view.svg")); capt=new RotatedLabel("", this); capt->setToolTip(tr("Double click to change window title\nDrag to change position")); connect(capt, SIGNAL(doubleClick()), this,SIGNAL(editCaption())); bDisc=new QToolButton(this); bDisc->setToolTip(tr("Disconnect")); bDisc->setIcon(QIcon(":/img/svg/network-disconnect.svg")); Client* client=(Client*)parent; connect(bDisc, SIGNAL(clicked(bool)),client, SLOT(slotDisconnect())); bMin=new QToolButton(this); bMin->setToolTip(tr("Minimize")); bMin->setIcon(QIcon(":/img/svg/minimize.svg")); connect(bMin, SIGNAL(clicked(bool)),client, SLOT(showMinimized())); QSettings s( "Obviously Nice","x2gokdriveclient"); isPinned=s.value("pinned",false).toBool(); position=s.value("position",0.5).toDouble(); QString orstr=s.value("orientation", "top").toString(); if(orstr=="bottom") orientation=BOTTOM; if(orstr=="left") orientation=LEFT; if(orstr=="right") orientation=RIGHT; setFocusPolicy(Qt::NoFocus); bPin->setFocusPolicy(Qt::NoFocus); bMin->setFocusPolicy(Qt::NoFocus); bDisc->setFocusPolicy(Qt::NoFocus); viewMenu->setFocusPolicy(Qt::NoFocus); capt->setFocusPolicy(Qt::NoFocus); setupFrame(); adjustPosition(); bPin->setChecked(isPinned); hovered=true; setHasPointer(false); applyStyle(); } void MenuFrame::setupFrame() { if(hLayout->count()) { hLayout->removeWidget(bPin); hLayout->removeWidget(viewMenu); hLayout->removeWidget(capt); hLayout->removeWidget(bMin); hLayout->removeWidget(bDisc); } if(vLayout->count()) { vLayout->removeWidget(bPin); vLayout->removeWidget(viewMenu); vLayout->removeWidget(capt); vLayout->removeWidget(bMin); vLayout->removeWidget(bDisc); } switch(orientation) { case TOP: case BOTTOM: vLayout->setSpacing(0); vLayout->setMargin(0); hLayout->setSpacing(defaultSpacing); hLayout->setMargin(defaultMargin); hLayout->addWidget(bPin); hLayout->addWidget(viewMenu); hLayout->addWidget(capt); hLayout->addWidget(bMin); hLayout->addWidget(bDisc); capt->setOrientation(RotatedLabel::NORMAL); setMinimumHeight(bDisc->sizeHint().height()+defaultMargin*2); setMaximumHeight(bDisc->sizeHint().height()+defaultMargin*2); setMinimumWidth(defaultSpacing*4+defaultMargin*2+capt->sizeHint().width()+bPin->sizeHint().width()*4); setMaximumWidth(defaultSpacing*4+defaultMargin*2+capt->sizeHint().width()+bPin->sizeHint().width()*4); break; case LEFT: capt->setOrientation(RotatedLabel::LEFT); // fall through case RIGHT: if(orientation!=LEFT) capt->setOrientation(RotatedLabel::RIGHT); hLayout->setSpacing(0); hLayout->setMargin(0); vLayout->setSpacing(defaultSpacing); vLayout->setMargin(defaultMargin); vLayout->addWidget(bPin); vLayout->addWidget(viewMenu); vLayout->addWidget(capt); vLayout->addWidget(bMin); vLayout->addWidget(bDisc); setMinimumWidth(bDisc->sizeHint().height()+defaultMargin*2); setMaximumWidth(bDisc->sizeHint().height()+defaultMargin*2); setMinimumHeight(defaultSpacing*5+defaultMargin*2+capt->sizeHint().width()+bPin->sizeHint().width()*4); setMaximumHeight(defaultSpacing*5+defaultMargin*2+capt->sizeHint().width()+bPin->sizeHint().width()*4); break; } } void MenuFrame::adjustPosition() { int y=0; int x=0; // Client::KDRStdErr()<<"Widget width"<height()-height(); // fall through case TOP: { if(position==0) { x=0; } else if(position==1) { x=parentWidget()->width()-width()-1; } else { x=parentWidget()->width()*position-width()/2; if(x<11) { x=11; } if(x+11>parentWidget()->width()-width()) { x=parentWidget()->width()-width()-11; } } break; } case RIGHT: x=parentWidget()->width()-width(); // fall through case LEFT: { if(position==0) { y=0; } else if(position==1) { y=parentWidget()->height()-height()-1; } else { y=parentWidget()->height()*position-height()/2; if(y<11) { y=11; } if(y+11>parentWidget()->height()-height()) { y=parentWidget()->height()-height()-11; } } break; } } move(x,y); hovered=true; setHasPointer(false); } void MenuFrame::setCaption(const QString& text) { capt->setText(text); switch(orientation) { case TOP: case BOTTOM: setMinimumWidth(defaultSpacing*4+defaultMargin*2+capt->sizeHint().width()+bPin->sizeHint().width()*4+4); setMaximumWidth(defaultSpacing*4+defaultMargin*2+capt->sizeHint().width()+bPin->sizeHint().width()*4+4); break; case LEFT: case RIGHT: setMinimumHeight(defaultSpacing*5+defaultMargin*2+capt->sizeHint().width()+bPin->sizeHint().width()*4+4); setMaximumHeight(defaultSpacing*5+defaultMargin*2+capt->sizeHint().width()+bPin->sizeHint().width()*4+4); break; } QTimer::singleShot(20,this, SLOT(adjustPosition())); } void MenuFrame::applyStyle() { QPalette pal=bPin->palette(); QString bgCol; QColor col=pal.color(QPalette::Window); bgCol.sprintf("rgba(%d,%d,%d,%d)",col.red(), col.green(), col.blue() ,col.alpha()) ; switch(orientation) { case TOP: setStyleSheet("QFrame#FSMenuBar{background-color:"+bgCol+";border-bottom-right-radius:5px;border-bottom-left-radius:5px;border-left-style:solid;border-right-style:solid;border-bottom-style:solid;border-width:1px;border-color:grey;}"); break; case BOTTOM: setStyleSheet("QFrame#FSMenuBar{background-color:"+bgCol+";border-top-right-radius:5px;border-top-left-radius:5px;border-left-style:solid;border-right-style:solid;border-top-style:solid;border-width:1px;border-color:grey;}"); break; case LEFT: setStyleSheet("QFrame#FSMenuBar{background-color:"+bgCol+";border-top-right-radius:5px;border-bottom-right-radius:5px;border-right-style:solid;border-bottom-style:solid;border-top-style:solid;border-width:1px;border-color:grey;}"); break; case RIGHT: setStyleSheet("QFrame#FSMenuBar{background-color:"+bgCol+";border-top-left-radius:5px;border-bottom-left-radius:5px;border-left-style:solid;border-bottom-style:solid;border-top-style:solid;border-width:1px;border-color:grey;}"); break; } } void MenuFrame::mouseMoveEvent(QMouseEvent* event) { setHasPointer(true); if(!drag) return; int deltaX=event->screenPos().x()-startPosX; startPosX=event->screenPos().x(); int deltaY=event->screenPos().y()-startPosY; startPosY=event->screenPos().y(); int localY=event->screenPos().y() - parentWidget()->geometry().y(); int localX=event->screenPos().x() - parentWidget()->geometry().x(); int rDist=parentWidget()->width()-localX; int bDist=parentWidget()->height()-localY; if(rDistheight()-height(); // fall through case TOP: { newX=x()+deltaX; if(newX<0) newX=0; if(newX+width() > parentWidget()->width()) newX=parentWidget()->width() - width(); move(newX,newY); position=(newX+width()/2.)/parentWidget()->width(); if(newX<=10) position=0; if(newX+width()>=parentWidget()->width()-10) position=1; } break; case RIGHT: newX=parentWidget()->width()-width(); // fall through case LEFT: { newY=y()+deltaY; if(newY<0) newY=0; if(newY+height() > parentWidget()->height()) newY=parentWidget()->height()-height(); move(newX, newY); position=(newY+height()/2.)/parentWidget()->height(); if(newY<=10) position=0; if(newY+height()>=parentWidget()->height()-10) position=1; } break; } QSettings s( "Obviously Nice","x2gokdriveclient"); s.setValue("position",position); switch(orientation) { case TOP: s.setValue("orientation","top"); break; case BOTTOM: s.setValue("orientation","bottom"); break; case LEFT: s.setValue("orientation","left"); break; case RIGHT: s.setValue("orientation","right"); break; } } void MenuFrame::setHasPointer(bool hasPointer) { if(hasPointer==hovered) return; hovered=hasPointer; // Client::KDRStdErr()<<"hovered:"<height()-height(); break; case LEFT: newX=0;break; case RIGHT:newX=parentWidget()->width()-width();break; } } else { switch(orientation) { case TOP: newY=0-height()+5; break; case BOTTOM: newY=parentWidget()->height()-5; break; case LEFT: newX=0-width()+5;break; case RIGHT: newX=parentWidget()->width()-5; break; } } move(newX, newY); } void MenuFrame::mousePressEvent(QMouseEvent* event) { drag=true; startPosX=event->screenPos().x(); startPosY=event->screenPos().y(); setCursor(Qt::SizeAllCursor); } void MenuFrame::mouseReleaseEvent(QMouseEvent* ) { drag=false; setCursor(Qt::ArrowCursor); } void MenuFrame::setPinned(bool toggled) { Client::KDRStdErr()<<"pinned: "<setEnabled(enabled); } x2gokdriveclient-0.0.0.1/src/menuframe.h0000644000000000000000000000447014441666201014747 0ustar /* * QT Client for X2GoKDrive * Copyright (C) 2018-2023 Oleksandr Shneyder * Copyright (C) 2018-2023 phoca-GmbH * * 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 3 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, see . * */ #ifndef MENUFRAME_H #define MENUFRAME_H #include #include class RotatedLabel: public QLabel { Q_OBJECT public: typedef enum{NORMAL,LEFT, RIGHT} orient; explicit RotatedLabel(QWidget *parent=0); explicit RotatedLabel(const QString &text, QWidget *parent=0); void setOrientation(orient ort); private: orient orientation=NORMAL; protected: void paintEvent(QPaintEvent* ev); void mouseDoubleClickEvent(QMouseEvent*); signals: void doubleClick(); }; class QMenu; class QLabel; class QHBoxLayout; class QVBoxLayout; class QToolButton; class MenuFrame : public QFrame { Q_OBJECT public: MenuFrame(QWidget* parent, QMenu* menu); void setHasPointer(bool hasPointer); void enableViewMenu(bool enabled); private: void applyStyle(); void setupFrame(); bool isPinned=false; int startPosX=0; int startPosY=0; double position; bool drag=false; bool hovered=false; int defaultMargin=0; int defaultSpacing=0; RotatedLabel *capt; QHBoxLayout* hLayout; QVBoxLayout* vLayout; QToolButton* bPin; QToolButton* viewMenu; QToolButton* bDisc; QToolButton* bMin; enum{TOP,BOTTOM, LEFT, RIGHT} orientation=TOP; protected: void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); public slots: void setPinned(bool toggled); void setCaption(const QString& text); void adjustPosition(); signals: void editCaption(); }; #endif // MENUFRAME_H x2gokdriveclient-0.0.0.1/src/screenidentifier.cpp0000644000000000000000000000237214441666201016644 0ustar /* * QT Client for X2GoKDrive * Copyright (C) 2018-2023 Oleksandr Shneyder * Copyright (C) 2018-2023 phoca-GmbH * * 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 3 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, see . * */ #include #include "screenidentifier.h" ScreenIdentifier::ScreenIdentifier(QWidget* parent, Qt::WindowFlags flags):QMainWindow(parent, flags) { label=new QLabel("", this); QFont f=label->font(); f.setBold(true); f.setPointSize(56); label->setFont(f); label->setAlignment(Qt::AlignCenter); setCentralWidget(label); label->setFrameStyle(QFrame::Box); } void ScreenIdentifier::setText(const QString& text) { label->setText(text); } x2gokdriveclient-0.0.0.1/src/screenidentifier.h0000644000000000000000000000215114441666201016304 0ustar /* * QT Client for X2GoKDrive * Copyright (C) 2018-2023 Oleksandr Shneyder * Copyright (C) 2018-2023 phoca-GmbH * * 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 3 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, see . * */ #ifndef SCREENIDENTIFIER_H #define SCREENIDENTIFIER_H #include class QLabel; class ScreenIdentifier: public QMainWindow { Q_OBJECT public: explicit ScreenIdentifier(QWidget *parent, Qt::WindowFlags flags); void setText(const QString& text); private: QLabel* label; }; #endif // SCREENIDENTIFIER_H x2gokdriveclient-0.0.0.1/src/xcbclip.cpp0000644000000000000000000011230414441666201014743 0ustar /* * QT Client for X2GoKDrive * Copyright (C) 2018-2023 Oleksandr Shneyder * Copyright (C) 2018-2023 phoca-GmbH * * 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 3 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, see . * */ #include "xcbclip.h" #include #include #include #include #define SELECTION_DELAY 30000 //timeout for selection operation #define INCR_SIZE 256*1024 //size of part for incr selection incr selection XCBClip::XCBClip(Client* parent) { this->parent=parent; uint32_t mask = 0; xcb_generic_error_t *error = 0; xcb_xfixes_query_version_cookie_t xfixes_query_cookie; xcb_xfixes_query_version_reply_t *xfixes_query; uint32_t values[2]; con = xcb_connect (NULL, NULL); /* Create the window */ xcb_screen_t *screen = xcb_setup_roots_iterator (xcb_get_setup (con)).data; clipWinId = xcb_generate_id (con); mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; values[0] = screen->white_pixel; values[1] = XCB_EVENT_MASK_PROPERTY_CHANGE; ATOM_CLIPBOARD=atom("CLIPBOARD"); //create window which will recieve selection events and provide remote selection to X-clients xcb_create_window (con, XCB_COPY_FROM_PARENT, clipWinId, screen->root, 0, 0, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, mask, values); xcb_flush(con); //check if we have xfixes, we need it to recieve selection owner events reply = xcb_get_extension_data(con, &xcb_xfixes_id); if (reply && reply->present) { xfixes_query_cookie = xcb_xfixes_query_version(con, XCB_XFIXES_MAJOR_VERSION, XCB_XFIXES_MINOR_VERSION); xfixes_query = xcb_xfixes_query_version_reply (con, xfixes_query_cookie, &error); if (!xfixes_query || error || xfixes_query->major_version < 2) { Client::KDRStdErr()<<"XFixes query failed"; free(error); } else { //we'll recieve sel owner events for primary amd clipboard mask = XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER; xcb_xfixes_select_selection_input_checked(con,clipWinId, XCB_ATOM_PRIMARY, mask); xcb_xfixes_select_selection_input_checked(con, clipWinId, ATOM_CLIPBOARD, mask); } free(xfixes_query); } xcb_flush(con); QTimer::singleShot(250, this, SLOT(checkEvents())); } XCBClip::~XCBClip() { for(uint i = delayedSelectionRequests.length()-1; i<=0;--i) { discardDelayedRequest(i); } //remove all pending INCR requests remove_obsolete_incr_transactions(false); xcb_destroy_window(con, clipWinId); xcb_disconnect(con); } xcb_atom_t XCBClip::atom(const QString& name) { //get atom for the name, return 0 if not found xcb_intern_atom_cookie_t cookie; xcb_intern_atom_reply_t *reply; xcb_atom_t a=0; cookie = xcb_intern_atom(con, 0, name.length(), name.toLatin1().data()); if ((reply = xcb_intern_atom_reply(con, cookie, NULL))) { // Client::KDRStdErr()<<"found atom for "<atom; free(reply); } return a; } bool XCBClip::is_image_atom(xcb_atom_t at) { //check if selection data is image if(!at) return false; if( at == atom("image/png") || at == atom("image/xpm") || at == atom("image/jpg") || at == atom("image/jpeg") || at == atom("PIXMAP") || at == atom("image/bmp")) return true; return false; } bool XCBClip::is_string_atom(xcb_atom_t at) { //check if selection data is string/text if(!at) return false; if( at == atom("UTF8_STRING") || at == atom("STRING") || at == atom("TEXT") || at == atom("text/plain;charset=utf-8") || at == atom("text/plain")) return true; return false; } QString XCBClip::atom_name(xcb_atom_t xatom) { QString name; xcb_get_atom_name_cookie_t cookie = xcb_get_atom_name(con, xatom); xcb_get_atom_name_reply_t *reply=xcb_get_atom_name_reply(con, cookie, NULL); if(!reply) return name; if(!reply->name_len) { free(reply); return name; } name=QString(QByteArray(xcb_get_atom_name_name(reply), xcb_get_atom_name_name_length(reply))); free(reply); return name; } QStringList XCBClip::atomsInReply(xcb_get_property_reply_t *reply) { QStringList atoms; xcb_atom_t* tg=(xcb_atom_t*) xcb_get_property_value(reply); for(uint i=0;irequest->requestor, XCB_EVENT_MASK_NO_EVENT, (char*)d->event); xcb_flush(con); free(d->event); free((xcb_generic_event_t *)(d->request)); delete d; } void XCBClip::processDelayedRequests() { //process delayed requests for(uint i = delayedSelectionRequests.length()-1; i<=0;--i) { DelayedRequest* d=delayedSelectionRequests[i]; SelectionType selection = selection_from_atom( d->request->selection); if(currentXTime() > (d->request->time + SELECTION_DELAY)) { // Client::KDRStdErr()<<"timeout selection: "< d->request->time ) { // Client::KDRStdErr()<<"selection request for "<request)) { // Client::KDRStdErr()<<"can't convert selection "<request->property; //our selection don't support requested mime type discardDelayedRequest(i); continue; } if(inputSelection[selection].state != InputSelection::COMPLETED) { //we don't have the data yet continue; } d->event->property=send_data(d->request); discardDelayedRequest(i); } } void XCBClip::updateCurrentTime(xcb_timestamp_t t) { //updating the current X time. It's not very precicely, but enough for us if(t > lastXTime) { //update current time lastXTime=t; timeDifference=QDateTime::currentMSecsSinceEpoch() - t; // Client::KDRStdErr()<<"X time dif:"<response_type & ~0x80; //we notified that selection is changed in primary or clipboard if (response_type == reply->first_event + XCB_XFIXES_SELECTION_NOTIFY) { xcb_xfixes_selection_notify_event_t *notify_event=(xcb_xfixes_selection_notify_event_t *)e; updateCurrentTime(notify_event->timestamp); // Client::KDRStdErr()<<"SEL OWNER notify, selection:"<selection<< " window "<< notify_event->window<< "owner"<< notify_event->owner; if(notify_event->owner == clipWinId) { // Client::KDRStdErr()<<"not processing, we are the owner of this notify"; } else { switch(parent->clipboardMode()) { case CLIP_SERVER: case CLIP_NONE: Client::KDRStdErr()<<"Client selection is disabled"; return; default: break; } //cancel all previous incr reading incrementalSize=incrementalSizeRead=0; incrAtom=0; if(notify_event->selection==XCB_ATOM_PRIMARY) { inputSelection[PRIMARY].owner=false; } else { inputSelection[CLIPBOARD].owner=false; } //get supported mime types request_selection_data( notify_event->selection, atom( "TARGETS"), atom( "TARGETS"), 0); } } else { //we notified that property is changed if (response_type == XCB_PROPERTY_NOTIFY) { process_property_notify(e); } //we got reply to our selection request (mime types or data) else if (response_type == XCB_SELECTION_NOTIFY) { process_selection_notify(e); } else if (response_type == XCB_SELECTION_REQUEST) { if(!process_selection_request(e)) { //we delayed processing of this request till data received from server //we will free the event when we have the data QTimer::singleShot(10, this, SLOT(checkEvents())); return; } } else { // Client::KDRStdErr()<<"not processing this event "<time); //processing the event which is reply for convert selection call if (sel_event->requestor != clipWinId) { // Client::KDRStdErr()<<("not our window"); return; } else { // Client::KDRStdErr()<<"selection notify sel , target , property "<< sel_event->selection<< sel_event->target<< sel_event->property; if(sel_event->property==XCB_NONE) { // Client::KDRStdErr()<<( "NO SELECTION"); } else { currentSelection=sel_event->selection; //read property read_selection_property(currentSelection, sel_event->property); } } } void XCBClip::destroy_incr_transaction(int index) { //destroy incr transaction with index IncrTransaction* tr=incrTransactions.takeAt(index); const quint32 mask[] = { XCB_EVENT_MASK_NO_EVENT }; //don't resive property notify events for this window anymore xcb_change_window_attributes(con, tr->requestor, XCB_CW_EVENT_MASK, mask); xcb_flush(con); delete tr; } void XCBClip::remove_obsolete_incr_transactions( bool checkTs) { //remove_obsolete_incr_transactions //if checkTS true, check timestamp and destroy only if ts exceed delay for (int i= incrTransactions.size()-1;i>=0;--i) { if( (!checkTs) || ( incrTransactions[i]->timestamp+SELECTION_DELAY < QDateTime::currentMSecsSinceEpoch())) { Client::KDRStdErr()<<"timeout INCR selection for "<requestor<<" "<timestamp<<" "<requestor == pn->window) && (tr->property == pn->atom ) && ( pn->state == XCB_PROPERTY_DELETE) ) { //requestor ready for the new portion of data uint left=tr->data.size()-tr->sentBytes; if(!left) { // Client::KDRStdErr()<<"all INCR data sent to "<requestor; //all data sent, sending NULL data and destroying transaction xcb_change_property(con, XCB_PROP_MODE_REPLACE, tr->requestor, tr->property, tr->target, 8, 0, NULL); xcb_flush(con); destroy_incr_transaction(i); return; } uint sendingBytes=(INCR_SIZE< left)?INCR_SIZE:left; // Client::KDRStdErr()<<"sending incr bytes "<requestor, tr->property, tr->target, 8, sendingBytes, tr->data.constData() + tr->sentBytes); xcb_flush(con); tr->sentBytes+=sendingBytes; tr->timestamp=QDateTime::currentMSecsSinceEpoch(); return; } } //notify event doesn't belong to any of started incr transactions or it's notification for new property return; } void XCBClip::process_property_notify(xcb_generic_event_t *e) { xcb_property_notify_event_t *pn; // Client::KDRStdErr()<<("property notify"); pn = (xcb_property_notify_event_t *)e; updateCurrentTime(pn->time); if (pn->window != clipWinId) { //this property doesn't belong to our window; //let's check if it's not the property corresponding to one of incr transactions process_incr_transaction_property(pn); return; } // Client::KDRStdErr()<<"property, state "<< pn->atom<< pn->state; if(pn->state==XCB_PROPERTY_NEW_VALUE) { if(incrAtom==pn->atom && incrementalSize) { //we recieveing the selection data incrementally, let's read a next chunk // Client::KDRStdErr()<<"reading incr property "<< pn->atom; read_selection_property(currentSelection, pn->atom); } } } void XCBClip::read_selection_property(xcb_atom_t selection, xcb_atom_t property) { QString stype, sprop; xcb_atom_t data_atom; unsigned int bytes_left, bytes_read=0; xcb_get_property_cookie_t cookie; xcb_get_property_reply_t *reply; OutputChunk* chunk; //request property which represents value of selection (data or mime types) //get max 100K of data, we don't need to send more than that over network for perfomance reasons cookie= xcb_get_property(con,false, clipWinId, property, XCB_GET_PROPERTY_TYPE_ANY, 0, parent->max_chunk()); reply=xcb_get_property_reply(con, cookie, NULL); if(!reply) { Client::KDRStdErr()<< "NULL reply"; } else { if(reply->type==XCB_NONE) { // Client::KDRStdErr()<< "NONE reply"; } else { //here we have type of data stype=atom_name(reply->type); sprop=atom_name(property); // Client::KDRStdErr()<< "Property, type, format, length"<< sprop<< stype<< reply->format<< reply->length; //need to read property incrementally if(reply->type == atom("INCR")) { unsigned int sz=*((unsigned int*) xcb_get_property_value(reply)); // Client::KDRStdErr()<< "have incr property size: "<< sz; incrAtom=property; incrementalSize=sz; incrementalSizeRead=0; //deleteing property should tell the selection owner that we are ready for incremental reading of data xcb_delete_property(con, clipWinId, property); xcb_flush(con); free(reply); return; } //we have supported mime types in reply if(reply->type == atom( "ATOM")) { if(reply->format!=32) { Client::KDRStdErr()<<( "wrong format for TARGETS"); } else { QStringList atoms=atomsInReply(reply); // Client::KDRStdErr() << "target supports mime types:"<serverSupportsExtSelection()) { //servere support extended selection, we'll send the selection data first when it's requested by the server //now we'll just notify the server that there is the new selection and send supported mime types SelectionType sel=selection_from_atom(selection); best_atom[sel]=data_atom; SelectionMime mime=UTF_STRING; if( ! is_string_atom(best_atom[sel]) ) { mime = PIXMAP; } // Client::KDRStdErr()<<"MIME"<send_selnotify_to_server(sel,mime); } else { xcb_delete_property( con, clipWinId, property); xcb_flush(con); //request the data from selection if(data_atom) request_selection_data( selection, data_atom, data_atom, 0); else { // Client::KDRStdErr()<<( "there are no supported mime types in the target"); } } } } else { //here we have selection as string or image if(is_image_atom( reply->type) || is_string_atom( reply->type)) { //read property data in loop in the chunks with size (100KB) do { bytes_left=reply->bytes_after; //now we can access property data /*FILE* cp=fopen("/tmp/clip", "a"); * fwrite(xcb_get_property_value(reply),1, xcb_get_property_value_length(reply),cp); * fclose(cp);*/ SelectionType sel= selection_from_atom(selection); SelectionMime mime= UTF_STRING; if(is_image_atom(reply->type)) mime=PIXMAP; chunk=new OutputChunk(sel, mime); if(xcb_get_property_value_length(reply)) { chunk->data.setRawData((const char*) xcb_get_property_value(reply),xcb_get_property_value_length(reply)); } if(is_string_atom(property)) { chunk->mimeData=UTF_STRING; } else chunk->mimeData=PIXMAP; chunk->selection=selection_from_atom(selection); if(incrementalSize && (incrAtom==property)) { //we are doing incremental reading if(incrementalSizeRead == 0) { //it's the first chunk chunk->firstChunk=true; } incrementalSizeRead+=xcb_get_property_value_length(reply); if(!bytes_left && ! bytes_read && !xcb_get_property_value_length(reply)) { //we got the property with 0 size it means that we recieved all data of incr property // Client::KDRStdErr()<<"INCR Property done, read " << incrementalSizeRead; incrAtom=0; incrementalSize=0; //it's the last chunk chunk->lastChunk=true; } chunk->totalSize=incrementalSize; } else { //we are doing simple read if(bytes_read==0) { //it's the first chunk chunk->firstChunk=true; } if(bytes_left==0) { //the last chunk chunk->lastChunk=true; } chunk->totalSize=xcb_get_property_value_length(reply)+bytes_left; } bytes_read+=xcb_get_property_value_length(reply); // Client::KDRStdErr()<<"read chunk of selection - size, total read, left, first:, last:"<< xcb_get_property_value_length(reply)<< bytes_read<< bytes_left<< chunk->firstChunk<< chunk->lastChunk; //attach chunk to the end of output chunk queue parent-> addToSelectionOutput(chunk); //send this chunk parent->sendOutputSelChunk(); if(bytes_left) { free(reply); cookie= xcb_get_property(con, 0, clipWinId, property, XCB_GET_PROPERTY_TYPE_ANY, bytes_read/4,parent->max_chunk()); reply=xcb_get_property_reply(con, cookie, NULL); if(!reply) { //something is wrong Client::KDRStdErr()<<("NULL reply"); break; } } //read in loop till no data left }while(bytes_left); } else { stype=atom_name(reply->type); Client::KDRStdErr()<<"Not supported mime type: "<type; } } if(reply) free(reply); //if reading incr property this will say sel owner that we are ready for the next chunk of data xcb_delete_property(con, clipWinId, property); xcb_flush(con); } } } SelectionType XCBClip::selection_from_atom(xcb_atom_t selection) { if(selection == XCB_ATOM_PRIMARY) return PRIMARY; return CLIPBOARD; } xcb_atom_t XCBClip::atom_from_selection(SelectionType selection) { if(selection == PRIMARY) return XCB_ATOM_PRIMARY; return ATOM_CLIPBOARD; } void XCBClip::requestSelectionData(SelectionType selection) { //Client requesting data for selection using this function request_selection_data(atom_from_selection(selection), best_atom[selection], best_atom[selection], 0); } void XCBClip::request_selection_data( xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property, xcb_timestamp_t t) { //execute convert selection for primary or clipboard to get mimetypes or data (depends on target atom) if(!t) t=XCB_CURRENT_TIME; if(property) { xcb_delete_property(con,clipWinId,property); } xcb_convert_selection(con, clipWinId,selection, target, property, t); xcb_flush(con); } void XCBClip::setInputSelectionData(SelectionType selection, SelectionMime mime, bool firstChunk, bool lastChunk, uint32_t compressed, uint size, char* data, bool notify) { //if notify is true, we don't have actual data, just notification //copy data to selection buffer // Client::KDRStdErr()<<"Get chunk of input selection: selection, myme, firstChunk, lastChunk, compressed, size:"<clipboardMode()) { case CLIP_CLIENT: case CLIP_NONE: Client::KDRStdErr()<<"Server selection is disabled"; return; default: break; } xcb_atom_t sel=atom_from_selection(selection); xcb_set_selection_owner(con, clipWinId, sel, XCB_CURRENT_TIME); xcb_flush(con); inputSelection[selection].owner=true; inputSelection[selection].timestamp=currentXTime(); } bool XCBClip::process_selection_request(xcb_generic_event_t *e) { //processing selection request. //return true if the processing is finishing after return //false if data is not ready and we are delaying processing of this request //in this case calling function SHOULD NOT destroy the request neither event should not be destroyed //we'll free this objects after processing of the request when the data is available xcb_selection_request_event_t *req=(xcb_selection_request_event_t*)e; updateCurrentTime(req->time); xcb_selection_notify_event_t* event= (xcb_selection_notify_event_t*)calloc(32, 1); event->response_type = XCB_SELECTION_NOTIFY; event->requestor = req->requestor; event->selection = req->selection; event->target = req->target; event->property = XCB_NONE; event->time = req->time; xcb_atom_t property=req->property; xcb_atom_t target=req->target; if(property == XCB_NONE) property=target; SelectionType sel=selection_from_atom(req->selection); // Client::KDRStdErr()<<"selection request for"<selection)<target)<property)<< "from "<requestor<<"we are "<requestor, XCB_EVENT_MASK_NO_EVENT, (char*)event); xcb_flush(con); free(event); return true; } if(inputSelection[sel].timestamp > req->time) { //selection changed after request // Client::KDRStdErr()<<"requested selection doesn't exist anymore"; xcb_send_event(con, false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (char*)event); xcb_flush(con); free(event); return true; } if(req->target==atom("TIMESTAMP")) { event->property=property; // Client::KDRStdErr()<<"requested TIMESTAMP"; xcb_change_property(con, XCB_PROP_MODE_REPLACE, req->requestor, property, XCB_ATOM_INTEGER, 32, 1, &inputSelection[sel].timestamp); } else if(req->target==atom("TARGETS")) { event->property=property; // Client::KDRStdErr()<<"requested TARGETS"; send_mime_types(req); } else { if(check_req_sanity(req)) { //if data is ready, send it to requestor if(inputSelection[sel].state == InputSelection::COMPLETED) event->property=send_data(req); else { //if data is not ready, request it from server and delay the processing of request delay_selection_request(req, event); return false; } } } xcb_send_event(con, false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (char*)event); xcb_flush(con); free(event); return true; } void XCBClip::delay_selection_request( xcb_selection_request_event_t *request, xcb_selection_notify_event_t* event) { SelectionType sel=selection_from_atom(request->selection); DelayedRequest* dr=new DelayedRequest; dr->event=event; dr->request=request; //add new request to the queue delayedSelectionRequests<requestSelectionFromServer(sel); inputSelection[sel].state=InputSelection::REQUESTED; } } QString XCBClip::mime_to_QT_img(const QString& mimeType) { //convert mimeType to internal QT image format: //https://doc.qt.io/qt-5/qimage.html#reading-and-writing-image-files QString f=mimeType; if(mimeType=="PIXMAP") return "XPM"; f=f.replace("image/","").toUpper(); return f; } xcb_atom_t XCBClip::set_data_property(xcb_selection_request_event_t* req, QByteArray* data) { //set data to window property //change when implemented bool support_incr=true; //this types of application not supporting incr selection if(atom_name(req->property)=="_XT_SELECTION_0" || atom_name(req->property)=="_QT_SELECTION") { // Client::KDRStdErr()<property)<<"doesn't support INCR"; support_incr=false; } //check if we are sending incr if(!support_incr) { if( data->size() < (int)xcb_get_maximum_request_length(con) * 4 - 24) { //requester doesn't support INCR, sending data in one chunk xcb_change_property(con, XCB_PROP_MODE_REPLACE, req->requestor, req->property, req->target, 8, data->size(), (const void *)data->constData()); xcb_flush(con); return req->property; } Client::KDRStdErr()<<"data is too big"; return XCB_NONE; } if(data->size() < INCR_SIZE) { //if size is < 256K send in one property xcb_change_property(con, XCB_PROP_MODE_REPLACE, req->requestor, req->property, req->target, 8, data->size(), (const void *)data->constData()); xcb_flush(con); return req->property; } //sending INCR atom to let requester know that we are starting data incrementally uint bytes=data->size(); Client::KDRStdErr()<<"starting INCR send of size "<size()<<" for win ID "<requestor; xcb_change_property(con, XCB_PROP_MODE_REPLACE, req->requestor, req->property, atom("INCR"), 32, 1, (const void *)&bytes); startIncrTransaction(req->requestor, req->property, req->target, *data ); xcb_flush(con); return req->property; } //creating INCR transaction void XCBClip::startIncrTransaction(xcb_window_t requestor, xcb_atom_t property, xcb_atom_t target, QByteArray data) { IncrTransaction* tr=new IncrTransaction; tr->requestor=requestor; tr->property=property; tr->target=target; tr->data=data; tr->sentBytes=0; tr->timestamp=QDateTime::currentMSecsSinceEpoch(); incrTransactions<timestamp; const quint32 mask[] = { XCB_EVENT_MASK_PROPERTY_CHANGE }; //we'll recive property change events for requestor window from now xcb_change_window_attributes(con, requestor, XCB_CW_EVENT_MASK, mask); } //check if the requested mime can be delivered bool XCBClip::check_req_sanity(xcb_selection_request_event_t* req) { SelectionType sel=selection_from_atom(req->selection); if(inputSelection[sel].selMime==UTF_STRING) { //if it's one of supported text formats send without convertion if(is_string_atom(req->target)) { // Client::KDRStdErr()<<"sending UTF text"; return true; } else { Client::KDRStdErr()<<"unsupported property requested: "<target); return false; } } else { if(!is_image_atom(req->target)) { Client::KDRStdErr()<<"unsupported property requested: "<target); return false; } // Client::KDRStdErr()<<"sending "<target); return true; } } xcb_atom_t XCBClip::send_data(xcb_selection_request_event_t* req) { //send data SelectionType sel=selection_from_atom(req->selection); if(inputSelection[sel].selMime==UTF_STRING) { //if it's one of supported text formats send without convertion return set_data_property(req, &inputSelection[sel].selData); } else { // Client::KDRStdErr()<<"sending "<target); //convert to desireable format QImage img=QImage::fromData(inputSelection[sel].selData); QByteArray ba; QBuffer buffer(&ba); buffer.open(QIODevice::WriteOnly); img.save(&buffer, mime_to_QT_img(atom_name(req->target)).toLatin1()); // Client::KDRStdErr()<<"converted to"<target))<selection); QVector targets; xcb_atom_t a; if((a=atom("TARGETS"))) targets.append(a); if((a=atom("TIMESTAMP"))) targets.append(a); if(inputSelection[sel].selMime==PIXMAP) { if((a=atom("image/png"))) targets.append(a); if((a=atom("image/jpg"))) targets.append(a); if((a=atom("image/jpeg"))) targets.append(a); if((a=atom("image/bmp"))) targets.append(a); if((a=atom("image/xpm"))) targets.append(a); } else { if((a=atom("UTF8_STRING"))) targets.append(a); if((a=atom("text/plain;charset=utf-8"))) targets.append(a); if((a=atom("STRING"))) targets.append(a); if((a=atom("TEXT"))) targets.append(a); if((a=atom("text/plain"))) targets.append(a); } xcb_change_property(con, XCB_PROP_MODE_REPLACE, req->requestor, req->property, XCB_ATOM_ATOM, 32, targets.size(), (const void *)targets.constData()); xcb_flush(con); } x2gokdriveclient-0.0.0.1/src/xcbclip.h0000644000000000000000000001133214441666201014407 0ustar /* * QT Client for X2GoKDrive * Copyright (C) 2018-2023 Oleksandr Shneyder * Copyright (C) 2018-2023 phoca-GmbH * * 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 3 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, see . * */ #ifndef XCBCLIP_H #define XCBCLIP_H #include #include #include #include #include #include "client.h" class XCBClip : public QObject { Q_OBJECT public: XCBClip(Client* parent); ~XCBClip(); void setInputSelectionData(SelectionType selection, SelectionMime mime, bool firstChunk, bool lastChunk, uint32_t compressed, uint size, char* data, bool notify=false); void requestSelectionData(SelectionType selection); private: xcb_atom_t atom(const QString& name); QString atom_name(xcb_atom_t xatom); QStringList atomsInReply(xcb_get_property_reply_t *reply); xcb_atom_t best_atom_from_list(const QStringList& atoms); void process_selection_notify(xcb_generic_event_t *e); bool process_selection_request(xcb_generic_event_t *e); void request_selection_data( xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property, xcb_timestamp_t t); void process_property_notify(xcb_generic_event_t *e); void read_selection_property(xcb_atom_t selection, xcb_atom_t property); bool is_string_atom( xcb_atom_t at); bool is_image_atom( xcb_atom_t at); xcb_atom_t target_has_atom(const QStringList& atoms, const QString& name); void own_selection(SelectionType selection); void send_mime_types(xcb_selection_request_event_t* req); xcb_atom_t send_data(xcb_selection_request_event_t* req); xcb_atom_t set_data_property(xcb_selection_request_event_t* req, QByteArray* data); SelectionType selection_from_atom(xcb_atom_t selection); xcb_atom_t atom_from_selection(SelectionType selection); QString mime_to_QT_img(const QString& mimeType); void delay_selection_request( xcb_selection_request_event_t *reqest, xcb_selection_notify_event_t* event); bool check_req_sanity(xcb_selection_request_event_t* req); void processDelayedRequests(); void discardDelayedRequest(uint index); void updateCurrentTime(xcb_timestamp_t t); xcb_timestamp_t currentXTime(); void startIncrTransaction(xcb_window_t requestor, xcb_atom_t property, xcb_atom_t target, QByteArray data); void process_incr_transaction_property(xcb_property_notify_event_t * pn); void destroy_incr_transaction(int index); void remove_obsolete_incr_transactions(bool checkTS=true); private slots: void checkEvents(); private: Client* parent; const xcb_query_extension_reply_t *reply; xcb_window_t clipWinId; xcb_connection_t* con; //output selection xcb_atom_t currentSelection; xcb_atom_t incrAtom=0; uint incrementalSize=0; uint incrementalSizeRead=0; xcb_atom_t best_atom[2]; //the best mime type for selection to request on demand sel request from server xcb_atom_t ATOM_CLIPBOARD=0; //atom for CLIPBOARD selection //input selection struct InputSelection{ SelectionMime selMime; //mime of selection (string or image) QByteArray selData; //data bool owner=false; //if we are owners of this selction enum { NOTIFIED, REQUESTED, COMPLETED} state; //state of the selection xcb_timestamp_t timestamp; //timestamp when we own selection }inputSelection[2]; //requests which processing should be delayed till we get data from server struct DelayedRequest { xcb_selection_request_event_t *request; // request from client xcb_selection_notify_event_t* event; // event which we are going to send to client }; QList delayedSelectionRequests; //save running INCR transactions in this struct struct IncrTransaction { xcb_window_t requestor; xcb_atom_t property; xcb_atom_t target; QByteArray data; uint sentBytes; qint64 timestamp; }; QList incrTransactions; xcb_timestamp_t lastXTime=XCB_TIME_CURRENT_TIME; //current time of X Server int32_t timeDifference=0; //differense between X server time and system time uint32_t total_compressed=0; }; #endif x2gokdriveclient-0.0.0.1/VERSION.x2gokdriveclient0000644000000000000000000000000714441666201016352 0ustar 0.0.0.1x2gokdriveclient-0.0.0.1/x2gokdriveclient.pro0000644000000000000000000000267114441666201016036 0ustar ###################################################################### # Automatically generated by qmake (3.0) Mi. Okt. 31 08:52:37 2018 ###################################################################### TEMPLATE = app TARGET = x2gokdriveclient INCLUDEPATH += src CONFIG += console c++11 QT += widgets QT += network linux { message("Building for Linux") QT += x11extras LIBS += -lxcb -lxcb-xfixes } RESOURCES += res/resources.qrc VERSION = "$$cat($${PWD}/VERSION.x2gokdriveclient)" # Input TRANSLATIONS += res/i18n/x2gokdriveclient_de.ts HEADERS += src/client.h \ src/displayarea.h \ src/menuframe.h \ src/screenidentifier.h \ src/extwin.h SOURCES += src/main.cpp \ src/client.cpp \ src/displayarea.cpp \ src/menuframe.cpp \ src/screenidentifier.cpp \ src/extwin.cpp linux { HEADERS += src/xcbclip.h SOURCES += src/xcbclip.cpp } windows { message("Building for Windows") LIBS += -ldwmapi } LIBS += -lz !isEmpty(TRANSLATIONS) { isEmpty(QMAKE_LRELEASE) { qtPrepareTool(QMAKE_LRELEASE, lrelease) } isEmpty(TS_DIR):TS_DIR = . TSQM.name = lrelease ${QMAKE_FILE_IN} TSQM.input = TRANSLATIONS TSQM.output = $$TS_DIR/${QMAKE_FILE_BASE}.qm TSQM.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} TSQM.CONFIG = no_link QMAKE_EXTRA_COMPILERS += TSQM PRE_TARGETDEPS += compiler_TSQM_make_all } else:message("No translation files in project")