2
* KMix -- KDE's full featured mini mixer
4
* Copyright (C) 2000 Stefan Schimanski <schimmi@kde.org>
5
* Copyright (C) 2001 Preston Brown <pbrown@kde.org>
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Library General Public
9
* License as published by the Free Software Foundation; either
10
* version 2 of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Library General Public License for more details.
17
* You should have received a copy of the GNU Library General Public
18
* License along with this program; if not, write to the Free
19
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
#include "apps/kmix.h"
27
bool KMixApp::_keepVisibility = false;
30
: KUniqueApplication(), m_kmix( 0 )
32
// We must disable QuitOnLastWindowClosed. Rationale:
33
// 1) The normal state of KMix is to only have the dock icon shown.
34
// 2a) The dock icon gets reconstructed, whenever a soundcard is hotplugged or unplugged.
35
// 2b) The dock icon gets reconstructed, when the user selects a new master.
36
// 3) During the reconstruction, it can easily happen that no window is present => KMix would quit
37
// => disable QuitOnLastWindowClosed
38
setQuitOnLastWindowClosed ( false );
49
KMixApp::newInstance()
51
// There are 3 cases for a new instance
53
//kDebug(67100) << "KMixApp::newInstance() isRestored()=" << isRestored() << "_keepVisibility=" << _keepVisibility;
54
static bool first = true;
56
{ // There already exists an instance/window
58
/* !!! @bug : _keepVisibilty has the wrong value here.
59
It is supposed to have the value set by the command line
60
arg, and the keepVisibilty() method.
61
All looks fine, BUT(!!!) THIS code is NEVER entered in
62
the just started process.
63
KDE IPC (DBUS) has instead notified the already running
64
KMix process, about a newInstance(). So _keepVisibilty
65
has always the value of the first started KMix process.
66
This is a bug in KMix and must be fixed.
70
kDebug(67100) << "KMixApp::newInstance() Instance exists";
72
if ( ! _keepVisibility && !isSessionRestored() ) {
73
kDebug(67100) << "KMixApp::newInstance() SHOW WINDOW (_keepVisibility=" << _keepVisibility << ", isSessionRestored=" << isSessionRestored();
74
// CASE 1: If KMix is running AND the *USER*
75
// starts it again, the KMix main window will be shown.
76
// If KMix is restored by SM or the --keepvisibilty is used, KMix will NOT
77
// explicitly be shown.
78
KUniqueApplication::newInstance();
82
// kWarning(67100) << "KMixApp::newInstance() Window has not finished constructing yet so ignoring the show() request.";
86
// CASE 2: If KMix is running, AND ( session gets restored OR keepvisibilty command line switch )
87
kDebug(67100) << "KMixApp::newInstance() REGULAR_START _keepVisibility=" << _keepVisibility;
88
// Special case: Command line arg --keepVisibility was used:
89
// We don't want to change the visibiliy, thus we don't call show() here.
91
// Hint: --keepVisibility is a special option for applications that
92
// want to start a mixer service, but don't need to show the KMix
93
// GUI (like KMilo , KAlarm, ...).
94
// See (e.g.) Bug 58901 for deeper insight.
99
// CASE 3: KMix was not running yet => instanciate a new one
100
//kDebug(67100) << "KMixApp::newInstance() Instanciate: _keepVisibility=" << _keepVisibility ;
101
first = false; // NB See https://qa.mandriva.com/show_bug.cgi?id=56893#c3
102
// It is important to track this via a separate variable and not
103
// based on m_kmix to handle this race condition.
104
// Specific protection for the activation-prior-to-full-construction
105
// case exists above in the 'already running case'
106
m_kmix = new KMixWindow(_keepVisibility);
107
//connect(this, SIGNAL(stopUpdatesOnVisibility()), m_kmix, SLOT(stopVisibilityUpdates()));
108
if ( isSessionRestored() && KMainWindow::canBeRestored(0) )
110
m_kmix->restore(0, false);
117
void KMixApp::keepVisibility(bool val_keepVisibility) {
118
_keepVisibility = val_keepVisibility;
123
KMixApp::quitExtended()
125
// This method is here to quit hold from the dock icon: When directly calling
126
// quit(), the main window will be hidden before saving the configuration.
127
// isVisible() would return on quit always false (which would be bad).
128
kDebug(67100) << "quitExtended ENTER";
129
emit stopUpdatesOnVisibility();