23 #ifdef HAVE_XCOMPOSITE
35 #undef TQT_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 TQT_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 <tdestandarddirs.h>
76 #include <kiconloader.h>
77 #include <kclipboard.h>
78 #include <tdeconfig.h>
79 #include <tdesimpleconfig.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 <tdeglobalaccel.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>
126 #if defined TQ_WS_X11
131 #include "tdeprocctrl.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(TQ_WS_QWS)
166 #define DISPLAY "QWS_DISPLAY"
169 #if defined TQ_WS_X11
174 #include <Carbon/Carbon.h>
178 #if defined TQ_WS_X11
179 #include <sys/ioctl.h>
181 #include <linux/vt.h>
184 extern int getfd(
const char *fnam);
188 #include "tdeappdcopinterface.h"
191 TDE_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 =
nullptr;
198 bool TDEApplication::s_dcopClientNeedsPostInit =
false;
201 static Atom atom_DesktopWindow;
202 static Atom atom_NetSupported;
205 #if defined(TQ_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 tdeApp->xioErrhandler( dpy );
231 static int kde_x_errhandler( Display *dpy, XErrorEvent *err )
233 return tdeApp->xErrhandler( dpy, err );
239 static void kde_ice_ioerrorhandler( IceConn conn )
242 tdeApp->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_TDEAppDCOPInterface( 0L ),
330 session_save( false )
332 ,oldXErrorHandler( NULL )
333 ,oldXIOErrorHandler( NULL )
334 #elif defined TQ_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 TQ_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, TQ_SIGNAL( destroyed() ),
this, TQ_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 static_cast<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 = ::tqt_cast<TQLineEdit *>(receiver);
574 TQKeyEvent *kevent =
static_cast<TQKeyEvent*
>(
event);
578 if (t == TQEvent::KeyPress)
589 if (key ==
KKey(TQt::CTRL + TQt::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 = ::tqt_cast<TQTextEdit *>(receiver);
612 TQKeyEvent *kevent =
static_cast<TQKeyEvent*
>(
event);
615 if (t == TQEvent::KeyPress)
627 if( t == TQEvent::Show && receiver->isWidgetType())
629 TQWidget* w =
static_cast<TQWidget*
>( receiver );
630 #if defined TQ_WS_X11
631 if( w->isTopLevel() && !
startupId().isEmpty() && !
static_cast<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, TQ_SIGNAL( timeout()), TQ_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;
654 #if defined TQ_WS_X11
660 return TQApplication::notify(receiver, event);
663 void TDEApplication::checkAppStartedSlot()
665 #if defined TQ_WS_X11
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());
761 d (new TDEApplicationPrivate)
763 aIconPixmap.pm.icon = 0L;
764 aIconPixmap.pm.miniIcon = 0L;
765 read_app_startup_id();
768 useStyles = allowStyles;
787 d (new TDEApplicationPrivate)
789 aIconPixmap.pm.icon = 0L;
790 aIconPixmap.pm.miniIcon = 0L;
791 read_app_startup_id();
794 useStyles = allowStyles;
806 getX11RGBAVisual(dpy), getX11RGBAColormap(dpy) ),
809 aIconPixmap.pm.icon = 0L;
810 aIconPixmap.pm.miniIcon = 0L;
811 read_app_startup_id();
812 useStyles = allowStyles;
822 disable_argb?visual:getX11RGBAVisual(dpy), disable_argb?colormap:getX11RGBAColormap(dpy) ),
825 aIconPixmap.pm.icon = 0L;
826 aIconPixmap.pm.miniIcon = 0L;
827 read_app_startup_id();
828 useStyles = allowStyles;
829 if (disable_argb) argb_visual =
false;
840 visual?visual:getX11RGBAVisual(dpy), colormap?colormap:getX11RGBAColormap(dpy) ),
843 if ((visual) && (colormap))
844 getX11RGBAInformation(dpy);
845 aIconPixmap.pm.icon = 0L;
846 aIconPixmap.pm.miniIcon = 0L;
847 read_app_startup_id();
848 useStyles = allowStyles;
859 visual?visual:getX11RGBAVisual(dpy), colormap?colormap:getX11RGBAColormap(dpy) ),
860 TDEInstance( _instance ), display(0L), d (new TDEApplicationPrivate)
862 if ((visual) && (colormap))
863 getX11RGBAInformation(dpy);
864 aIconPixmap.pm.icon = 0L;
865 aIconPixmap.pm.miniIcon = 0L;
866 read_app_startup_id();
867 useStyles = allowStyles;
884 d (new TDEApplicationPrivate)
886 aIconPixmap.pm.icon = 0L;
887 aIconPixmap.pm.miniIcon = 0L;
888 read_app_startup_id();
891 useStyles = allowStyles;
902 bool allowStyles,
bool GUIenabled ) :
906 d (new TDEApplicationPrivate())
908 aIconPixmap.pm.icon = 0L;
909 aIconPixmap.pm.miniIcon = 0L;
910 read_app_startup_id();
913 useStyles = allowStyles;
915 Q_ASSERT (!rAppName.isEmpty());
919 TDECmdLineArgs::initIgnore(argc, argv, rAppName.data());
926 int TDEApplication::xioErrhandler( Display* dpy )
932 d->oldXIOErrorHandler( dpy );
941 int TDEApplication::xErrhandler( Display* dpy,
void* err_ )
944 XErrorEvent* err =
static_cast< XErrorEvent*
>( err_ );
948 d->oldXErrorHandler( dpy, err );
954 void TDEApplication::iceIOErrorHandler( _IceConn *conn )
959 if ( d->oldIceIOErrorHandler != NULL )
960 (*d->oldIceIOErrorHandler)( conn );
965 class KDETranslator :
public TQTranslator
968 KDETranslator(TQObject *parent) : TQTranslator(parent,
"kdetranslator") {}
969 virtual TQTranslatorMessage findMessage(
const char* context,
970 const char *sourceText,
971 const char* message)
const
973 TQTranslatorMessage res;
974 res.setTranslation(
TDEGlobal::locale()->translateQt(context, sourceText, message));
979 void TDEApplication::init(
bool GUIenabled)
981 d->guiEnabled = GUIenabled;
982 if ((getuid() != geteuid()) ||
983 (getgid() != getegid()) )
987 struct group *man = getgrnam(
"man");
988 if ( !man || man->gr_gid != getegid() ){
989 fprintf(stderr,
"The TDE libraries are not designed to run with suid privileges.\n");
998 TQApplication::setDesktopSettingsAware(
false );
1003 #ifdef TQ_WS_X11 //FIXME(E)
1009 Atom atoms_return[max];
1012 atoms[n] = &kipcCommAtom;
1013 names[n++] = (
char *)
"KIPC_COMM_ATOM";
1015 atoms[n] = &atom_DesktopWindow;
1016 names[n++] = (
char *)
"KDE_DESKTOP_WINDOW";
1018 atoms[n] = &atom_NetSupported;
1019 names[n++] = (
char *)
"_NET_SUPPORTED";
1021 XInternAtoms( tqt_xdisplay(), names, n,
false, atoms_return );
1023 for (
int i = 0; i < n; i++ )
1024 *atoms[i] = atoms_return[i];
1028 dcopAutoRegistration();
1029 dcopClientPostInit();
1034 #if defined TQ_WS_X11
1035 kipcEventMask = (1 << KIPC::StyleChanged) | (1 << KIPC::PaletteChanged) |
1036 (1 << KIPC::FontChanged) | (1 << KIPC::BackgroundChanged) |
1037 (1 << KIPC::ToolbarStyleChanged) | (1 << KIPC::SettingsChanged) |
1045 d->actionRestrictions =
config->
hasGroup(
"KDE Action Restrictions" ) && !kde_kiosk_exception;
1050 TQCString readOnly = getenv(
"TDE_HOME_READONLY");
1051 if (readOnly.isEmpty() && (qstrcmp(
name(),
"kdialog") != 0))
1062 fcntl(ConnectionNumber(tqt_xdisplay()), F_SETFD, FD_CLOEXEC);
1064 d->oldXErrorHandler = XSetErrorHandler( kde_x_errhandler );
1065 d->oldXIOErrorHandler = XSetIOErrorHandler( kde_xio_errhandler );
1068 connect(
this, TQ_SIGNAL( aboutToQuit() ),
this, TQ_SIGNAL(
shutDown() ) );
1070 #ifdef TQ_WS_X11 //FIXME(E)
1071 display = desktop()->x11Display();
1076 TQStringList::Iterator it = plugins.begin();
1077 while (it != plugins.end()) {
1078 addLibraryPath( *it );
1083 tdedisplaySetStyle();
1084 tdedisplaySetFont();
1086 propagateSettings(SETTINGS_QT);
1096 TQMimeSourceFactory* oldDefaultFactory = TQMimeSourceFactory::takeDefaultFactory();
1098 if ( oldDefaultFactory ) {
1099 TQMimeSourceFactory::addFactory( oldDefaultFactory );
1102 d->checkAccelerators =
new KCheckAccelerators(
this );
1109 if (!pixmap.isNull()) {
1110 TQImage i = pixmap.convertToImage().convertDepth(32).smoothScale(40, 40);
1111 for(
int y = 0; y < i.height(); y++) {
1112 uchar *l = i.scanLine(y);
1113 for(
int x = 0; x < i.width(); x+=4)
1116 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
1117 CGDataProviderRef dp = CGDataProviderCreateWithData(NULL,
1118 i.bits(), i.numBytes(), NULL);
1119 CGImageRef ir = CGImageCreate(i.width(), i.height(), 8, 32, i.bytesPerLine(),
1120 cs, kCGImageAlphaNoneSkipFirst, dp,
1121 0, 0, kCGRenderingIntentDefault);
1123 SetApplicationDockTileImage(ir);
1125 CGColorSpaceRelease(cs);
1126 CGDataProviderRelease(dp);
1134 bool rtl = reverseLayout();
1135 installTranslator(
new KDETranslator(
this));
1136 setReverseLayout( rtl );
1137 if (i18n(
"_: Dear Translator! Translate this string to the string 'LTR' in "
1138 "left-to-right languages (as english) or to 'RTL' in right-to-left "
1139 "languages (such as Hebrew and Arabic) to get proper widget layout." ) ==
"RTL")
1140 setReverseLayout( !rtl );
1144 + TQString::fromLatin1(
name()) +
'/');
1145 pSessionConfig = 0L;
1146 bSessionManagement =
true;
1150 if (GUIenabled && kde_have_kipc )
1152 smw =
new TQWidget(0,0);
1154 XChangeProperty(tqt_xdisplay(), smw->winId(),
1155 atom_DesktopWindow, atom_DesktopWindow,
1156 32, PropModeReplace, (
unsigned char *)&data, 1);
1158 d->oldIceIOErrorHandler = IceSetIOErrorHandler( kde_ice_ioerrorhandler );
1159 #elif defined(TQ_WS_WIN)
1160 TDEApplication_init_windows(GUIenabled);
1166 static int my_system (
const char *command) {
1173 const char* shell =
"/bin/sh";
1174 execl(shell, shell,
"-c", command, (
void *)0);
1178 if (waitpid(pid, &status, 0) == -1) {
1190 return s_DCOPClient;
1194 if (args && args->
isSet(
"dcopserver"))
1199 connect(s_DCOPClient, TQ_SIGNAL(attachFailed(
const TQString &)),
1200 tdeApp, TQ_SLOT(dcopFailure(
const TQString &)));
1201 connect(s_DCOPClient, TQ_SIGNAL(blockUserInput(
bool) ),
1202 tdeApp, TQ_SLOT(dcopBlockUserInput(
bool)) );
1205 s_dcopClientNeedsPostInit =
true;
1208 return s_DCOPClient;
1211 void TDEApplication::dcopClientPostInit()
1213 if( s_dcopClientNeedsPostInit )
1215 s_dcopClientNeedsPostInit =
false;
1216 connect(s_DCOPClient, TQ_SIGNAL(blockUserInput(
bool) ),
1217 TQ_SLOT(dcopBlockUserInput(
bool)) );
1218 s_DCOPClient->bindToApp();
1222 void TDEApplication::dcopAutoRegistration()
1224 if (autoDcopRegistration)
1234 autoDcopRegistration =
false;
1240 return pSessionConfig;
1243 pSessionConfig =
new TDEConfig( sessionConfigName(),
false,
false);
1244 return pSessionConfig;
1257 if ( d->refCount <= 0 )
1261 KSessionManaged::KSessionManaged()
1263 sessionClients()->remove(
this );
1264 sessionClients()->append(
this );
1267 KSessionManaged::~KSessionManaged()
1269 sessionClients()->remove(
this );
1284 bSessionManagement =
false;
1288 bSessionManagement =
true;
1299 if( mySmcConnection ) {
1300 SmcRequestSaveYourself( mySmcConnection, SmSaveLocal, False,
1305 IceFlush(SmcGetIceConnection(mySmcConnection));
1315 TQApplication::syncX();
1322 TQDataStream arg(data, IO_WriteOnly);
1323 arg << (int)confirm << (
int)sdtype << (int)sdmode;
1325 "logout(int,int,int)", data );
1328 if ( mySmcConnection ) {
1330 SmcRequestSaveYourself( mySmcConnection, SmSaveBoth, True,
1335 IceFlush(SmcGetIceConnection(mySmcConnection));
1342 TQCString smEnv = ::getenv(
"SESSION_MANAGER");
1343 if (smEnv.isEmpty())
1346 if (! tmpSmcConnection) {
1351 tmpSmcConnection = SmcOpenConnection( 0, 0, 1, 0,
1358 if (!tmpSmcConnection )
1362 SmcRequestSaveYourself( tmpSmcConnection, SmSaveBoth, True,
1363 SmInteractStyleAny, False, True );
1366 IceFlush(SmcGetIceConnection(tmpSmcConnection));
1377 TQCString fName = TQFile::encodeName(locateLocal(
"socket",
"KSMserver"));
1378 TQCString display = ::getenv(DISPLAY);
1380 display.replace(TQRegExp(
"\\.[0-9]+$"),
"");
1382 while( (i = display.find(
':')) >= 0)
1385 fName +=
"_"+display;
1386 TQCString smEnv = ::getenv(
"SESSION_MANAGER");
1387 bool check = smEnv.isEmpty();
1388 if ( !check && smModificationTime ) {
1389 TQFileInfo info( fName );
1390 TQTime current = info.lastModified().time();
1391 check = current > *smModificationTime;
1394 delete smModificationTime;
1396 if ( !f.open( IO_ReadOnly ) )
1398 TQFileInfo info ( f );
1399 smModificationTime =
new TQTime( info.lastModified().time() );
1401 t.setEncoding( TQTextStream::Latin1 );
1402 TQString s = t.readLine();
1404 ::setenv(
"SESSION_MANAGER", s.latin1(),
true );
1411 d->session_save =
true;
1412 bool canceled =
false;
1415 it = sessionClients()->next() ) {
1416 canceled = !it->commitData( sm );
1421 if ( sm.allowsInteraction() ) {
1423 TQWidgetList *list = TQApplication::topLevelWidgets();
1424 bool canceled =
false;
1425 TQWidget* w = list->first();
1426 while ( !canceled && w ) {
1427 if ( !w->testWState( WState_ForceHide ) && !w->inherits(
"TDEMainWindow") ) {
1430 canceled = !e.isAccepted();
1434 list = TQApplication::topLevelWidgets();
1439 while ( w && done.containsRef( w ) )
1446 if ( !bSessionManagement )
1447 sm.setRestartHint( TQSessionManager::RestartNever );
1449 sm.setRestartHint( TQSessionManager::RestartIfRunning );
1450 d->session_save =
false;
1453 static void checkRestartVersion( TQSessionManager& sm )
1455 Display* dpy = tqt_xdisplay();
1458 unsigned long nitems, after;
1459 unsigned char* data;
1460 if( XGetWindowProperty( dpy, RootWindow( dpy, 0 ), XInternAtom( dpy,
"TDE_FULL_SESSION", False ),
1461 0, 1, False, AnyPropertyType, &type, &format, &nitems, &after, &data ) == Success ) {
1464 if( type == XA_STRING && format == 8 ) {
1465 if( XGetWindowProperty( dpy, RootWindow( dpy, 0 ), XInternAtom( dpy,
"TDE_SESSION_VERSION", False ),
1466 0, 1, False, AnyPropertyType, &type, &format, &nitems, &after, &data ) == Success ) {
1477 TQStringList restartCommand = sm.restartCommand();
1478 restartCommand.prepend( wrapper );
1479 sm.setRestartCommand( restartCommand );
1484 d->session_save =
true;
1486 static bool firstTime =
true;
1487 mySmcConnection = (SmcConn) sm.handle();
1489 if ( !bSessionManagement ) {
1490 sm.setRestartHint( TQSessionManager::RestartNever );
1491 d->session_save =
false;
1495 sm.setRestartHint( TQSessionManager::RestartIfRunning );
1499 d->session_save =
false;
1509 if ( pSessionConfig ) {
1510 delete pSessionConfig;
1515 TQStringList restartCommand = sm.restartCommand();
1517 TQCString multiHead = getenv(
"TDE_MULTIHEAD");
1518 if (multiHead.lower() ==
"true") {
1525 TQCString displayname = getenv(DISPLAY);
1526 if (! displayname.isNull()) {
1529 restartCommand.append(
"-display");
1530 restartCommand.append(displayname);
1532 sm.setRestartCommand( restartCommand );
1535 checkRestartVersion( sm );
1539 bool canceled =
false;
1542 it = sessionClients()->next() ) {
1543 canceled = !it->saveState( sm );
1547 if ( pSessionConfig ) {
1548 pSessionConfig->
sync();
1549 TQStringList discard;
1550 discard <<
"rm" << locateLocal(
"config", sessionConfigName());
1551 sm.setDiscardCommand( discard );
1553 sm.setDiscardCommand( TQStringList(
"") );
1561 d->session_save =
false;
1566 return d->session_save;
1569 void TDEApplication::startKdeinit()
1571 #ifndef TQ_WS_WIN //TODO
1573 TDELockFile lock( locateLocal(
"tmp",
"starttdeinitlock", &inst ));
1586 if (tdeApp && (Tty != tdeApp->type()))
1587 setOverrideCursor( TQt::waitCursor );
1588 my_system(TQFile::encodeName(srv)+
" --suicide"+
" --new-startup");
1589 if (tdeApp && (Tty != tdeApp->type()))
1590 restoreOverrideCursor();
1594 void TDEApplication::dcopFailure(
const TQString &msg)
1596 static int failureCount = 0;
1598 if (failureCount == 1)
1603 if (failureCount == 2)
1610 TQString msgStr(i18n(
"There was an error setting up inter-process "
1611 "communications for TDE. The message returned "
1612 "by the system was:\n\n"));
1614 msgStr += i18n(
"\n\nPlease check that the \"dcopserver\" program is running!");
1616 if (Tty != tdeApp->type())
1618 TQMessageBox::critical
1620 tdeApp->mainWidget(),
1621 i18n(
"DCOP communications error (%1)").arg(tdeApp->caption()),
1628 fprintf(stderr,
"%s\n", msgStr.local8Bit().data());
1639 {
"display <displayname>",
I18N_NOOP(
"Use the X-server display 'displayname'"), 0},
1641 {
"display <displayname>",
I18N_NOOP(
"Use the QWS display 'displayname'"), 0},
1643 {
"session <sessionId>",
I18N_NOOP(
"Restore the application for the given 'sessionId'"), 0},
1644 {
"cmap",
I18N_NOOP(
"Causes the application to install a private color\nmap on an 8-bit display"), 0},
1645 {
"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},
1646 {
"nograb",
I18N_NOOP(
"tells TQt to never grab the mouse or the keyboard"), 0},
1647 {
"dograb",
I18N_NOOP(
"running under a debugger can cause an implicit\n-nograb, use -dograb to override"), 0},
1648 {
"sync",
I18N_NOOP(
"switches to synchronous mode for debugging"), 0},
1650 {
"font <fontname>",
I18N_NOOP(
"defines the application font"), 0},
1652 {
"background <color>",
I18N_NOOP(
"sets the default background color and an\napplication palette (light and dark shades are\ncalculated)"), 0},
1654 {
"foreground <color>",
I18N_NOOP(
"sets the default foreground color"), 0},
1656 {
"button <color>",
I18N_NOOP(
"sets the default button color"), 0},
1657 {
"name <name>",
I18N_NOOP(
"sets the application name"), 0},
1658 {
"title <title>",
I18N_NOOP(
"sets the application title (caption)"), 0},
1660 {
"visual TrueColor",
I18N_NOOP(
"forces the application to use a TrueColor visual on\nan 8-bit display"), 0},
1661 {
"inputstyle <inputstyle>",
I18N_NOOP(
"sets XIM (X Input Method) input style. Possible\nvalues are onthespot, overthespot, offthespot and\nroot"), 0 },
1662 {
"im <XIM server>",
I18N_NOOP(
"set XIM server"),0},
1663 {
"noxim",
I18N_NOOP(
"disable XIM"), 0 },
1666 {
"qws",
I18N_NOOP(
"forces the application to run as QWS Server"), 0},
1668 {
"reverse",
I18N_NOOP(
"mirrors the whole layout of widgets"), 0},
1669 TDECmdLineLastOption
1674 {
"caption <caption>",
I18N_NOOP(
"Use 'caption' as name in the titlebar"), 0},
1675 {
"icon <icon>",
I18N_NOOP(
"Use 'icon' as the application icon"), 0},
1676 {
"miniicon <icon>",
I18N_NOOP(
"Use 'icon' as the icon in the titlebar"), 0},
1677 {
"config <filename>",
I18N_NOOP(
"Use alternative configuration file"), 0},
1678 {
"dcopserver <server>",
I18N_NOOP(
"Use the DCOP Server specified by 'server'"), 0},
1679 {
"nocrashhandler",
I18N_NOOP(
"Disable crash handler, to get core dumps"), 0},
1680 {
"waitforwm",
I18N_NOOP(
"Waits for a WM_NET compatible windowmanager"), 0},
1681 {
"style <style>",
I18N_NOOP(
"sets the application GUI style"), 0},
1682 {
"geometry <geometry>",
I18N_NOOP(
"sets the client geometry of the main widget - see man X for the argument format"), 0},
1683 {
"smkey <sessionKey>", 0, 0},
1686 TDECmdLineLastOption
1696 void TDEApplication::parseCommandLine( )
1700 if ( !args )
return;
1702 if (args->
isSet(
"config"))
1708 if (args->
isSet(
"style"))
1712 TQStringList::Iterator itp = plugins.begin();
1713 while (itp != plugins.end()) {
1714 addLibraryPath( *itp );
1718 TQStringList styles = TQStyleFactory::keys();
1719 TQString reqStyle(args->
getOption(
"style").lower());
1721 TQStringList list = libraryPaths();
1722 TQStringList::Iterator it = list.begin();
1723 while( it != list.end() ) {
1727 for (TQStringList::ConstIterator it = styles.begin(); it != styles.end(); ++it) {
1728 if ((*it).lower() == reqStyle)
1730 d->overrideStyle = *it;
1735 if (d->overrideStyle.isEmpty())
1736 fprintf(stderr,
"%s", TQString(i18n(
"The style %1 was not found\n").arg(reqStyle)).local8Bit().data());
1739 if (args->
isSet(
"caption"))
1741 aCaption = TQString::fromLocal8Bit(args->
getOption(
"caption"));
1744 if (args->
isSet(
"miniicon"))
1746 const char *tmp = args->
getOption(
"miniicon");
1747 if (!aIconPixmap.pm.miniIcon) {
1748 aIconPixmap.pm.miniIcon =
new TQPixmap;
1750 *aIconPixmap.pm.miniIcon = SmallIcon(tmp);
1751 aMiniIconName = tmp;
1754 if (args->
isSet(
"icon"))
1756 const char *tmp = args->
getOption(
"icon");
1757 if (!aIconPixmap.pm.icon) {
1758 aIconPixmap.pm.icon =
new TQPixmap;
1760 *aIconPixmap.pm.icon = DesktopIcon( tmp );
1762 if (!aIconPixmap.pm.miniIcon) {
1763 aIconPixmap.pm.miniIcon =
new TQPixmap;
1765 if (aIconPixmap.pm.miniIcon->isNull())
1767 *aIconPixmap.pm.miniIcon = SmallIcon( tmp );
1768 aMiniIconName = tmp;
1772 bool nocrashhandler = (getenv(
"TDE_DEBUG") != NULL);
1773 if (!nocrashhandler && args->
isSet(
"crashhandler"))
1783 if ( args->
isSet(
"waitforwm" ) ) {
1787 unsigned long length, after;
1788 unsigned char *data;
1789 while ( XGetWindowProperty( tqt_xdisplay(), tqt_xrootwin(), atom_NetSupported,
1790 0, 1,
false, AnyPropertyType, &type, &format,
1791 &length, &after, &data ) != Success || !length ) {
1795 XWindowEvent( tqt_xdisplay(), tqt_xrootwin(), PropertyChangeMask, &event );
1804 if (args->
isSet(
"geometry"))
1806 d->geometry_arg = args->
getOption(
"geometry");
1809 if (args->
isSet(
"smkey"))
1811 d->sessionKey = args->
getOption(
"smkey");
1818 return d->geometry_arg;
1821 TQPixmap TDEApplication::icon()
const
1823 if( !aIconPixmap.pm.icon) {
1824 aIconPixmap.pm.icon =
new TQPixmap;
1826 if( aIconPixmap.pm.icon->isNull()) {
1829 return *aIconPixmap.pm.icon;
1834 return aIconName.isNull() ? (TQString)
instanceName() : aIconName;
1837 TQPixmap TDEApplication::miniIcon()
const
1839 if (!aIconPixmap.pm.miniIcon) {
1840 aIconPixmap.pm.miniIcon =
new TQPixmap;
1842 if (aIconPixmap.pm.miniIcon->isNull()) {
1843 *aIconPixmap.pm.miniIcon = SmallIcon(
instanceName() );
1845 return *aIconPixmap.pm.miniIcon;
1850 return aMiniIconName.isNull() ? (TQString)
instanceName() : aMiniIconName;
1853 extern void kDebugCleanup();
1855 TDEApplication::~TDEApplication()
1857 delete aIconPixmap.pm.miniIcon;
1858 aIconPixmap.pm.miniIcon = 0L;
1859 delete aIconPixmap.pm.icon;
1860 aIconPixmap.pm.icon = 0L;
1861 delete d->m_TDEAppDCOPInterface;
1867 KLibLoader::cleanUp();
1872 delete s_DCOPClient;
1873 s_DCOPClient =
nullptr;
1878 if ( d->oldXErrorHandler != NULL )
1879 XSetErrorHandler( d->oldXErrorHandler );
1880 if ( d->oldXIOErrorHandler != NULL )
1881 XSetIOErrorHandler( d->oldXIOErrorHandler );
1882 if ( d->oldIceIOErrorHandler != NULL )
1883 IceSetIOErrorHandler( d->oldIceIOErrorHandler );
1890 mySmcConnection = 0;
1891 delete smModificationTime;
1892 smModificationTime = 0;
1895 if (tmpSmcConnection) {
1896 SmcCloseConnection( tmpSmcConnection, 0, 0 );
1897 tmpSmcConnection = 0;
1906 class KAppX11HackWidget:
public TQWidget
1909 bool publicx11Event( XEvent * e) {
return x11Event( e ); }
1913 #if defined(TQ_WS_X11) && defined(COMPOSITE)
1915 bool have_manager =
false;
1918 const char *pidfile =
"compton-tde.available";
1919 char uidstr[
sizeof(uid_t)*8+1];
1920 sprintf(uidstr,
"%d", getuid());
1921 int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
1922 filename = (
char*)malloc(n*
sizeof(
char)+1);
1923 memset(filename,0,n);
1924 strcat(filename, P_tmpdir);
1925 strcat(filename,
"/.");
1926 strcat(filename, uidstr);
1927 strcat(filename,
"-");
1928 strcat(filename, pidfile);
1932 pFile = fopen(filename,
"r");
1934 have_manager =
true;
1941 return have_manager;
1945 bool compositing_manager_available;
1946 if (force_available) {
1947 compositing_manager_available = available;
1952 char *displayname = 0;
1953 if ( qtargs->
isSet(
"display"))
1954 displayname = qtargs->
getOption(
"display" ).data();
1956 Display *dpy = XOpenDisplay( displayname );
1958 x11_composite_error_generated =
false;
1959 compositing_manager_available =
false;
1960 XSetErrorHandler(x11_error);
1961 if (!XQueryExtension (dpy, COMPOSITE_NAME, &composite_opcode, &composite_event, &composite_error)) {
1962 XSetErrorHandler(NULL);
1963 compositing_manager_available =
false;
1967 Window root_window = XDefaultRootWindow(dpy);
1968 XCompositeRedirectSubwindows(dpy, root_window, CompositeRedirectManual);
1970 if (x11_composite_error_generated ==
true) {
1971 compositing_manager_available =
true;
1974 XCompositeUnredirectSubwindows(dpy, root_window, CompositeRedirectManual);
1975 compositing_manager_available =
false;
1977 XSetErrorHandler(NULL);
1981 compositing_manager_available =
true;
1987 const char *pidfile =
"compton-tde.available";
1988 char uidstr[
sizeof(uid_t)*8+1];
1989 sprintf(uidstr,
"%d", getuid());
1990 int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
1991 filename = (
char*)malloc(n*
sizeof(
char)+1);
1992 memset(filename,0,n);
1993 strcat(filename, P_tmpdir);
1994 strcat(filename,
"/.");
1995 strcat(filename, uidstr);
1996 strcat(filename,
"-");
1997 strcat(filename, pidfile);
2000 if (compositing_manager_available) {
2003 sprintf(buffer,
"available");
2004 pFile = fopen(filename,
"w");
2006 fwrite(buffer,1,strlen(buffer), pFile);
2017 return compositing_manager_available;
2020 Display* TDEApplication::openX11RGBADisplay() {
2023 if ( qtargs->
isSet(
"display"))
2024 display = qtargs->
getOption(
"display" ).data();
2026 Display *dpy = XOpenDisplay( display );
2028 kdError() <<
"cannot connect to X server " << display <<
endl;
2036 getX11RGBAInformation(dpy);
2038 return argb_x11_visual;
2041 return (TQt::HANDLE)NULL;
2046 getX11RGBAInformation(dpy);
2048 return argb_x11_colormap;
2051 return (TQt::HANDLE)NULL;
2059 void TDEApplication::getX11RGBAInformation(Display *dpy) {
2061 argb_visual =
false;
2065 int screen = DefaultScreen( dpy );
2066 Colormap colormap = 0;
2068 int event_base, error_base;
2070 if ( XRenderQueryExtension( dpy, &event_base, &error_base ) ) {
2073 templ.screen = screen;
2075 templ.c_class = TrueColor;
2076 XVisualInfo *xvi = XGetVisualInfo( dpy, VisualScreenMask | VisualDepthMask
2077 | VisualClassMask, &templ, &nvi );
2079 for (
int i = 0; i < nvi; i++ ) {
2080 XRenderPictFormat *format = XRenderFindVisualFormat( dpy, xvi[i].visual );
2081 if ( format->type == PictTypeDirect && format->direct.alphaMask ) {
2082 visual = xvi[i].visual;
2083 colormap = XCreateColormap( dpy, RootWindow( dpy, screen ), visual, AllocNone );
2084 kdDebug() <<
"[tdecore-tdeapplication] Found visual with alpha support" <<
endl;
2092 argb_x11_visual = TQt::HANDLE( visual );
2093 argb_x11_colormap = TQt::HANDLE( colormap );
2097 argb_visual =
false;
2101 void TDEApplication::getX11RGBAInformation(Display *dpy) {
2110 const char *pidfile =
"compton-tde.available";
2111 char uidstr[
sizeof(uid_t)*8+1];
2112 sprintf(uidstr,
"%d", getuid());
2113 int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
2114 filename = (
char*)malloc(n*
sizeof(
char)+1);
2115 memset(filename,0,n);
2116 strcat(filename, P_tmpdir);
2117 strcat(filename,
"/.");
2118 strcat(filename, uidstr);
2119 strcat(filename,
"-");
2120 strcat(filename, pidfile);
2123 if (force_available) {
2126 sprintf(buffer,
"available");
2127 pFile = fopen(filename,
"w");
2129 fwrite(buffer,1,strlen(buffer), pFile);
2143 Display* TDEApplication::openX11RGBADisplay() {
2160 static bool kapp_block_user_input =
false;
2162 void TDEApplication::dcopBlockUserInput(
bool b )
2164 kapp_block_user_input = b;
2168 bool TDEApplication::x11EventFilter( XEvent *_event )
2170 if ( kapp_block_user_input ) {
2171 switch ( _event->type ) {
2186 for (TQWidget *w=x11Filter->first(); w; w=x11Filter->next()) {
2187 if (((KAppX11HackWidget*) w)->publicx11Event(_event))
2192 if ((_event->type == ClientMessage) &&
2193 (_event->xclient.message_type == kipcCommAtom))
2195 XClientMessageEvent *cme = (XClientMessageEvent *) _event;
2197 int id = cme->data.l[0];
2198 int arg = cme->data.l[1];
2199 if ((
id < 32) && (kipcEventMask & (1 << id)))
2203 case KIPC::StyleChanged:
2205 tdedisplaySetStyle();
2208 case KIPC::ToolbarStyleChanged:
2214 case KIPC::PaletteChanged:
2216 tdedisplaySetPalette();
2219 case KIPC::FontChanged:
2221 TDEGlobalSettings::rereadFontSettings();
2222 tdedisplaySetFont();
2225 case KIPC::BackgroundChanged:
2229 case KIPC::SettingsChanged:
2231 if (arg == SETTINGS_PATHS)
2232 TDEGlobalSettings::rereadPathSettings();
2233 else if (arg == SETTINGS_MOUSE)
2234 TDEGlobalSettings::rereadMouseSettings();
2238 case KIPC::IconChanged:
2239 TQPixmapCache::clear();
2242 emit updateIconLoaders();
2246 case KIPC::ClipboardConfigChanged:
2247 TDEClipboardSynchronizer::newConfiguration(arg);
2251 TDEGlobalAccel::blockShortcuts(arg);
2268 #if defined TQ_WS_X11
2269 Display *display = tqt_xdisplay();
2275 Window w = XCreateSimpleWindow( display, tqt_xrootwin(), 0, 0, 1, 1, 0, 0, 0 );
2276 XSelectInput( tqt_xdisplay(), w, PropertyChangeMask );
2277 unsigned char data[ 1 ];
2278 XChangeProperty( display, w, XA_ATOM, XA_ATOM, 8, PropModeAppend, data, 1 );
2280 XWindowEvent( display, w, PropertyChangeMask, &ev );
2281 time = ev.xproperty.time;
2282 XDestroyWindow( display, w );
2284 if( get_tqt_x_user_time() == 0
2286 set_tqt_x_user_time(time);
2292 #if defined TQ_WS_X11
2293 return get_tqt_x_user_time();
2301 #if defined TQ_WS_X11
2303 time = get_tqt_x_user_time();
2304 DCOPRef( dcopId,
"MainApplication-Interface" ).
call(
"updateUserTimestamp", time );
2310 TQObject *
object = focusWidget();
2314 TQMetaObject *meta =
object->metaObject();
2316 int idx = meta->findSlot( slot + 1,
true );
2320 object->tqt_invoke( idx, 0 );
2327 kdDebug(101) <<
"[tdecore-tdeapplication] Cannot use KIPC event mask for message IDs >= 32\n";
2330 kipcEventMask |= (1 << id);
2337 kdDebug(101) <<
"[tdecore-tdeapplication] Cannot use KIPC event mask for message IDs >= 32\n";
2340 kipcEventMask &= ~(1 << id);
2357 void TDEApplication::applyGUIStyle()
2359 if ( !useStyles )
return;
2362 TQString defaultStyle = TDEStyle::defaultStyle();
2363 TQString styleStr = pConfig.readEntry(
"widgetStyle", defaultStyle);
2365 if (d->overrideStyle.isEmpty()) {
2369 TQStyle* sp = TQStyleFactory::create( styleStr );
2372 if ( !sp && styleStr != defaultStyle)
2373 sp = TQStyleFactory::create( defaultStyle );
2375 sp = TQStyleFactory::create( *(TQStyleFactory::keys().begin()) );
2379 setStyle(d->overrideStyle);
2381 tdedisplaySetPalette();
2387 if( !aCaption.isNull() )
2404 bool withAppName,
bool modified )
const
2406 TQString s = userCaption.isEmpty() ?
caption() : userCaption;
2410 s += TQString::fromUtf8(
" [") + i18n(
"modified") + TQString::fromUtf8(
"]");
2412 if ( !userCaption.isEmpty() ) {
2415 if ( withAppName && !
caption().isNull() && !userCaption.endsWith(
caption()) )
2416 s += TQString::fromUtf8(
" - ") +
caption();
2431 TQColor trinity4Background( 239, 239, 239 );
2432 TQColor trinity4Blue( 103,141,178 );
2434 TQColor trinity4Button;
2435 if ( TQPixmap::defaultDepth() > 8 )
2436 trinity4Button.setRgb( 221, 223, 228 );
2438 trinity4Button.setRgb( 220, 220, 220 );
2440 TQColor trinity4Link( 0, 0, 238 );
2441 TQColor trinity4VisitedLink( 82, 24, 139 );
2454 int highlightVal, lowlightVal;
2455 highlightVal = 100 + (2*contrast_+4)*16/10;
2456 lowlightVal = 100 + (2*contrast_+4)*10;
2458 TQColor disfg = foreground;
2461 disfg.hsv( &h, &s, &v );
2464 disfg = disfg.dark(lowlightVal);
2465 else if (disfg != TQt::black)
2467 disfg = disfg.light(highlightVal);
2470 disfg = TQt::darkGray;
2473 TQColorGroup disabledgrp(disfg, background,
2474 background.light(highlightVal),
2475 background.dark(lowlightVal),
2476 background.dark(120),
2477 background.dark(120), base);
2479 TQColorGroup colgrp(foreground, background, background.light(highlightVal),
2480 background.dark(lowlightVal),
2481 background.dark(120),
2484 int inlowlightVal = lowlightVal-25;
2485 if(inlowlightVal < 120)
2486 inlowlightVal = 120;
2488 colgrp.setColor(TQColorGroup::Highlight, highlight);
2489 colgrp.setColor(TQColorGroup::HighlightedText, highlightedText);
2490 colgrp.setColor(TQColorGroup::Button, button);
2491 colgrp.setColor(TQColorGroup::ButtonText, buttonText);
2492 colgrp.setColor(TQColorGroup::Midlight, background.light(110));
2493 colgrp.setColor(TQColorGroup::Link, link);
2494 colgrp.setColor(TQColorGroup::LinkVisited, visitedLink);
2496 disabledgrp.setColor(TQColorGroup::Button, button);
2498 TQColor disbtntext = buttonText;
2499 disbtntext.hsv( &h, &s, &v );
2502 disbtntext = disbtntext.dark(lowlightVal);
2503 else if (disbtntext != TQt::black)
2505 disbtntext = disbtntext.light(highlightVal);
2508 disbtntext = TQt::darkGray;
2510 disabledgrp.setColor(TQColorGroup::ButtonText, disbtntext);
2511 disabledgrp.setColor(TQColorGroup::Midlight, background.light(110));
2512 disabledgrp.setColor(TQColorGroup::Highlight, highlight.dark(120));
2513 disabledgrp.setColor(TQColorGroup::Link, link);
2514 disabledgrp.setColor(TQColorGroup::LinkVisited, visitedLink);
2516 return TQPalette(colgrp, disabledgrp, colgrp);
2520 void TDEApplication::tdedisplaySetPalette()
2527 bool do_not_set_palette =
false;
2538 void TDEApplication::tdedisplaySetFont()
2546 TQStyleSheet* sheet = TQStyleSheet::defaultSheet();
2556 void TDEApplication::tdedisplaySetStyle()
2567 void TDEApplication::propagateSettings(SettingsCategory arg)
2572 #ifdef QT_HAVE_MAX_IMAGE_SIZE
2573 TQSize maxImageSize(4096, 4096);
2575 TQImage::setMaxImageSize(maxImageSize);
2579 if ((num != 0) && (num < 200))
2583 TQApplication::setCursorFlashTime(num);
2584 num =
config->
readNumEntry(
"DoubleClickInterval", TQApplication::doubleClickInterval());
2585 TQApplication::setDoubleClickInterval(num);
2587 TQApplication::setStartDragTime(num);
2589 TQApplication::setStartDragDistance(num);
2591 TQApplication::setWheelScrollLines(num);
2594 TQApplication::setEffectEnabled( TQt::UI_AnimateMenu, b);
2596 TQApplication::setEffectEnabled( TQt::UI_FadeMenu, b);
2598 TQApplication::setEffectEnabled( TQt::UI_AnimateCombo, b);
2600 TQApplication::setEffectEnabled( TQt::UI_AnimateTooltip, b);
2602 TQApplication::setEffectEnabled( TQt::UI_FadeTooltip, b);
2604 TQToolTip::setGloballyEnabled( b );
2612 static bool installed =
false;
2613 if (installed)
return;
2622 TQSqlPropertyMap *kdeMap =
new TQSqlPropertyMap;
2623 kdeMap->insert(
"KColorButton",
"color" );
2624 kdeMap->insert(
"KComboBox",
"currentItem" );
2625 kdeMap->insert(
"KDatePicker",
"date" );
2626 kdeMap->insert(
"KDateWidget",
"date" );
2627 kdeMap->insert(
"KDateTimeWidget",
"dateTime" );
2628 kdeMap->insert(
"KEditListBox",
"items" );
2629 kdeMap->insert(
"TDEFontCombo",
"family" );
2630 kdeMap->insert(
"TDEFontRequester",
"font" );
2631 kdeMap->insert(
"TDEFontChooser",
"font" );
2632 kdeMap->insert(
"KHistoryCombo",
"currentItem" );
2633 kdeMap->insert(
"TDEListBox",
"currentItem" );
2634 kdeMap->insert(
"KLineEdit",
"text" );
2635 kdeMap->insert(
"KRestrictedLine",
"text" );
2636 kdeMap->insert(
"KSqueezedTextLabel",
"text" );
2637 kdeMap->insert(
"KTextBrowser",
"source" );
2638 kdeMap->insert(
"KTextEdit",
"text" );
2639 kdeMap->insert(
"KURLRequester",
"url" );
2640 kdeMap->insert(
"KPasswordEdit",
"password" );
2641 kdeMap->insert(
"KIntNumInput",
"value" );
2642 kdeMap->insert(
"KIntSpinBox",
"value" );
2643 kdeMap->insert(
"KDoubleNumInput",
"value" );
2645 kdeMap->insert(
"TQGroupBox",
"checked" );
2646 kdeMap->insert(
"TQTabWidget",
"currentPage" );
2647 TQSqlPropertyMap::installDefaultMap( kdeMap );
2652 const TQString& _appname)
const
2661 const TQString& _appname,
2662 const TQCString& startup_id )
const
2666 if (_appname.isEmpty())
2671 if (!anchor.isEmpty())
2672 url = TQString(
"help:/%1?anchor=%2").arg(appname).arg(anchor);
2674 url = TQString(
"help:/%1/index.html").arg(appname);
2677 if ( !
dcopClient()->isApplicationRegistered(
"khelpcenter") )
2681 if (Tty != tdeApp->type())
2682 TQMessageBox::critical(tdeApp->mainWidget(), i18n(
"Could not Launch Help Center"),
2683 i18n(
"Could not launch the TDE Help Center:\n\n%1").arg(error), i18n(
"&OK"));
2685 kdWarning() <<
"Could not launch help:\n" << error <<
endl;
2690 DCOPRef(
"khelpcenter",
"KHelpCenterIface" ).
send(
"openUrl", url, startup_id );
2696 kdWarning() <<
"invoking HTML help is deprecated! use docbook and invokeHelp!\n";
2700 if( _filename.isEmpty() )
2701 filename = TQString(name()) +
"/index.html";
2703 filename = _filename;
2706 if (!topic.isEmpty())
2707 url = TQString(
"help:/%1#%2").arg(filename).arg(topic);
2709 url = TQString(
"help:/%1").arg(filename);
2712 if ( !
dcopClient()->isApplicationRegistered(
"khelpcenter") )
2716 if (Tty != tdeApp->type())
2717 TQMessageBox::critical(tdeApp->mainWidget(), i18n(
"Could not Launch Help Center"),
2718 i18n(
"Could not launch the TDE Help Center:\n\n%1").arg(error), i18n(
"&OK"));
2720 kdWarning() <<
"Could not launch help:\n" << error <<
endl;
2725 DCOPRef(
"khelpcenter",
"KHelpCenterIface" ).
send(
"openUrl", url );
2736 invokeMailer(address, TQString::null, TQString::null, subject, TQString::null, TQString::null,
2737 TQStringList(), startup_id );
2753 TQStringList queries = TQStringList::split(
'&', mailtoURL.
query().mid(1));
2754 TQStringList attachURLs;
2755 for (TQStringList::Iterator it = queries.begin(); it != queries.end(); ++it)
2757 TQString q = (*it).lower();
2758 if (q.startsWith(
"subject="))
2761 if (q.startsWith(
"cc="))
2764 if (q.startsWith(
"bcc="))
2767 if (q.startsWith(
"body="))
2770 if (allowAttachments && q.startsWith(
"attach="))
2773 if (allowAttachments && q.startsWith(
"attachment="))
2776 if (q.startsWith(
"to="))
2780 invokeMailer( address, cc, bcc, subject, body, TQString::null, attachURLs, startup_id );
2784 const TQString &subject,
const TQString &body,
2785 const TQString & messageFile,
const TQStringList &attachURLs)
2787 return invokeMailer(to,cc,bcc,subject,body,messageFile,attachURLs,
"");
2794 static TQStringList splitEmailAddressList(
const TQString & aStr )
2812 int commentlevel = 0;
2813 bool insidequote =
false;
2815 for (uint index=0; index<aStr.length(); index++) {
2818 switch (aStr[index].latin1()) {
2820 if (commentlevel == 0)
2821 insidequote = !insidequote;
2829 if (commentlevel > 0)
2842 if (!insidequote && (commentlevel == 0)) {
2843 addr = aStr.mid(addrstart, index-addrstart);
2844 if (!addr.isEmpty())
2845 list += addr.simplifyWhiteSpace();
2846 addrstart = index+1;
2852 if (!insidequote && (commentlevel == 0)) {
2853 addr = aStr.mid(addrstart, aStr.length()-addrstart);
2854 if (!addr.isEmpty())
2855 list += addr.simplifyWhiteSpace();
2866 const TQString &subject,
const TQString &body,
2867 const TQString & ,
const TQStringList &attachURLs,
2868 const TQCString& startup_id )
2878 TQString to, cc, bcc;
2879 if (command.isEmpty() || command == TQString::fromLatin1(
"kmail")
2880 || command.endsWith(
"/kmail"))
2882 command = TQString::fromLatin1(
"kmail --composer -s %s -c %c -b %b --body %B --attach %A -- %t");
2883 if ( !_to.isEmpty() )
2887 to = TQString(
"=?utf8?b?%1?=" )
2890 if ( !_cc.isEmpty() )
2891 cc = TQString(
"=?utf8?b?%1?=" )
2893 if ( !_bcc.isEmpty() )
2894 bcc = TQString(
"=?utf8?b?%1?=" )
2900 if( !command.contains(
'%' ))
2907 TQString preferredTerminal = confGroup.readPathEntry(
"TerminalApplication",
"konsole");
2908 command = preferredTerminal +
" -e " + command;
2912 TQString cmd = cmdTokens[0];
2913 cmdTokens.remove(cmdTokens.begin());
2919 TQStringList tos = splitEmailAddressList( to );
2921 tos.remove( tos.begin() );
2922 for (TQStringList::ConstIterator it = tos.begin(); it != tos.end(); ++it)
2925 const TQStringList ccs = splitEmailAddressList( cc );
2926 for (TQStringList::ConstIterator it = ccs.begin(); it != ccs.end(); ++it)
2928 const TQStringList bccs = splitEmailAddressList( bcc );
2929 for (TQStringList::ConstIterator it = bccs.begin(); it != bccs.end(); ++it)
2931 for (TQStringList::ConstIterator it = attachURLs.begin(); it != attachURLs.end(); ++it)
2933 if (!subject.isEmpty())
2935 if (!body.isEmpty())
2938 if ( ! (to.isEmpty() && qry.isEmpty()) )
2941 TQMap<TQChar, TQString> keyMap;
2942 keyMap.insert(
't', to);
2943 keyMap.insert(
's', subject);
2944 keyMap.insert(
'c', cc);
2945 keyMap.insert(
'b', bcc);
2946 keyMap.insert(
'B', body);
2947 keyMap.insert(
'u', url.
url());
2949 TQString attachlist = attachURLs.join(
",");
2950 attachlist.prepend(
'\'');
2951 attachlist.append(
'\'');
2952 keyMap.insert(
'A', attachlist);
2954 for (TQStringList::Iterator it = cmdTokens.begin(); it != cmdTokens.end(); )
2958 if (it == cmdTokens.begin())
2960 TQStringList::ConstIterator urlit = attachURLs.begin();
2961 TQStringList::ConstIterator urlend = attachURLs.end();
2962 if ( urlit != urlend )
2964 TQStringList::Iterator previt = it;
2968 while ( ++urlit != urlend )
2970 cmdTokens.insert( it, *previt );
2971 cmdTokens.insert( it, *urlit );
2975 it = cmdTokens.remove( cmdTokens.remove( it ) );
2986 if (
tdeinitExec(cmd, cmdTokens, &error, NULL, startup_id )) {
2987 if (Tty != tdeApp->type()) {
2988 TQMessageBox::critical(tdeApp->mainWidget(), i18n(
"Could not Launch Mail Client"),
2989 i18n(
"Could not launch the mail client:\n\n%1").arg(error), i18n(
"&OK"));
2992 kdWarning() <<
"Could not launch mail client:\n" << error <<
endl;
3012 if (Tty != tdeApp->type())
3013 TQMessageBox::critical(tdeApp->mainWidget(), i18n(
"Could not Launch Browser"),
3014 i18n(
"Could not launch the browser:\n\n%1").arg(error), i18n(
"&OK"));
3016 kdWarning() <<
"Could not launch browser:\n" << error <<
endl;
3049 emit coreFakeKeyPress(keyCode);
3055 return "tdelauncher";
3059 startServiceInternal(
const TQCString &
function,
3060 const TQString& _name,
const TQStringList &URLs,
3061 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3063 struct serviceResult
3074 dcopClient = tdeApp->dcopClient();
3080 if (!dcopClient->
attach())
3083 *error =
i18n(
"Could not register with DCOP.\n");
3091 TQDataStream stream(params, IO_WriteOnly);
3092 stream << _name << URLs;
3093 TQCString replyType;
3094 TQByteArray replyData;
3096 TQValueList<TQCString> envs;
3098 if (tqt_xdisplay()) {
3099 TQCString dpystring(XDisplayString(tqt_xdisplay()));
3100 envs.append( TQCString(
"DISPLAY=") + dpystring );
3101 }
else if( getenv(
"DISPLAY" )) {
3102 TQCString dpystring( getenv(
"DISPLAY" ));
3103 envs.append( TQCString(
"DISPLAY=") + dpystring );
3107 #if defined TQ_WS_X11
3109 stream << ( startup_id.isEmpty() ? TDEStartupInfo::createNewStartupId() : startup_id );
3111 if(
function.left( 12 ) !=
"tdeinit_exec" )
3114 if (!dcopClient->
call(_launcher, _launcher,
3115 function, params, replyType, replyData))
3118 *error =
i18n(
"TDELauncher could not be reached via DCOP.\n");
3129 TQDataStream stream2(replyData, IO_ReadOnly);
3130 serviceResult result;
3131 stream2 >> result.result >> result.dcopName >> result.error >> result.pid;
3133 *dcopService = result.dcopName;
3135 *error = result.error;
3138 return result.result;
3143 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3148 return startServiceInternal(
3149 "start_service_by_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3150 _name, URLs, error, dcopService, pid, startup_id, noWait);
3155 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3157 return startServiceInternal(
3158 "start_service_by_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3159 _name, URLs, error, dcopService, pid, startup_id, noWait);
3164 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3169 return startServiceInternal(
3170 "start_service_by_desktop_path(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3171 _name, URLs, error, dcopService, pid, startup_id, noWait);
3176 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3178 return startServiceInternal(
3179 "start_service_by_desktop_path(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3180 _name, URLs, error, dcopService, pid, startup_id, noWait);
3185 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3190 return startServiceInternal(
3191 "start_service_by_desktop_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3192 _name, URLs, error, dcopService, pid, startup_id, noWait);
3197 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3199 return startServiceInternal(
3200 "start_service_by_desktop_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3201 _name, URLs, error, dcopService, pid, startup_id, noWait);
3206 TQString *error,
int *pid )
3213 TQString *error,
int *pid,
const TQCString& startup_id )
3215 return startServiceInternal(
"tdeinit_exec(TQString,TQStringList,TQValueList<TQCString>,TQCString)",
3216 name, args, error, 0, pid, startup_id,
false);
3221 TQString *error,
int *pid )
3228 TQString *error,
int *pid,
const TQCString& startup_id )
3230 return startServiceInternal(
"tdeinit_exec_wait(TQString,TQStringList,TQValueList<TQCString>,TQCString)",
3231 name, args, error, 0, pid, startup_id,
false);
3238 if( TQDir::isRelativePath(pFilename) )
3240 kdWarning(101) <<
"Relative filename passed to TDEApplication::tempSaveName" <<
endl;
3241 aFilename = TQFileInfo( TQDir(
"." ), pFilename ).absFilePath();
3244 aFilename = pFilename;
3246 TQDir aAutosaveDir( TQDir::homeDirPath() +
"/autosave/" );
3247 if( !aAutosaveDir.exists() )
3249 if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) )
3256 aFilename.replace(
"/",
"\\!" ).prepend(
"#" ).append(
"#" ).prepend(
"/" ).prepend( aAutosaveDir.absPath() );
3263 bool& bRecover )
const
3267 if( TQDir::isRelativePath(pFilename) )
3269 kdWarning(101) <<
"Relative filename passed to TDEApplication::tempSaveName" <<
endl;
3270 aFilename = TQFileInfo( TQDir(
"." ), pFilename ).absFilePath();
3273 aFilename = pFilename;
3275 TQDir aAutosaveDir( TQDir::homeDirPath() +
"/autosave/" );
3276 if( !aAutosaveDir.exists() )
3278 if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) )
3285 aFilename.replace(
"/",
"\\!" ).prepend(
"#" ).append(
"#" ).prepend(
"/" ).prepend( aAutosaveDir.absPath() );
3287 if( TQFile( aFilename ).exists() )
3302 int accessOK = access( TQFile::encodeName(pathname), mode );
3303 if ( accessOK == 0 )
3309 if ( (mode & W_OK) == 0 )
3313 if (!access( TQFile::encodeName(pathname), F_OK))
3317 TQString dirName(pathname);
3318 int pos = dirName.findRev(
'/');
3321 else if ( pos == 0 )
3324 dirName.truncate(pos);
3326 accessOK = access( TQFile::encodeName(dirName), W_OK );
3328 if ( accessOK == 0 )
3340 if ( !topWidget->inherits(
"TDEMainWindow") ) {
3341 topWidget->setCaption(
caption() );
3345 topWidget->setIcon( icon() );
3346 #if defined TQ_WS_X11
3351 TDEStartupInfo::setWindowStartupId( topWidget->winId(),
startupId());
3357 return d->startup_id;
3360 void TDEApplication::setStartupId(
const TQCString& startup_id )
3362 if( startup_id == d->startup_id )
3364 #if defined TQ_WS_X11
3365 TDEStartupInfo::handleAutoAppStartedSending();
3367 if( startup_id.isEmpty())
3368 d->startup_id =
"0";
3371 d->startup_id = startup_id;
3372 #if defined TQ_WS_X11
3373 TDEStartupInfoId id;
3374 id.initId( startup_id );
3375 long timestamp =
id.timestamp();
3376 if( timestamp != 0 )
3384 void TDEApplication::read_app_startup_id()
3386 #if defined TQ_WS_X11
3387 TDEStartupInfoId
id = TDEStartupInfo::currentStartupIdEnv();
3388 TDEStartupInfo::resetStartupEnv();
3389 d->startup_id =
id.id();
3395 static bool init =
false;
3400 int fd = open(
"/dev/urandom", O_RDONLY);
3401 if (fd < 0 || ::read(fd, &seed,
sizeof(seed)) !=
sizeof(seed))
3405 seed = rand()+time(0);
3407 if (fd >= 0) close(fd);
3415 if (length <=0 )
return TQString::null;
3417 TQString str; str.setLength( length );
3433 if (!d->actionRestrictions)
3443 if (!d->actionRestrictions || !action)
3448 return authorize(action_prefix + action);
3453 if (menuId.isEmpty() || kde_kiosk_exception)
3464 TQStringList result;
3465 for(TQStringList::ConstIterator it = menuIds.begin();
3466 it != menuIds.end(); ++it)
3474 void TDEApplication::initUrlActionRestrictions()
3476 d->urlActionRestrictions.setAutoDelete(
true);
3477 d->urlActionRestrictions.clear();
3478 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3479 (
"open", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, TQString::null,
true));
3480 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3481 (
"list", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, TQString::null,
true));
3487 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3488 (
"link", TQString::null, TQString::null, TQString::null,
":internet", TQString::null, TQString::null,
true));
3489 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3490 (
"redirect", TQString::null, TQString::null, TQString::null,
":internet", TQString::null, TQString::null,
true));
3494 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3495 (
"redirect", TQString::null, TQString::null, TQString::null,
"file", TQString::null, TQString::null,
true));
3496 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3497 (
"redirect",
":internet", TQString::null, TQString::null,
"file", TQString::null, TQString::null,
false));
3500 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3501 (
"redirect",
":local", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null,
true));
3504 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3505 (
"redirect", TQString::null, TQString::null, TQString::null,
"about", TQString::null, TQString::null,
true));
3508 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3509 (
"redirect", TQString::null, TQString::null, TQString::null,
"=", TQString::null, TQString::null,
true));
3514 TQString keyFormat = TQString(
"rule_%1");
3515 for(
int i = 1; i <= count; i++)
3517 TQString key = keyFormat.arg(i);
3519 if (rule.count() != 8)
3521 TQString action = rule[0];
3522 TQString refProt = rule[1];
3523 TQString refHost = rule[2];
3524 TQString refPath = rule[3];
3525 TQString urlProt = rule[4];
3526 TQString urlHost = rule[5];
3527 TQString urlPath = rule[6];
3528 TQString strEnabled = rule[7].lower();
3530 bool bEnabled = (strEnabled ==
"true");
3532 if (refPath.startsWith(
"$HOME"))
3533 refPath.replace(0, 5, TQDir::homeDirPath());
3534 else if (refPath.startsWith(
"~"))
3535 refPath.replace(0, 1, TQDir::homeDirPath());
3536 if (urlPath.startsWith(
"$HOME"))
3537 urlPath.replace(0, 5, TQDir::homeDirPath());
3538 else if (urlPath.startsWith(
"~"))
3539 urlPath.replace(0, 1, TQDir::homeDirPath());
3541 if (refPath.startsWith(
"$TMP"))
3543 if (urlPath.startsWith(
"$TMP"))
3546 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3547 ( action, refProt, refHost, refPath, urlProt, urlHost, urlPath, bEnabled));
3556 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3566 bool result =
false;
3567 if (d->urlActionRestrictions.isEmpty())
3568 initUrlActionRestrictions();
3570 KURL baseURL(_baseURL);
3571 baseURL.
setPath(TQDir::cleanDirPath(baseURL.
path()));
3572 TQString baseClass = KProtocolInfo::protocolClass(baseURL.
protocol());
3573 KURL destURL(_destURL);
3574 destURL.
setPath(TQDir::cleanDirPath(destURL.
path()));
3575 TQString destClass = KProtocolInfo::protocolClass(destURL.
protocol());
3577 for(TDEApplicationPrivate::URLActionRule *rule = d->urlActionRestrictions.first();
3578 rule; rule = d->urlActionRestrictions.next())
3580 if ((result != rule->permission) &&
3581 (action == rule->action) &&
3582 rule->baseMatch(baseURL, baseClass) &&
3583 rule->destMatch(destURL, destClass, baseURL, baseClass))
3585 result = rule->permission;
3597 int root_x, root_y, win_x, win_y;
3599 XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
3600 &root_x, &root_y, &win_x, &win_y, &keybstate );
3601 return keybstate & 0x00ff;
3602 #elif defined W_WS_MACX
3603 return GetCurrentEventKeyModifiers() & 0x00ff;
3616 int root_x, root_y, win_x, win_y;
3617 XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
3618 &root_x, &root_y, &win_x, &win_y, &mousestate );
3619 #elif defined(TQ_WS_WIN)
3620 const bool mousebtn_swapped = GetSystemMetrics(SM_SWAPBUTTON);
3621 if (GetAsyncKeyState(VK_LBUTTON))
3622 mousestate |= (mousebtn_swapped ? Button3Mask : Button1Mask);
3623 if (GetAsyncKeyState(VK_MBUTTON))
3624 mousestate |= Button2Mask;
3625 if (GetAsyncKeyState(VK_RBUTTON))
3626 mousestate |= (mousebtn_swapped ? Button1Mask : Button3Mask);
3627 #elif defined(TQ_WS_MACX)
3628 mousestate = GetCurrentEventButtonState();
3632 return mousestate & 0xff00;
3641 int root_x, root_y, win_x, win_y;
3643 XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
3644 &root_x, &root_y, &win_x, &win_y, &state );
3646 if( state & Button1Mask )
3648 if( state & Button2Mask )
3650 if( state & Button3Mask )
3652 if( state & ShiftMask )
3654 if( state & ControlMask )
3655 ret |= ControlButton;
3656 if( state & KKeyNative::modX( KKey::ALT ))
3658 if( state & KKeyNative::modX( KKey::WIN ))
3660 #elif defined(TQ_WS_WIN)
3661 const bool mousebtn_swapped = GetSystemMetrics(SM_SWAPBUTTON);
3662 if (GetAsyncKeyState(VK_LBUTTON))
3663 ret |= (mousebtn_swapped ? RightButton : LeftButton);
3664 if (GetAsyncKeyState(VK_MBUTTON))
3666 if (GetAsyncKeyState(VK_RBUTTON))
3667 ret |= (mousebtn_swapped ? LeftButton : RightButton);
3668 if (GetAsyncKeyState(VK_SHIFT))
3670 if (GetAsyncKeyState(VK_CONTROL))
3671 ret |= ControlButton;
3672 if (GetAsyncKeyState(VK_MENU))
3674 if (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN))
3679 return static_cast< ButtonState
>( ret );
3682 #if defined TQ_WS_X11
3685 return get_x_vtnum(TQPaintDevice::x11AppDisplay());
3697 struct sigaction act;
3698 act.sa_handler = SIG_IGN;
3699 sigemptyset( &act.sa_mask );
3701 sigaction( SIGPIPE, &act, 0 );
3705 void TDEApplication::sigpipeHandler(
int)
3707 int saved_errno = errno;
3711 sprintf(msg,
"*** SIGPIPE *** (ignored, pid = %ld)\n", (
long) getpid());
3712 if (write(2, msg, strlen(msg)) < 0) {
3718 errno = saved_errno;
3721 bool TDEApplication::guiEnabled()
3723 return tdeApp && tdeApp->d->guiEnabled;
3726 void TDEApplication::virtual_hook(
int id,
void* data )
3727 { TDEInstance::virtual_hook(
id, data ); }
3729 void KSessionManaged::virtual_hook(
int,
void* )
3732 #include "tdeapplication.moc"