23 #ifdef HAVE_XCOMPOSITE
35 #undef QT_NO_TRANSLATION
36 #undef TQT_NO_TRANSLATION
37 #include <tqtranslator.h>
38 #include "tdeapplication.h"
39 #define QT_NO_TRANSLATION
40 #define TQT_NO_TRANSLATION
42 #include <tqptrcollection.h>
43 #include <tqwidgetlist.h>
44 #include <tqstrlist.h>
46 #include <tqmessagebox.h>
47 #include <tqtextstream.h>
49 #include <tqlineedit.h>
50 #include <tqtextedit.h>
51 #include <tqsessionmanager.h>
52 #include <tqptrlist.h>
54 #include <tqstylesheet.h>
55 #include <tqpixmapcache.h>
56 #include <tqtooltip.h>
57 #include <tqstylefactory.h>
58 #include <tqmetaobject.h>
61 #include <tqsqlpropertymap.h>
64 #include <tdeglobal.h>
65 #include <kstandarddirs.h>
69 #include <kiconloader.h>
70 #include <kclipboard.h>
71 #include <tdeconfig.h>
72 #include <ksimpleconfig.h>
73 #include <tdecmdlineargs.h>
74 #include <tdeaboutdata.h>
75 #include <tdeglobalsettings.h>
77 #include <kdatastream.h>
78 #include <klibloader.h>
79 #include <kmimesourcefactory.h>
80 #include <tdestdaccel.h>
82 #include "kcheckaccelerators.h"
83 #include <tqptrdict.h>
84 #include <kmacroexpander.h>
86 #include <kprotocolinfo.h>
87 #include <kkeynative.h>
89 #include <kglobalaccel.h>
92 #include <tdestartupinfo.h>
95 #include <dcopclient.h>
98 #include <sys/types.h>
99 #ifdef HAVE_SYS_STAT_H
100 #include <sys/stat.h>
102 #include <sys/wait.h>
104 #include <sys/types.h>
115 #include <sys/time.h>
124 #include "kprocctrl.h"
131 #include <X11/Xlib.h>
133 #include <X11/extensions/Xrender.h>
134 #include <X11/extensions/Xcomposite.h>
137 #include <X11/Xutil.h>
138 #include <X11/Xatom.h>
139 #include <X11/SM/SMlib.h>
146 #include <KDE-ICE/ICElib.h>
148 typedef void* IceIOErrorHandler;
151 #define Button1Mask (1<<8)
152 #define Button2Mask (1<<9)
153 #define Button3Mask (1<<10)
157 #define DISPLAY "DISPLAY"
158 #elif defined(Q_WS_QWS)
159 #define DISPLAY "QWS_DISPLAY"
167 #include <Carbon/Carbon.h>
171 #include "kappdcopiface.h"
174 KDE_EXPORT
bool kde_have_kipc =
true;
175 bool kde_kiosk_exception =
false;
176 bool kde_kiosk_admin =
false;
179 bool TDEApplication::loadedByKdeinit =
false;
180 DCOPClient *TDEApplication::s_DCOPClient = 0L;
181 bool TDEApplication::s_dcopClientNeedsPostInit =
false;
184 static Atom atom_DesktopWindow;
185 static Atom atom_NetSupported;
186 static Atom kde_xdnd_drop;
190 static int composite_event, composite_error, composite_opcode;
191 static bool x11_composite_error_generated;
192 static int x11_error(Display *dpy, XErrorEvent *ev) {
193 if (ev->request_code == composite_opcode && ev->minor_code == X_CompositeRedirectSubwindows)
195 x11_composite_error_generated =
true;
204 TDECORE_EXPORT
bool tqt_qclipboard_bailout_hack =
false;
206 template class TQPtrList<KSessionManaged>;
210 static int kde_xio_errhandler( Display * dpy )
212 return kapp->xioErrhandler( dpy );
215 static int kde_x_errhandler( Display *dpy, XErrorEvent *err )
217 return kapp->xErrhandler( dpy, err );
223 static void kde_ice_ioerrorhandler( IceConn conn )
226 kapp->iceIOErrorHandler( conn );
233 void TDEApplication_init_windows(
bool GUIenabled);
235 class QAssistantClient;
241 class TDEApplicationPrivate
244 TDEApplicationPrivate()
245 : actionRestrictions( false ),
247 oldIceIOErrorHandler( 0 ),
248 checkAccelerators( 0 ),
249 overrideStyle( TQString::null ),
251 app_started_timer( NULL ),
252 m_KAppDCOPInterface( 0L ),
253 session_save( false )
255 ,oldXErrorHandler( NULL )
256 ,oldXIOErrorHandler( NULL )
257 #elif defined Q_WS_WIN
258 ,qassistantclient( 0 )
263 ~TDEApplicationPrivate()
266 delete qassistantclient;
271 bool actionRestrictions : 1;
280 IceIOErrorHandler oldIceIOErrorHandler;
281 KCheckAccelerators* checkAccelerators;
282 TQString overrideStyle;
283 TQString geometry_arg;
284 TQCString startup_id;
285 TQTimer* app_started_timer;
289 int (*oldXErrorHandler)(Display*,XErrorEvent*);
290 int (*oldXIOErrorHandler)(Display*);
291 #elif defined Q_WS_WIN
292 QAssistantClient* qassistantclient;
298 #define checkExactMatch(s, b) \
299 if (s.isEmpty()) b = true; \
300 else if (s[s.length()-1] == '!') \
301 { b = false; s.truncate(s.length()-1); } \
303 #define checkStartWildCard(s, b) \
304 if (s.isEmpty()) b = true; \
305 else if (s[0] == '*') \
306 { b = true; s = s.mid(1); } \
308 #define checkEqual(s, b) \
311 URLActionRule(
const TQString &act,
312 const TQString &bProt,
const TQString &bHost,
const TQString &bPath,
313 const TQString &dProt,
const TQString &dHost,
const TQString &dPath,
316 baseProt(bProt), baseHost(bHost), basePath(bPath),
317 destProt(dProt), destHost(dHost), destPath(dPath),
320 checkExactMatch(baseProt, baseProtWildCard);
321 checkStartWildCard(baseHost, baseHostWildCard);
322 checkExactMatch(basePath, basePathWildCard);
323 checkExactMatch(destProt, destProtWildCard);
324 checkStartWildCard(destHost, destHostWildCard);
325 checkExactMatch(destPath, destPathWildCard);
326 checkEqual(destProt, destProtEqual);
327 checkEqual(destHost, destHostEqual);
330 bool baseMatch(
const KURL &url,
const TQString &protClass)
332 if (baseProtWildCard)
334 if ( !baseProt.isEmpty() && !url.
protocol().startsWith(baseProt) &&
335 (protClass.isEmpty() || (protClass != baseProt)) )
340 if ( (url.
protocol() != baseProt) &&
341 (protClass.isEmpty() || (protClass != baseProt)) )
344 if (baseHostWildCard)
346 if (!baseHost.isEmpty() && !url.
host().endsWith(baseHost))
351 if (url.
host() != baseHost)
354 if (basePathWildCard)
356 if (!basePath.isEmpty() && !url.
path().startsWith(basePath))
361 if (url.
path() != basePath)
367 bool destMatch(
const KURL &url,
const TQString &protClass,
const KURL &base,
const TQString &baseClass)
372 (protClass.isEmpty() || baseClass.isEmpty() || protClass != baseClass) )
375 else if (destProtWildCard)
377 if ( !destProt.isEmpty() && !url.
protocol().startsWith(destProt) &&
378 (protClass.isEmpty() || (protClass != destProt)) )
383 if ( (url.
protocol() != destProt) &&
384 (protClass.isEmpty() || (protClass != destProt)) )
387 if (destHostWildCard)
389 if (!destHost.isEmpty() && !url.
host().endsWith(destHost))
392 else if (destHostEqual)
399 if (url.
host() != destHost)
402 if (destPathWildCard)
404 if (!destPath.isEmpty() && !url.
path().startsWith(destPath))
409 if (url.
path() != destPath)
422 bool baseProtWildCard : 1;
423 bool baseHostWildCard : 1;
424 bool basePathWildCard : 1;
425 bool destProtWildCard : 1;
426 bool destHostWildCard : 1;
427 bool destPathWildCard : 1;
428 bool destProtEqual : 1;
429 bool destHostEqual : 1;
432 TQPtrList<URLActionRule> urlActionRestrictions;
435 TQString pSessionConfigFile;
439 static TQPtrList<TQWidget>*x11Filter = 0;
440 static bool autoDcopRegistration =
true;
447 x11Filter =
new TQPtrList<TQWidget>;
448 connect ( filter, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( x11FilterDestroyed() ) );
449 x11Filter->append( filter );
452 void TDEApplication::x11FilterDestroyed()
459 if ( !x11Filter || !filter )
461 x11Filter->removeRef( filter );
462 if ( x11Filter->isEmpty() ) {
472 extern bool kde_g_bKillAccelOverride;
474 bool TDEApplication::notify(TQObject *receiver, TQEvent *event)
476 TQEvent::Type t = event->type();
477 if (kde_g_bKillAccelOverride)
479 kde_g_bKillAccelOverride =
false;
481 if (t == TQEvent::AccelOverride)
483 TQT_TQKEYEVENT(event)->accept();
487 kdWarning(125) <<
"kde_g_bKillAccelOverride set, but received an event other than AccelOverride." <<
endl;
490 if ((t == TQEvent::AccelOverride) || (t == TQEvent::KeyPress))
493 TQLineEdit *edit = ::tqqt_cast<TQLineEdit *>(receiver);
497 TQKeyEvent *kevent = TQT_TQKEYEVENT(event);
501 if (t == TQEvent::KeyPress)
512 if (key ==
KKey(Qt::CTRL + Qt::Key_U))
514 if (t == TQEvent::KeyPress)
516 if (!edit->isReadOnly())
518 TQString t(edit->text());
519 t = t.mid(edit->cursorPosition());
520 edit->validateAndSet(t, 0, 0, 0);
531 TQTextEdit *medit = ::tqqt_cast<TQTextEdit *>(receiver);
535 TQKeyEvent *kevent = TQT_TQKEYEVENT(event);
538 if (t == TQEvent::KeyPress)
550 if( t == TQEvent::Show && receiver->isWidgetType())
552 TQWidget* w = TQT_TQWIDGET( receiver );
554 if( w->isTopLevel() && !
startupId().isEmpty() && !TQT_TQSHOWEVENT(event)->spontaneous())
555 TDEStartupInfo::setWindowStartupId( w->winId(),
startupId());
557 if( w->isTopLevel() && !w->testWFlags( WX11BypassWM ) && !w->isPopup() && !event->spontaneous())
559 if( d->app_started_timer == NULL )
561 d->app_started_timer =
new TQTimer(
this,
"app_started_timer" );
562 connect( d->app_started_timer, TQT_SIGNAL( timeout()), TQT_SLOT( checkAppStartedSlot()));
564 if( !d->app_started_timer->isActive())
565 d->app_started_timer->start( 0,
true );
567 if( w->isTopLevel() && ( w->icon() == NULL || w->icon()->isNull()))
570 static TQPixmap* ic = NULL;
583 return TQApplication::notify(receiver, event);
586 void TDEApplication::checkAppStartedSlot()
589 TDEStartupInfo::handleAutoAppStartedSending();
594 static TQPtrList<KSessionManaged>* sessionClients()
596 static TQPtrList<KSessionManaged>* session_clients = 0L;
597 if ( !session_clients )
598 session_clients =
new TQPtrList<KSessionManaged>;
599 return session_clients;
607 TQString TDEApplication::sessionConfigName()
const
609 TQString sessKey = sessionKey();
610 if ( sessKey.isEmpty() && !d->sessionKey.isEmpty() )
611 sessKey = d->sessionKey;
612 return TQString(
"session/%1_%2_%3").arg(
name()).arg(sessionId()).arg(sessKey);
616 static SmcConn mySmcConnection = 0;
617 static SmcConn tmpSmcConnection = 0;
622 static TQTime* smModificationTime = 0;
625 bool allowStyles,
bool GUIenabled ) :
626 TQApplication( argc, argv, GUIenabled ),
TDEInstance(rAppName),
631 d (new TDEApplicationPrivate())
633 aIconPixmap.pm.icon = 0L;
634 aIconPixmap.pm.miniIcon = 0L;
635 read_app_startup_id();
638 useStyles = allowStyles;
639 Q_ASSERT (!rAppName.isEmpty());
643 TDECmdLineArgs::initIgnore(argc, argv, rAppName.data());
657 d (new TDEApplicationPrivate)
659 aIconPixmap.pm.icon = 0L;
660 aIconPixmap.pm.miniIcon = 0L;
661 read_app_startup_id();
664 useStyles = allowStyles;
676 getX11RGBAVisual(dpy), getX11RGBAColormap(dpy) ),
679 aIconPixmap.pm.icon = 0L;
680 aIconPixmap.pm.miniIcon = 0L;
681 read_app_startup_id();
682 useStyles = allowStyles;
692 disable_argb?visual:getX11RGBAVisual(dpy), disable_argb?colormap:getX11RGBAColormap(dpy) ),
695 aIconPixmap.pm.icon = 0L;
696 aIconPixmap.pm.miniIcon = 0L;
697 read_app_startup_id();
698 useStyles = allowStyles;
699 if (disable_argb) argb_visual =
false;
710 visual?visual:getX11RGBAVisual(dpy), colormap?colormap:getX11RGBAColormap(dpy) ),
713 if ((visual) && (colormap))
714 getX11RGBAInformation(dpy);
715 aIconPixmap.pm.icon = 0L;
716 aIconPixmap.pm.miniIcon = 0L;
717 read_app_startup_id();
718 useStyles = allowStyles;
729 visual?visual:getX11RGBAVisual(dpy), colormap?colormap:getX11RGBAColormap(dpy) ),
730 TDEInstance( _instance ), display(0L), d (new TDEApplicationPrivate)
732 if ((visual) && (colormap))
733 getX11RGBAInformation(dpy);
734 aIconPixmap.pm.icon = 0L;
735 aIconPixmap.pm.miniIcon = 0L;
736 read_app_startup_id();
737 useStyles = allowStyles;
754 d (new TDEApplicationPrivate)
756 aIconPixmap.pm.icon = 0L;
757 aIconPixmap.pm.miniIcon = 0L;
758 read_app_startup_id();
761 useStyles = allowStyles;
772 bool allowStyles,
bool GUIenabled ) :
776 d (new TDEApplicationPrivate())
778 aIconPixmap.pm.icon = 0L;
779 aIconPixmap.pm.miniIcon = 0L;
780 read_app_startup_id();
783 useStyles = allowStyles;
785 Q_ASSERT (!rAppName.isEmpty());
789 TDECmdLineArgs::initIgnore(argc, argv, rAppName.data());
796 int TDEApplication::xioErrhandler( Display* dpy )
802 d->oldXIOErrorHandler( dpy );
811 int TDEApplication::xErrhandler( Display* dpy,
void* err_ )
814 XErrorEvent* err =
static_cast< XErrorEvent*
>( err_ );
818 d->oldXErrorHandler( dpy, err );
824 void TDEApplication::iceIOErrorHandler( _IceConn *conn )
829 if ( d->oldIceIOErrorHandler != NULL )
830 (*d->oldIceIOErrorHandler)( conn );
835 class KDETranslator :
public TQTranslator
838 KDETranslator(TQObject *parent) : TQTranslator(parent,
"kdetranslator") {}
839 virtual TQTranslatorMessage findMessage(
const char* context,
840 const char *sourceText,
841 const char* message)
const
843 TQTranslatorMessage res;
844 res.setTranslation(
TDEGlobal::locale()->translateQt(context, sourceText, message));
849 void TDEApplication::init(
bool GUIenabled)
851 d->guiEnabled = GUIenabled;
852 if ((getuid() != geteuid()) ||
853 (getgid() != getegid()) )
857 struct group *man = getgrnam(
"man");
858 if ( !man || man->gr_gid != getegid() ){
859 fprintf(stderr,
"The TDE libraries are not designed to run with suid privileges.\n");
868 TQApplication::setDesktopSettingsAware(
false );
873 #ifdef Q_WS_X11 //FIXME(E)
879 Atom atoms_return[max];
882 atoms[n] = &kipcCommAtom;
883 names[n++] = (
char *)
"KIPC_COMM_ATOM";
885 atoms[n] = &atom_DesktopWindow;
886 names[n++] = (
char *)
"KDE_DESKTOP_WINDOW";
888 atoms[n] = &atom_NetSupported;
889 names[n++] = (
char *)
"_NET_SUPPORTED";
891 atoms[n] = &kde_xdnd_drop;
892 names[n++] = (
char *)
"XdndDrop";
894 XInternAtoms( tqt_xdisplay(), names, n,
false, atoms_return );
896 for (
int i = 0; i < n; i++ )
897 *atoms[i] = atoms_return[i];
901 dcopAutoRegistration();
902 dcopClientPostInit();
908 kipcEventMask = (1 << KIPC::StyleChanged) | (1 << KIPC::PaletteChanged) |
909 (1 << KIPC::FontChanged) | (1 << KIPC::BackgroundChanged) |
910 (1 << KIPC::ToolbarStyleChanged) | (1 << KIPC::SettingsChanged) |
918 d->actionRestrictions = config->
hasGroup(
"KDE Action Restrictions" ) && !kde_kiosk_exception;
923 TQCString readOnly = getenv(
"TDE_HOME_READONLY");
924 if (readOnly.isEmpty() && (tqstrcmp(
name(),
"kdialog") != 0))
935 fcntl(ConnectionNumber(tqt_xdisplay()), F_SETFD, FD_CLOEXEC);
937 d->oldXErrorHandler = XSetErrorHandler( kde_x_errhandler );
938 d->oldXIOErrorHandler = XSetIOErrorHandler( kde_xio_errhandler );
941 connect(
this, TQT_SIGNAL( aboutToQuit() ),
this, TQT_SIGNAL(
shutDown() ) );
943 #ifdef Q_WS_X11 //FIXME(E)
944 display = desktop()->x11Display();
949 TQStringList::Iterator it = plugins.begin();
950 while (it != plugins.end()) {
951 addLibraryPath( *it );
956 tdedisplaySetStyle();
959 propagateSettings(SETTINGS_QT);
969 TQMimeSourceFactory* oldDefaultFactory = TQMimeSourceFactory::takeDefaultFactory();
971 if ( oldDefaultFactory ) {
972 TQMimeSourceFactory::addFactory( oldDefaultFactory );
975 d->checkAccelerators =
new KCheckAccelerators( TQT_TQOBJECT(
this) );
982 if (!pixmap.isNull()) {
983 TQImage i = pixmap.convertToImage().convertDepth(32).smoothScale(40, 40);
984 for(
int y = 0; y < i.height(); y++) {
985 uchar *l = i.scanLine(y);
986 for(
int x = 0; x < i.width(); x+=4)
989 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
990 CGDataProviderRef dp = CGDataProviderCreateWithData(NULL,
991 i.bits(), i.numBytes(), NULL);
992 CGImageRef ir = CGImageCreate(i.width(), i.height(), 8, 32, i.bytesPerLine(),
993 cs, kCGImageAlphaNoneSkipFirst, dp,
994 0, 0, kCGRenderingIntentDefault);
996 SetApplicationDockTileImage(ir);
998 CGColorSpaceRelease(cs);
999 CGDataProviderRelease(dp);
1007 bool rtl = reverseLayout();
1008 installTranslator(
new KDETranslator(TQT_TQOBJECT(
this)));
1009 setReverseLayout( rtl );
1010 if (i18n(
"_: Dear Translator! Translate this string to the string 'LTR' in "
1011 "left-to-right languages (as english) or to 'RTL' in right-to-left "
1012 "languages (such as Hebrew and Arabic) to get proper widget layout." ) ==
"RTL")
1013 setReverseLayout( !rtl );
1017 + TQString::fromLatin1(
name()) +
'/');
1018 pSessionConfig = 0L;
1019 bSessionManagement =
true;
1023 if (GUIenabled && kde_have_kipc )
1025 smw =
new TQWidget(0,0);
1027 XChangeProperty(tqt_xdisplay(), smw->winId(),
1028 atom_DesktopWindow, atom_DesktopWindow,
1029 32, PropModeReplace, (
unsigned char *)&data, 1);
1031 d->oldIceIOErrorHandler = IceSetIOErrorHandler( kde_ice_ioerrorhandler );
1032 #elif defined(Q_WS_WIN)
1033 TDEApplication_init_windows(GUIenabled);
1039 static int my_system (
const char *command) {
1046 const char* shell =
"/bin/sh";
1047 execl(shell, shell,
"-c", command, (
void *)0);
1051 if (waitpid(pid, &status, 0) == -1) {
1063 return s_DCOPClient;
1067 if (args && args->
isSet(
"dcopserver"))
1072 connect(s_DCOPClient, TQT_SIGNAL(attachFailed(
const TQString &)),
1073 kapp, TQT_SLOT(dcopFailure(
const TQString &)));
1074 connect(s_DCOPClient, TQT_SIGNAL(blockUserInput(
bool) ),
1075 kapp, TQT_SLOT(dcopBlockUserInput(
bool)) );
1078 s_dcopClientNeedsPostInit =
true;
1081 return s_DCOPClient;
1084 void TDEApplication::dcopClientPostInit()
1086 if( s_dcopClientNeedsPostInit )
1088 s_dcopClientNeedsPostInit =
false;
1089 connect(s_DCOPClient, TQT_SIGNAL(blockUserInput(
bool) ),
1090 TQT_SLOT(dcopBlockUserInput(
bool)) );
1091 s_DCOPClient->bindToApp();
1095 void TDEApplication::dcopAutoRegistration()
1097 if (autoDcopRegistration)
1107 autoDcopRegistration =
false;
1113 return pSessionConfig;
1116 pSessionConfig =
new TDEConfig( sessionConfigName(),
false,
false);
1117 return pSessionConfig;
1130 if ( d->refCount <= 0 )
1134 KSessionManaged::KSessionManaged()
1136 sessionClients()->remove(
this );
1137 sessionClients()->append(
this );
1140 KSessionManaged::~KSessionManaged()
1142 sessionClients()->remove(
this );
1157 bSessionManagement =
false;
1161 bSessionManagement =
true;
1172 if( mySmcConnection ) {
1173 SmcRequestSaveYourself( mySmcConnection, SmSaveLocal, False,
1178 IceFlush(SmcGetIceConnection(mySmcConnection));
1188 TQApplication::syncX();
1195 TQDataStream arg(data, IO_WriteOnly);
1196 arg << (int)confirm << (
int)sdtype << (int)sdmode;
1198 "logout(int,int,int)", data );
1201 if ( mySmcConnection ) {
1203 SmcRequestSaveYourself( mySmcConnection, SmSaveBoth, True,
1208 IceFlush(SmcGetIceConnection(mySmcConnection));
1215 TQCString smEnv = ::getenv(
"SESSION_MANAGER");
1216 if (smEnv.isEmpty())
1219 if (! tmpSmcConnection) {
1224 tmpSmcConnection = SmcOpenConnection( 0, 0, 1, 0,
1231 if (!tmpSmcConnection )
1235 SmcRequestSaveYourself( tmpSmcConnection, SmSaveBoth, True,
1236 SmInteractStyleAny, False, True );
1239 IceFlush(SmcGetIceConnection(tmpSmcConnection));
1250 TQCString fName = TQFile::encodeName(locateLocal(
"socket",
"KSMserver"));
1251 TQCString display = ::getenv(DISPLAY);
1253 display.replace(TQRegExp(
"\\.[0-9]+$"),
"");
1255 while( (i = display.find(
':')) >= 0)
1258 fName +=
"_"+display;
1259 TQCString smEnv = ::getenv(
"SESSION_MANAGER");
1260 bool check = smEnv.isEmpty();
1261 if ( !check && smModificationTime ) {
1262 TQFileInfo info( fName );
1263 TQTime current = TQT_TQTIME_OBJECT(info.lastModified().time());
1264 check = current > *smModificationTime;
1267 delete smModificationTime;
1269 if ( !f.open( IO_ReadOnly ) )
1271 TQFileInfo info ( f );
1272 smModificationTime =
new TQTime( TQT_TQTIME_OBJECT(info.lastModified().time()) );
1274 t.setEncoding( TQTextStream::Latin1 );
1275 TQString s = t.readLine();
1277 ::setenv(
"SESSION_MANAGER", s.latin1(), true );
1284 d->session_save =
true;
1285 bool canceled =
false;
1288 it = sessionClients()->next() ) {
1289 canceled = !it->commitData( sm );
1294 if ( sm.allowsInteraction() ) {
1296 TQWidgetList *list = TQApplication::topLevelWidgets();
1297 bool canceled =
false;
1298 TQWidget* w = list->first();
1299 while ( !canceled && w ) {
1300 if ( !w->testWState( WState_ForceHide ) && !w->inherits(
"TDEMainWindow") ) {
1303 canceled = !e.isAccepted();
1307 list = TQApplication::topLevelWidgets();
1312 while ( w && done.containsRef( w ) )
1319 if ( !bSessionManagement )
1320 sm.setRestartHint( TQSessionManager::RestartNever );
1322 sm.setRestartHint( TQSessionManager::RestartIfRunning );
1323 d->session_save =
false;
1326 static void checkRestartVersion( TQSessionManager& sm )
1328 Display* dpy = tqt_xdisplay();
1331 unsigned long nitems, after;
1332 unsigned char* data;
1333 if( XGetWindowProperty( dpy, RootWindow( dpy, 0 ), XInternAtom( dpy,
"TDE_FULL_SESSION", False ),
1334 0, 1, False, AnyPropertyType, &type, &format, &nitems, &after, &data ) == Success ) {
1337 if( type == XA_STRING && format == 8 ) {
1338 if( XGetWindowProperty( dpy, RootWindow( dpy, 0 ), XInternAtom( dpy,
"TDE_SESSION_VERSION", False ),
1339 0, 1, False, AnyPropertyType, &type, &format, &nitems, &after, &data ) == Success ) {
1350 TQStringList restartCommand = sm.restartCommand();
1351 restartCommand.prepend( wrapper );
1352 sm.setRestartCommand( restartCommand );
1357 d->session_save =
true;
1359 static bool firstTime =
true;
1360 mySmcConnection = (SmcConn) sm.handle();
1362 if ( !bSessionManagement ) {
1363 sm.setRestartHint( TQSessionManager::RestartNever );
1364 d->session_save =
false;
1368 sm.setRestartHint( TQSessionManager::RestartIfRunning );
1372 d->session_save =
false;
1382 if ( pSessionConfig ) {
1383 delete pSessionConfig;
1388 TQStringList restartCommand = sm.restartCommand();
1390 TQCString multiHead = getenv(
"TDE_MULTIHEAD");
1391 if (multiHead.lower() ==
"true") {
1398 TQCString displayname = getenv(DISPLAY);
1399 if (! displayname.isNull()) {
1402 restartCommand.append(
"-display");
1403 restartCommand.append(displayname);
1405 sm.setRestartCommand( restartCommand );
1408 checkRestartVersion( sm );
1412 bool canceled =
false;
1415 it = sessionClients()->next() ) {
1416 canceled = !it->saveState( sm );
1420 if ( pSessionConfig ) {
1421 pSessionConfig->
sync();
1422 TQStringList discard;
1423 discard <<
"rm" << locateLocal(
"config", sessionConfigName());
1424 sm.setDiscardCommand( discard );
1426 sm.setDiscardCommand( TQStringList(
"") );
1434 d->session_save =
false;
1439 return d->session_save;
1442 void TDEApplication::startKdeinit()
1444 #ifndef Q_WS_WIN //TODO
1446 TDELockFile lock( locateLocal(
"tmp",
"starttdeinitlock", &inst ));
1459 if (kapp && (Tty != kapp->type()))
1460 setOverrideCursor( tqwaitCursor );
1461 my_system(TQFile::encodeName(srv)+
" --suicide"+
" --new-startup");
1462 if (kapp && (Tty != kapp->type()))
1463 restoreOverrideCursor();
1467 void TDEApplication::dcopFailure(
const TQString &msg)
1469 static int failureCount = 0;
1471 if (failureCount == 1)
1476 if (failureCount == 2)
1483 TQString msgStr(i18n(
"There was an error setting up inter-process "
1484 "communications for TDE. The message returned "
1485 "by the system was:\n\n"));
1487 msgStr += i18n(
"\n\nPlease check that the \"dcopserver\" program is running!");
1489 if (Tty != kapp->type())
1491 TQMessageBox::critical
1494 i18n(
"DCOP communications error (%1)").arg(kapp->caption()),
1501 fprintf(stderr,
"%s\n", msgStr.local8Bit().data());
1512 {
"display <displayname>",
I18N_NOOP(
"Use the X-server display 'displayname'"), 0},
1514 {
"display <displayname>",
I18N_NOOP(
"Use the QWS display 'displayname'"), 0},
1516 {
"session <sessionId>",
I18N_NOOP(
"Restore the application for the given 'sessionId'"), 0},
1517 {
"cmap",
I18N_NOOP(
"Causes the application to install a private color\nmap on an 8-bit display"), 0},
1518 {
"ncols <count>",
I18N_NOOP(
"Limits the number of colors allocated in the color\ncube on an 8-bit display, if the application is\nusing the TQApplication::ManyColor color\nspecification"), 0},
1519 {
"nograb",
I18N_NOOP(
"tells Qt to never grab the mouse or the keyboard"), 0},
1520 {
"dograb",
I18N_NOOP(
"running under a debugger can cause an implicit\n-nograb, use -dograb to override"), 0},
1521 {
"sync",
I18N_NOOP(
"switches to synchronous mode for debugging"), 0},
1523 {
"font <fontname>",
I18N_NOOP(
"defines the application font"), 0},
1525 {
"background <color>",
I18N_NOOP(
"sets the default background color and an\napplication palette (light and dark shades are\ncalculated)"), 0},
1527 {
"foreground <color>",
I18N_NOOP(
"sets the default foreground color"), 0},
1529 {
"button <color>",
I18N_NOOP(
"sets the default button color"), 0},
1530 {
"name <name>",
I18N_NOOP(
"sets the application name"), 0},
1531 {
"title <title>",
I18N_NOOP(
"sets the application title (caption)"), 0},
1533 {
"visual TrueColor",
I18N_NOOP(
"forces the application to use a TrueColor visual on\nan 8-bit display"), 0},
1534 {
"inputstyle <inputstyle>",
I18N_NOOP(
"sets XIM (X Input Method) input style. Possible\nvalues are onthespot, overthespot, offthespot and\nroot"), 0 },
1535 {
"im <XIM server>",
I18N_NOOP(
"set XIM server"),0},
1536 {
"noxim",
I18N_NOOP(
"disable XIM"), 0 },
1539 {
"qws",
I18N_NOOP(
"forces the application to run as QWS Server"), 0},
1541 {
"reverse",
I18N_NOOP(
"mirrors the whole layout of widgets"), 0},
1542 TDECmdLineLastOption
1547 {
"caption <caption>",
I18N_NOOP(
"Use 'caption' as name in the titlebar"), 0},
1548 {
"icon <icon>",
I18N_NOOP(
"Use 'icon' as the application icon"), 0},
1549 {
"miniicon <icon>",
I18N_NOOP(
"Use 'icon' as the icon in the titlebar"), 0},
1550 {
"config <filename>",
I18N_NOOP(
"Use alternative configuration file"), 0},
1551 {
"dcopserver <server>",
I18N_NOOP(
"Use the DCOP Server specified by 'server'"), 0},
1552 {
"nocrashhandler",
I18N_NOOP(
"Disable crash handler, to get core dumps"), 0},
1553 {
"waitforwm",
I18N_NOOP(
"Waits for a WM_NET compatible windowmanager"), 0},
1554 {
"style <style>",
I18N_NOOP(
"sets the application GUI style"), 0},
1555 {
"geometry <geometry>",
I18N_NOOP(
"sets the client geometry of the main widget - see man X for the argument format"), 0},
1556 {
"smkey <sessionKey>", 0, 0},
1559 TDECmdLineLastOption
1569 void TDEApplication::parseCommandLine( )
1573 if ( !args )
return;
1575 if (args->
isSet(
"config"))
1577 TQString config = TQString::fromLocal8Bit(args->
getOption(
"config"));
1581 if (args->
isSet(
"style"))
1585 TQStringList::Iterator itp = plugins.begin();
1586 while (itp != plugins.end()) {
1587 addLibraryPath( *itp );
1591 TQStringList styles = TQStyleFactory::keys();
1592 TQString reqStyle(args->
getOption(
"style").lower());
1594 TQStringList list = libraryPaths();
1595 TQStringList::Iterator it = list.begin();
1596 while( it != list.end() ) {
1600 for (TQStringList::ConstIterator it = styles.begin(); it != styles.end(); ++it) {
1601 if ((*it).lower() == reqStyle)
1603 d->overrideStyle = *it;
1608 if (d->overrideStyle.isEmpty())
1609 fprintf(stderr,
"%s", TQString(i18n(
"The style %1 was not found\n").arg(reqStyle)).local8Bit().data());
1612 if (args->
isSet(
"caption"))
1614 aCaption = TQString::fromLocal8Bit(args->
getOption(
"caption"));
1617 if (args->
isSet(
"miniicon"))
1619 const char *tmp = args->
getOption(
"miniicon");
1620 if (!aIconPixmap.pm.miniIcon) {
1621 aIconPixmap.pm.miniIcon =
new TQPixmap;
1623 *aIconPixmap.pm.miniIcon = SmallIcon(tmp);
1624 aMiniIconName = tmp;
1627 if (args->
isSet(
"icon"))
1629 const char *tmp = args->
getOption(
"icon");
1630 if (!aIconPixmap.pm.icon) {
1631 aIconPixmap.pm.icon =
new TQPixmap;
1633 *aIconPixmap.pm.icon = DesktopIcon( tmp );
1635 if (!aIconPixmap.pm.miniIcon) {
1636 aIconPixmap.pm.miniIcon =
new TQPixmap;
1638 if (aIconPixmap.pm.miniIcon->isNull())
1640 *aIconPixmap.pm.miniIcon = SmallIcon( tmp );
1641 aMiniIconName = tmp;
1645 bool nocrashhandler = (getenv(
"TDE_DEBUG") != NULL);
1646 if (!nocrashhandler && args->
isSet(
"crashhandler"))
1656 if ( args->
isSet(
"waitforwm" ) ) {
1660 unsigned long length, after;
1661 unsigned char *data;
1662 while ( XGetWindowProperty( tqt_xdisplay(), tqt_xrootwin(), atom_NetSupported,
1663 0, 1,
false, AnyPropertyType, &type, &format,
1664 &length, &after, &data ) != Success || !length ) {
1668 XWindowEvent( tqt_xdisplay(), tqt_xrootwin(), PropertyChangeMask, &event );
1677 if (args->
isSet(
"geometry"))
1679 d->geometry_arg = args->
getOption(
"geometry");
1682 if (args->
isSet(
"smkey"))
1684 d->sessionKey = args->
getOption(
"smkey");
1691 return d->geometry_arg;
1696 if( !aIconPixmap.pm.icon) {
1697 aIconPixmap.pm.icon =
new TQPixmap;
1699 if( aIconPixmap.pm.icon->isNull()) {
1702 return *aIconPixmap.pm.icon;
1707 return aIconName.isNull() ? (TQString)
instanceName() : aIconName;
1712 if (!aIconPixmap.pm.miniIcon) {
1713 aIconPixmap.pm.miniIcon =
new TQPixmap;
1715 if (aIconPixmap.pm.miniIcon->isNull()) {
1716 *aIconPixmap.pm.miniIcon = SmallIcon(
instanceName() );
1718 return *aIconPixmap.pm.miniIcon;
1723 return aMiniIconName.isNull() ? (TQString)
instanceName() : aMiniIconName;
1726 extern void kDebugCleanup();
1728 TDEApplication::~TDEApplication()
1730 delete aIconPixmap.pm.miniIcon;
1731 aIconPixmap.pm.miniIcon = 0L;
1732 delete aIconPixmap.pm.icon;
1733 aIconPixmap.pm.icon = 0L;
1734 delete d->m_KAppDCOPInterface;
1740 KLibLoader::cleanUp();
1745 delete s_DCOPClient;
1751 if ( d->oldXErrorHandler != NULL )
1752 XSetErrorHandler( d->oldXErrorHandler );
1753 if ( d->oldXIOErrorHandler != NULL )
1754 XSetIOErrorHandler( d->oldXIOErrorHandler );
1755 if ( d->oldIceIOErrorHandler != NULL )
1756 IceSetIOErrorHandler( d->oldIceIOErrorHandler );
1763 mySmcConnection = 0;
1764 delete smModificationTime;
1765 smModificationTime = 0;
1768 if (tmpSmcConnection) {
1769 SmcCloseConnection( tmpSmcConnection, 0, 0 );
1770 tmpSmcConnection = 0;
1779 class KAppX11HackWidget:
public TQWidget
1782 bool publicx11Event( XEvent * e) {
return x11Event( e ); }
1786 #if defined(Q_WS_X11) && defined(COMPOSITE)
1788 bool have_manager =
false;
1791 p = getpwuid(getuid());
1795 home = getenv(
"HOME");
1798 const char *configfile =
"/.kompmgr.available";
1799 int n = strlen(home)+strlen(configfile)+1;
1800 filename = (
char*)malloc(n*
sizeof(
char));
1801 memset(filename,0,n);
1802 strcat(filename, home);
1803 strcat(filename, configfile);
1807 pFile = fopen(filename,
"r");
1809 have_manager =
true;
1816 return have_manager;
1820 bool compositing_manager_available;
1821 if (force_available) {
1822 compositing_manager_available = available;
1827 char *displayname = 0;
1828 if ( qtargs->
isSet(
"display"))
1829 displayname = qtargs->
getOption(
"display" ).data();
1831 Display *dpy = XOpenDisplay( displayname );
1833 x11_composite_error_generated =
false;
1834 compositing_manager_available =
false;
1835 XSetErrorHandler(x11_error);
1836 if (!XQueryExtension (dpy, COMPOSITE_NAME, &composite_opcode, &composite_event, &composite_error)) {
1837 XSetErrorHandler(NULL);
1838 compositing_manager_available =
false;
1842 Window root_window = XDefaultRootWindow(dpy);
1843 XCompositeRedirectSubwindows(dpy, root_window, CompositeRedirectManual);
1845 if (x11_composite_error_generated ==
true) {
1846 compositing_manager_available =
true;
1849 XCompositeUnredirectSubwindows(dpy, root_window, CompositeRedirectManual);
1850 compositing_manager_available =
false;
1852 XSetErrorHandler(NULL);
1856 compositing_manager_available =
true;
1863 p = getpwuid(getuid());
1867 home = getenv(
"HOME");
1870 const char *configfile =
"/.kompmgr.available";
1871 int n = strlen(home)+strlen(configfile)+1;
1872 filename = (
char*)malloc(n*
sizeof(
char));
1873 memset(filename,0,n);
1874 strcat(filename, home);
1875 strcat(filename, configfile);
1878 if (compositing_manager_available) {
1881 sprintf(buffer,
"available");
1882 pFile = fopen(filename,
"w");
1884 fwrite(buffer,1,strlen(buffer), pFile);
1895 return compositing_manager_available;
1898 Display* TDEApplication::openX11RGBADisplay() {
1901 if ( qtargs->
isSet(
"display"))
1902 display = qtargs->
getOption(
"display" ).data();
1904 Display *dpy = XOpenDisplay( display );
1906 kdError() <<
"cannot connect to X server " << display <<
endl;
1914 getX11RGBAInformation(dpy);
1916 return argb_x11_visual;
1919 return (Qt::HANDLE)NULL;
1924 getX11RGBAInformation(dpy);
1926 return argb_x11_colormap;
1929 return (Qt::HANDLE)NULL;
1937 void TDEApplication::getX11RGBAInformation(Display *dpy) {
1939 argb_visual =
false;
1943 int screen = DefaultScreen( dpy );
1944 Colormap colormap = 0;
1946 int event_base, error_base;
1948 if ( XRenderQueryExtension( dpy, &event_base, &error_base ) ) {
1951 templ.screen = screen;
1953 templ.c_class = TrueColor;
1954 XVisualInfo *xvi = XGetVisualInfo( dpy, VisualScreenMask | VisualDepthMask
1955 | VisualClassMask, &templ, &nvi );
1957 for (
int i = 0; i < nvi; i++ ) {
1958 XRenderPictFormat *format = XRenderFindVisualFormat( dpy, xvi[i].visual );
1959 if ( format->type == PictTypeDirect && format->direct.alphaMask ) {
1960 visual = xvi[i].visual;
1961 colormap = XCreateColormap( dpy, RootWindow( dpy, screen ), visual, AllocNone );
1962 kdDebug() <<
"found visual with alpha support" <<
endl;
1970 argb_x11_visual = Qt::HANDLE( visual );
1971 argb_x11_colormap = Qt::HANDLE( colormap );
1975 argb_visual =
false;
1979 void TDEApplication::getX11RGBAInformation(Display *dpy) {
1989 p = getpwuid(getuid());
1993 home = getenv(
"HOME");
1996 const char *configfile =
"/.kompmgr.available";
1997 int n = strlen(home)+strlen(configfile)+1;
1998 filename = (
char*)malloc(n*
sizeof(
char));
1999 memset(filename,0,n);
2000 strcat(filename, home);
2001 strcat(filename, configfile);
2004 if (force_available) {
2007 sprintf(buffer,
"available");
2008 pFile = fopen(filename,
"w");
2010 fwrite(buffer,1,strlen(buffer), pFile);
2024 Display* TDEApplication::openX11RGBADisplay() {
2040 TDEApplication TDEApplication::KARGBApplication(
bool allowStyles ) {
2045 static bool kapp_block_user_input =
false;
2047 void TDEApplication::dcopBlockUserInput(
bool b )
2049 kapp_block_user_input = b;
2053 bool TDEApplication::x11EventFilter( XEvent *_event )
2055 switch ( _event->type ) {
2058 #if KDE_IS_VERSION( 3, 90, 90 )
2059 #warning This should be already in Qt, check.
2066 if( _event->xclient.message_type == kde_xdnd_drop )
2068 if( _event->xclient.data.l[ 1 ] == 1 << 24
2069 && _event->xclient.data.l[ 2 ] == 0
2070 && _event->xclient.data.l[ 4 ] == 0
2071 && _event->xclient.data.l[ 3 ] != 0 )
2073 if( GET_QT_X_USER_TIME() == 0
2076 SET_QT_X_USER_TIME(_event->xclient.data.l[ 3 ]);
2081 if( GET_QT_X_USER_TIME() == 0
2084 SET_QT_X_USER_TIME(_event->xclient.data.l[ 2 ]);
2092 if ( kapp_block_user_input ) {
2093 switch ( _event->type ) {
2108 for (TQWidget *w=x11Filter->first(); w; w=x11Filter->next()) {
2109 if (((KAppX11HackWidget*) w)->publicx11Event(_event))
2114 if ((_event->type == ClientMessage) &&
2115 (_event->xclient.message_type == kipcCommAtom))
2117 XClientMessageEvent *cme = (XClientMessageEvent *) _event;
2119 int id = cme->data.l[0];
2120 int arg = cme->data.l[1];
2121 if ((
id < 32) && (kipcEventMask & (1 << id)))
2125 case KIPC::StyleChanged:
2127 tdedisplaySetStyle();
2130 case KIPC::ToolbarStyleChanged:
2136 case KIPC::PaletteChanged:
2138 tdedisplaySetPalette();
2141 case KIPC::FontChanged:
2143 TDEGlobalSettings::rereadFontSettings();
2144 tdedisplaySetFont();
2147 case KIPC::BackgroundChanged:
2151 case KIPC::SettingsChanged:
2153 if (arg == SETTINGS_PATHS)
2154 TDEGlobalSettings::rereadPathSettings();
2155 else if (arg == SETTINGS_MOUSE)
2156 TDEGlobalSettings::rereadMouseSettings();
2160 case KIPC::IconChanged:
2161 TQPixmapCache::clear();
2164 emit updateIconLoaders();
2168 case KIPC::ClipboardConfigChanged:
2169 TDEClipboardSynchronizer::newConfiguration(arg);
2173 TDEGlobalAccel::blockShortcuts(arg);
2190 #if defined Q_WS_X11
2193 Window w = XCreateSimpleWindow( tqt_xdisplay(), tqt_xrootwin(), 0, 0, 1, 1, 0, 0, 0 );
2194 XSelectInput( tqt_xdisplay(), w, PropertyChangeMask );
2195 unsigned char data[ 1 ];
2196 XChangeProperty( tqt_xdisplay(), w, XA_ATOM, XA_ATOM, 8, PropModeAppend, data, 1 );
2198 XWindowEvent( tqt_xdisplay(), w, PropertyChangeMask, &ev );
2199 time = ev.xproperty.time;
2200 XDestroyWindow( tqt_xdisplay(), w );
2202 if( GET_QT_X_USER_TIME() == 0
2204 SET_QT_X_USER_TIME(time);
2210 #if defined Q_WS_X11
2211 return GET_QT_X_USER_TIME();
2219 #if defined Q_WS_X11
2221 time = GET_QT_X_USER_TIME();
2222 DCOPRef( dcopId,
"MainApplication-Interface" ).
call(
"updateUserTimestamp", time );
2228 TQObject *
object = TQT_TQOBJECT(focusWidget());
2232 TQMetaObject *meta =
object->metaObject();
2234 int idx = meta->findSlot( slot + 1,
true );
2238 object->tqt_invoke( idx, 0 );
2245 kdDebug(101) <<
"Cannot use KIPC event mask for message IDs >= 32\n";
2248 kipcEventMask |= (1 << id);
2255 kdDebug(101) <<
"Cannot use KIPC event mask for message IDs >= 32\n";
2258 kipcEventMask &= ~(1 << id);
2275 void TDEApplication::applyGUIStyle()
2277 if ( !useStyles )
return;
2280 TQString defaultStyle = TDEStyle::defaultStyle();
2281 TQString styleStr = pConfig.readEntry(
"widgetStyle", defaultStyle);
2283 if (d->overrideStyle.isEmpty()) {
2287 TQStyle* sp = TQStyleFactory::create( styleStr );
2290 if ( !sp && styleStr != defaultStyle)
2291 sp = TQStyleFactory::create( defaultStyle );
2293 sp = TQStyleFactory::create( *(TQStyleFactory::keys().begin()) );
2297 setStyle(d->overrideStyle);
2299 tdedisplaySetPalette();
2305 if( !aCaption.isNull() )
2322 bool withAppName,
bool modified )
const
2324 TQString s = userCaption.isEmpty() ?
caption() : userCaption;
2328 s += TQString::fromUtf8(
" [") + i18n(
"modified") + TQString::fromUtf8(
"]");
2330 if ( !userCaption.isEmpty() ) {
2333 if ( withAppName && !
caption().isNull() && !userCaption.endsWith(
caption()) )
2334 s += TQString::fromUtf8(
" - ") +
caption();
2349 TQColor trinity4Background( 239, 239, 239 );
2350 TQColor trinity4Blue( 103,141,178 );
2352 TQColor trinity4Button;
2353 if ( TQPixmap::defaultDepth() > 8 )
2354 trinity4Button.setRgb( 221, 223, 228 );
2356 trinity4Button.setRgb( 220, 220, 220 );
2358 TQColor trinity4Link( 0, 0, 238 );
2359 TQColor trinity4VisitedLink( 82, 24, 139 );
2361 TQColor background = config->
readColorEntry(
"background", &trinity4Background );
2362 TQColor foreground = config->
readColorEntry(
"foreground", tqblackptr );
2363 TQColor button = config->
readColorEntry(
"buttonBackground", &trinity4Button );
2364 TQColor buttonText = config->
readColorEntry(
"buttonForeground", tqblackptr );
2365 TQColor highlight = config->
readColorEntry(
"selectBackground", &trinity4Blue );
2366 TQColor highlightedText = config->
readColorEntry(
"selectForeground", tqwhiteptr );
2367 TQColor base = config->
readColorEntry(
"windowBackground", tqwhiteptr );
2368 TQColor baseText = config->
readColorEntry(
"windowForeground", tqblackptr );
2369 TQColor link = config->
readColorEntry(
"linkColor", &trinity4Link );
2370 TQColor visitedLink = config->
readColorEntry(
"visitedLinkColor", &trinity4VisitedLink );
2372 int highlightVal, lowlightVal;
2373 highlightVal = 100 + (2*contrast_+4)*16/10;
2374 lowlightVal = 100 + (2*contrast_+4)*10;
2376 TQColor disfg = foreground;
2379 disfg.hsv( &h, &s, &v );
2382 disfg = disfg.dark(lowlightVal);
2383 else if (disfg != Qt::black)
2385 disfg = disfg.light(highlightVal);
2388 disfg = Qt::darkGray;
2391 TQColorGroup disabledgrp(disfg, background,
2392 background.light(highlightVal),
2393 background.dark(lowlightVal),
2394 background.dark(120),
2395 background.dark(120), base);
2397 TQColorGroup colgrp(foreground, background, background.light(highlightVal),
2398 background.dark(lowlightVal),
2399 background.dark(120),
2402 int inlowlightVal = lowlightVal-25;
2403 if(inlowlightVal < 120)
2404 inlowlightVal = 120;
2406 colgrp.setColor(TQColorGroup::Highlight, highlight);
2407 colgrp.setColor(TQColorGroup::HighlightedText, highlightedText);
2408 colgrp.setColor(TQColorGroup::Button, button);
2409 colgrp.setColor(TQColorGroup::ButtonText, buttonText);
2410 colgrp.setColor(TQColorGroup::Midlight, background.light(110));
2411 colgrp.setColor(TQColorGroup::Link, link);
2412 colgrp.setColor(TQColorGroup::LinkVisited, visitedLink);
2414 disabledgrp.setColor(TQColorGroup::Button, button);
2416 TQColor disbtntext = buttonText;
2417 disbtntext.hsv( &h, &s, &v );
2420 disbtntext = disbtntext.dark(lowlightVal);
2421 else if (disbtntext != Qt::black)
2423 disbtntext = disbtntext.light(highlightVal);
2426 disbtntext = Qt::darkGray;
2428 disabledgrp.setColor(TQColorGroup::ButtonText, disbtntext);
2429 disabledgrp.setColor(TQColorGroup::Midlight, background.light(110));
2430 disabledgrp.setColor(TQColorGroup::Highlight, highlight.dark(120));
2431 disabledgrp.setColor(TQColorGroup::Link, link);
2432 disabledgrp.setColor(TQColorGroup::LinkVisited, visitedLink);
2434 return TQPalette(colgrp, disabledgrp, colgrp);
2438 void TDEApplication::tdedisplaySetPalette()
2445 bool do_not_set_palette = FALSE;
2446 if(config->
readBoolEntry(
"nopaletteChange", &do_not_set_palette))
2456 void TDEApplication::tdedisplaySetFont()
2464 TQStyleSheet* sheet = TQStyleSheet::defaultSheet();
2474 void TDEApplication::tdedisplaySetStyle()
2485 void TDEApplication::propagateSettings(SettingsCategory arg)
2490 #ifdef QT_HAVE_MAX_IMAGE_SIZE
2491 TQSize maxImageSize(4096, 4096);
2492 maxImageSize = config->
readSizeEntry(
"MaxImageSize", &maxImageSize);
2493 TQImage::setMaxImageSize(maxImageSize);
2496 int num = config->
readNumEntry(
"CursorBlinkRate", TQApplication::cursorFlashTime());
2497 if ((num != 0) && (num < 200))
2501 TQApplication::setCursorFlashTime(num);
2502 num = config->
readNumEntry(
"DoubleClickInterval", TQApplication::doubleClickInterval());
2503 TQApplication::setDoubleClickInterval(num);
2504 num = config->
readNumEntry(
"StartDragTime", TQApplication::startDragTime());
2505 TQApplication::setStartDragTime(num);
2506 num = config->
readNumEntry(
"StartDragDist", TQApplication::startDragDistance());
2507 TQApplication::setStartDragDistance(num);
2508 num = config->
readNumEntry(
"WheelScrollLines", TQApplication::wheelScrollLines());
2509 TQApplication::setWheelScrollLines(num);
2512 TQApplication::setEffectEnabled( Qt::UI_AnimateMenu, b);
2514 TQApplication::setEffectEnabled( Qt::UI_FadeMenu, b);
2516 TQApplication::setEffectEnabled( Qt::UI_AnimateCombo, b);
2518 TQApplication::setEffectEnabled( Qt::UI_AnimateTooltip, b);
2520 TQApplication::setEffectEnabled( Qt::UI_FadeTooltip, b);
2522 TQToolTip::setGloballyEnabled( b );
2530 static bool installed =
false;
2531 if (installed)
return;
2540 TQSqlPropertyMap *kdeMap =
new TQSqlPropertyMap;
2541 kdeMap->insert(
"KColorButton",
"color" );
2542 kdeMap->insert(
"KComboBox",
"currentItem" );
2543 kdeMap->insert(
"KDatePicker",
"date" );
2544 kdeMap->insert(
"KDateWidget",
"date" );
2545 kdeMap->insert(
"KDateTimeWidget",
"dateTime" );
2546 kdeMap->insert(
"KEditListBox",
"items" );
2547 kdeMap->insert(
"TDEFontCombo",
"family" );
2548 kdeMap->insert(
"TDEFontRequester",
"font" );
2549 kdeMap->insert(
"TDEFontChooser",
"font" );
2550 kdeMap->insert(
"KHistoryCombo",
"currentItem" );
2551 kdeMap->insert(
"TDEListBox",
"currentItem" );
2552 kdeMap->insert(
"KLineEdit",
"text" );
2553 kdeMap->insert(
"KRestrictedLine",
"text" );
2554 kdeMap->insert(
"KSqueezedTextLabel",
"text" );
2555 kdeMap->insert(
"KTextBrowser",
"source" );
2556 kdeMap->insert(
"KTextEdit",
"text" );
2557 kdeMap->insert(
"KURLRequester",
"url" );
2558 kdeMap->insert(
"KPasswordEdit",
"password" );
2559 kdeMap->insert(
"KIntNumInput",
"value" );
2560 kdeMap->insert(
"KIntSpinBox",
"value" );
2561 kdeMap->insert(
"KDoubleNumInput",
"value" );
2563 kdeMap->insert( TQGROUPBOX_OBJECT_NAME_STRING,
"checked" );
2564 kdeMap->insert( TQTABWIDGET_OBJECT_NAME_STRING,
"currentPage" );
2565 TQSqlPropertyMap::installDefaultMap( kdeMap );
2570 const TQString& _appname)
const
2579 const TQString& _appname,
2580 const TQCString& startup_id )
const
2584 if (_appname.isEmpty())
2589 if (!anchor.isEmpty())
2590 url = TQString(
"help:/%1?anchor=%2").arg(appname).arg(anchor);
2592 url = TQString(
"help:/%1/index.html").arg(appname);
2595 if ( !
dcopClient()->isApplicationRegistered(
"khelpcenter") )
2599 if (Tty != kapp->type())
2600 TQMessageBox::critical(kapp->mainWidget(), i18n(
"Could not Launch Help Center"),
2601 i18n(
"Could not launch the TDE Help Center:\n\n%1").arg(error), i18n(
"&OK"));
2603 kdWarning() <<
"Could not launch help:\n" << error <<
endl;
2608 DCOPRef(
"khelpcenter",
"KHelpCenterIface" ).
send(
"openUrl", url, startup_id );
2614 kdWarning() <<
"invoking HTML help is deprecated! use docbook and invokeHelp!\n";
2618 if( _filename.isEmpty() )
2619 filename = TQString(name()) +
"/index.html";
2621 filename = _filename;
2624 if (!topic.isEmpty())
2625 url = TQString(
"help:/%1#%2").arg(filename).arg(topic);
2627 url = TQString(
"help:/%1").arg(filename);
2630 if ( !
dcopClient()->isApplicationRegistered(
"khelpcenter") )
2634 if (Tty != kapp->type())
2635 TQMessageBox::critical(kapp->mainWidget(), i18n(
"Could not Launch Help Center"),
2636 i18n(
"Could not launch the TDE Help Center:\n\n%1").arg(error), i18n(
"&OK"));
2638 kdWarning() <<
"Could not launch help:\n" << error <<
endl;
2643 DCOPRef(
"khelpcenter",
"KHelpCenterIface" ).
send(
"openUrl", url );
2654 invokeMailer(address, TQString::null, TQString::null, subject, TQString::null, TQString::null,
2655 TQStringList(), startup_id );
2671 TQStringList queries = TQStringList::split(
'&', mailtoURL.
query().mid(1));
2672 TQStringList attachURLs;
2673 for (TQStringList::Iterator it = queries.begin(); it != queries.end(); ++it)
2675 TQString q = (*it).lower();
2676 if (q.startsWith(
"subject="))
2679 if (q.startsWith(
"cc="))
2682 if (q.startsWith(
"bcc="))
2685 if (q.startsWith(
"body="))
2688 if (allowAttachments && q.startsWith(
"attach="))
2691 if (allowAttachments && q.startsWith(
"attachment="))
2694 if (q.startsWith(
"to="))
2698 invokeMailer( address, cc, bcc, subject, body, TQString::null, attachURLs, startup_id );
2702 const TQString &subject,
const TQString &body,
2703 const TQString & messageFile,
const TQStringList &attachURLs)
2705 return invokeMailer(to,cc,bcc,subject,body,messageFile,attachURLs,
"");
2712 static TQStringList splitEmailAddressList(
const TQString & aStr )
2730 int commentlevel = 0;
2731 bool insidequote =
false;
2733 for (uint index=0; index<aStr.length(); index++) {
2736 switch (aStr[index].latin1()) {
2738 if (commentlevel == 0)
2739 insidequote = !insidequote;
2747 if (commentlevel > 0)
2760 if (!insidequote && (commentlevel == 0)) {
2761 addr = aStr.mid(addrstart, index-addrstart);
2762 if (!addr.isEmpty())
2763 list += addr.simplifyWhiteSpace();
2764 addrstart = index+1;
2770 if (!insidequote && (commentlevel == 0)) {
2771 addr = aStr.mid(addrstart, aStr.length()-addrstart);
2772 if (!addr.isEmpty())
2773 list += addr.simplifyWhiteSpace();
2784 const TQString &subject,
const TQString &body,
2785 const TQString & ,
const TQStringList &attachURLs,
2786 const TQCString& startup_id )
2791 TQString group = config.
readEntry(
"Profile",
"Default");
2793 config.
setGroup( TQString(
"PROFILE_%1").arg(group) );
2796 TQString to, cc, bcc;
2797 if (command.isEmpty() || command == TQString::fromLatin1(
"kmail")
2798 || command.endsWith(
"/kmail"))
2800 command = TQString::fromLatin1(
"kmail --composer -s %s -c %c -b %b --body %B --attach %A -- %t");
2801 if ( !_to.isEmpty() )
2805 to = TQString(
"=?utf8?b?%1?=" )
2808 if ( !_cc.isEmpty() )
2809 cc = TQString(
"=?utf8?b?%1?=" )
2811 if ( !_bcc.isEmpty() )
2812 bcc = TQString(
"=?utf8?b?%1?=" )
2818 if( !command.contains(
'%' ))
2825 TQString preferredTerminal = confGroup.readPathEntry(
"TerminalApplication",
"konsole");
2826 command = preferredTerminal +
" -e " + command;
2830 TQString cmd = cmdTokens[0];
2831 cmdTokens.remove(cmdTokens.begin());
2837 TQStringList tos = splitEmailAddressList( to );
2839 tos.remove( tos.begin() );
2840 for (TQStringList::ConstIterator it = tos.begin(); it != tos.end(); ++it)
2843 const TQStringList ccs = splitEmailAddressList( cc );
2844 for (TQStringList::ConstIterator it = ccs.begin(); it != ccs.end(); ++it)
2846 const TQStringList bccs = splitEmailAddressList( bcc );
2847 for (TQStringList::ConstIterator it = bccs.begin(); it != bccs.end(); ++it)
2849 for (TQStringList::ConstIterator it = attachURLs.begin(); it != attachURLs.end(); ++it)
2851 if (!subject.isEmpty())
2853 if (!body.isEmpty())
2856 if ( ! (to.isEmpty() && qry.isEmpty()) )
2859 TQMap<TQChar, TQString> keyMap;
2860 keyMap.insert(
't', to);
2861 keyMap.insert(
's', subject);
2862 keyMap.insert(
'c', cc);
2863 keyMap.insert(
'b', bcc);
2864 keyMap.insert(
'B', body);
2865 keyMap.insert(
'u', url.
url());
2867 TQString attachlist = attachURLs.join(
",");
2868 attachlist.prepend(
'\'');
2869 attachlist.append(
'\'');
2870 keyMap.insert(
'A', attachlist);
2872 for (TQStringList::Iterator it = cmdTokens.begin(); it != cmdTokens.end(); )
2876 if (it == cmdTokens.begin())
2878 TQStringList::ConstIterator urlit = attachURLs.begin();
2879 TQStringList::ConstIterator urlend = attachURLs.end();
2880 if ( urlit != urlend )
2882 TQStringList::Iterator previt = it;
2886 while ( ++urlit != urlend )
2888 cmdTokens.insert( it, *previt );
2889 cmdTokens.insert( it, *urlit );
2893 it = cmdTokens.remove( cmdTokens.remove( it ) );
2904 if (
tdeinitExec(cmd, cmdTokens, &error, NULL, startup_id )) {
2905 if (Tty != kapp->type()) {
2906 TQMessageBox::critical(kapp->mainWidget(), i18n(
"Could not Launch Mail Client"),
2907 i18n(
"Could not launch the mail client:\n\n%1").arg(error), i18n(
"&OK"));
2910 kdWarning() <<
"Could not launch mail client:\n" << error <<
endl;
2930 if (Tty != kapp->type())
2931 TQMessageBox::critical(kapp->mainWidget(), i18n(
"Could not Launch Browser"),
2932 i18n(
"Could not launch the browser:\n\n%1").arg(error), i18n(
"&OK"));
2934 kdWarning() <<
"Could not launch browser:\n" << error <<
endl;
2967 emit coreFakeKeyPress(keyCode);
2973 return "tdelauncher";
2977 startServiceInternal(
const TQCString &
function,
2978 const TQString& _name,
const TQStringList &URLs,
2979 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
2981 struct serviceResult
2992 dcopClient = kapp->dcopClient();
2998 if (!dcopClient->
attach())
3001 *error =
i18n(
"Could not register with DCOP.\n");
3009 TQDataStream stream(params, IO_WriteOnly);
3010 stream << _name << URLs;
3011 TQCString replyType;
3012 TQByteArray replyData;
3014 TQValueList<TQCString> envs;
3016 if (tqt_xdisplay()) {
3017 TQCString dpystring(XDisplayString(tqt_xdisplay()));
3018 envs.append( TQCString(
"DISPLAY=") + dpystring );
3019 }
else if( getenv(
"DISPLAY" )) {
3020 TQCString dpystring( getenv(
"DISPLAY" ));
3021 envs.append( TQCString(
"DISPLAY=") + dpystring );
3025 #if defined Q_WS_X11
3027 stream << ( startup_id.isEmpty() ? TDEStartupInfo::createNewStartupId() : startup_id );
3029 if(
function.left( 12 ) !=
"tdeinit_exec" )
3032 if (!dcopClient->
call(_launcher, _launcher,
3033 function, params, replyType, replyData))
3036 *error =
i18n(
"TDELauncher could not be reached via DCOP.\n");
3047 TQDataStream stream2(replyData, IO_ReadOnly);
3048 serviceResult result;
3049 stream2 >> result.result >> result.dcopName >> result.error >> result.pid;
3051 *dcopService = result.dcopName;
3053 *error = result.error;
3056 return result.result;
3061 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3066 return startServiceInternal(
3067 "start_service_by_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3068 _name, URLs, error, dcopService, pid, startup_id, noWait);
3073 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3075 return startServiceInternal(
3076 "start_service_by_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3077 _name, URLs, error, dcopService, pid, startup_id, noWait);
3082 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3087 return startServiceInternal(
3088 "start_service_by_desktop_path(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3089 _name, URLs, error, dcopService, pid, startup_id, noWait);
3094 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3096 return startServiceInternal(
3097 "start_service_by_desktop_path(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3098 _name, URLs, error, dcopService, pid, startup_id, noWait);
3103 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3108 return startServiceInternal(
3109 "start_service_by_desktop_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3110 _name, URLs, error, dcopService, pid, startup_id, noWait);
3115 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3117 return startServiceInternal(
3118 "start_service_by_desktop_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3119 _name, URLs, error, dcopService, pid, startup_id, noWait);
3124 TQString *error,
int *pid )
3131 TQString *error,
int *pid,
const TQCString& startup_id )
3133 return startServiceInternal(
"tdeinit_exec(TQString,TQStringList,TQValueList<TQCString>,TQCString)",
3134 name, args, error, 0, pid, startup_id,
false);
3139 TQString *error,
int *pid )
3146 TQString *error,
int *pid,
const TQCString& startup_id )
3148 return startServiceInternal(
"tdeinit_exec_wait(TQString,TQStringList,TQValueList<TQCString>,TQCString)",
3149 name, args, error, 0, pid, startup_id,
false);
3156 if( TQDir::isRelativePath(pFilename) )
3158 kdWarning(101) <<
"Relative filename passed to TDEApplication::tempSaveName" <<
endl;
3159 aFilename = TQFileInfo( TQDir(
"." ), pFilename ).absFilePath();
3162 aFilename = pFilename;
3164 TQDir aAutosaveDir( TQDir::homeDirPath() +
"/autosave/" );
3165 if( !aAutosaveDir.exists() )
3167 if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) )
3174 aFilename.replace(
"/",
"\\!" ).prepend(
"#" ).append(
"#" ).prepend(
"/" ).prepend( aAutosaveDir.absPath() );
3181 bool& bRecover )
const
3185 if( TQDir::isRelativePath(pFilename) )
3187 kdWarning(101) <<
"Relative filename passed to TDEApplication::tempSaveName" <<
endl;
3188 aFilename = TQFileInfo( TQDir(
"." ), pFilename ).absFilePath();
3191 aFilename = pFilename;
3193 TQDir aAutosaveDir( TQDir::homeDirPath() +
"/autosave/" );
3194 if( !aAutosaveDir.exists() )
3196 if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) )
3203 aFilename.replace(
"/",
"\\!" ).prepend(
"#" ).append(
"#" ).prepend(
"/" ).prepend( aAutosaveDir.absPath() );
3205 if( TQFile( aFilename ).exists() )
3220 int accessOK = access( TQFile::encodeName(pathname), mode );
3221 if ( accessOK == 0 )
3227 if ( (mode & W_OK) == 0 )
3231 if (!access( TQFile::encodeName(pathname), F_OK))
3235 TQString dirName(pathname);
3236 int pos = dirName.findRev(
'/');
3239 else if ( pos == 0 )
3242 dirName.truncate(pos);
3244 accessOK = access( TQFile::encodeName(dirName), W_OK );
3246 if ( accessOK == 0 )
3258 if ( !topWidget->inherits(
"TDEMainWindow") ) {
3259 topWidget->setCaption(
caption() );
3263 topWidget->setIcon(
icon() );
3264 #if defined Q_WS_X11
3269 TDEStartupInfo::setWindowStartupId( topWidget->winId(),
startupId());
3275 return d->startup_id;
3278 void TDEApplication::setStartupId(
const TQCString& startup_id )
3280 if( startup_id == d->startup_id )
3282 #if defined Q_WS_X11
3283 TDEStartupInfo::handleAutoAppStartedSending();
3285 if( startup_id.isEmpty())
3286 d->startup_id =
"0";
3289 d->startup_id = startup_id;
3290 #
if defined Q_WS_X11
3291 TDEStartupInfoId
id;
3292 id.initId( startup_id );
3293 long timestamp =
id.timestamp();
3294 if( timestamp != 0 )
3302 void TDEApplication::read_app_startup_id()
3304 #if defined Q_WS_X11
3305 TDEStartupInfoId
id = TDEStartupInfo::currentStartupIdEnv();
3306 TDEStartupInfo::resetStartupEnv();
3307 d->startup_id =
id.id();
3313 static bool init =
false;
3318 int fd = open(
"/dev/urandom", O_RDONLY);
3319 if (fd < 0 || ::read(fd, &seed,
sizeof(seed)) !=
sizeof(seed))
3323 seed = rand()+time(0);
3325 if (fd >= 0) close(fd);
3333 if (length <=0 )
return TQString::null;
3335 TQString str; str.setLength( length );
3351 if (!d->actionRestrictions)
3361 if (!d->actionRestrictions || !action)
3366 return authorize(action_prefix + action);
3371 if (menuId.isEmpty() || kde_kiosk_exception)
3382 TQStringList result;
3383 for(TQStringList::ConstIterator it = menuIds.begin();
3384 it != menuIds.end(); ++it)
3392 void TDEApplication::initUrlActionRestrictions()
3394 d->urlActionRestrictions.setAutoDelete(
true);
3395 d->urlActionRestrictions.clear();
3396 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3397 (
"open", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, TQString::null,
true));
3398 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3399 (
"list", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, TQString::null,
true));
3405 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3406 (
"link", TQString::null, TQString::null, TQString::null,
":internet", TQString::null, TQString::null,
true));
3407 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3408 (
"redirect", TQString::null, TQString::null, TQString::null,
":internet", TQString::null, TQString::null,
true));
3412 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3413 (
"redirect", TQString::null, TQString::null, TQString::null,
"file", TQString::null, TQString::null,
true));
3414 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3415 (
"redirect",
":internet", TQString::null, TQString::null,
"file", TQString::null, TQString::null,
false));
3418 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3419 (
"redirect",
":local", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null,
true));
3422 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3423 (
"redirect", TQString::null, TQString::null, TQString::null,
"about", TQString::null, TQString::null,
true));
3426 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3427 (
"redirect", TQString::null, TQString::null, TQString::null,
"=", TQString::null, TQString::null,
true));
3432 TQString keyFormat = TQString(
"rule_%1");
3433 for(
int i = 1; i <= count; i++)
3435 TQString key = keyFormat.arg(i);
3437 if (rule.count() != 8)
3439 TQString action = rule[0];
3440 TQString refProt = rule[1];
3441 TQString refHost = rule[2];
3442 TQString refPath = rule[3];
3443 TQString urlProt = rule[4];
3444 TQString urlHost = rule[5];
3445 TQString urlPath = rule[6];
3446 TQString strEnabled = rule[7].lower();
3448 bool bEnabled = (strEnabled ==
"true");
3450 if (refPath.startsWith(
"$HOME"))
3451 refPath.replace(0, 5, TQDir::homeDirPath());
3452 else if (refPath.startsWith(
"~"))
3453 refPath.replace(0, 1, TQDir::homeDirPath());
3454 if (urlPath.startsWith(
"$HOME"))
3455 urlPath.replace(0, 5, TQDir::homeDirPath());
3456 else if (urlPath.startsWith(
"~"))
3457 urlPath.replace(0, 1, TQDir::homeDirPath());
3459 if (refPath.startsWith(
"$TMP"))
3461 if (urlPath.startsWith(
"$TMP"))
3464 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3465 ( action, refProt, refHost, refPath, urlProt, urlHost, urlPath, bEnabled));
3474 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3484 bool result =
false;
3485 if (d->urlActionRestrictions.isEmpty())
3486 initUrlActionRestrictions();
3488 KURL baseURL(_baseURL);
3489 baseURL.
setPath(TQDir::cleanDirPath(baseURL.
path()));
3490 TQString baseClass = KProtocolInfo::protocolClass(baseURL.
protocol());
3491 KURL destURL(_destURL);
3492 destURL.setPath(TQDir::cleanDirPath(destURL.path()));
3493 TQString destClass = KProtocolInfo::protocolClass(destURL.protocol());
3495 for(TDEApplicationPrivate::URLActionRule *rule = d->urlActionRestrictions.first();
3496 rule; rule = d->urlActionRestrictions.next())
3498 if ((result != rule->permission) &&
3499 (action == rule->action) &&
3500 rule->baseMatch(baseURL, baseClass) &&
3501 rule->destMatch(destURL, destClass, baseURL, baseClass))
3503 result = rule->permission;
3515 int root_x, root_y, win_x, win_y;
3517 XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
3518 &root_x, &root_y, &win_x, &win_y, &keybstate );
3519 return keybstate & 0x00ff;
3520 #elif defined W_WS_MACX
3521 return GetCurrentEventKeyModifiers() & 0x00ff;
3534 int root_x, root_y, win_x, win_y;
3535 XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
3536 &root_x, &root_y, &win_x, &win_y, &mousestate );
3537 #elif defined(Q_WS_WIN)
3538 const bool mousebtn_swapped = GetSystemMetrics(SM_SWAPBUTTON);
3539 if (GetAsyncKeyState(VK_LBUTTON))
3540 mousestate |= (mousebtn_swapped ? Button3Mask : Button1Mask);
3541 if (GetAsyncKeyState(VK_MBUTTON))
3542 mousestate |= Button2Mask;
3543 if (GetAsyncKeyState(VK_RBUTTON))
3544 mousestate |= (mousebtn_swapped ? Button1Mask : Button3Mask);
3545 #elif defined(Q_WS_MACX)
3546 mousestate = GetCurrentEventButtonState();
3550 return mousestate & 0xff00;
3559 int root_x, root_y, win_x, win_y;
3561 XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
3562 &root_x, &root_y, &win_x, &win_y, &state );
3564 if( state & Button1Mask )
3565 ret |= TQ_LeftButton;
3566 if( state & Button2Mask )
3567 ret |= TQ_MidButton;
3568 if( state & Button3Mask )
3569 ret |= TQ_RightButton;
3570 if( state & ShiftMask )
3571 ret |= TQ_ShiftButton;
3572 if( state & ControlMask )
3573 ret |= TQ_ControlButton;
3574 if( state & KKeyNative::modX( KKey::ALT ))
3575 ret |= TQ_AltButton;
3576 if( state & KKeyNative::modX( KKey::WIN ))
3577 ret |= TQ_MetaButton;
3578 #elif defined(Q_WS_WIN)
3579 const bool mousebtn_swapped = GetSystemMetrics(SM_SWAPBUTTON);
3580 if (GetAsyncKeyState(VK_LBUTTON))
3581 ret |= (mousebtn_swapped ? RightButton : LeftButton);
3582 if (GetAsyncKeyState(VK_MBUTTON))
3583 ret |= TQ_MidButton;
3584 if (GetAsyncKeyState(VK_RBUTTON))
3585 ret |= (mousebtn_swapped ? TQ_LeftButton : TQ_RightButton);
3586 if (GetAsyncKeyState(VK_SHIFT))
3587 ret |= TQ_ShiftButton;
3588 if (GetAsyncKeyState(VK_CONTROL))
3589 ret |= TQ_ControlButton;
3590 if (GetAsyncKeyState(VK_MENU))
3591 ret |= TQ_AltButton;
3592 if (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN))
3593 ret |= TQ_MetaButton;
3597 return static_cast< ButtonState
>( ret );
3603 struct sigaction act;
3604 act.sa_handler = SIG_IGN;
3605 sigemptyset( &act.sa_mask );
3607 sigaction( SIGPIPE, &act, 0 );
3611 void TDEApplication::sigpipeHandler(
int)
3613 int saved_errno = errno;
3617 sprintf(msg,
"*** SIGPIPE *** (ignored, pid = %ld)\n", (
long) getpid());
3618 if (write(2, msg, strlen(msg)) < 0) {
3624 errno = saved_errno;
3627 bool TDEApplication::guiEnabled()
3629 return kapp && kapp->d->guiEnabled;
3632 void TDEApplication::virtual_hook(
int id,
void* data )
3633 { TDEInstance::virtual_hook(
id, data ); }
3635 void KSessionManaged::virtual_hook(
int,
void* )
3638 #include "tdeapplication.moc"