KiCad PCB EDA Suite
Loading...
Searching...
No Matches
unix/app.cpp
Go to the documentation of this file.
1/*
2* This program source code file is part of KiCad, a free EDA CAD application.
3*
4* Copyright (C) 2020 Mark Roszko <[email protected]>
5* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6*
7* This program is free software: you can redistribute it and/or modify it
8* under the terms of the GNU General Public License as published by the
9* Free Software Foundation, either version 3 of the License, or (at your
10* option) any later version.
11*
12* This program is distributed in the hope that it will be useful, but
13* WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public License
18* along with this program. If not, see <https://www.gnu.org/licenses/>.
19*/
20
21#include <kiplatform/app.h>
22
23#ifdef __linux__
24#include <sys/resource.h>
25#include <sys/syscall.h>
26#include <unistd.h>
27#endif
28
29#include <glib.h>
30
31#include <wx/string.h>
32#include <wx/utils.h>
33
34
35/*
36 * Function to attach to the glib logger to eat the output it gives so we don't
37 * get the message spam on the terminal from wxWidget's abuse of the GTK API.
38 */
39static GLogWriterOutput nullLogWriter( GLogLevelFlags log_level, const GLogField* fields,
40 gsize n_fields, gpointer user_data )
41{
42 return G_LOG_WRITER_HANDLED;
43}
44
45
47{
48 // Set KICAD_SHOW_GTK_MESSAGES=1 env var to show GTK messages,
49 // otherwise, we hide them to avoid message spam.
50
51 wxString showMessages;
52 wxGetEnv( wxT( "KICAD_SHOW_GTK_MESSAGES" ), &showMessages );
53
54 if( showMessages.IsEmpty() || showMessages != "1" )
55 {
56 // Attach a logger that will consume the annoying GTK error messages
57 g_log_set_writer_func( nullLogWriter, nullptr, nullptr );
58 }
59
60 return true;
61}
62
63
65{
66}
67
68
69bool KIPLATFORM::APP::AttachConsole( bool aTryAlloc )
70{
71 // Not implemented on this platform
72 return true;
73}
74
75
77{
78 // Not implemented on this platform
79 return false;
80}
81
82
83bool KIPLATFORM::APP::RegisterApplicationRestart( const wxString& aCommandLine )
84{
85 // Not implemented on this platform
86 return true;
87}
88
89
91{
92 // Not implemented on this platform
93 return true;
94}
95
96
98{
99 return false;
100}
101
102
104{
105}
106
107
108void KIPLATFORM::APP::SetShutdownBlockReason( wxWindow* aWindow, const wxString& aReason )
109{
110}
111
112
116
117
119{
120}
121
122
124{
125#ifdef __linux__
126 // Each Linux thread has its own nice value, and a negative one needs privilege
127 const pid_t tid = static_cast<pid_t>( syscall( SYS_gettid ) );
128
129 return setpriority( PRIO_PROCESS, tid, aRaise ? -5 : 5 ) == 0;
130#else
131 return false;
132#endif
133}
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition unix/app.cpp:108
bool UnregisterApplicationRestart()
Unregisters the application from automatic restart.
Definition unix/app.cpp:90
bool SetCurrentThreadPriority(bool aRaise)
Raise or lower the scheduling priority of the calling thread.
Definition unix/app.cpp:123
bool AttachConsole(bool aTryAlloc)
Tries to attach a console window with stdout, stderr and stdin.
Definition unix/app.cpp:69
void RemoveShutdownBlockReason(wxWindow *aWindow)
Removes any shutdown block reason set.
Definition unix/app.cpp:103
bool RegisterApplicationRestart(const wxString &aCommandLine)
Registers the application for restart with the OS with the given command line string to pass as args.
Definition unix/app.cpp:83
bool Init()
Perform application-specific initialization tasks.
Definition unix/app.cpp:46
void ForceTimerMessagesToBeCreatedIfNecessary()
Forces wxTimers to fire more promptly on Win32.
Definition unix/app.cpp:113
bool IsOperatingSystemUnsupported()
Checks if the Operating System is explicitly unsupported and we want to prevent users from sending bu...
Definition unix/app.cpp:76
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition unix/app.cpp:97
void EnableDarkMode(bool aForce)
Definition unix/app.cpp:64
void AddDynamicLibrarySearchPath(const wxString &aPath)
Inserts a search path for loading dynamic libraries.
Definition unix/app.cpp:118
static GLogWriterOutput nullLogWriter(GLogLevelFlags log_level, const GLogField *fields, gsize n_fields, gpointer user_data)
Definition unix/app.cpp:39