Warn when somebody plays too much, turns off a border and doesn't know how

to put it back *sigh*.

CCMAIL: 64938-done@bugs.kde.org

svn path=/trunk/kdebase/kwin/; revision=258583
icc-effect-5.14.5
Luboš Luňák 2003-10-13 16:22:39 +00:00
parent a77da4851e
commit 8b5159bb1a
7 changed files with 136 additions and 3 deletions

View File

@ -1,6 +1,6 @@
INCLUDES = -I$(srcdir)/lib $(all_includes)
SUBDIRS = lib . killer kcmkwin pics clients oldheaders
SUBDIRS = lib . killer dialog kcmkwin pics clients oldheaders
bin_PROGRAMS =
lib_LTLIBRARIES =

View File

@ -1007,7 +1007,7 @@ void Client::killProcess( bool ask, Time timestamp )
if( machine != "localhost" )
{
KProcess proc;
proc << "xon" << machine << "kill" << pid;
proc << "xon" << machine << "kill" << pid;
proc.start( KProcess::DontCare );
}
else

9
dialog/Makefile.am Normal file
View File

@ -0,0 +1,9 @@
INCLUDES = $(all_includes)
bin_PROGRAMS = kwin_dialog_helper
kwin_dialog_helper_SOURCES = dialog.cpp
kwin_dialog_helper_LDADD = $(LIB_KDEUI)
kwin_dialog_helper_LDFLAGS = $(all_libraries) $(KDE_RPATH)
METASOURCES = AUTO

75
dialog/dialog.cpp Normal file
View File

@ -0,0 +1,75 @@
/****************************************************************************
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
****************************************************************************/
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <kmessagebox.h>
#include <kprocess.h>
#include <klocale.h>
#include <unistd.h>
#include <kwin.h>
#include <X11/Xlib.h>
static const KCmdLineOptions options[] =
{ // no need for I18N_NOOP(), this is not supposed to be used directly
{ "message <message>", "Type of dialog message.", 0 },
{ "type <type>", "Dont show again type of dialog message.", 0 },
{ "window <wid>", "Window for which the dialog is shown.", 0 },
{ "+[data]", "Additional data.", 0 },
KCmdLineLastOption
};
int main( int argc, char* argv[] )
{
KCmdLineArgs::init( argc, argv, "kwin_dialog_helper", I18N_NOOP( "KWin" ),
I18N_NOOP( "KWin helper utility" ), "1.0" );
KCmdLineArgs::addCmdLineOptions( options );
KApplication app;
KGlobal::locale()->insertCatalogue( "kwin" ); // the messages are in kwin's .po file
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
QString message = args->getOption( "message" );
QString type = args->getOption( "type" );
QString text;
WId window = args->getOption( "window" ).toULong();
if( message == "noborderaltf3" && args->count() == 1 )
text = i18n( "You have selected to show a window without its border.\n"
"Without the border, you won't be able to enable the border "
"again using the mouse. Use the window operations menu instead, "
"activated using the %1 keyboard shortcut." ).arg( args->arg( 0 ));
else if( message == "fullscreenaltf3" && args->count() == 1 )
text = i18n( "You have selected to show a window in fullscreen mode.\n"
"If the application itself doesn't have an option to turn the fullscreen "
"mode off, you won't be able to disable it "
"again using the mouse. Use the window operations menu instead, "
"activated using the %1 keyboard shortcut." ).arg( args->arg( 0 ));
else
{
KCmdLineArgs::usage( i18n( "This helper utility is not supposed to be called directly!" ));
return 1;
}
if( window != 0 )
KMessageBox::informationWId( window, text, "", type );
else
KMessageBox::information( NULL, text, "", type );
}

View File

@ -105,6 +105,7 @@ void Workspace::clientPopupAboutToShow()
popup->setItemChecked( Options::MaximizeOp, popup_client->maximizeMode() == Client::MaximizeFull );
// TODO this doesn't show it's shaded when it's hovered or activated
popup->setItemChecked( Options::ShadeOp, popup_client->isShade() );
popup->setItemEnabled( Options::ShadeOp, popup_client->isShadeable());
options_popup->setItemChecked( Options::KeepAboveOp, popup_client->keepAbove() );
options_popup->setItemChecked( Options::KeepBelowOp, popup_client->keepBelow() );
options_popup->setItemChecked( Options::FullScreenOp, popup_client->isFullScreen() );
@ -196,7 +197,25 @@ void Workspace::readShortcuts()
void Workspace::clientPopupActivated( int id )
{
performWindowOperation( popup_client ? popup_client : active_client, (Options::WindowOperation) id );
WindowOperation op = static_cast< WindowOperation >( id );
Client* c = popup_client ? popup_client : active_client;
QString type;
switch( op )
{
case FullScreenOp:
if( !c->isFullScreen() && c->userCanSetFullScreen())
type = "fullscreenaltf3";
break;
case NoBorderOp:
if( !c->noBorder() && c->userCanSetNoBorder())
type = "noborderaltf3";
break;
default:
break;
};
if( !type.isEmpty())
helperDialog( type, c );
performWindowOperation( c, op );
}

View File

@ -25,6 +25,8 @@ License. See the file "COPYING" for the exact licensing terms.
#include <qbitmap.h>
#include <qclipboard.h>
#include <kmenubar.h>
#include <kprocess.h>
#include <kglobalaccel.h>
#include "plugins.h"
#include "client.h"
@ -1852,6 +1854,32 @@ void Workspace::focusToNull()
XSetInputFocus(qt_xdisplay(), null_focus_window, RevertToPointerRoot, qt_x_time );
}
void Workspace::helperDialog( const QString& message, const Client* c )
{
QStringList args;
QString type;
if( message == "noborderaltf3" || message == "fullscreenaltf3" )
{
args.append( "\'" + keys->shortcut( "Window Operations Menu" ).seq( 0 ).toString() + "\'" );
type = "altf3warning";
}
else
return;
KProcess proc;
proc << "kwin_dialog_helper" << "--message" << message;
if( !type.isEmpty())
{
KConfig cfg( "kwin_dialog_helperrc" );
cfg.setGroup( "Notification Messages" ); // this depends on KMessageBox
if( !cfg.readBoolEntry( type, true )) // has don't show again checked
return;
proc << "--type" << type;
}
if( c != NULL )
proc << "--window" << QString::number( c->window());
proc << "--" << args;
proc.start( KProcess::DontCare );
}
} // namespace

View File

@ -375,6 +375,8 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine
void raiseElectricBorders();
// ------------------
void helperDialog( const QString& message, const Client* c );
void calcDesktopLayout(int &x, int &y);