forked from H-uru/Plasma
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
503 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
|
||
#include "plClient.h" | ||
#include "plClientLoader.h" | ||
#include "plX11ClientWindow.h" | ||
|
||
#include "pnEncryption/plChallengeHash.h" | ||
|
||
|
@@ -88,10 +89,11 @@ extern bool gPythonLocal; | |
extern bool gSDLLocal; | ||
|
||
static plClientLoader gClient; | ||
static xcb_connection_t* gXConn; | ||
static xcb_key_symbols_t* keysyms; | ||
static pcSmallRect gWindowSize; | ||
static bool gHasXFixes = false; | ||
static plClientWindow* gWindow = nullptr; | ||
//static xcb_connection_t* gXConn; | ||
//static xcb_key_symbols_t* keysyms; | ||
//static pcSmallRect gWindowSize; | ||
//static bool gHasXFixes = false; | ||
static hsSemaphore statusFlag; | ||
|
||
enum | ||
|
@@ -165,22 +167,26 @@ void plClient::IResizeNativeDisplayDevice(int width, int height, bool windowed) | |
{ | ||
hsStatusMessage(ST::format("Setting window size to {}×{}", width, height).c_str()); | ||
|
||
#if 0 | ||
const uint32_t values[] = { uint32_t(width), uint32_t(height) }; | ||
xcb_configure_window(gXConn, (xcb_window_t)(uintptr_t)fWindowHndl, | ||
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, | ||
values); | ||
|
||
gWindowSize.fWidth = width; | ||
gWindowSize.fHeight = height; | ||
#endif | ||
} | ||
|
||
void plClient::IChangeResolution(int width, int height) {} | ||
void plClient::IUpdateProgressIndicator(plOperationProgress* progress) {} | ||
|
||
void plClient::ShowClientWindow() { | ||
#if 0 | ||
/* Map the window on the screen */ | ||
xcb_map_window(gXConn, (xcb_window_t)(uintptr_t)fWindowHndl); | ||
xcb_flush(gXConn); | ||
#endif | ||
} | ||
|
||
void plClient::FlashWindow() {} | ||
|
@@ -372,6 +378,7 @@ static uint32_t ParseRendererArgument(const ST::string& requested) | |
return hsG3DDeviceSelector::kDevTypeUnknown; | ||
} | ||
|
||
#if 0 | ||
static bool XInit(xcb_connection_t* connection) | ||
{ | ||
gWindowSize.Set(0, 0, 800, 600); | ||
|
@@ -442,6 +449,7 @@ static bool XInit(xcb_connection_t* connection) | |
gClient.Init(); | ||
return true; | ||
} | ||
#endif | ||
|
||
static void PumpMessageQueueProc() | ||
{ | ||
|
@@ -457,6 +465,7 @@ static void PumpMessageQueueProc() | |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 | ||
}; | ||
|
||
#if 0 | ||
xcb_generic_event_t* event; | ||
while ((event = xcb_poll_for_event(gXConn))) { | ||
switch (event->response_type & ~0x80) | ||
|
@@ -643,9 +652,9 @@ static void PumpMessageQueueProc() | |
|
||
free(event); | ||
} | ||
#endif | ||
} | ||
|
||
// Stub main function so it compiles on non-Windows | ||
int main(int argc, const char** argv) | ||
{ | ||
PF_CONSOLE_INIT_ALL(); | ||
|
@@ -689,6 +698,12 @@ int main(int argc, const char** argv) | |
if (cmdParser.IsSpecified(kArgServerIni)) | ||
serverIni = cmdParser.GetString(kArgServerIni); | ||
|
||
gWindow = new plX11ClientWindow(); | ||
if (!gWindow->PreInit()) { | ||
hsMessageBox(ST_LITERAL("Failed to initialize plClient"), ST_LITERAL("Error"), hsMessageBoxNormal); | ||
return 1; | ||
} | ||
|
||
// Load an optional general.ini | ||
plFileName gipath = plFileName::Join(plFileSystem::GetInitPath(), "general.ini"); | ||
FILE *generalini = plFileSystem::Open(gipath, "rb"); | ||
|
@@ -712,22 +727,27 @@ int main(int argc, const char** argv) | |
} | ||
else | ||
{ | ||
hsMessageBox("No server.ini file found. Please check your URU installation.", "Error", hsMessageBoxNormal); | ||
return 1; | ||
} | ||
|
||
if (!XInitThreads()) { | ||
hsMessageBox("Failed to initialize plClient", "Error", hsMessageBoxNormal); | ||
hsMessageBox(ST_LITERAL("No server.ini file found. Please check your URU installation."), ST_LITERAL("Error"), hsMessageBoxNormal); | ||
return 1; | ||
} | ||
|
||
#if 0 | ||
/* Open the connection to the X server */ | ||
gXConn = xcb_connect(nullptr, nullptr); | ||
|
||
if (!XInit(gXConn)) { | ||
hsMessageBox("Failed to initialize plClient", "Error", hsMessageBoxNormal); | ||
return 1; | ||
} | ||
#endif | ||
|
||
if (!gWindow->CreateClientWindow()) { | ||
hsMessageBox(ST_LITERAL("Failed to initialize plClient"), ST_LITERAL("Error"), hsMessageBoxNormal); | ||
return 1; | ||
} | ||
|
||
gClient.SetClientWindow(gWindow); | ||
gClient.Init(); | ||
|
||
NetCliAuthAutoReconnectEnable(false); | ||
NetCommStartup(); | ||
|
@@ -740,7 +760,7 @@ int main(int argc, const char** argv) | |
gClient.ShutdownEnd(); | ||
NetCommShutdown(); | ||
|
||
xcb_disconnect(gXConn); | ||
//xcb_disconnect(gXConn); | ||
|
||
return 0; | ||
} | ||
|
@@ -780,7 +800,7 @@ int main(int argc, const char** argv) | |
gClient.ShutdownEnd(); | ||
NetCommShutdown(); | ||
|
||
xcb_disconnect(gXConn); | ||
//xcb_disconnect(gXConn); | ||
|
||
return 0; | ||
} |
113 changes: 113 additions & 0 deletions
113
Sources/Plasma/Apps/plClient/linux/plX11ClientWindow.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/*==LICENSE==* | ||
CyanWorlds.com Engine - MMOG client, server and tools | ||
Copyright (C) 2011 Cyan Worlds, Inc. | ||
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 <http://www.gnu.org/licenses/>. | ||
Additional permissions under GNU GPL version 3 section 7 | ||
If you modify this Program, or any covered work, by linking or | ||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, | ||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent | ||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK | ||
(or a modified version of those libraries), | ||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, | ||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG | ||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the | ||
licensors of this Program grant you additional | ||
permission to convey the resulting work. Corresponding Source for a | ||
non-source form of such a combination shall include the source code for | ||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered | ||
work. | ||
You can contact Cyan Worlds, Inc. by email [email protected] | ||
or by snail mail at: | ||
Cyan Worlds, Inc. | ||
14617 N Newport Hwy | ||
Mead, WA 99021 | ||
*==LICENSE==*/ | ||
|
||
#include "plX11ClientWindow.h" | ||
#include "hsOptionalCall.h" | ||
#include "plProduct.h" | ||
|
||
#include <string_theory/format> | ||
#include <X11/Xlib.h> | ||
|
||
hsOptionalCallDecl("libX11.so", XCloseDisplay); | ||
hsOptionalCallDecl("libX11.so", XCreateWindow); | ||
hsOptionalCallDecl("libX11.so", XDestroyWindow); | ||
hsOptionalCallDecl("libX11.so", XFlush); | ||
hsOptionalCallDecl("libX11.so", XInitThreads); | ||
hsOptionalCallDecl("libX11.so", XMapWindow); | ||
hsOptionalCallDecl("libX11.so", XOpenDisplay); | ||
hsOptionalCallDecl("libX11.so", XStoreName); | ||
|
||
bool plX11ClientWindow::PreInit() | ||
{ | ||
// First: Check that we were able to dynamically load the X11 functions | ||
if (!(bool)__XOpenDisplay) | ||
return false; | ||
|
||
if (!*__XInitThreads()) | ||
return false; | ||
|
||
return true; | ||
} | ||
|
||
bool plX11ClientWindow::CreateClientWindow() | ||
{ | ||
fXDisplay = *__XOpenDisplay(nullptr); | ||
if (!fXDisplay) { | ||
hsDebugMessage("Could not connect to X server", -1); | ||
return false; | ||
} | ||
|
||
Window root = DefaultRootWindow(fXDisplay); | ||
|
||
XSetWindowAttributes win_attrs; | ||
win_attrs.background_pixmap = None; | ||
win_attrs.event_mask = ExposureMask | ||
| EnterWindowMask | ||
| LeaveWindowMask | ||
| PointerMotionMask | ||
| ButtonPressMask | ||
| ButtonReleaseMask | ||
| KeyPressMask | ||
| KeyReleaseMask | ||
| StructureNotifyMask; | ||
|
||
fXWindow = *__XCreateWindow(fXDisplay, root, fWindowSize.fX, fWindowSize.fY, fWindowSize.fWidth, fWindowSize.fHeight, 0, CopyFromParent, InputOutput, CopyFromParent, CWEventMask | CWBackPixmap, &win_attrs); | ||
|
||
const char* title = ST::format("{}", plProduct::LongName()).c_str(); | ||
__XStoreName(fXDisplay, fXWindow, title); | ||
|
||
return true; | ||
} | ||
|
||
void plX11ClientWindow::ShowClientWindow() | ||
{ | ||
__XMapWindow(fXDisplay, fXWindow); | ||
__XFlush(fXDisplay); | ||
} | ||
|
||
void plX11ClientWindow::DeInit() | ||
{ | ||
if (fXWindow) | ||
__XDestroyWindow(fXDisplay, fXWindow); | ||
if (fXDisplay) | ||
__XCloseDisplay(fXDisplay); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/*==LICENSE==* | ||
CyanWorlds.com Engine - MMOG client, server and tools | ||
Copyright (C) 2011 Cyan Worlds, Inc. | ||
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 <http://www.gnu.org/licenses/>. | ||
Additional permissions under GNU GPL version 3 section 7 | ||
If you modify this Program, or any covered work, by linking or | ||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, | ||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent | ||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK | ||
(or a modified version of those libraries), | ||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, | ||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG | ||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the | ||
licensors of this Program grant you additional | ||
permission to convey the resulting work. Corresponding Source for a | ||
non-source form of such a combination shall include the source code for | ||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered | ||
work. | ||
You can contact Cyan Worlds, Inc. by email [email protected] | ||
or by snail mail at: | ||
Cyan Worlds, Inc. | ||
14617 N Newport Hwy | ||
Mead, WA 99021 | ||
*==LICENSE==*/ | ||
|
||
#include "plClientWindow.h" | ||
|
||
class plX11ClientWindow : public plClientWindow | ||
{ | ||
private: | ||
struct _XDisplay* fXDisplay; | ||
uint32_t fXWindow; | ||
|
||
public: | ||
plX11ClientWindow() : plClientWindow(), fXDisplay(), fXWindow() { } | ||
|
||
bool PreInit() override; | ||
bool CreateClientWindow() override; | ||
void ShowClientWindow() override; | ||
void DeInit() override; | ||
|
||
hsWindowHndl GetWindowHandle() const override { | ||
return (hsWindowHndl)(uintptr_t)fXWindow; | ||
} | ||
hsWindowHndl GetDisplayHandle() const override { | ||
return (hsWindowHndl)fXDisplay; | ||
} | ||
}; |
Oops, something went wrong.