initial commit
Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
175
libs/wxWidgets-3.3.1/include/wx/unix/private/displayx11.h
Normal file
175
libs/wxWidgets-3.3.1/include/wx/unix/private/displayx11.h
Normal file
@@ -0,0 +1,175 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/unix/private/displayx11.h
|
||||
// Purpose: Helper functions used by wxX11 and wxGTK ports
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2018-10-04 (extracted from src/unix/displayx11.cpp)
|
||||
// Copyright: (c) 2002-2018 wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_UNIX_PRIVATE_DISPLAYX11_H_
|
||||
#define _WX_UNIX_PRIVATE_DISPLAYX11_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#include "wx/unix/private/x11ptr.h"
|
||||
|
||||
#if wxUSE_DISPLAY
|
||||
|
||||
#include "wx/log.h"
|
||||
#include "wx/translation.h"
|
||||
|
||||
#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
|
||||
|
||||
#include <X11/extensions/xf86vmode.h>
|
||||
|
||||
//
|
||||
// See (http://www.xfree86.org/4.2.0/XF86VidModeDeleteModeLine.3.html) for more
|
||||
// info about xf86 video mode extensions
|
||||
//
|
||||
|
||||
//free private data common to x (usually s3) servers
|
||||
#define wxClearXVM(vm) if(vm.privsize) XFree(vm.c_private)
|
||||
|
||||
// Correct res rate from GLFW
|
||||
#define wxCRR2(v,dc) (int) (((1000.0f * (float) dc) /*PIXELS PER SECOND */) / ((float) v.htotal * v.vtotal /*PIXELS PER FRAME*/) + 0.5f)
|
||||
#define wxCRR(v) wxCRR2(v,v.dotclock)
|
||||
#define wxCVM2(v, dc, display, nScreen) wxVideoMode(v.hdisplay, v.vdisplay, DefaultDepth(display, nScreen), wxCRR2(v,dc))
|
||||
#define wxCVM(v, display, nScreen) wxCVM2(v, v.dotclock, display, nScreen)
|
||||
|
||||
wxArrayVideoModes wxXF86VidMode_GetModes(const wxVideoMode& mode, Display* display, int nScreen)
|
||||
{
|
||||
wxX11Ptr<XF86VidModeModeInfo*> ppXModes; //Enumerated Modes
|
||||
int nNumModes; //Number of modes enumerated....
|
||||
|
||||
wxArrayVideoModes Modes; //modes to return...
|
||||
|
||||
if (XF86VidModeGetAllModeLines(display, nScreen, &nNumModes, ppXModes.Out()))
|
||||
{
|
||||
for (int i = 0; i < nNumModes; ++i)
|
||||
{
|
||||
XF86VidModeModeInfo& info = *ppXModes[i];
|
||||
const wxVideoMode vm = wxCVM(info, display, nScreen);
|
||||
if (vm.Matches(mode))
|
||||
{
|
||||
Modes.Add(vm);
|
||||
}
|
||||
wxClearXVM(info);
|
||||
}
|
||||
}
|
||||
else //OOPS!
|
||||
{
|
||||
wxLogSysError(_("Failed to enumerate video modes"));
|
||||
}
|
||||
|
||||
return Modes;
|
||||
}
|
||||
|
||||
wxVideoMode wxXF86VidMode_GetCurrentMode(Display* display, int nScreen)
|
||||
{
|
||||
XF86VidModeModeLine VM;
|
||||
int nDotClock;
|
||||
if ( !XF86VidModeGetModeLine(display, nScreen, &nDotClock, &VM) )
|
||||
return wxVideoMode();
|
||||
|
||||
wxClearXVM(VM);
|
||||
return wxCVM2(VM, nDotClock, display, nScreen);
|
||||
}
|
||||
|
||||
bool wxXF86VidMode_ChangeMode(const wxVideoMode& mode, Display* display, int nScreen)
|
||||
{
|
||||
wxX11Ptr<XF86VidModeModeInfo*> ppXModes; //Enumerated Modes
|
||||
int nNumModes; //Number of modes enumerated....
|
||||
|
||||
if(!XF86VidModeGetAllModeLines(display, nScreen, &nNumModes, ppXModes.Out()))
|
||||
{
|
||||
wxLogSysError(_("Failed to change video mode"));
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bRet = false;
|
||||
if (mode == wxDefaultVideoMode)
|
||||
{
|
||||
bRet = XF86VidModeSwitchToMode(display, nScreen, ppXModes[0]) != 0;
|
||||
|
||||
for (int i = 0; i < nNumModes; ++i)
|
||||
{
|
||||
wxClearXVM((*ppXModes[i]));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < nNumModes; ++i)
|
||||
{
|
||||
if (!bRet &&
|
||||
ppXModes[i]->hdisplay == mode.GetWidth() &&
|
||||
ppXModes[i]->vdisplay == mode.GetHeight() &&
|
||||
wxCRR((*ppXModes[i])) == mode.GetRefresh())
|
||||
{
|
||||
//switch!
|
||||
bRet = XF86VidModeSwitchToMode(display, nScreen, ppXModes[i]) != 0;
|
||||
}
|
||||
wxClearXVM((*ppXModes[i]));
|
||||
}
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
#else // !HAVE_X11_EXTENSIONS_XF86VMODE_H
|
||||
|
||||
wxArrayVideoModes wxX11_GetModes(const wxDisplayImpl* impl, const wxVideoMode& modeMatch, Display* display)
|
||||
{
|
||||
int count_return;
|
||||
wxX11Ptr<int> depths(XListDepths(display, 0, &count_return));
|
||||
wxArrayVideoModes modes;
|
||||
if ( depths )
|
||||
{
|
||||
const wxRect rect = impl->GetGeometry();
|
||||
for ( int x = 0; x < count_return; ++x )
|
||||
{
|
||||
wxVideoMode mode(rect.width, rect.height, depths[x]);
|
||||
if ( mode.Matches(modeMatch) )
|
||||
{
|
||||
modes.Add(mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
return modes;
|
||||
}
|
||||
|
||||
#endif // !HAVE_X11_EXTENSIONS_XF86VMODE_H
|
||||
|
||||
#endif // wxUSE_DISPLAY
|
||||
|
||||
void wxGetWorkAreaX11(Screen* screen, int& x, int& y, int& width, int& height)
|
||||
{
|
||||
Display* display = DisplayOfScreen(screen);
|
||||
Atom property = XInternAtom(display, "_NET_WORKAREA", true);
|
||||
if (property)
|
||||
{
|
||||
Atom actual_type;
|
||||
int actual_format;
|
||||
unsigned long nitems;
|
||||
unsigned long bytes_after;
|
||||
wxX11Ptr<unsigned char> data;
|
||||
Status status = XGetWindowProperty(
|
||||
display, RootWindowOfScreen(screen), property,
|
||||
0, 4, false, XA_CARDINAL,
|
||||
&actual_type, &actual_format, &nitems, &bytes_after, data.Out());
|
||||
if (status == Success && actual_type == XA_CARDINAL &&
|
||||
actual_format == 32 && nitems == 4)
|
||||
{
|
||||
const long* p = (const long*)data.get();
|
||||
x = p[0];
|
||||
y = p[1];
|
||||
width = p[2];
|
||||
height = p[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _WX_UNIX_PRIVATE_DISPLAYX11_H_
|
||||
@@ -0,0 +1,53 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/unix/private/epolldispatcher.h
|
||||
// Purpose: wxEpollDispatcher class
|
||||
// Authors: Lukasz Michalski
|
||||
// Created: April 2007
|
||||
// Copyright: (c) Lukasz Michalski
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_EPOLLDISPATCHER_H_
|
||||
#define _WX_PRIVATE_EPOLLDISPATCHER_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#ifdef wxUSE_EPOLL_DISPATCHER
|
||||
|
||||
#include "wx/private/fdiodispatcher.h"
|
||||
|
||||
struct epoll_event;
|
||||
|
||||
class WXDLLIMPEXP_BASE wxEpollDispatcher : public wxFDIODispatcher
|
||||
{
|
||||
public:
|
||||
// create a new instance of this class, can return nullptr if
|
||||
// epoll() is not supported on this system
|
||||
//
|
||||
// the caller should delete the returned pointer
|
||||
static wxEpollDispatcher *Create();
|
||||
|
||||
virtual ~wxEpollDispatcher();
|
||||
|
||||
// implement base class pure virtual methods
|
||||
virtual bool RegisterFD(int fd, wxFDIOHandler* handler, int flags = wxFDIO_ALL) override;
|
||||
virtual bool ModifyFD(int fd, wxFDIOHandler* handler, int flags = wxFDIO_ALL) override;
|
||||
virtual bool UnregisterFD(int fd) override;
|
||||
virtual bool HasPending() const override;
|
||||
virtual int Dispatch(int timeout = TIMEOUT_INFINITE) override;
|
||||
|
||||
private:
|
||||
// ctor is private, use Create()
|
||||
wxEpollDispatcher(int epollDescriptor);
|
||||
|
||||
// common part of HasPending() and Dispatch(): calls epoll_wait() with the
|
||||
// given timeout
|
||||
int DoPoll(epoll_event *events, int numEvents, int timeout) const;
|
||||
|
||||
|
||||
int m_epollDescriptor;
|
||||
};
|
||||
|
||||
#endif // wxUSE_EPOLL_DISPATCHER
|
||||
|
||||
#endif // _WX_PRIVATE_SOCKETEVTDISPATCH_H_
|
||||
102
libs/wxWidgets-3.3.1/include/wx/unix/private/execute.h
Normal file
102
libs/wxWidgets-3.3.1/include/wx/unix/private/execute.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/unix/private/execute.h
|
||||
// Purpose: private details of wxExecute() implementation
|
||||
// Author: Vadim Zeitlin
|
||||
// Copyright: (c) 1998 Robert Roebling, Julian Smart, Vadim Zeitlin
|
||||
// (c) 2013 Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_UNIX_EXECUTE_H
|
||||
#define _WX_UNIX_EXECUTE_H
|
||||
|
||||
#include "wx/app.h"
|
||||
#include "wx/process.h"
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
#include "wx/unix/pipe.h"
|
||||
#include "wx/private/streamtempinput.h"
|
||||
#endif
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
class wxEventLoopBase;
|
||||
|
||||
// Information associated with a running child process.
|
||||
class wxExecuteData
|
||||
{
|
||||
public:
|
||||
wxExecuteData()
|
||||
{
|
||||
m_flags =
|
||||
m_pid = 0;
|
||||
m_exitcode = -1;
|
||||
|
||||
m_process = nullptr;
|
||||
|
||||
m_syncEventLoop = nullptr;
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
m_fdOut =
|
||||
m_fdErr = wxPipe::INVALID_FD;
|
||||
#endif // wxUSE_STREAMS
|
||||
}
|
||||
|
||||
// This must be called in the parent process as soon as fork() returns to
|
||||
// update us with the effective child PID. It also ensures that we handle
|
||||
// SIGCHLD to be able to detect when this PID exits, so wxTheApp must be
|
||||
// available.
|
||||
void OnStart(int pid);
|
||||
|
||||
// Called when the child process exits.
|
||||
void OnExit(int exitcode);
|
||||
|
||||
// Return true if we should (or already did) redirect the child IO.
|
||||
bool IsRedirected() const { return m_process && m_process->IsRedirected(); }
|
||||
|
||||
|
||||
// wxExecute() flags
|
||||
int m_flags;
|
||||
|
||||
// the pid of the child process
|
||||
int m_pid;
|
||||
|
||||
// The exit code of the process, set once the child terminates.
|
||||
int m_exitcode;
|
||||
|
||||
// the associated process object or nullptr
|
||||
wxProcess *m_process;
|
||||
|
||||
// Local event loop used to wait for the child process termination in
|
||||
// synchronous execution case. We can't create it ourselves as its exact
|
||||
// type depends on the application kind (console/GUI), so we rely on
|
||||
// wxAppTraits setting up this pointer to point to the appropriate object.
|
||||
wxEventLoopBase *m_syncEventLoop;
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
// the input buffer bufOut is connected to stdout, this is why it is
|
||||
// called bufOut and not bufIn
|
||||
wxStreamTempInputBuffer m_bufOut,
|
||||
m_bufErr;
|
||||
|
||||
// the corresponding FDs, -1 if not redirected
|
||||
int m_fdOut,
|
||||
m_fdErr;
|
||||
#endif // wxUSE_STREAMS
|
||||
|
||||
|
||||
private:
|
||||
// SIGCHLD signal handler that checks whether any of the currently running
|
||||
// children have exited.
|
||||
static void OnSomeChildExited(int sig);
|
||||
|
||||
// All currently running child processes indexed by their PID.
|
||||
//
|
||||
// Notice that the container doesn't own its elements.
|
||||
using ChildProcessesData = std::unordered_map<int, wxExecuteData*>;
|
||||
static ChildProcessesData ms_childProcesses;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxExecuteData);
|
||||
};
|
||||
|
||||
#endif // _WX_UNIX_EXECUTE_H
|
||||
136
libs/wxWidgets-3.3.1/include/wx/unix/private/executeiohandler.h
Normal file
136
libs/wxWidgets-3.3.1/include/wx/unix/private/executeiohandler.h
Normal file
@@ -0,0 +1,136 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/unix/private/executeiohandler.h
|
||||
// Purpose: IO handler class for the FD used by wxExecute() under Unix
|
||||
// Author: Rob Bresalier, Vadim Zeitlin
|
||||
// Created: 2013-01-06
|
||||
// Copyright: (c) 2013 Rob Bresalier, Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_UNIX_PRIVATE_EXECUTEIOHANDLER_H_
|
||||
#define _WX_UNIX_PRIVATE_EXECUTEIOHANDLER_H_
|
||||
|
||||
#include "wx/private/streamtempinput.h"
|
||||
|
||||
// This class handles IO events on the pipe FD connected to the child process
|
||||
// stdout/stderr and is used by wxExecute().
|
||||
//
|
||||
// Currently it can derive from either wxEventLoopSourceHandler or
|
||||
// wxFDIOHandler depending on the kind of dispatcher/event loop it is used
|
||||
// with. In the future, when we get rid of wxFDIOHandler entirely, it will
|
||||
// derive from wxEventLoopSourceHandler only.
|
||||
template <class T>
|
||||
class wxExecuteIOHandlerBase : public T
|
||||
{
|
||||
public:
|
||||
wxExecuteIOHandlerBase(int fd, wxStreamTempInputBuffer& buf)
|
||||
: m_fd(fd),
|
||||
m_buf(buf)
|
||||
{
|
||||
m_callbackDisabled = false;
|
||||
}
|
||||
|
||||
// Called when the associated descriptor is available for reading.
|
||||
virtual void OnReadWaiting() override
|
||||
{
|
||||
// Sync process, process all data coming at us from the pipe so that
|
||||
// the pipe does not get full and cause a deadlock situation.
|
||||
m_buf.Update();
|
||||
|
||||
if ( m_buf.Eof() )
|
||||
DisableCallback();
|
||||
}
|
||||
|
||||
// These methods are never called as we only monitor the associated FD for
|
||||
// reading, but we still must implement them as they're pure virtual in the
|
||||
// base class.
|
||||
virtual void OnWriteWaiting() override { }
|
||||
virtual void OnExceptionWaiting() override { }
|
||||
|
||||
// Disable any future calls to our OnReadWaiting(), can be called when
|
||||
// we're sure that no more input is forthcoming.
|
||||
void DisableCallback()
|
||||
{
|
||||
if ( !m_callbackDisabled )
|
||||
{
|
||||
m_callbackDisabled = true;
|
||||
|
||||
DoDisable();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
const int m_fd;
|
||||
|
||||
private:
|
||||
virtual void DoDisable() = 0;
|
||||
|
||||
wxStreamTempInputBuffer& m_buf;
|
||||
|
||||
// If true, DisableCallback() had been already called.
|
||||
bool m_callbackDisabled;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxExecuteIOHandlerBase);
|
||||
};
|
||||
|
||||
// This is the version used with wxFDIODispatcher, which must be passed to the
|
||||
// ctor in order to register this handler with it.
|
||||
class wxExecuteFDIOHandler : public wxExecuteIOHandlerBase<wxFDIOHandler>
|
||||
{
|
||||
public:
|
||||
wxExecuteFDIOHandler(wxFDIODispatcher& dispatcher,
|
||||
int fd,
|
||||
wxStreamTempInputBuffer& buf)
|
||||
: wxExecuteIOHandlerBase<wxFDIOHandler>(fd, buf),
|
||||
m_dispatcher(dispatcher)
|
||||
{
|
||||
dispatcher.RegisterFD(fd, this, wxFDIO_INPUT);
|
||||
}
|
||||
|
||||
virtual ~wxExecuteFDIOHandler()
|
||||
{
|
||||
DisableCallback();
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void DoDisable() override
|
||||
{
|
||||
m_dispatcher.UnregisterFD(m_fd);
|
||||
}
|
||||
|
||||
wxFDIODispatcher& m_dispatcher;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxExecuteFDIOHandler);
|
||||
};
|
||||
|
||||
// And this is the version used with an event loop. As AddSourceForFD() is
|
||||
// static, we don't require passing the event loop to the ctor but an event
|
||||
// loop must be running to handle our events.
|
||||
class wxExecuteEventLoopSourceHandler
|
||||
: public wxExecuteIOHandlerBase<wxEventLoopSourceHandler>
|
||||
{
|
||||
public:
|
||||
wxExecuteEventLoopSourceHandler(int fd, wxStreamTempInputBuffer& buf)
|
||||
: wxExecuteIOHandlerBase<wxEventLoopSourceHandler>(fd, buf)
|
||||
{
|
||||
m_source = wxEventLoop::AddSourceForFD(fd, this, wxEVENT_SOURCE_INPUT);
|
||||
}
|
||||
|
||||
virtual ~wxExecuteEventLoopSourceHandler()
|
||||
{
|
||||
DisableCallback();
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void DoDisable() override
|
||||
{
|
||||
delete m_source;
|
||||
m_source = nullptr;
|
||||
}
|
||||
|
||||
wxEventLoopSource* m_source;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxExecuteEventLoopSourceHandler);
|
||||
};
|
||||
|
||||
#endif // _WX_UNIX_PRIVATE_EXECUTEIOHANDLER_H_
|
||||
27
libs/wxWidgets-3.3.1/include/wx/unix/private/fdiounix.h
Normal file
27
libs/wxWidgets-3.3.1/include/wx/unix/private/fdiounix.h
Normal file
@@ -0,0 +1,27 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/unix/private/fdiounix.h
|
||||
// Purpose: wxFDIOManagerUnix class used by console Unix applications
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2009-08-17
|
||||
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _UNIX_PRIVATE_FDIOUNIX_H_
|
||||
#define _UNIX_PRIVATE_FDIOUNIX_H_
|
||||
|
||||
#include "wx/private/fdiomanager.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFDIOManagerUnix: implement wxFDIOManager interface using wxFDIODispatcher
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxFDIOManagerUnix : public wxFDIOManager
|
||||
{
|
||||
public:
|
||||
virtual int AddInput(wxFDIOHandler *handler, int fd, Direction d) override;
|
||||
virtual void RemoveInput(wxFDIOHandler *handler, int fd, Direction d) override;
|
||||
};
|
||||
|
||||
#endif // _UNIX_PRIVATE_FDIOUNIX_H_
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/unix/private/fswatcher_inotify.h
|
||||
// Purpose: File system watcher impl classes
|
||||
// Author: Bartosz Bekier
|
||||
// Created: 2009-05-26
|
||||
// Copyright: (c) 2009 Bartosz Bekier <bartosz.bekier@gmail.com>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef WX_UNIX_PRIVATE_FSWATCHER_INOTIFY_H_
|
||||
#define WX_UNIX_PRIVATE_FSWATCHER_INOTIFY_H_
|
||||
|
||||
#include "wx/filename.h"
|
||||
#include "wx/evtloopsrc.h"
|
||||
|
||||
// ============================================================================
|
||||
// wxFSWatcherEntry implementation & helper declarations
|
||||
// ============================================================================
|
||||
|
||||
class wxFSWatcherImplUNIX;
|
||||
|
||||
class wxFSWatchEntry : public wxFSWatchInfo
|
||||
{
|
||||
public:
|
||||
wxFSWatchEntry(const wxFSWatchInfo& winfo) :
|
||||
wxFSWatchInfo(winfo)
|
||||
{
|
||||
}
|
||||
|
||||
int GetWatchDescriptor() const
|
||||
{
|
||||
return m_wd;
|
||||
}
|
||||
|
||||
void SetWatchDescriptor(int wd)
|
||||
{
|
||||
m_wd = wd;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_wd;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxFSWatchEntry);
|
||||
};
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// wxFSWSourceHandler helper class
|
||||
// ============================================================================
|
||||
|
||||
class wxFSWatcherImplUnix;
|
||||
|
||||
/**
|
||||
* Handler for handling i/o from inotify descriptor
|
||||
*/
|
||||
class wxFSWSourceHandler : public wxEventLoopSourceHandler
|
||||
{
|
||||
public:
|
||||
wxFSWSourceHandler(wxFSWatcherImplUnix* service) :
|
||||
m_service(service)
|
||||
{ }
|
||||
|
||||
virtual void OnReadWaiting() override;
|
||||
virtual void OnWriteWaiting() override;
|
||||
virtual void OnExceptionWaiting() override;
|
||||
|
||||
protected:
|
||||
wxFSWatcherImplUnix* m_service;
|
||||
};
|
||||
|
||||
#endif /* WX_UNIX_PRIVATE_FSWATCHER_INOTIFY_H_ */
|
||||
108
libs/wxWidgets-3.3.1/include/wx/unix/private/fswatcher_kqueue.h
Normal file
108
libs/wxWidgets-3.3.1/include/wx/unix/private/fswatcher_kqueue.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/unix/private/fswatcher_kqueue.h
|
||||
// Purpose: File system watcher impl classes
|
||||
// Author: Bartosz Bekier
|
||||
// Created: 2009-05-26
|
||||
// Copyright: (c) 2009 Bartosz Bekier <bartosz.bekier@gmail.com>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef WX_UNIX_PRIVATE_FSWATCHER_KQUEUE_H_
|
||||
#define WX_UNIX_PRIVATE_FSWATCHER_KQUEUE_H_
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "wx/dir.h"
|
||||
#include "wx/debug.h"
|
||||
#include "wx/arrstr.h"
|
||||
|
||||
// ============================================================================
|
||||
// wxFSWatcherEntry implementation & helper declarations
|
||||
// ============================================================================
|
||||
|
||||
class wxFSWatcherImplKqueue;
|
||||
|
||||
class wxFSWatchEntryKq : public wxFSWatchInfo
|
||||
{
|
||||
public:
|
||||
struct wxDirState
|
||||
{
|
||||
wxDirState(const wxFSWatchInfo& winfo)
|
||||
{
|
||||
if (!wxDir::Exists(winfo.GetPath()))
|
||||
return;
|
||||
|
||||
wxDir dir(winfo.GetPath());
|
||||
wxCHECK_RET( dir.IsOpened(),
|
||||
wxString::Format(wxASCII_STR("Unable to open dir '%s'"), winfo.GetPath()));
|
||||
|
||||
wxString filename;
|
||||
bool ret = dir.GetFirst(&filename);
|
||||
while (ret)
|
||||
{
|
||||
files.push_back(filename);
|
||||
ret = dir.GetNext(&filename);
|
||||
}
|
||||
}
|
||||
|
||||
wxSortedArrayString files;
|
||||
};
|
||||
|
||||
wxFSWatchEntryKq(const wxFSWatchInfo& winfo) :
|
||||
wxFSWatchInfo(winfo), m_lastState(winfo)
|
||||
{
|
||||
m_fd = wxOpen(m_path, O_RDONLY, 0);
|
||||
if (m_fd == -1)
|
||||
{
|
||||
wxLogSysError(_("Unable to open path '%s'"), m_path);
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~wxFSWatchEntryKq()
|
||||
{
|
||||
(void) Close();
|
||||
}
|
||||
|
||||
bool Close()
|
||||
{
|
||||
if (!IsOk())
|
||||
return false;
|
||||
|
||||
int ret = close(m_fd);
|
||||
if (ret == -1)
|
||||
{
|
||||
wxLogSysError(_("Unable to close path '%s'"), m_path);
|
||||
}
|
||||
m_fd = -1;
|
||||
|
||||
return ret != -1;
|
||||
}
|
||||
|
||||
bool IsOk() const
|
||||
{
|
||||
return m_fd != -1;
|
||||
}
|
||||
|
||||
int GetFileDescriptor() const
|
||||
{
|
||||
return m_fd;
|
||||
}
|
||||
|
||||
void RefreshState()
|
||||
{
|
||||
m_lastState = wxDirState(*this);
|
||||
}
|
||||
|
||||
const wxDirState& GetLastState() const
|
||||
{
|
||||
return m_lastState;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_fd;
|
||||
wxDirState m_lastState;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxFSWatchEntryKq);
|
||||
};
|
||||
|
||||
#endif /* WX_UNIX_PRIVATE_FSWATCHER_KQUEUE_H_ */
|
||||
37
libs/wxWidgets-3.3.1/include/wx/unix/private/pipestream.h
Normal file
37
libs/wxWidgets-3.3.1/include/wx/unix/private/pipestream.h
Normal file
@@ -0,0 +1,37 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/unix/private/pipestream.h
|
||||
// Purpose: Unix wxPipeInputStream and wxPipeOutputStream declarations
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2013-06-08 (extracted from wx/unix/pipe.h)
|
||||
// Copyright: (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_UNIX_PRIVATE_PIPESTREAM_H_
|
||||
#define _WX_UNIX_PRIVATE_PIPESTREAM_H_
|
||||
|
||||
#include "wx/wfstream.h"
|
||||
|
||||
class wxPipeInputStream : public wxFileInputStream
|
||||
{
|
||||
public:
|
||||
explicit wxPipeInputStream(int fd) : wxFileInputStream(fd) { }
|
||||
|
||||
// return true if the pipe is still opened
|
||||
bool IsOpened() const { return !Eof(); }
|
||||
|
||||
// return true if we have anything to read, don't block
|
||||
virtual bool CanRead() const override;
|
||||
};
|
||||
|
||||
class wxPipeOutputStream : public wxFileOutputStream
|
||||
{
|
||||
public:
|
||||
wxPipeOutputStream(int fd) : wxFileOutputStream(fd) { }
|
||||
|
||||
// Override the base class version to ignore "pipe full" errors: this is
|
||||
// not an error for this class.
|
||||
size_t OnSysWrite(const void *buffer, size_t size) override;
|
||||
};
|
||||
|
||||
#endif // _WX_UNIX_PRIVATE_PIPESTREAM_H_
|
||||
151
libs/wxWidgets-3.3.1/include/wx/unix/private/sockunix.h
Normal file
151
libs/wxWidgets-3.3.1/include/wx/unix/private/sockunix.h
Normal file
@@ -0,0 +1,151 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/unix/private/sockunix.h
|
||||
// Purpose: wxSocketImpl implementation for Unix systems
|
||||
// Authors: Guilhem Lavaux, Vadim Zeitlin
|
||||
// Created: April 1997
|
||||
// Copyright: (c) 1997 Guilhem Lavaux
|
||||
// (c) 2008 Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_UNIX_GSOCKUNX_H_
|
||||
#define _WX_UNIX_GSOCKUNX_H_
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
// Under older (Open)Solaris versions FIONBIO is declared in this header only.
|
||||
// In the newer versions it's included by sys/ioctl.h but it's simpler to just
|
||||
// include it always instead of testing for whether it is or not.
|
||||
#ifdef __SOLARIS__
|
||||
#include <sys/filio.h>
|
||||
#endif
|
||||
|
||||
#include "wx/private/fdiomanager.h"
|
||||
|
||||
#define wxCloseSocket close
|
||||
|
||||
class wxSocketImplUnix : public wxSocketImpl,
|
||||
public wxFDIOHandler
|
||||
{
|
||||
public:
|
||||
wxSocketImplUnix(wxSocketBase& wxsocket)
|
||||
: wxSocketImpl(wxsocket)
|
||||
{
|
||||
m_fds[0] =
|
||||
m_fds[1] = -1;
|
||||
}
|
||||
|
||||
virtual void ReenableEvents(wxSocketEventFlags flags) override
|
||||
{
|
||||
// Events are only ever used for non-blocking sockets.
|
||||
if ( GetSocketFlags() & wxSOCKET_BLOCK )
|
||||
return;
|
||||
|
||||
// enable the notifications about input/output being available again in
|
||||
// case they were disabled by OnRead/WriteWaiting()
|
||||
//
|
||||
// notice that we'd like to enable the events here only if there is
|
||||
// nothing more left on the socket right now as otherwise we're going
|
||||
// to get a "ready for whatever" notification immediately (well, during
|
||||
// the next event loop iteration) and disable the event back again
|
||||
// which is rather inefficient but unfortunately doing it like this
|
||||
// doesn't work because the existing code (e.g. src/common/sckipc.cpp)
|
||||
// expects to keep getting notifications about the data available from
|
||||
// the socket even if it didn't read all the data the last time, so we
|
||||
// absolutely have to continue generating them
|
||||
EnableEvents(flags);
|
||||
}
|
||||
|
||||
virtual void UpdateBlockingState() override
|
||||
{
|
||||
// Make this int and not bool to allow passing it to ioctl().
|
||||
int isNonBlocking = (GetSocketFlags() & wxSOCKET_BLOCK) == 0;
|
||||
ioctl(m_fd, FIONBIO, &isNonBlocking);
|
||||
|
||||
DoEnableEvents(wxSOCKET_INPUT_FLAG | wxSOCKET_OUTPUT_FLAG, isNonBlocking);
|
||||
}
|
||||
|
||||
// wxFDIOHandler methods
|
||||
virtual void OnReadWaiting() override;
|
||||
virtual void OnWriteWaiting() override;
|
||||
virtual void OnExceptionWaiting() override;
|
||||
virtual bool IsOk() const override { return m_fd != INVALID_SOCKET; }
|
||||
|
||||
private:
|
||||
virtual wxSocketError GetLastError() const override;
|
||||
|
||||
virtual void DoClose() override
|
||||
{
|
||||
DisableEvents();
|
||||
|
||||
wxCloseSocket(m_fd);
|
||||
}
|
||||
|
||||
// enable or disable notifications for socket input/output events
|
||||
void EnableEvents(int flags = wxSOCKET_INPUT_FLAG | wxSOCKET_OUTPUT_FLAG)
|
||||
{ DoEnableEvents(flags, true); }
|
||||
void DisableEvents(int flags = wxSOCKET_INPUT_FLAG | wxSOCKET_OUTPUT_FLAG)
|
||||
{ DoEnableEvents(flags, false); }
|
||||
|
||||
// really enable or disable socket input/output events
|
||||
void DoEnableEvents(int flags, bool enable);
|
||||
|
||||
protected:
|
||||
// descriptors for input and output event notification channels associated
|
||||
// with the socket
|
||||
int m_fds[2];
|
||||
|
||||
private:
|
||||
// notify the associated wxSocket about a change in socket state and shut
|
||||
// down the socket if the event is wxSOCKET_LOST
|
||||
void OnStateChange(wxSocketNotify event);
|
||||
|
||||
// check if there is any input available, return 1 if yes, 0 if no or -1 on
|
||||
// error
|
||||
int CheckForInput();
|
||||
|
||||
|
||||
// give it access to our m_fds
|
||||
friend class wxSocketFDBasedManager;
|
||||
};
|
||||
|
||||
// A version of wxSocketManager which uses FDs for socket IO: it is used by
|
||||
// Unix console applications and some X11-like ports (wxGTK and wxQt but not
|
||||
// wxX11 currently) which implement their own port-specific wxFDIOManagers
|
||||
class wxSocketFDBasedManager : public wxSocketManager
|
||||
{
|
||||
public:
|
||||
wxSocketFDBasedManager()
|
||||
{
|
||||
m_fdioManager = nullptr;
|
||||
}
|
||||
|
||||
virtual bool OnInit() override;
|
||||
virtual void OnExit() override { }
|
||||
|
||||
virtual wxSocketImpl *CreateSocket(wxSocketBase& wxsocket) override
|
||||
{
|
||||
return new wxSocketImplUnix(wxsocket);
|
||||
}
|
||||
|
||||
virtual void Install_Callback(wxSocketImpl *socket_, wxSocketNotify event) override;
|
||||
virtual void Uninstall_Callback(wxSocketImpl *socket_, wxSocketNotify event) override;
|
||||
|
||||
protected:
|
||||
// get the FD index corresponding to the given wxSocketNotify
|
||||
wxFDIOManager::Direction
|
||||
GetDirForEvent(wxSocketImpl *socket, wxSocketNotify event);
|
||||
|
||||
// access the FDs we store
|
||||
int& FD(wxSocketImplUnix *socket, wxFDIOManager::Direction d)
|
||||
{
|
||||
return socket->m_fds[d];
|
||||
}
|
||||
|
||||
wxFDIOManager *m_fdioManager;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxSocketFDBasedManager);
|
||||
};
|
||||
|
||||
#endif /* _WX_UNIX_GSOCKUNX_H_ */
|
||||
138
libs/wxWidgets-3.3.1/include/wx/unix/private/timer.h
Normal file
138
libs/wxWidgets-3.3.1/include/wx/unix/private/timer.h
Normal file
@@ -0,0 +1,138 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/unix/private/timer.h
|
||||
// Purpose: wxTimer for wxBase (unix)
|
||||
// Author: Lukasz Michalski
|
||||
// Created: 15/01/2005
|
||||
// Copyright: (c) Lukasz Michalski
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_UNIX_PRIVATE_TIMER_H_
|
||||
#define _WX_UNIX_PRIVATE_TIMER_H_
|
||||
|
||||
#if wxUSE_TIMER
|
||||
|
||||
#include "wx/private/timer.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
// the type used for milliseconds is large enough for microseconds too but
|
||||
// introduce a synonym for it to avoid confusion
|
||||
typedef wxMilliClock_t wxUsecClock_t;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTimer implementation class for Unix platforms
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// NB: we have to export at least this symbol from the shared library, because
|
||||
// it's used by wxDFB's wxCore
|
||||
class WXDLLIMPEXP_BASE wxUnixTimerImpl : public wxTimerImpl
|
||||
{
|
||||
public:
|
||||
wxUnixTimerImpl(wxTimer *timer);
|
||||
virtual ~wxUnixTimerImpl();
|
||||
|
||||
virtual bool IsRunning() const override;
|
||||
virtual bool Start(int milliseconds = -1, bool oneShot = false) override;
|
||||
virtual void Stop() override;
|
||||
|
||||
// for wxTimerScheduler only: resets the internal flag indicating that the
|
||||
// timer is running
|
||||
void MarkStopped()
|
||||
{
|
||||
wxASSERT_MSG( m_isRunning, wxT("stopping non-running timer?") );
|
||||
|
||||
m_isRunning = false;
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_isRunning;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTimerSchedule: information about a single timer, used by wxTimerScheduler
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
struct wxTimerSchedule
|
||||
{
|
||||
wxTimerSchedule(wxUnixTimerImpl *timer, wxUsecClock_t expiration)
|
||||
: m_timer(timer),
|
||||
m_expiration(expiration)
|
||||
{
|
||||
}
|
||||
|
||||
// the timer itself (we don't own this pointer)
|
||||
wxUnixTimerImpl *m_timer;
|
||||
|
||||
// the time of its next expiration, in usec
|
||||
wxUsecClock_t m_expiration;
|
||||
};
|
||||
|
||||
// the linked list of all active timers, we keep it sorted by expiration time
|
||||
using wxTimerList = std::list<wxTimerSchedule>;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTimerScheduler: class responsible for updating all timers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxTimerScheduler
|
||||
{
|
||||
public:
|
||||
// get the unique timer scheduler instance
|
||||
static wxTimerScheduler& Get()
|
||||
{
|
||||
if ( !ms_instance )
|
||||
ms_instance = new wxTimerScheduler;
|
||||
|
||||
return *ms_instance;
|
||||
}
|
||||
|
||||
// must be called on shutdown to delete the global timer scheduler
|
||||
static void Shutdown()
|
||||
{
|
||||
if ( ms_instance )
|
||||
{
|
||||
delete ms_instance;
|
||||
ms_instance = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// adds timer which should expire at the given absolute time to the list
|
||||
void AddTimer(wxUnixTimerImpl *timer, wxUsecClock_t expiration);
|
||||
|
||||
// remove timer from the list, called automatically from timer dtor
|
||||
void RemoveTimer(wxUnixTimerImpl *timer);
|
||||
|
||||
|
||||
// the functions below are used by the event loop implementation to monitor
|
||||
// and notify timers:
|
||||
|
||||
// if this function returns true, the time remaining until the next time
|
||||
// expiration is returned in the provided parameter (always positive or 0)
|
||||
//
|
||||
// it returns false if there are no timers
|
||||
bool GetNext(wxUsecClock_t *remaining) const;
|
||||
|
||||
// trigger the timer event for all timers which have expired, return true
|
||||
// if any did
|
||||
bool NotifyExpired();
|
||||
|
||||
private:
|
||||
// ctor and dtor are private, this is a singleton class only created by
|
||||
// Get() and destroyed by Shutdown()
|
||||
wxTimerScheduler() = default;
|
||||
~wxTimerScheduler() = default;
|
||||
|
||||
// add the given timer schedule to the list in the right place
|
||||
void DoAddTimer(const wxTimerSchedule& s);
|
||||
|
||||
|
||||
// the list of all currently active timers sorted by expiration
|
||||
wxTimerList m_timers;
|
||||
|
||||
static wxTimerScheduler *ms_instance;
|
||||
};
|
||||
|
||||
#endif // wxUSE_TIMER
|
||||
|
||||
#endif // _WX_UNIX_PRIVATE_TIMER_H_
|
||||
69
libs/wxWidgets-3.3.1/include/wx/unix/private/uilocale.h
Normal file
69
libs/wxWidgets-3.3.1/include/wx/unix/private/uilocale.h
Normal file
@@ -0,0 +1,69 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/unix/private/uilocale.h
|
||||
// Purpose: Various locale-related helpers used under Unix systems only
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2021-08-14 (extracted from src/common/intl.cpp)
|
||||
// Copyright: (c) 2021 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_UNIX_PRIVATE_UILOCALE_H_
|
||||
#define _WX_UNIX_PRIVATE_UILOCALE_H_
|
||||
|
||||
#include "wx/string.h"
|
||||
|
||||
// get just the language part ("en" in "en_GB")
|
||||
inline wxString ExtractLang(const wxString& langFull)
|
||||
{
|
||||
return langFull.BeforeFirst('_');
|
||||
}
|
||||
|
||||
// get everything else (including the leading '_')
|
||||
inline wxString ExtractNotLang(const wxString& langFull)
|
||||
{
|
||||
size_t pos = langFull.find('_');
|
||||
if ( pos != wxString::npos )
|
||||
return langFull.substr(pos);
|
||||
else
|
||||
return wxString();
|
||||
}
|
||||
|
||||
const char *wxSetlocaleTryAll(int c, const wxLocaleIdent& lc);
|
||||
|
||||
// Extract date format from D_T_FMT value.
|
||||
wxString wxGetDateFormatOnly(const wxString& fmt);
|
||||
|
||||
// Helper class changing the global locale to the one specified by the
|
||||
// environment variables in its ctor and restoring it in its dtor.
|
||||
namespace
|
||||
{
|
||||
|
||||
class TempLocaleSetter
|
||||
{
|
||||
public:
|
||||
wxCLANG_WARNING_SUPPRESS(unused-member-function)
|
||||
explicit TempLocaleSetter(int localeCategory,
|
||||
const wxString& localeId = wxString())
|
||||
: m_localeCategory(localeCategory),
|
||||
m_localeOrig(strdup(setlocale(localeCategory, nullptr)))
|
||||
{
|
||||
setlocale(localeCategory, localeId.mb_str());
|
||||
}
|
||||
|
||||
~TempLocaleSetter()
|
||||
{
|
||||
setlocale(m_localeCategory, m_localeOrig);
|
||||
free(m_localeOrig);
|
||||
}
|
||||
wxCLANG_WARNING_RESTORE(unused-member-function)
|
||||
|
||||
private:
|
||||
const int m_localeCategory;
|
||||
char* const m_localeOrig;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(TempLocaleSetter);
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
#endif // _WX_UNIX_PRIVATE_UILOCALE_H_
|
||||
97
libs/wxWidgets-3.3.1/include/wx/unix/private/wakeuppipe.h
Normal file
97
libs/wxWidgets-3.3.1/include/wx/unix/private/wakeuppipe.h
Normal file
@@ -0,0 +1,97 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/unix/private/wakeuppipe.h
|
||||
// Purpose: Helper class allowing to wake up the main thread.
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2013-06-09 (extracted from src/unix/evtloopunix.cpp)
|
||||
// Copyright: (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_UNIX_PRIVATE_WAKEUPPIPE_H_
|
||||
#define _WX_UNIX_PRIVATE_WAKEUPPIPE_H_
|
||||
|
||||
#include "wx/unix/pipe.h"
|
||||
#include "wx/evtloopsrc.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxWakeUpPipe: allows to wake up the event loop by writing to it
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// This class is not MT-safe, see wxWakeUpPipeMT below for a wake up pipe
|
||||
// usable from other threads.
|
||||
|
||||
class wxWakeUpPipe : public wxEventLoopSourceHandler
|
||||
{
|
||||
public:
|
||||
// Create and initialize the pipe.
|
||||
//
|
||||
// It's the callers responsibility to add the read end of this pipe,
|
||||
// returned by GetReadFd(), to the code blocking on input.
|
||||
wxWakeUpPipe();
|
||||
|
||||
// Wake up the blocking operation involving this pipe.
|
||||
//
|
||||
// It simply writes to the write end of the pipe.
|
||||
//
|
||||
// As indicated by its name, this method does no locking and so can be
|
||||
// called only from the main thread.
|
||||
void WakeUpNoLock();
|
||||
|
||||
// Same as WakeUp() but without locking.
|
||||
|
||||
// Return the read end of the pipe.
|
||||
int GetReadFd() { return m_pipe[wxPipe::Read]; }
|
||||
|
||||
|
||||
// Implement wxEventLoopSourceHandler pure virtual methods
|
||||
virtual void OnReadWaiting() override;
|
||||
virtual void OnWriteWaiting() override { }
|
||||
virtual void OnExceptionWaiting() override { }
|
||||
|
||||
private:
|
||||
wxPipe m_pipe;
|
||||
|
||||
// This flag is set to true after writing to the pipe and reset to false
|
||||
// after reading from it in the main thread. Having it allows us to avoid
|
||||
// overflowing the pipe with too many writes if the main thread can't keep
|
||||
// up with reading from it.
|
||||
bool m_pipeIsEmpty;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxWakeUpPipeMT: thread-safe version of wxWakeUpPipe
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// This class can be used from multiple threads, i.e. its WakeUp() can be
|
||||
// called concurrently.
|
||||
|
||||
class wxWakeUpPipeMT : public wxWakeUpPipe
|
||||
{
|
||||
#if wxUSE_THREADS
|
||||
public:
|
||||
wxWakeUpPipeMT() = default;
|
||||
|
||||
// Thread-safe wrapper around WakeUpNoLock(): can be called from another
|
||||
// thread to wake up the main one.
|
||||
void WakeUp()
|
||||
{
|
||||
wxCriticalSectionLocker lock(m_pipeLock);
|
||||
|
||||
WakeUpNoLock();
|
||||
}
|
||||
|
||||
virtual void OnReadWaiting() override
|
||||
{
|
||||
wxCriticalSectionLocker lock(m_pipeLock);
|
||||
|
||||
wxWakeUpPipe::OnReadWaiting();
|
||||
}
|
||||
|
||||
private:
|
||||
// Protects access to m_pipeIsEmpty.
|
||||
wxCriticalSection m_pipeLock;
|
||||
|
||||
#endif // wxUSE_THREADS
|
||||
};
|
||||
|
||||
#endif // _WX_UNIX_PRIVATE_WAKEUPPIPE_H_
|
||||
67
libs/wxWidgets-3.3.1/include/wx/unix/private/x11ptr.h
Normal file
67
libs/wxWidgets-3.3.1/include/wx/unix/private/x11ptr.h
Normal file
@@ -0,0 +1,67 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/unix/private/x11ptr.h
|
||||
// Purpose: Simple RAII helper for calling XFree() automatically
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2025-04-28
|
||||
// Copyright: (c) 2025 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_UNIX_PRIVATE_X11PTR_H_
|
||||
#define _WX_UNIX_PRIVATE_X11PTR_H_
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Convenience class for calling XFree() automatically
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
template <typename T>
|
||||
class wxX11Ptr
|
||||
{
|
||||
public:
|
||||
wxX11Ptr() = default;
|
||||
explicit wxX11Ptr(const T *p) : m_ptr(const_cast<T*>(p)) { }
|
||||
wxX11Ptr(wxX11Ptr&& other) : m_ptr(other.m_ptr) { other.m_ptr = nullptr; }
|
||||
~wxX11Ptr() { reset(); }
|
||||
|
||||
wxX11Ptr& operator=(wxX11Ptr&& other)
|
||||
{
|
||||
if ( &other != this )
|
||||
{
|
||||
reset(other.m_ptr);
|
||||
other.m_ptr = nullptr;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
const T* get() const { return m_ptr; }
|
||||
|
||||
operator const T*() const { return m_ptr; }
|
||||
T* operator->() const { return m_ptr; }
|
||||
|
||||
void reset(T* p = nullptr)
|
||||
{
|
||||
if ( m_ptr )
|
||||
XFree(m_ptr);
|
||||
|
||||
m_ptr = p;
|
||||
}
|
||||
|
||||
T** Out()
|
||||
{
|
||||
wxASSERT_MSG( !m_ptr, wxS("Can't reuse the same object.") );
|
||||
|
||||
return &m_ptr;
|
||||
}
|
||||
|
||||
private:
|
||||
// We store the pointer as non-const because it avoids casts in the dtor
|
||||
// and Out(), but it's actually always handled as a const one.
|
||||
T* m_ptr = nullptr;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxX11Ptr);
|
||||
};
|
||||
|
||||
#endif // _WX_UNIX_PRIVATE_X11PTR_H_
|
||||
Reference in New Issue
Block a user