[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/kdepim/enterprise4/kdelibs-4.0.83/kdeui
From:       Jaroslaw Staniek <js () iidea ! pl>
Date:       2008-07-02 13:29:04
Message-ID: 1215005344.763770.30189.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 827258 by staniek:

Windows:
activateWindowForProcess() ported to mingw. Added explicit dependency on oleaut32.



 M  +1 -1      CMakeLists.txt  
 M  +24 -15    kernel/kapplication_win.cpp  


--- branches/kdepim/enterprise4/kdelibs-4.0.83/kdeui/CMakeLists.txt #827257:827258
@@ -296,7 +296,7 @@
 target_link_libraries(kdeui  ${QT_QTSVG_LIBRARY} ${KDE4_KDECORE_LIBS} \
${X11_LIBRARIES} ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY} )  
 if(MINGW)
-   target_link_libraries(kdeui gdi32)
+   target_link_libraries(kdeui gdi32 oleaut32)
 endif(MINGW)
 
 if(X11_XTest_FOUND)
--- branches/kdepim/enterprise4/kdelibs-4.0.83/kdeui/kernel/kapplication_win.cpp \
#827257:827258 @@ -51,11 +51,13 @@
 
 // <copy of kdepim/libkdepim/utils.cpp, TODO: move to a shared helper library>
 
+#include <windows.h>
 #ifdef _MSC_VER
-//TODO support mingw
-
-#include <windows.h>
-#include <comdef.h> // (bstr_t)
+# include <comdef.h> // (bstr_t)
+#else
+// mingw: get patched comutil.h from http://pastebin.ca/raw/1060471 and save to \
kde4/mingw/include/ +# include <comutil.h> // (bstr_t)
+#endif
 #include <winperf.h>
 #include <psapi.h>
 #include <signal.h>
@@ -108,7 +110,7 @@
 
 void KApplication_getProcessesIdForName( const QString& processName, QList<int>& \
pids )  {
-  LPCTSTR pProcessName = (LPCTSTR)processName.utf16();
+  qDebug() << "KApplication_getProcessesIdForName" << processName;
   PPERF_OBJECT_TYPE perfObject;
   PPERF_INSTANCE_DEFINITION perfInstance;
   PPERF_COUNTER_DEFINITION perfCounter, curCounter;
@@ -143,19 +145,22 @@
     pids.clear();
     perfCounter = FirstCounter( perfObject );
     perfInstance = FirstInstance( perfObject );
-    _bstr_t bstrProcessName,bstrInput;
+    _bstr_t bstrProcessName;
     // retrieve the instances
+    qDebug() << "INSTANCES: " << perfObject->NumInstances;
     for( int instance = 0; instance < perfObject->NumInstances; instance++ ) {
       curCounter = perfCounter;
-      bstrInput = pProcessName;
+
       bstrProcessName = (wchar_t *)((PBYTE)perfInstance + perfInstance->NameOffset);
-      if (!_wcsicmp((LPCWSTR)bstrProcessName, (LPCWSTR) bstrInput)) {
+      qDebug() << "bstrProcessName: " << \
QString::fromWCharArray((LPCWSTR)bstrProcessName); +      if \
(QString::fromWCharArray((LPCWSTR)bstrProcessName) == processName) {  // retrieve the \
                counters
         for( uint counter = 0; counter < perfObject->NumCounters; counter++ ) {
           if (curCounter->CounterNameTitleIndex == GETPID_PROC_ID_COUNTER) {
             counterPtr = CounterBlock(perfInstance);
             DWORD *value = (DWORD*)((LPBYTE) counterPtr + \
curCounter->CounterOffset);  pids.append( int( *value ) );
+            qDebug() << "found PID: " << int( *value );
             break;
           }
           curCounter = NextCounter( curCounter );
@@ -225,10 +230,19 @@
 {
   QList<int> pids;
   KApplication_getProcessesIdForName( executableName, pids );
-  if ( pids.isEmpty() )
+  int myPid = getpid();
+  int foundPid = 0;
+  foreach ( int pid, pids ) {
+    if (myPid != pid) {
+      qDebug() << "activateWindowForProcess(): PID to activate:" << pid;
+      foundPid = pid;
+      break;
+    }
+  }
+  if ( foundPid == 0 )
     return;
   EnumWindowsStruct winStruct;
-  winStruct.pid = pids.first();
+  winStruct.pid = foundPid;
   EnumWindows( EnumWindowsProc, (LPARAM)&winStruct );
   if ( winStruct.windowId == NULL )
     return;
@@ -237,8 +251,3 @@
 
 // </copy>
 
-#else
-void KApplication_activateWindowForProcess( const QString& executableName )
-{
-}
-#endif //!_MSC_VER


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic