23 #ifdef HAVE_XCOMPOSITE
35 #undef QT_NO_TRANSLATION
36 #undef TQT_NO_TRANSLATION
37 #include <tqtranslator.h>
42 #define TDEAPPLICATION_BINARY_COMPAT_HACK 1
43 #include "tdeapplication.h"
44 #undef TDEAPPLICATION_BINARY_COMPAT_HACK
46 #define QT_NO_TRANSLATION
47 #define TQT_NO_TRANSLATION
49 #include <tqptrcollection.h>
50 #include <tqwidgetlist.h>
51 #include <tqstrlist.h>
53 #include <tqmessagebox.h>
54 #include <tqtextstream.h>
56 #include <tqlineedit.h>
57 #include <tqtextedit.h>
58 #include <tqsessionmanager.h>
59 #include <tqptrlist.h>
61 #include <tqstylesheet.h>
62 #include <tqpixmapcache.h>
63 #include <tqtooltip.h>
64 #include <tqstylefactory.h>
65 #include <tqmetaobject.h>
68 #include <tqsqlpropertymap.h>
71 #include <tdeglobal.h>
72 #include <kstandarddirs.h>
76 #include <kiconloader.h>
77 #include <kclipboard.h>
78 #include <tdeconfig.h>
79 #include <ksimpleconfig.h>
80 #include <tdecmdlineargs.h>
81 #include <tdeaboutdata.h>
82 #include <tdeglobalsettings.h>
84 #include <kdatastream.h>
85 #include <klibloader.h>
86 #include <kmimesourcefactory.h>
87 #include <tdestdaccel.h>
89 #include "kcheckaccelerators.h"
90 #include <tqptrdict.h>
91 #include <kmacroexpander.h>
93 #include <kprotocolinfo.h>
94 #include <kkeynative.h>
96 #include <kglobalaccel.h>
99 #include <tdestartupinfo.h>
102 #include <dcopclient.h>
105 #include <sys/types.h>
106 #ifdef HAVE_SYS_STAT_H
107 #include <sys/stat.h>
109 #include <sys/wait.h>
111 #include <sys/types.h>
122 #include <sys/time.h>
131 #include "kprocctrl.h"
138 #include <X11/Xlib.h>
140 #include <X11/extensions/Xrender.h>
141 #include <X11/extensions/Xcomposite.h>
144 #include <X11/Xutil.h>
145 #include <X11/Xatom.h>
146 #include <X11/SM/SMlib.h>
153 #include <KDE-ICE/ICElib.h>
155 typedef void* IceIOErrorHandler;
158 #define Button1Mask (1<<8)
159 #define Button2Mask (1<<9)
160 #define Button3Mask (1<<10)
164 #define DISPLAY "DISPLAY"
165 #elif defined(Q_WS_QWS)
166 #define DISPLAY "QWS_DISPLAY"
174 #include <Carbon/Carbon.h>
179 #include <sys/ioctl.h>
181 #include <linux/vt.h>
184 extern int getfd(
const char *fnam);
188 #include "kappdcopiface.h"
191 KDE_EXPORT
bool kde_have_kipc =
true;
192 bool kde_kiosk_exception =
false;
193 bool kde_kiosk_admin =
false;
196 bool TDEApplication::loadedByKdeinit =
false;
197 DCOPClient *TDEApplication::s_DCOPClient = 0L;
198 bool TDEApplication::s_dcopClientNeedsPostInit =
false;
201 static Atom atom_DesktopWindow;
202 static Atom atom_NetSupported;
205 #if defined(Q_WS_X11) && defined(COMPOSITE)
206 static int composite_event, composite_error, composite_opcode;
207 static bool x11_composite_error_generated;
208 static int x11_error(Display *dpy, XErrorEvent *ev) {
209 if (ev->request_code == composite_opcode && ev->minor_code == X_CompositeRedirectSubwindows)
211 x11_composite_error_generated =
true;
220 TDECORE_EXPORT
bool tqt_qclipboard_bailout_hack =
false;
222 template class TQPtrList<KSessionManaged>;
226 static int kde_xio_errhandler( Display * dpy )
228 return kapp->xioErrhandler( dpy );
231 static int kde_x_errhandler( Display *dpy, XErrorEvent *err )
233 return kapp->xErrhandler( dpy, err );
239 static void kde_ice_ioerrorhandler( IceConn conn )
242 kapp->iceIOErrorHandler( conn );
249 void TDEApplication_init_windows(
bool GUIenabled);
251 class QAssistantClient;
259 int get_x_vtnum(Display *dpy)
264 unsigned long nitems;
265 unsigned long bytes_after;
269 prop = XInternAtom (dpy,
"XFree86_VT", False);
273 if (XGetWindowProperty (dpy, DefaultRootWindow (dpy), prop, 0, 1,
274 False, AnyPropertyType, &actualtype, &actualformat,
275 &nitems, &bytes_after, &buf)) {
284 switch (actualtype) {
288 switch (actualformat) {
290 num = (*(uint8_t *)(
void *)buf);
293 num = (*(uint16_t *)(
void *)buf);
296 num = (*(uint32_t *)(
void *)buf);
318 class TDEApplicationPrivate
321 TDEApplicationPrivate()
322 : actionRestrictions( false ),
324 oldIceIOErrorHandler( 0 ),
325 checkAccelerators( 0 ),
326 overrideStyle( TQString::null ),
328 app_started_timer( NULL ),
329 m_KAppDCOPInterface( 0L ),
330 session_save( false )
332 ,oldXErrorHandler( NULL )
333 ,oldXIOErrorHandler( NULL )
334 #elif defined Q_WS_WIN
335 ,qassistantclient( 0 )
340 ~TDEApplicationPrivate()
343 delete qassistantclient;
348 bool actionRestrictions : 1;
357 IceIOErrorHandler oldIceIOErrorHandler;
358 KCheckAccelerators* checkAccelerators;
359 TQString overrideStyle;
360 TQString geometry_arg;
361 TQCString startup_id;
362 TQTimer* app_started_timer;
366 int (*oldXErrorHandler)(Display*,XErrorEvent*);
367 int (*oldXIOErrorHandler)(Display*);
368 #elif defined Q_WS_WIN
369 QAssistantClient* qassistantclient;
375 #define checkExactMatch(s, b) \
376 if (s.isEmpty()) b = true; \
377 else if (s[s.length()-1] == '!') \
378 { b = false; s.truncate(s.length()-1); } \
380 #define checkStartWildCard(s, b) \
381 if (s.isEmpty()) b = true; \
382 else if (s[0] == '*') \
383 { b = true; s = s.mid(1); } \
385 #define checkEqual(s, b) \
388 URLActionRule(
const TQString &act,
389 const TQString &bProt,
const TQString &bHost,
const TQString &bPath,
390 const TQString &dProt,
const TQString &dHost,
const TQString &dPath,
393 baseProt(bProt), baseHost(bHost), basePath(bPath),
394 destProt(dProt), destHost(dHost), destPath(dPath),
397 checkExactMatch(baseProt, baseProtWildCard);
398 checkStartWildCard(baseHost, baseHostWildCard);
399 checkExactMatch(basePath, basePathWildCard);
400 checkExactMatch(destProt, destProtWildCard);
401 checkStartWildCard(destHost, destHostWildCard);
402 checkExactMatch(destPath, destPathWildCard);
403 checkEqual(destProt, destProtEqual);
404 checkEqual(destHost, destHostEqual);
407 bool baseMatch(
const KURL &url,
const TQString &protClass)
409 if (baseProtWildCard)
411 if ( !baseProt.isEmpty() && !url.
protocol().startsWith(baseProt) &&
412 (protClass.isEmpty() || (protClass != baseProt)) )
417 if ( (url.
protocol() != baseProt) &&
418 (protClass.isEmpty() || (protClass != baseProt)) )
421 if (baseHostWildCard)
423 if (!baseHost.isEmpty() && !url.
host().endsWith(baseHost))
428 if (url.
host() != baseHost)
431 if (basePathWildCard)
433 if (!basePath.isEmpty() && !url.
path().startsWith(basePath))
438 if (url.
path() != basePath)
444 bool destMatch(
const KURL &url,
const TQString &protClass,
const KURL &base,
const TQString &baseClass)
449 (protClass.isEmpty() || baseClass.isEmpty() || protClass != baseClass) )
452 else if (destProtWildCard)
454 if ( !destProt.isEmpty() && !url.
protocol().startsWith(destProt) &&
455 (protClass.isEmpty() || (protClass != destProt)) )
460 if ( (url.
protocol() != destProt) &&
461 (protClass.isEmpty() || (protClass != destProt)) )
464 if (destHostWildCard)
466 if (!destHost.isEmpty() && !url.
host().endsWith(destHost))
469 else if (destHostEqual)
476 if (url.
host() != destHost)
479 if (destPathWildCard)
481 if (!destPath.isEmpty() && !url.
path().startsWith(destPath))
486 if (url.
path() != destPath)
499 bool baseProtWildCard : 1;
500 bool baseHostWildCard : 1;
501 bool basePathWildCard : 1;
502 bool destProtWildCard : 1;
503 bool destHostWildCard : 1;
504 bool destPathWildCard : 1;
505 bool destProtEqual : 1;
506 bool destHostEqual : 1;
509 TQPtrList<URLActionRule> urlActionRestrictions;
512 TQString pSessionConfigFile;
516 static TQPtrList<TQWidget>*x11Filter = 0;
517 static bool autoDcopRegistration =
true;
524 x11Filter =
new TQPtrList<TQWidget>;
525 connect ( filter, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( x11FilterDestroyed() ) );
526 x11Filter->append( filter );
529 void TDEApplication::x11FilterDestroyed()
536 if ( !x11Filter || !filter )
538 x11Filter->removeRef( filter );
539 if ( x11Filter->isEmpty() ) {
549 extern bool kde_g_bKillAccelOverride;
551 bool TDEApplication::notify(TQObject *receiver, TQEvent *event)
553 TQEvent::Type t = event->type();
554 if (kde_g_bKillAccelOverride)
556 kde_g_bKillAccelOverride =
false;
558 if (t == TQEvent::AccelOverride)
560 TQT_TQKEYEVENT(event)->accept();
564 kdWarning(125) <<
"kde_g_bKillAccelOverride set, but received an event other than AccelOverride." <<
endl;
567 if ((t == TQEvent::AccelOverride) || (t == TQEvent::KeyPress))
570 TQLineEdit *edit = ::tqqt_cast<TQLineEdit *>(receiver);
574 TQKeyEvent *kevent = TQT_TQKEYEVENT(event);
578 if (t == TQEvent::KeyPress)
589 if (key ==
KKey(Qt::CTRL + Qt::Key_U))
591 if (t == TQEvent::KeyPress)
593 if (!edit->isReadOnly())
595 TQString t(edit->text());
596 t = t.mid(edit->cursorPosition());
597 edit->validateAndSet(t, 0, 0, 0);
608 TQTextEdit *medit = ::tqqt_cast<TQTextEdit *>(receiver);
612 TQKeyEvent *kevent = TQT_TQKEYEVENT(event);
615 if (t == TQEvent::KeyPress)
627 if( t == TQEvent::Show && receiver->isWidgetType())
629 TQWidget* w = TQT_TQWIDGET( receiver );
631 if( w->isTopLevel() && !
startupId().isEmpty() && !TQT_TQSHOWEVENT(event)->spontaneous())
632 TDEStartupInfo::setWindowStartupId( w->winId(),
startupId());
634 if( w->isTopLevel() && !w->testWFlags( WX11BypassWM ) && !w->isPopup() && !event->spontaneous())
636 if( d->app_started_timer == NULL )
638 d->app_started_timer =
new TQTimer(
this,
"app_started_timer" );
639 connect( d->app_started_timer, TQT_SIGNAL( timeout()), TQT_SLOT( checkAppStartedSlot()));
641 if( !d->app_started_timer->isActive())
642 d->app_started_timer->start( 0,
true );
644 if( w->isTopLevel() && ( w->icon() == NULL || w->icon()->isNull()))
647 static TQPixmap* ic = NULL;
660 return TQApplication::notify(receiver, event);
663 void TDEApplication::checkAppStartedSlot()
666 TDEStartupInfo::handleAutoAppStartedSending();
671 static TQPtrList<KSessionManaged>* sessionClients()
673 static TQPtrList<KSessionManaged>* session_clients = 0L;
674 if ( !session_clients )
675 session_clients =
new TQPtrList<KSessionManaged>;
676 return session_clients;
684 TQString TDEApplication::sessionConfigName()
const
686 TQString sessKey = sessionKey();
687 if ( sessKey.isEmpty() && !d->sessionKey.isEmpty() )
688 sessKey = d->sessionKey;
689 return TQString(
"session/%1_%2_%3").arg(
name()).arg(sessionId()).arg(sessKey);
693 static SmcConn mySmcConnection = 0;
694 static SmcConn tmpSmcConnection = 0;
699 static TQTime* smModificationTime = 0;
702 bool allowStyles,
bool GUIenabled,
bool SMenabled ) :
703 TQApplication( argc, argv, GUIenabled, SMenabled ),
TDEInstance(rAppName),
708 d (new TDEApplicationPrivate())
710 aIconPixmap.pm.icon = 0L;
711 aIconPixmap.pm.miniIcon = 0L;
712 read_app_startup_id();
715 useStyles = allowStyles;
716 Q_ASSERT (!rAppName.isEmpty());
720 TDECmdLineArgs::initIgnore(argc, argv, rAppName.data());
730 bool allowStyles,
bool GUIenabled ) :
731 TQApplication( argc, argv, GUIenabled ),
TDEInstance(rAppName),
736 d (new TDEApplicationPrivate())
738 aIconPixmap.pm.icon = 0L;
739 aIconPixmap.pm.miniIcon = 0L;
740 read_app_startup_id();
743 useStyles = allowStyles;
744 Q_ASSERT (!rAppName.isEmpty());
748 TDECmdLineArgs::initIgnore(argc, argv, rAppName.data());
762 d (new TDEApplicationPrivate)
764 aIconPixmap.pm.icon = 0L;
765 aIconPixmap.pm.miniIcon = 0L;
766 read_app_startup_id();
769 useStyles = allowStyles;
789 d (new TDEApplicationPrivate)
791 aIconPixmap.pm.icon = 0L;
792 aIconPixmap.pm.miniIcon = 0L;
793 read_app_startup_id();
796 useStyles = allowStyles;
808 getX11RGBAVisual(dpy), getX11RGBAColormap(dpy) ),
811 aIconPixmap.pm.icon = 0L;
812 aIconPixmap.pm.miniIcon = 0L;
813 read_app_startup_id();
814 useStyles = allowStyles;
824 disable_argb?visual:getX11RGBAVisual(dpy), disable_argb?colormap:getX11RGBAColormap(dpy) ),
827 aIconPixmap.pm.icon = 0L;
828 aIconPixmap.pm.miniIcon = 0L;
829 read_app_startup_id();
830 useStyles = allowStyles;
831 if (disable_argb) argb_visual =
false;
842 visual?visual:getX11RGBAVisual(dpy), colormap?colormap:getX11RGBAColormap(dpy) ),
845 if ((visual) && (colormap))
846 getX11RGBAInformation(dpy);
847 aIconPixmap.pm.icon = 0L;
848 aIconPixmap.pm.miniIcon = 0L;
849 read_app_startup_id();
850 useStyles = allowStyles;
861 visual?visual:getX11RGBAVisual(dpy), colormap?colormap:getX11RGBAColormap(dpy) ),
862 TDEInstance( _instance ), display(0L), d (new TDEApplicationPrivate)
864 if ((visual) && (colormap))
865 getX11RGBAInformation(dpy);
866 aIconPixmap.pm.icon = 0L;
867 aIconPixmap.pm.miniIcon = 0L;
868 read_app_startup_id();
869 useStyles = allowStyles;
886 d (new TDEApplicationPrivate)
888 aIconPixmap.pm.icon = 0L;
889 aIconPixmap.pm.miniIcon = 0L;
890 read_app_startup_id();
893 useStyles = allowStyles;
904 bool allowStyles,
bool GUIenabled ) :
908 d (new TDEApplicationPrivate())
910 aIconPixmap.pm.icon = 0L;
911 aIconPixmap.pm.miniIcon = 0L;
912 read_app_startup_id();
915 useStyles = allowStyles;
917 Q_ASSERT (!rAppName.isEmpty());
921 TDECmdLineArgs::initIgnore(argc, argv, rAppName.data());
928 int TDEApplication::xioErrhandler( Display* dpy )
934 d->oldXIOErrorHandler( dpy );
943 int TDEApplication::xErrhandler( Display* dpy,
void* err_ )
946 XErrorEvent* err =
static_cast< XErrorEvent*
>( err_ );
950 d->oldXErrorHandler( dpy, err );
956 void TDEApplication::iceIOErrorHandler( _IceConn *conn )
961 if ( d->oldIceIOErrorHandler != NULL )
962 (*d->oldIceIOErrorHandler)( conn );
967 class KDETranslator :
public TQTranslator
970 KDETranslator(TQObject *parent) : TQTranslator(parent,
"kdetranslator") {}
971 virtual TQTranslatorMessage findMessage(
const char* context,
972 const char *sourceText,
973 const char* message)
const
975 TQTranslatorMessage res;
976 res.setTranslation(
TDEGlobal::locale()->translateQt(context, sourceText, message));
981 void TDEApplication::init(
bool GUIenabled)
983 d->guiEnabled = GUIenabled;
984 if ((getuid() != geteuid()) ||
985 (getgid() != getegid()) )
989 struct group *man = getgrnam(
"man");
990 if ( !man || man->gr_gid != getegid() ){
991 fprintf(stderr,
"The TDE libraries are not designed to run with suid privileges.\n");
1000 TQApplication::setDesktopSettingsAware(
false );
1005 #ifdef Q_WS_X11 //FIXME(E)
1011 Atom atoms_return[max];
1014 atoms[n] = &kipcCommAtom;
1015 names[n++] = (
char *)
"KIPC_COMM_ATOM";
1017 atoms[n] = &atom_DesktopWindow;
1018 names[n++] = (
char *)
"KDE_DESKTOP_WINDOW";
1020 atoms[n] = &atom_NetSupported;
1021 names[n++] = (
char *)
"_NET_SUPPORTED";
1023 XInternAtoms( tqt_xdisplay(), names, n,
false, atoms_return );
1025 for (
int i = 0; i < n; i++ )
1026 *atoms[i] = atoms_return[i];
1030 dcopAutoRegistration();
1031 dcopClientPostInit();
1036 #if defined Q_WS_X11
1037 kipcEventMask = (1 << KIPC::StyleChanged) | (1 << KIPC::PaletteChanged) |
1038 (1 << KIPC::FontChanged) | (1 << KIPC::BackgroundChanged) |
1039 (1 << KIPC::ToolbarStyleChanged) | (1 << KIPC::SettingsChanged) |
1047 d->actionRestrictions = config->
hasGroup(
"KDE Action Restrictions" ) && !kde_kiosk_exception;
1052 TQCString readOnly = getenv(
"TDE_HOME_READONLY");
1053 if (readOnly.isEmpty() && (tqstrcmp(
name(),
"kdialog") != 0))
1064 fcntl(ConnectionNumber(tqt_xdisplay()), F_SETFD, FD_CLOEXEC);
1066 d->oldXErrorHandler = XSetErrorHandler( kde_x_errhandler );
1067 d->oldXIOErrorHandler = XSetIOErrorHandler( kde_xio_errhandler );
1070 connect(
this, TQT_SIGNAL( aboutToQuit() ),
this, TQT_SIGNAL(
shutDown() ) );
1072 #ifdef Q_WS_X11 //FIXME(E)
1073 display = desktop()->x11Display();
1078 TQStringList::Iterator it = plugins.begin();
1079 while (it != plugins.end()) {
1080 addLibraryPath( *it );
1085 tdedisplaySetStyle();
1086 tdedisplaySetFont();
1088 propagateSettings(SETTINGS_QT);
1098 TQMimeSourceFactory* oldDefaultFactory = TQMimeSourceFactory::takeDefaultFactory();
1100 if ( oldDefaultFactory ) {
1101 TQMimeSourceFactory::addFactory( oldDefaultFactory );
1104 d->checkAccelerators =
new KCheckAccelerators( TQT_TQOBJECT(
this) );
1111 if (!pixmap.isNull()) {
1112 TQImage i = pixmap.convertToImage().convertDepth(32).smoothScale(40, 40);
1113 for(
int y = 0; y < i.height(); y++) {
1114 uchar *l = i.scanLine(y);
1115 for(
int x = 0; x < i.width(); x+=4)
1118 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
1119 CGDataProviderRef dp = CGDataProviderCreateWithData(NULL,
1120 i.bits(), i.numBytes(), NULL);
1121 CGImageRef ir = CGImageCreate(i.width(), i.height(), 8, 32, i.bytesPerLine(),
1122 cs, kCGImageAlphaNoneSkipFirst, dp,
1123 0, 0, kCGRenderingIntentDefault);
1125 SetApplicationDockTileImage(ir);
1127 CGColorSpaceRelease(cs);
1128 CGDataProviderRelease(dp);
1136 bool rtl = reverseLayout();
1137 installTranslator(
new KDETranslator(TQT_TQOBJECT(
this)));
1138 setReverseLayout( rtl );
1139 if (i18n(
"_: Dear Translator! Translate this string to the string 'LTR' in "
1140 "left-to-right languages (as english) or to 'RTL' in right-to-left "
1141 "languages (such as Hebrew and Arabic) to get proper widget layout." ) ==
"RTL")
1142 setReverseLayout( !rtl );
1146 + TQString::fromLatin1(
name()) +
'/');
1147 pSessionConfig = 0L;
1148 bSessionManagement =
true;
1152 if (GUIenabled && kde_have_kipc )
1154 smw =
new TQWidget(0,0);
1156 XChangeProperty(tqt_xdisplay(), smw->winId(),
1157 atom_DesktopWindow, atom_DesktopWindow,
1158 32, PropModeReplace, (
unsigned char *)&data, 1);
1160 d->oldIceIOErrorHandler = IceSetIOErrorHandler( kde_ice_ioerrorhandler );
1161 #elif defined(Q_WS_WIN)
1162 TDEApplication_init_windows(GUIenabled);
1168 static int my_system (
const char *command) {
1175 const char* shell =
"/bin/sh";
1176 execl(shell, shell,
"-c", command, (
void *)0);
1180 if (waitpid(pid, &status, 0) == -1) {
1192 return s_DCOPClient;
1196 if (args && args->
isSet(
"dcopserver"))
1201 connect(s_DCOPClient, TQT_SIGNAL(attachFailed(
const TQString &)),
1202 kapp, TQT_SLOT(dcopFailure(
const TQString &)));
1203 connect(s_DCOPClient, TQT_SIGNAL(blockUserInput(
bool) ),
1204 kapp, TQT_SLOT(dcopBlockUserInput(
bool)) );
1207 s_dcopClientNeedsPostInit =
true;
1210 return s_DCOPClient;
1213 void TDEApplication::dcopClientPostInit()
1215 if( s_dcopClientNeedsPostInit )
1217 s_dcopClientNeedsPostInit =
false;
1218 connect(s_DCOPClient, TQT_SIGNAL(blockUserInput(
bool) ),
1219 TQT_SLOT(dcopBlockUserInput(
bool)) );
1224 void TDEApplication::dcopAutoRegistration()
1226 if (autoDcopRegistration)
1236 autoDcopRegistration =
false;
1242 return pSessionConfig;
1245 pSessionConfig =
new TDEConfig( sessionConfigName(),
false,
false);
1246 return pSessionConfig;
1259 if ( d->refCount <= 0 )
1263 KSessionManaged::KSessionManaged()
1265 sessionClients()->remove(
this );
1266 sessionClients()->append(
this );
1269 KSessionManaged::~KSessionManaged()
1271 sessionClients()->remove(
this );
1286 bSessionManagement =
false;
1290 bSessionManagement =
true;
1301 if( mySmcConnection ) {
1302 SmcRequestSaveYourself( mySmcConnection, SmSaveLocal, False,
1307 IceFlush(SmcGetIceConnection(mySmcConnection));
1317 TQApplication::syncX();
1324 TQDataStream arg(data, IO_WriteOnly);
1325 arg << (int)confirm << (
int)sdtype << (int)sdmode;
1327 "logout(int,int,int)", data );
1330 if ( mySmcConnection ) {
1332 SmcRequestSaveYourself( mySmcConnection, SmSaveBoth, True,
1337 IceFlush(SmcGetIceConnection(mySmcConnection));
1344 TQCString smEnv = ::getenv(
"SESSION_MANAGER");
1345 if (smEnv.isEmpty())
1348 if (! tmpSmcConnection) {
1353 tmpSmcConnection = SmcOpenConnection( 0, 0, 1, 0,
1360 if (!tmpSmcConnection )
1364 SmcRequestSaveYourself( tmpSmcConnection, SmSaveBoth, True,
1365 SmInteractStyleAny, False, True );
1368 IceFlush(SmcGetIceConnection(tmpSmcConnection));
1379 TQCString fName = TQFile::encodeName(locateLocal(
"socket",
"KSMserver"));
1380 TQCString display = ::getenv(DISPLAY);
1382 display.replace(TQRegExp(
"\\.[0-9]+$"),
"");
1384 while( (i = display.find(
':')) >= 0)
1387 fName +=
"_"+display;
1388 TQCString smEnv = ::getenv(
"SESSION_MANAGER");
1389 bool check = smEnv.isEmpty();
1390 if ( !check && smModificationTime ) {
1391 TQFileInfo info( fName );
1392 TQTime current = TQT_TQTIME_OBJECT(info.lastModified().time());
1393 check = current > *smModificationTime;
1396 delete smModificationTime;
1398 if ( !f.open( IO_ReadOnly ) )
1400 TQFileInfo info ( f );
1401 smModificationTime =
new TQTime( TQT_TQTIME_OBJECT(info.lastModified().time()) );
1403 t.setEncoding( TQTextStream::Latin1 );
1404 TQString s = t.readLine();
1406 ::setenv(
"SESSION_MANAGER", s.latin1(), true );
1413 d->session_save =
true;
1414 bool canceled =
false;
1417 it = sessionClients()->next() ) {
1418 canceled = !it->commitData( sm );
1423 if ( sm.allowsInteraction() ) {
1425 TQWidgetList *list = TQApplication::topLevelWidgets();
1426 bool canceled =
false;
1427 TQWidget* w = list->first();
1428 while ( !canceled && w ) {
1429 if ( !w->testWState( WState_ForceHide ) && !w->inherits(
"TDEMainWindow") ) {
1432 canceled = !e.isAccepted();
1436 list = TQApplication::topLevelWidgets();
1441 while ( w && done.containsRef( w ) )
1448 if ( !bSessionManagement )
1449 sm.setRestartHint( TQSessionManager::RestartNever );
1451 sm.setRestartHint( TQSessionManager::RestartIfRunning );
1452 d->session_save =
false;
1455 static void checkRestartVersion( TQSessionManager& sm )
1457 Display* dpy = tqt_xdisplay();
1460 unsigned long nitems, after;
1461 unsigned char* data;
1462 if( XGetWindowProperty( dpy, RootWindow( dpy, 0 ), XInternAtom( dpy,
"TDE_FULL_SESSION", False ),
1463 0, 1, False, AnyPropertyType, &type, &format, &nitems, &after, &data ) == Success ) {
1466 if( type == XA_STRING && format == 8 ) {
1467 if( XGetWindowProperty( dpy, RootWindow( dpy, 0 ), XInternAtom( dpy,
"TDE_SESSION_VERSION", False ),
1468 0, 1, False, AnyPropertyType, &type, &format, &nitems, &after, &data ) == Success ) {
1479 TQStringList restartCommand = sm.restartCommand();
1480 restartCommand.prepend( wrapper );
1481 sm.setRestartCommand( restartCommand );
1486 d->session_save =
true;
1488 static bool firstTime =
true;
1489 mySmcConnection = (SmcConn) sm.handle();
1491 if ( !bSessionManagement ) {
1492 sm.setRestartHint( TQSessionManager::RestartNever );
1493 d->session_save =
false;
1497 sm.setRestartHint( TQSessionManager::RestartIfRunning );
1501 d->session_save =
false;
1511 if ( pSessionConfig ) {
1512 delete pSessionConfig;
1517 TQStringList restartCommand = sm.restartCommand();
1519 TQCString multiHead = getenv(
"TDE_MULTIHEAD");
1520 if (multiHead.lower() ==
"true") {
1527 TQCString displayname = getenv(DISPLAY);
1528 if (! displayname.isNull()) {
1531 restartCommand.append(
"-display");
1532 restartCommand.append(displayname);
1534 sm.setRestartCommand( restartCommand );
1537 checkRestartVersion( sm );
1541 bool canceled =
false;
1544 it = sessionClients()->next() ) {
1545 canceled = !it->saveState( sm );
1549 if ( pSessionConfig ) {
1550 pSessionConfig->
sync();
1551 TQStringList discard;
1552 discard <<
"rm" << locateLocal(
"config", sessionConfigName());
1553 sm.setDiscardCommand( discard );
1555 sm.setDiscardCommand( TQStringList(
"") );
1563 d->session_save =
false;
1568 return d->session_save;
1571 void TDEApplication::startKdeinit()
1573 #ifndef Q_WS_WIN //TODO
1575 TDELockFile lock( locateLocal(
"tmp",
"starttdeinitlock", &inst ));
1588 if (kapp && (Tty != kapp->type()))
1589 setOverrideCursor( tqwaitCursor );
1590 my_system(TQFile::encodeName(srv)+
" --suicide"+
" --new-startup");
1591 if (kapp && (Tty != kapp->type()))
1592 restoreOverrideCursor();
1596 void TDEApplication::dcopFailure(
const TQString &msg)
1598 static int failureCount = 0;
1600 if (failureCount == 1)
1605 if (failureCount == 2)
1612 TQString msgStr(i18n(
"There was an error setting up inter-process "
1613 "communications for TDE. The message returned "
1614 "by the system was:\n\n"));
1616 msgStr += i18n(
"\n\nPlease check that the \"dcopserver\" program is running!");
1618 if (Tty != kapp->type())
1620 TQMessageBox::critical
1623 i18n(
"DCOP communications error (%1)").arg(kapp->caption()),
1630 fprintf(stderr,
"%s\n", msgStr.local8Bit().data());
1641 {
"display <displayname>",
I18N_NOOP(
"Use the X-server display 'displayname'"), 0},
1643 {
"display <displayname>",
I18N_NOOP(
"Use the QWS display 'displayname'"), 0},
1645 {
"session <sessionId>",
I18N_NOOP(
"Restore the application for the given 'sessionId'"), 0},
1646 {
"cmap",
I18N_NOOP(
"Causes the application to install a private color\nmap on an 8-bit display"), 0},
1647 {
"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},
1648 {
"nograb",
I18N_NOOP(
"tells TQt to never grab the mouse or the keyboard"), 0},
1649 {
"dograb",
I18N_NOOP(
"running under a debugger can cause an implicit\n-nograb, use -dograb to override"), 0},
1650 {
"sync",
I18N_NOOP(
"switches to synchronous mode for debugging"), 0},
1652 {
"font <fontname>",
I18N_NOOP(
"defines the application font"), 0},
1654 {
"background <color>",
I18N_NOOP(
"sets the default background color and an\napplication palette (light and dark shades are\ncalculated)"), 0},
1656 {
"foreground <color>",
I18N_NOOP(
"sets the default foreground color"), 0},
1658 {
"button <color>",
I18N_NOOP(
"sets the default button color"), 0},
1659 {
"name <name>",
I18N_NOOP(
"sets the application name"), 0},
1660 {
"title <title>",
I18N_NOOP(
"sets the application title (caption)"), 0},
1662 {
"visual TrueColor",
I18N_NOOP(
"forces the application to use a TrueColor visual on\nan 8-bit display"), 0},
1663 {
"inputstyle <inputstyle>",
I18N_NOOP(
"sets XIM (X Input Method) input style. Possible\nvalues are onthespot, overthespot, offthespot and\nroot"), 0 },
1664 {
"im <XIM server>",
I18N_NOOP(
"set XIM server"),0},
1665 {
"noxim",
I18N_NOOP(
"disable XIM"), 0 },
1668 {
"qws",
I18N_NOOP(
"forces the application to run as QWS Server"), 0},
1670 {
"reverse",
I18N_NOOP(
"mirrors the whole layout of widgets"), 0},
1671 TDECmdLineLastOption
1676 {
"caption <caption>",
I18N_NOOP(
"Use 'caption' as name in the titlebar"), 0},
1677 {
"icon <icon>",
I18N_NOOP(
"Use 'icon' as the application icon"), 0},
1678 {
"miniicon <icon>",
I18N_NOOP(
"Use 'icon' as the icon in the titlebar"), 0},
1679 {
"config <filename>",
I18N_NOOP(
"Use alternative configuration file"), 0},
1680 {
"dcopserver <server>",
I18N_NOOP(
"Use the DCOP Server specified by 'server'"), 0},
1681 {
"nocrashhandler",
I18N_NOOP(
"Disable crash handler, to get core dumps"), 0},
1682 {
"waitforwm",
I18N_NOOP(
"Waits for a WM_NET compatible windowmanager"), 0},
1683 {
"style <style>",
I18N_NOOP(
"sets the application GUI style"), 0},
1684 {
"geometry <geometry>",
I18N_NOOP(
"sets the client geometry of the main widget - see man X for the argument format"), 0},
1685 {
"smkey <sessionKey>", 0, 0},
1688 TDECmdLineLastOption
1698 void TDEApplication::parseCommandLine( )
1702 if ( !args )
return;
1704 if (args->
isSet(
"config"))
1706 TQString config = TQString::fromLocal8Bit(args->
getOption(
"config"));
1710 if (args->
isSet(
"style"))
1714 TQStringList::Iterator itp = plugins.begin();
1715 while (itp != plugins.end()) {
1716 addLibraryPath( *itp );
1720 TQStringList styles = TQStyleFactory::keys();
1721 TQString reqStyle(args->
getOption(
"style").lower());
1723 TQStringList list = libraryPaths();
1724 TQStringList::Iterator it = list.begin();
1725 while( it != list.end() ) {
1729 for (TQStringList::ConstIterator it = styles.begin(); it != styles.end(); ++it) {
1730 if ((*it).lower() == reqStyle)
1732 d->overrideStyle = *it;
1737 if (d->overrideStyle.isEmpty())
1738 fprintf(stderr,
"%s", TQString(i18n(
"The style %1 was not found\n").arg(reqStyle)).local8Bit().data());
1741 if (args->
isSet(
"caption"))
1743 aCaption = TQString::fromLocal8Bit(args->
getOption(
"caption"));
1746 if (args->
isSet(
"miniicon"))
1748 const char *tmp = args->
getOption(
"miniicon");
1749 if (!aIconPixmap.pm.miniIcon) {
1750 aIconPixmap.pm.miniIcon =
new TQPixmap;
1752 *aIconPixmap.pm.miniIcon = SmallIcon(tmp);
1753 aMiniIconName = tmp;
1756 if (args->
isSet(
"icon"))
1758 const char *tmp = args->
getOption(
"icon");
1759 if (!aIconPixmap.pm.icon) {
1760 aIconPixmap.pm.icon =
new TQPixmap;
1762 *aIconPixmap.pm.icon = DesktopIcon( tmp );
1764 if (!aIconPixmap.pm.miniIcon) {
1765 aIconPixmap.pm.miniIcon =
new TQPixmap;
1767 if (aIconPixmap.pm.miniIcon->isNull())
1769 *aIconPixmap.pm.miniIcon = SmallIcon( tmp );
1770 aMiniIconName = tmp;
1774 bool nocrashhandler = (getenv(
"TDE_DEBUG") != NULL);
1775 if (!nocrashhandler && args->
isSet(
"crashhandler"))
1785 if ( args->
isSet(
"waitforwm" ) ) {
1789 unsigned long length, after;
1790 unsigned char *data;
1791 while ( XGetWindowProperty( tqt_xdisplay(), tqt_xrootwin(), atom_NetSupported,
1792 0, 1,
false, AnyPropertyType, &type, &format,
1793 &length, &after, &data ) != Success || !length ) {
1797 XWindowEvent( tqt_xdisplay(), tqt_xrootwin(), PropertyChangeMask, &event );
1806 if (args->
isSet(
"geometry"))
1808 d->geometry_arg = args->
getOption(
"geometry");
1811 if (args->
isSet(
"smkey"))
1813 d->sessionKey = args->
getOption(
"smkey");
1820 return d->geometry_arg;
1825 if( !aIconPixmap.pm.icon) {
1826 aIconPixmap.pm.icon =
new TQPixmap;
1828 if( aIconPixmap.pm.icon->isNull()) {
1831 return *aIconPixmap.pm.icon;
1836 return aIconName.isNull() ? (TQString)
instanceName() : aIconName;
1841 if (!aIconPixmap.pm.miniIcon) {
1842 aIconPixmap.pm.miniIcon =
new TQPixmap;
1844 if (aIconPixmap.pm.miniIcon->isNull()) {
1845 *aIconPixmap.pm.miniIcon = SmallIcon(
instanceName() );
1847 return *aIconPixmap.pm.miniIcon;
1852 return aMiniIconName.isNull() ? (TQString)
instanceName() : aMiniIconName;
1855 extern void kDebugCleanup();
1857 TDEApplication::~TDEApplication()
1859 delete aIconPixmap.pm.miniIcon;
1860 aIconPixmap.pm.miniIcon = 0L;
1861 delete aIconPixmap.pm.icon;
1862 aIconPixmap.pm.icon = 0L;
1863 delete d->m_KAppDCOPInterface;
1869 KLibLoader::cleanUp();
1874 delete s_DCOPClient;
1880 if ( d->oldXErrorHandler != NULL )
1881 XSetErrorHandler( d->oldXErrorHandler );
1882 if ( d->oldXIOErrorHandler != NULL )
1883 XSetIOErrorHandler( d->oldXIOErrorHandler );
1884 if ( d->oldIceIOErrorHandler != NULL )
1885 IceSetIOErrorHandler( d->oldIceIOErrorHandler );
1892 mySmcConnection = 0;
1893 delete smModificationTime;
1894 smModificationTime = 0;
1897 if (tmpSmcConnection) {
1898 SmcCloseConnection( tmpSmcConnection, 0, 0 );
1899 tmpSmcConnection = 0;
1908 class KAppX11HackWidget:
public TQWidget
1911 bool publicx11Event( XEvent * e) {
return x11Event( e ); }
1915 #if defined(Q_WS_X11) && defined(COMPOSITE)
1917 bool have_manager =
false;
1920 const char *pidfile =
"compton-tde.available";
1921 char uidstr[
sizeof(uid_t)*8+1];
1922 sprintf(uidstr,
"%d", getuid());
1923 int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
1924 filename = (
char*)malloc(n*
sizeof(
char)+1);
1925 memset(filename,0,n);
1926 strcat(filename, P_tmpdir);
1927 strcat(filename,
"/.");
1928 strcat(filename, uidstr);
1929 strcat(filename,
"-");
1930 strcat(filename, pidfile);
1934 pFile = fopen(filename,
"r");
1936 have_manager =
true;
1943 return have_manager;
1947 bool compositing_manager_available;
1948 if (force_available) {
1949 compositing_manager_available = available;
1954 char *displayname = 0;
1955 if ( qtargs->
isSet(
"display"))
1956 displayname = qtargs->
getOption(
"display" ).data();
1958 Display *dpy = XOpenDisplay( displayname );
1960 x11_composite_error_generated =
false;
1961 compositing_manager_available =
false;
1962 XSetErrorHandler(x11_error);
1963 if (!XQueryExtension (dpy, COMPOSITE_NAME, &composite_opcode, &composite_event, &composite_error)) {
1964 XSetErrorHandler(NULL);
1965 compositing_manager_available =
false;
1969 Window root_window = XDefaultRootWindow(dpy);
1970 XCompositeRedirectSubwindows(dpy, root_window, CompositeRedirectManual);
1972 if (x11_composite_error_generated ==
true) {
1973 compositing_manager_available =
true;
1976 XCompositeUnredirectSubwindows(dpy, root_window, CompositeRedirectManual);
1977 compositing_manager_available =
false;
1979 XSetErrorHandler(NULL);
1983 compositing_manager_available =
true;
1989 const char *pidfile =
"compton-tde.available";
1990 char uidstr[
sizeof(uid_t)*8+1];
1991 sprintf(uidstr,
"%d", getuid());
1992 int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
1993 filename = (
char*)malloc(n*
sizeof(
char)+1);
1994 memset(filename,0,n);
1995 strcat(filename, P_tmpdir);
1996 strcat(filename,
"/.");
1997 strcat(filename, uidstr);
1998 strcat(filename,
"-");
1999 strcat(filename, pidfile);
2002 if (compositing_manager_available) {
2005 sprintf(buffer,
"available");
2006 pFile = fopen(filename,
"w");
2008 fwrite(buffer,1,strlen(buffer), pFile);
2019 return compositing_manager_available;
2022 Display* TDEApplication::openX11RGBADisplay() {
2025 if ( qtargs->
isSet(
"display"))
2026 display = qtargs->
getOption(
"display" ).data();
2028 Display *dpy = XOpenDisplay( display );
2030 kdError() <<
"cannot connect to X server " << display <<
endl;
2038 getX11RGBAInformation(dpy);
2040 return argb_x11_visual;
2043 return (Qt::HANDLE)NULL;
2048 getX11RGBAInformation(dpy);
2050 return argb_x11_colormap;
2053 return (Qt::HANDLE)NULL;
2061 void TDEApplication::getX11RGBAInformation(Display *dpy) {
2063 argb_visual =
false;
2067 int screen = DefaultScreen( dpy );
2068 Colormap colormap = 0;
2070 int event_base, error_base;
2072 if ( XRenderQueryExtension( dpy, &event_base, &error_base ) ) {
2075 templ.screen = screen;
2077 templ.c_class = TrueColor;
2078 XVisualInfo *xvi = XGetVisualInfo( dpy, VisualScreenMask | VisualDepthMask
2079 | VisualClassMask, &templ, &nvi );
2081 for (
int i = 0; i < nvi; i++ ) {
2082 XRenderPictFormat *format = XRenderFindVisualFormat( dpy, xvi[i].visual );
2083 if ( format->type == PictTypeDirect && format->direct.alphaMask ) {
2084 visual = xvi[i].visual;
2085 colormap = XCreateColormap( dpy, RootWindow( dpy, screen ), visual, AllocNone );
2086 kdDebug() <<
"[tdecore-tdeapplication] Found visual with alpha support" <<
endl;
2094 argb_x11_visual = Qt::HANDLE( visual );
2095 argb_x11_colormap = Qt::HANDLE( colormap );
2099 argb_visual =
false;
2103 void TDEApplication::getX11RGBAInformation(Display *dpy) {
2112 const char *pidfile =
"compton-tde.available";
2113 char uidstr[
sizeof(uid_t)*8+1];
2114 sprintf(uidstr,
"%d", getuid());
2115 int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
2116 filename = (
char*)malloc(n*
sizeof(
char)+1);
2117 memset(filename,0,n);
2118 strcat(filename, P_tmpdir);
2119 strcat(filename,
"/.");
2120 strcat(filename, uidstr);
2121 strcat(filename,
"-");
2122 strcat(filename, pidfile);
2125 if (force_available) {
2128 sprintf(buffer,
"available");
2129 pFile = fopen(filename,
"w");
2131 fwrite(buffer,1,strlen(buffer), pFile);
2145 Display* TDEApplication::openX11RGBADisplay() {
2162 static bool kapp_block_user_input =
false;
2164 void TDEApplication::dcopBlockUserInput(
bool b )
2166 kapp_block_user_input = b;
2170 bool TDEApplication::x11EventFilter( XEvent *_event )
2172 if ( kapp_block_user_input ) {
2173 switch ( _event->type ) {
2188 for (TQWidget *w=x11Filter->first(); w; w=x11Filter->next()) {
2189 if (((KAppX11HackWidget*) w)->publicx11Event(_event))
2194 if ((_event->type == ClientMessage) &&
2195 (_event->xclient.message_type == kipcCommAtom))
2197 XClientMessageEvent *cme = (XClientMessageEvent *) _event;
2199 int id = cme->data.l[0];
2200 int arg = cme->data.l[1];
2201 if ((
id < 32) && (kipcEventMask & (1 << id)))
2205 case KIPC::StyleChanged:
2207 tdedisplaySetStyle();
2210 case KIPC::ToolbarStyleChanged:
2216 case KIPC::PaletteChanged:
2218 tdedisplaySetPalette();
2221 case KIPC::FontChanged:
2223 TDEGlobalSettings::rereadFontSettings();
2224 tdedisplaySetFont();
2227 case KIPC::BackgroundChanged:
2231 case KIPC::SettingsChanged:
2233 if (arg == SETTINGS_PATHS)
2234 TDEGlobalSettings::rereadPathSettings();
2235 else if (arg == SETTINGS_MOUSE)
2236 TDEGlobalSettings::rereadMouseSettings();
2240 case KIPC::IconChanged:
2244 emit updateIconLoaders();
2248 case KIPC::ClipboardConfigChanged:
2249 TDEClipboardSynchronizer::newConfiguration(arg);
2253 TDEGlobalAccel::blockShortcuts(arg);
2270 #if defined Q_WS_X11
2271 Display *display = tqt_xdisplay();
2277 Window w = XCreateSimpleWindow( display, tqt_xrootwin(), 0, 0, 1, 1, 0, 0, 0 );
2278 XSelectInput( tqt_xdisplay(), w, PropertyChangeMask );
2279 unsigned char data[ 1 ];
2280 XChangeProperty( display, w, XA_ATOM, XA_ATOM, 8, PropModeAppend, data, 1 );
2282 XWindowEvent( display, w, PropertyChangeMask, &ev );
2283 time = ev.xproperty.time;
2284 XDestroyWindow( display, w );
2286 if( GET_QT_X_USER_TIME() == 0
2288 SET_QT_X_USER_TIME(time);
2294 #if defined Q_WS_X11
2295 return GET_QT_X_USER_TIME();
2303 #if defined Q_WS_X11
2305 time = GET_QT_X_USER_TIME();
2306 DCOPRef( dcopId,
"MainApplication-Interface" ).
call(
"updateUserTimestamp", time );
2312 TQObject *
object = TQT_TQOBJECT(focusWidget());
2316 TQMetaObject *meta =
object->metaObject();
2318 int idx = meta->findSlot( slot + 1,
true );
2322 object->tqt_invoke( idx, 0 );
2329 kdDebug(101) <<
"[tdecore-tdeapplication] Cannot use KIPC event mask for message IDs >= 32\n";
2332 kipcEventMask |= (1 << id);
2339 kdDebug(101) <<
"[tdecore-tdeapplication] Cannot use KIPC event mask for message IDs >= 32\n";
2342 kipcEventMask &= ~(1 << id);
2359 void TDEApplication::applyGUIStyle()
2361 if ( !useStyles )
return;
2364 TQString defaultStyle = TDEStyle::defaultStyle();
2365 TQString styleStr = pConfig.readEntry(
"widgetStyle", defaultStyle);
2367 if (d->overrideStyle.isEmpty()) {
2371 TQStyle* sp = TQStyleFactory::create( styleStr );
2374 if ( !sp && styleStr != defaultStyle)
2375 sp = TQStyleFactory::create( defaultStyle );
2377 sp = TQStyleFactory::create( *(TQStyleFactory::keys().begin()) );
2381 setStyle(d->overrideStyle);
2383 tdedisplaySetPalette();
2389 if( !aCaption.isNull() )
2406 bool withAppName,
bool modified )
const
2408 TQString s = userCaption.isEmpty() ?
caption() : userCaption;
2412 s += TQString::fromUtf8(
" [") + i18n(
"modified") + TQString::fromUtf8(
"]");
2414 if ( !userCaption.isEmpty() ) {
2417 if ( withAppName && !
caption().isNull() && !userCaption.endsWith(
caption()) )
2418 s += TQString::fromUtf8(
" - ") +
caption();
2433 TQColor trinity4Background( 239, 239, 239 );
2434 TQColor trinity4Blue( 103,141,178 );
2436 TQColor trinity4Button;
2437 if ( TQPixmap::defaultDepth() > 8 )
2438 trinity4Button.setRgb( 221, 223, 228 );
2440 trinity4Button.setRgb( 220, 220, 220 );
2442 TQColor trinity4Link( 0, 0, 238 );
2443 TQColor trinity4VisitedLink( 82, 24, 139 );
2445 TQColor background = config->
readColorEntry(
"background", &trinity4Background );
2446 TQColor foreground = config->
readColorEntry(
"foreground", tqblackptr );
2447 TQColor button = config->
readColorEntry(
"buttonBackground", &trinity4Button );
2448 TQColor buttonText = config->
readColorEntry(
"buttonForeground", tqblackptr );
2449 TQColor highlight = config->
readColorEntry(
"selectBackground", &trinity4Blue );
2450 TQColor highlightedText = config->
readColorEntry(
"selectForeground", tqwhiteptr );
2451 TQColor base = config->
readColorEntry(
"windowBackground", tqwhiteptr );
2452 TQColor baseText = config->
readColorEntry(
"windowForeground", tqblackptr );
2453 TQColor link = config->
readColorEntry(
"linkColor", &trinity4Link );
2454 TQColor visitedLink = config->
readColorEntry(
"visitedLinkColor", &trinity4VisitedLink );
2456 int highlightVal, lowlightVal;
2457 highlightVal = 100 + (2*contrast_+4)*16/10;
2458 lowlightVal = 100 + (2*contrast_+4)*10;
2460 TQColor disfg = foreground;
2463 disfg.hsv( &h, &s, &v );
2466 disfg = disfg.dark(lowlightVal);
2467 else if (disfg != Qt::black)
2469 disfg = disfg.light(highlightVal);
2472 disfg = Qt::darkGray;
2475 TQColorGroup disabledgrp(disfg, background,
2476 background.light(highlightVal),
2477 background.dark(lowlightVal),
2478 background.dark(120),
2479 background.dark(120), base);
2481 TQColorGroup colgrp(foreground, background, background.light(highlightVal),
2482 background.dark(lowlightVal),
2483 background.dark(120),
2486 int inlowlightVal = lowlightVal-25;
2487 if(inlowlightVal < 120)
2488 inlowlightVal = 120;
2490 colgrp.setColor(TQColorGroup::Highlight, highlight);
2491 colgrp.setColor(TQColorGroup::HighlightedText, highlightedText);
2492 colgrp.setColor(TQColorGroup::Button, button);
2493 colgrp.setColor(TQColorGroup::ButtonText, buttonText);
2494 colgrp.setColor(TQColorGroup::Midlight, background.light(110));
2495 colgrp.setColor(TQColorGroup::Link, link);
2496 colgrp.setColor(TQColorGroup::LinkVisited, visitedLink);
2498 disabledgrp.setColor(TQColorGroup::Button, button);
2500 TQColor disbtntext = buttonText;
2501 disbtntext.hsv( &h, &s, &v );
2504 disbtntext = disbtntext.dark(lowlightVal);
2505 else if (disbtntext != Qt::black)
2507 disbtntext = disbtntext.light(highlightVal);
2510 disbtntext = Qt::darkGray;
2512 disabledgrp.setColor(TQColorGroup::ButtonText, disbtntext);
2513 disabledgrp.setColor(TQColorGroup::Midlight, background.light(110));
2514 disabledgrp.setColor(TQColorGroup::Highlight, highlight.dark(120));
2515 disabledgrp.setColor(TQColorGroup::Link, link);
2516 disabledgrp.setColor(TQColorGroup::LinkVisited, visitedLink);
2518 return TQPalette(colgrp, disabledgrp, colgrp);
2522 void TDEApplication::tdedisplaySetPalette()
2529 bool do_not_set_palette = FALSE;
2530 if(config->
readBoolEntry(
"nopaletteChange", &do_not_set_palette))
2540 void TDEApplication::tdedisplaySetFont()
2548 TQStyleSheet* sheet = TQStyleSheet::defaultSheet();
2558 void TDEApplication::tdedisplaySetStyle()
2569 void TDEApplication::propagateSettings(SettingsCategory arg)
2574 #ifdef QT_HAVE_MAX_IMAGE_SIZE
2575 TQSize maxImageSize(4096, 4096);
2576 maxImageSize = config->
readSizeEntry(
"MaxImageSize", &maxImageSize);
2577 TQImage::setMaxImageSize(maxImageSize);
2580 int num = config->
readNumEntry(
"CursorBlinkRate", TQApplication::cursorFlashTime());
2581 if ((num != 0) && (num < 200))
2585 TQApplication::setCursorFlashTime(num);
2586 num = config->
readNumEntry(
"DoubleClickInterval", TQApplication::doubleClickInterval());
2587 TQApplication::setDoubleClickInterval(num);
2588 num = config->
readNumEntry(
"StartDragTime", TQApplication::startDragTime());
2589 TQApplication::setStartDragTime(num);
2590 num = config->
readNumEntry(
"StartDragDist", TQApplication::startDragDistance());
2591 TQApplication::setStartDragDistance(num);
2592 num = config->
readNumEntry(
"WheelScrollLines", TQApplication::wheelScrollLines());
2593 TQApplication::setWheelScrollLines(num);
2596 TQApplication::setEffectEnabled( Qt::UI_AnimateMenu, b);
2598 TQApplication::setEffectEnabled( Qt::UI_FadeMenu, b);
2600 TQApplication::setEffectEnabled( Qt::UI_AnimateCombo, b);
2602 TQApplication::setEffectEnabled( Qt::UI_AnimateTooltip, b);
2604 TQApplication::setEffectEnabled( Qt::UI_FadeTooltip, b);
2606 TQToolTip::setGloballyEnabled( b );
2614 static bool installed =
false;
2615 if (installed)
return;
2624 TQSqlPropertyMap *kdeMap =
new TQSqlPropertyMap;
2625 kdeMap->insert(
"KColorButton",
"color" );
2626 kdeMap->insert(
"KComboBox",
"currentItem" );
2627 kdeMap->insert(
"KDatePicker",
"date" );
2628 kdeMap->insert(
"KDateWidget",
"date" );
2629 kdeMap->insert(
"KDateTimeWidget",
"dateTime" );
2630 kdeMap->insert(
"KEditListBox",
"items" );
2631 kdeMap->insert(
"TDEFontCombo",
"family" );
2632 kdeMap->insert(
"TDEFontRequester",
"font" );
2633 kdeMap->insert(
"TDEFontChooser",
"font" );
2634 kdeMap->insert(
"KHistoryCombo",
"currentItem" );
2635 kdeMap->insert(
"TDEListBox",
"currentItem" );
2636 kdeMap->insert(
"KLineEdit",
"text" );
2637 kdeMap->insert(
"KRestrictedLine",
"text" );
2638 kdeMap->insert(
"KSqueezedTextLabel",
"text" );
2639 kdeMap->insert(
"KTextBrowser",
"source" );
2640 kdeMap->insert(
"KTextEdit",
"text" );
2641 kdeMap->insert(
"KURLRequester",
"url" );
2642 kdeMap->insert(
"KPasswordEdit",
"password" );
2643 kdeMap->insert(
"KIntNumInput",
"value" );
2644 kdeMap->insert(
"KIntSpinBox",
"value" );
2645 kdeMap->insert(
"KDoubleNumInput",
"value" );
2647 kdeMap->insert( TQGROUPBOX_OBJECT_NAME_STRING,
"checked" );
2648 kdeMap->insert( TQTABWIDGET_OBJECT_NAME_STRING,
"currentPage" );
2649 TQSqlPropertyMap::installDefaultMap( kdeMap );
2654 const TQString& _appname)
const
2663 const TQString& _appname,
2664 const TQCString& startup_id )
const
2668 if (_appname.isEmpty())
2673 if (!anchor.isEmpty())
2674 url = TQString(
"help:/%1?anchor=%2").arg(appname).arg(anchor);
2676 url = TQString(
"help:/%1/index.html").arg(appname);
2679 if ( !
dcopClient()->isApplicationRegistered(
"khelpcenter") )
2683 if (Tty != kapp->type())
2684 TQMessageBox::critical(kapp->mainWidget(), i18n(
"Could not Launch Help Center"),
2685 i18n(
"Could not launch the TDE Help Center:\n\n%1").arg(error), i18n(
"&OK"));
2687 kdWarning() <<
"Could not launch help:\n" << error <<
endl;
2692 DCOPRef(
"khelpcenter",
"KHelpCenterIface" ).
send(
"openUrl", url, startup_id );
2698 kdWarning() <<
"invoking HTML help is deprecated! use docbook and invokeHelp!\n";
2702 if( _filename.isEmpty() )
2703 filename = TQString(name()) +
"/index.html";
2705 filename = _filename;
2708 if (!topic.isEmpty())
2709 url = TQString(
"help:/%1#%2").arg(filename).arg(topic);
2711 url = TQString(
"help:/%1").arg(filename);
2714 if ( !
dcopClient()->isApplicationRegistered(
"khelpcenter") )
2718 if (Tty != kapp->type())
2719 TQMessageBox::critical(kapp->mainWidget(), i18n(
"Could not Launch Help Center"),
2720 i18n(
"Could not launch the TDE Help Center:\n\n%1").arg(error), i18n(
"&OK"));
2722 kdWarning() <<
"Could not launch help:\n" << error <<
endl;
2727 DCOPRef(
"khelpcenter",
"KHelpCenterIface" ).
send(
"openUrl", url );
2738 invokeMailer(address, TQString::null, TQString::null, subject, TQString::null, TQString::null,
2739 TQStringList(), startup_id );
2755 TQStringList queries = TQStringList::split(
'&', mailtoURL.
query().mid(1));
2756 TQStringList attachURLs;
2757 for (TQStringList::Iterator it = queries.begin(); it != queries.end(); ++it)
2759 TQString q = (*it).lower();
2760 if (q.startsWith(
"subject="))
2763 if (q.startsWith(
"cc="))
2766 if (q.startsWith(
"bcc="))
2769 if (q.startsWith(
"body="))
2772 if (allowAttachments && q.startsWith(
"attach="))
2775 if (allowAttachments && q.startsWith(
"attachment="))
2778 if (q.startsWith(
"to="))
2782 invokeMailer( address, cc, bcc, subject, body, TQString::null, attachURLs, startup_id );
2786 const TQString &subject,
const TQString &body,
2787 const TQString & messageFile,
const TQStringList &attachURLs)
2789 return invokeMailer(to,cc,bcc,subject,body,messageFile,attachURLs,
"");
2796 static TQStringList splitEmailAddressList(
const TQString & aStr )
2814 int commentlevel = 0;
2815 bool insidequote =
false;
2817 for (uint index=0; index<aStr.length(); index++) {
2820 switch (aStr[index].latin1()) {
2822 if (commentlevel == 0)
2823 insidequote = !insidequote;
2831 if (commentlevel > 0)
2844 if (!insidequote && (commentlevel == 0)) {
2845 addr = aStr.mid(addrstart, index-addrstart);
2846 if (!addr.isEmpty())
2847 list += addr.simplifyWhiteSpace();
2848 addrstart = index+1;
2854 if (!insidequote && (commentlevel == 0)) {
2855 addr = aStr.mid(addrstart, aStr.length()-addrstart);
2856 if (!addr.isEmpty())
2857 list += addr.simplifyWhiteSpace();
2868 const TQString &subject,
const TQString &body,
2869 const TQString & ,
const TQStringList &attachURLs,
2870 const TQCString& startup_id )
2875 TQString group = config.
readEntry(
"Profile",
"Default");
2877 config.
setGroup( TQString(
"PROFILE_%1").arg(group) );
2880 TQString to, cc, bcc;
2881 if (command.isEmpty() || command == TQString::fromLatin1(
"kmail")
2882 || command.endsWith(
"/kmail"))
2884 command = TQString::fromLatin1(
"kmail --composer -s %s -c %c -b %b --body %B --attach %A -- %t");
2885 if ( !_to.isEmpty() )
2889 to = TQString(
"=?utf8?b?%1?=" )
2892 if ( !_cc.isEmpty() )
2893 cc = TQString(
"=?utf8?b?%1?=" )
2895 if ( !_bcc.isEmpty() )
2896 bcc = TQString(
"=?utf8?b?%1?=" )
2902 if( !command.contains(
'%' ))
2909 TQString preferredTerminal = confGroup.readPathEntry(
"TerminalApplication",
"konsole");
2910 command = preferredTerminal +
" -e " + command;
2914 TQString cmd = cmdTokens[0];
2915 cmdTokens.remove(cmdTokens.begin());
2921 TQStringList tos = splitEmailAddressList( to );
2923 tos.remove( tos.begin() );
2924 for (TQStringList::ConstIterator it = tos.begin(); it != tos.end(); ++it)
2927 const TQStringList ccs = splitEmailAddressList( cc );
2928 for (TQStringList::ConstIterator it = ccs.begin(); it != ccs.end(); ++it)
2930 const TQStringList bccs = splitEmailAddressList( bcc );
2931 for (TQStringList::ConstIterator it = bccs.begin(); it != bccs.end(); ++it)
2933 for (TQStringList::ConstIterator it = attachURLs.begin(); it != attachURLs.end(); ++it)
2935 if (!subject.isEmpty())
2937 if (!body.isEmpty())
2940 if ( ! (to.isEmpty() && qry.isEmpty()) )
2943 TQMap<TQChar, TQString> keyMap;
2944 keyMap.insert(
't', to);
2945 keyMap.insert(
's', subject);
2946 keyMap.insert(
'c', cc);
2947 keyMap.insert(
'b', bcc);
2948 keyMap.insert(
'B', body);
2949 keyMap.insert(
'u', url.
url());
2951 TQString attachlist = attachURLs.join(
",");
2952 attachlist.prepend(
'\'');
2953 attachlist.append(
'\'');
2954 keyMap.insert(
'A', attachlist);
2956 for (TQStringList::Iterator it = cmdTokens.begin(); it != cmdTokens.end(); )
2960 if (it == cmdTokens.begin())
2962 TQStringList::ConstIterator urlit = attachURLs.begin();
2963 TQStringList::ConstIterator urlend = attachURLs.end();
2964 if ( urlit != urlend )
2966 TQStringList::Iterator previt = it;
2970 while ( ++urlit != urlend )
2972 cmdTokens.insert( it, *previt );
2973 cmdTokens.insert( it, *urlit );
2977 it = cmdTokens.remove( cmdTokens.remove( it ) );
2988 if (
tdeinitExec(cmd, cmdTokens, &error, NULL, startup_id )) {
2989 if (Tty != kapp->type()) {
2990 TQMessageBox::critical(kapp->mainWidget(), i18n(
"Could not Launch Mail Client"),
2991 i18n(
"Could not launch the mail client:\n\n%1").arg(error), i18n(
"&OK"));
2994 kdWarning() <<
"Could not launch mail client:\n" << error <<
endl;
3014 if (Tty != kapp->type())
3015 TQMessageBox::critical(kapp->mainWidget(), i18n(
"Could not Launch Browser"),
3016 i18n(
"Could not launch the browser:\n\n%1").arg(error), i18n(
"&OK"));
3018 kdWarning() <<
"Could not launch browser:\n" << error <<
endl;
3051 emit coreFakeKeyPress(keyCode);
3057 return "tdelauncher";
3061 startServiceInternal(
const TQCString &
function,
3062 const TQString& _name,
const TQStringList &URLs,
3063 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3065 struct serviceResult
3076 dcopClient = kapp->dcopClient();
3082 if (!dcopClient->
attach())
3085 *error =
i18n(
"Could not register with DCOP.\n");
3093 TQDataStream stream(params, IO_WriteOnly);
3094 stream << _name << URLs;
3095 TQCString replyType;
3096 TQByteArray replyData;
3098 TQValueList<TQCString> envs;
3100 if (tqt_xdisplay()) {
3101 TQCString dpystring(XDisplayString(tqt_xdisplay()));
3102 envs.append( TQCString(
"DISPLAY=") + dpystring );
3103 }
else if( getenv(
"DISPLAY" )) {
3104 TQCString dpystring( getenv(
"DISPLAY" ));
3105 envs.append( TQCString(
"DISPLAY=") + dpystring );
3109 #if defined Q_WS_X11
3111 stream << ( startup_id.isEmpty() ? TDEStartupInfo::createNewStartupId() : startup_id );
3113 if(
function.left( 12 ) !=
"tdeinit_exec" )
3116 if (!dcopClient->
call(_launcher, _launcher,
3117 function, params, replyType, replyData))
3120 *error =
i18n(
"TDELauncher could not be reached via DCOP.\n");
3131 TQDataStream stream2(replyData, IO_ReadOnly);
3132 serviceResult result;
3133 stream2 >> result.result >> result.dcopName >> result.error >> result.pid;
3135 *dcopService = result.dcopName;
3137 *error = result.error;
3140 return result.result;
3145 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3150 return startServiceInternal(
3151 "start_service_by_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3152 _name, URLs, error, dcopService, pid, startup_id, noWait);
3157 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3159 return startServiceInternal(
3160 "start_service_by_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3161 _name, URLs, error, dcopService, pid, startup_id, noWait);
3166 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3171 return startServiceInternal(
3172 "start_service_by_desktop_path(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3173 _name, URLs, error, dcopService, pid, startup_id, noWait);
3178 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3180 return startServiceInternal(
3181 "start_service_by_desktop_path(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3182 _name, URLs, error, dcopService, pid, startup_id, noWait);
3187 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3192 return startServiceInternal(
3193 "start_service_by_desktop_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3194 _name, URLs, error, dcopService, pid, startup_id, noWait);
3199 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3201 return startServiceInternal(
3202 "start_service_by_desktop_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3203 _name, URLs, error, dcopService, pid, startup_id, noWait);
3208 TQString *error,
int *pid )
3215 TQString *error,
int *pid,
const TQCString& startup_id )
3217 return startServiceInternal(
"tdeinit_exec(TQString,TQStringList,TQValueList<TQCString>,TQCString)",
3218 name, args, error, 0, pid, startup_id,
false);
3223 TQString *error,
int *pid )
3230 TQString *error,
int *pid,
const TQCString& startup_id )
3232 return startServiceInternal(
"tdeinit_exec_wait(TQString,TQStringList,TQValueList<TQCString>,TQCString)",
3233 name, args, error, 0, pid, startup_id,
false);
3240 if( TQDir::isRelativePath(pFilename) )
3242 kdWarning(101) <<
"Relative filename passed to TDEApplication::tempSaveName" <<
endl;
3243 aFilename = TQFileInfo( TQDir(
"." ), pFilename ).absFilePath();
3246 aFilename = pFilename;
3248 TQDir aAutosaveDir( TQDir::homeDirPath() +
"/autosave/" );
3249 if( !aAutosaveDir.exists() )
3251 if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) )
3258 aFilename.replace(
"/",
"\\!" ).prepend(
"#" ).append(
"#" ).prepend(
"/" ).prepend( aAutosaveDir.absPath() );
3265 bool& bRecover )
const
3269 if( TQDir::isRelativePath(pFilename) )
3271 kdWarning(101) <<
"Relative filename passed to TDEApplication::tempSaveName" <<
endl;
3272 aFilename = TQFileInfo( TQDir(
"." ), pFilename ).absFilePath();
3275 aFilename = pFilename;
3277 TQDir aAutosaveDir( TQDir::homeDirPath() +
"/autosave/" );
3278 if( !aAutosaveDir.exists() )
3280 if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) )
3287 aFilename.replace(
"/",
"\\!" ).prepend(
"#" ).append(
"#" ).prepend(
"/" ).prepend( aAutosaveDir.absPath() );
3289 if( TQFile( aFilename ).exists() )
3304 int accessOK = access( TQFile::encodeName(pathname), mode );
3305 if ( accessOK == 0 )
3311 if ( (mode & W_OK) == 0 )
3315 if (!access( TQFile::encodeName(pathname), F_OK))
3319 TQString dirName(pathname);
3320 int pos = dirName.findRev(
'/');
3323 else if ( pos == 0 )
3326 dirName.truncate(pos);
3328 accessOK = access( TQFile::encodeName(dirName), W_OK );
3330 if ( accessOK == 0 )
3342 if ( !topWidget->inherits(
"TDEMainWindow") ) {
3343 topWidget->setCaption(
caption() );
3347 topWidget->setIcon(
icon() );
3348 #if defined Q_WS_X11
3353 TDEStartupInfo::setWindowStartupId( topWidget->winId(),
startupId());
3359 return d->startup_id;
3362 void TDEApplication::setStartupId(
const TQCString& startup_id )
3364 if( startup_id == d->startup_id )
3366 #if defined Q_WS_X11
3367 TDEStartupInfo::handleAutoAppStartedSending();
3369 if( startup_id.isEmpty())
3370 d->startup_id =
"0";
3373 d->startup_id = startup_id;
3374 #
if defined Q_WS_X11
3375 TDEStartupInfoId
id;
3376 id.initId( startup_id );
3377 long timestamp =
id.timestamp();
3378 if( timestamp != 0 )
3386 void TDEApplication::read_app_startup_id()
3388 #if defined Q_WS_X11
3389 TDEStartupInfoId
id = TDEStartupInfo::currentStartupIdEnv();
3390 TDEStartupInfo::resetStartupEnv();
3391 d->startup_id =
id.id();
3397 static bool init =
false;
3402 int fd = open(
"/dev/urandom", O_RDONLY);
3403 if (fd < 0 || ::read(fd, &seed,
sizeof(seed)) !=
sizeof(seed))
3407 seed = rand()+time(0);
3409 if (fd >= 0) close(fd);
3417 if (length <=0 )
return TQString::null;
3419 TQString str; str.setLength( length );
3435 if (!d->actionRestrictions)
3445 if (!d->actionRestrictions || !action)
3450 return authorize(action_prefix + action);
3455 if (menuId.isEmpty() || kde_kiosk_exception)
3466 TQStringList result;
3467 for(TQStringList::ConstIterator it = menuIds.begin();
3468 it != menuIds.end(); ++it)
3476 void TDEApplication::initUrlActionRestrictions()
3478 d->urlActionRestrictions.setAutoDelete(
true);
3479 d->urlActionRestrictions.clear();
3480 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3481 (
"open", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, TQString::null,
true));
3482 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3483 (
"list", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, TQString::null,
true));
3489 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3490 (
"link", TQString::null, TQString::null, TQString::null,
":internet", TQString::null, TQString::null,
true));
3491 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3492 (
"redirect", TQString::null, TQString::null, TQString::null,
":internet", TQString::null, TQString::null,
true));
3496 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3497 (
"redirect", TQString::null, TQString::null, TQString::null,
"file", TQString::null, TQString::null,
true));
3498 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3499 (
"redirect",
":internet", TQString::null, TQString::null,
"file", TQString::null, TQString::null,
false));
3502 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3503 (
"redirect",
":local", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null,
true));
3506 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3507 (
"redirect", TQString::null, TQString::null, TQString::null,
"about", TQString::null, TQString::null,
true));
3510 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3511 (
"redirect", TQString::null, TQString::null, TQString::null,
"=", TQString::null, TQString::null,
true));
3516 TQString keyFormat = TQString(
"rule_%1");
3517 for(
int i = 1; i <= count; i++)
3519 TQString key = keyFormat.arg(i);
3521 if (rule.count() != 8)
3523 TQString action = rule[0];
3524 TQString refProt = rule[1];
3525 TQString refHost = rule[2];
3526 TQString refPath = rule[3];
3527 TQString urlProt = rule[4];
3528 TQString urlHost = rule[5];
3529 TQString urlPath = rule[6];
3530 TQString strEnabled = rule[7].lower();
3532 bool bEnabled = (strEnabled ==
"true");
3534 if (refPath.startsWith(
"$HOME"))
3535 refPath.replace(0, 5, TQDir::homeDirPath());
3536 else if (refPath.startsWith(
"~"))
3537 refPath.replace(0, 1, TQDir::homeDirPath());
3538 if (urlPath.startsWith(
"$HOME"))
3539 urlPath.replace(0, 5, TQDir::homeDirPath());
3540 else if (urlPath.startsWith(
"~"))
3541 urlPath.replace(0, 1, TQDir::homeDirPath());
3543 if (refPath.startsWith(
"$TMP"))
3545 if (urlPath.startsWith(
"$TMP"))
3548 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3549 ( action, refProt, refHost, refPath, urlProt, urlHost, urlPath, bEnabled));
3558 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3568 bool result =
false;
3569 if (d->urlActionRestrictions.isEmpty())
3570 initUrlActionRestrictions();
3572 KURL baseURL(_baseURL);
3573 baseURL.
setPath(TQDir::cleanDirPath(baseURL.
path()));
3574 TQString baseClass = KProtocolInfo::protocolClass(baseURL.
protocol());
3575 KURL destURL(_destURL);
3576 destURL.setPath(TQDir::cleanDirPath(destURL.path()));
3577 TQString destClass = KProtocolInfo::protocolClass(destURL.protocol());
3579 for(TDEApplicationPrivate::URLActionRule *rule = d->urlActionRestrictions.first();
3580 rule; rule = d->urlActionRestrictions.next())
3582 if ((result != rule->permission) &&
3583 (action == rule->action) &&
3584 rule->baseMatch(baseURL, baseClass) &&
3585 rule->destMatch(destURL, destClass, baseURL, baseClass))
3587 result = rule->permission;
3599 int root_x, root_y, win_x, win_y;
3601 XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
3602 &root_x, &root_y, &win_x, &win_y, &keybstate );
3603 return keybstate & 0x00ff;
3604 #elif defined W_WS_MACX
3605 return GetCurrentEventKeyModifiers() & 0x00ff;
3618 int root_x, root_y, win_x, win_y;
3619 XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
3620 &root_x, &root_y, &win_x, &win_y, &mousestate );
3621 #elif defined(Q_WS_WIN)
3622 const bool mousebtn_swapped = GetSystemMetrics(SM_SWAPBUTTON);
3623 if (GetAsyncKeyState(VK_LBUTTON))
3624 mousestate |= (mousebtn_swapped ? Button3Mask : Button1Mask);
3625 if (GetAsyncKeyState(VK_MBUTTON))
3626 mousestate |= Button2Mask;
3627 if (GetAsyncKeyState(VK_RBUTTON))
3628 mousestate |= (mousebtn_swapped ? Button1Mask : Button3Mask);
3629 #elif defined(Q_WS_MACX)
3630 mousestate = GetCurrentEventButtonState();
3634 return mousestate & 0xff00;
3643 int root_x, root_y, win_x, win_y;
3645 XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
3646 &root_x, &root_y, &win_x, &win_y, &state );
3648 if( state & Button1Mask )
3649 ret |= TQ_LeftButton;
3650 if( state & Button2Mask )
3651 ret |= TQ_MidButton;
3652 if( state & Button3Mask )
3653 ret |= TQ_RightButton;
3654 if( state & ShiftMask )
3655 ret |= TQ_ShiftButton;
3656 if( state & ControlMask )
3657 ret |= TQ_ControlButton;
3658 if( state & KKeyNative::modX( KKey::ALT ))
3659 ret |= TQ_AltButton;
3660 if( state & KKeyNative::modX( KKey::WIN ))
3661 ret |= TQ_MetaButton;
3662 #elif defined(Q_WS_WIN)
3663 const bool mousebtn_swapped = GetSystemMetrics(SM_SWAPBUTTON);
3664 if (GetAsyncKeyState(VK_LBUTTON))
3665 ret |= (mousebtn_swapped ? RightButton : LeftButton);
3666 if (GetAsyncKeyState(VK_MBUTTON))
3667 ret |= TQ_MidButton;
3668 if (GetAsyncKeyState(VK_RBUTTON))
3669 ret |= (mousebtn_swapped ? TQ_LeftButton : TQ_RightButton);
3670 if (GetAsyncKeyState(VK_SHIFT))
3671 ret |= TQ_ShiftButton;
3672 if (GetAsyncKeyState(VK_CONTROL))
3673 ret |= TQ_ControlButton;
3674 if (GetAsyncKeyState(VK_MENU))
3675 ret |= TQ_AltButton;
3676 if (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN))
3677 ret |= TQ_MetaButton;
3681 return static_cast< ButtonState
>( ret );
3684 #if defined Q_WS_X11
3687 return get_x_vtnum(TQPaintDevice::x11AppDisplay());
3699 struct sigaction act;
3700 act.sa_handler = SIG_IGN;
3701 sigemptyset( &act.sa_mask );
3703 sigaction( SIGPIPE, &act, 0 );
3707 void TDEApplication::sigpipeHandler(
int)
3709 int saved_errno = errno;
3713 sprintf(msg,
"*** SIGPIPE *** (ignored, pid = %ld)\n", (
long) getpid());
3714 if (write(2, msg, strlen(msg)) < 0) {
3720 errno = saved_errno;
3723 bool TDEApplication::guiEnabled()
3725 return kapp && kapp->d->guiEnabled;
3728 void TDEApplication::virtual_hook(
int id,
void* data )
3729 { TDEInstance::virtual_hook(
id, data ); }
3731 void KSessionManaged::virtual_hook(
int,
void* )
3734 #include "tdeapplication.moc"