diff options
Diffstat (limited to 'activator')
-rw-r--r-- | activator/MacOSWindowActivator | bin | 15260 -> 0 bytes | |||
-rw-r--r-- | activator/Makefile | 20 | ||||
-rw-r--r-- | activator/WindowActivator | bin | 13885 -> 0 bytes | |||
-rw-r--r-- | activator/WindowActivator.cpp | 365 | ||||
-rw-r--r-- | activator/WindowActivator.exe | bin | 105984 -> 0 bytes | |||
-rw-r--r-- | activator/WindowActivator.h | 62 | ||||
-rw-r--r-- | activator/macoswindowactivator.sh | 15 | ||||
-rw-r--r-- | activator/main.cpp | 63 | ||||
-rw-r--r-- | activator/windowactivator.bat | 10 | ||||
-rw-r--r-- | activator/windowactivator.sh | 15 | ||||
-rw-r--r-- | activator/windowactivator.vbs | 11 |
11 files changed, 0 insertions, 561 deletions
diff --git a/activator/MacOSWindowActivator b/activator/MacOSWindowActivator Binary files differdeleted file mode 100644 index 74f6290..0000000 --- a/activator/MacOSWindowActivator +++ /dev/null diff --git a/activator/Makefile b/activator/Makefile deleted file mode 100644 index 642e0f0..0000000 --- a/activator/Makefile +++ /dev/null @@ -1,20 +0,0 @@ - -HEADER = WindowActivator.h - -SRCS = main.cpp WindowActivator.cpp - -TARGET = WindowActivator - -FLAGS = -Wall - -#LDFLAGS = -lstdc++ -lX11 -LDFLAGS = -lstdc++ -framework IOKit -framework ApplicationServices - -all: $(TARGET) - -$(TARGET): $(SRCS) $(HEADER) - $(CC) -o $@ $(FLAGS) $(SRCS) $(LDFLAGS) - -clean: - rm $(TARGET) - diff --git a/activator/WindowActivator b/activator/WindowActivator Binary files differdeleted file mode 100644 index 8fe0876..0000000 --- a/activator/WindowActivator +++ /dev/null diff --git a/activator/WindowActivator.cpp b/activator/WindowActivator.cpp deleted file mode 100644 index 49584bd..0000000 --- a/activator/WindowActivator.cpp +++ /dev/null @@ -1,365 +0,0 @@ -/* - * Window Activator - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * - * Jaewon Lim <jaewon81.lim@samsung.com> - * Juyoung Kim <j0.kim@samsung.com> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - - - -/** - * @summary - * @create date : 2011. 8. 16. - * @author(create) : Lee JaeYeol / jaeyeol148.lee@samsung.com / S-Core - * @revision date : 2011. 8. 16. - * @author(revision) : Lee JaeYeol / jaeyeol148.lee@samsung.com / S-Core - * @refactoring date : 2012. 4. 14 - * @author(refactoring) : Jaewon Lim / jaewon81.lim@samsung.com / S-Core - */ - -#include "WindowActivator.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -WindowActivator::WindowActivator() -{ -} - -WindowActivator::~WindowActivator() -{ -} - -bool WindowActivator::ActivateWindow(const std::string pid) -{ - return ActivateWindow(atoi(pid.c_str())); -} - - -#ifdef _WIN32 || _WIN64 -#include <windows.h> -//#using <System.dll> -//using namespace System; -//using namespace System::Diagnostics; -//using namespace System::ComponentModel; - -ULONG ProcIDFromWnd(HWND hwnd); -HWND GetWinHandle(ULONG pid); -void ActiveWindow(HWND hWnd); - -bool WindowActivator::ActivateWindow(int pid) -{ - ActiveWindow(GetWinHandle(pid)); - return true; -} - -ULONG ProcIDFromWnd(HWND hwnd) -{ - ULONG idProc; - GetWindowThreadProcessId( hwnd, &idProc ); - return idProc; -} - -HWND GetWinHandle(ULONG pid) -{ -// Process^ fproc = Process::GetProcessById(pid); -// return (HWND)fproc->MainWindowHandle.ToPointer(); - - HWND tempHwnd = FindWindow(NULL,NULL); - - while(tempHwnd != NULL ) - { - if(GetParent(tempHwnd) == NULL ) - { - if(GetWindow(tempHwnd, GW_OWNER) == NULL) - { - if( pid == ProcIDFromWnd(tempHwnd) ) - return tempHwnd; - } - } - tempHwnd = GetWindow(tempHwnd, GW_HWNDNEXT); - } - return NULL; -} - -void ActiveWindow(HWND hWnd) -{ - HWND hWndForeground = ::GetForegroundWindow(); - if(hWndForeground == hWnd) - { - printf("same as foreground window\n"); - return; - } - - DWORD Strange = ::GetWindowThreadProcessId(hWndForeground, NULL); - DWORD My = ::GetWindowThreadProcessId(hWnd, NULL); - if( !::AttachThreadInput(Strange, My, TRUE) ) - { - // ASSERT(0); - } - ::SetForegroundWindow(hWnd); - ::BringWindowToTop(hWnd); - if( !::AttachThreadInput(Strange, My, FALSE) ) - { - // ASSERT(0); - } - if (::IsIconic(hWnd)) - ::ShowWindow(hWnd, SW_RESTORE); -} - -#elif __linux // if Linux - -#include <X11/Xlib.h> -#include <X11/Xatom.h> - -#define PERROR(...) fprintf(stderr, __VA_ARGS__) - -bool findWindow(Display *disp, int idepid); -Window* getClientList(Display *disp, unsigned long *size); -char *getProperty(Display *disp, Window win, Atom xaPropType, const char *propName, unsigned long *size); -char *getWindowTitle(Display *disp, Window win); -int findProcessID(Display *disp, Window win); -void activateWindow(Display *disp, Window win); -bool sendEvent(Display *disp, Window win, char *msg, unsigned long data0, unsigned long data1, unsigned long data2, unsigned long data3, unsigned long data4); - -bool WindowActivator::ActivateWindow(int pid) -{ - - Display *disp; - - if (!(disp = XOpenDisplay(NULL))) - { - PERROR("XOpenDisplay error"); - return false; - } - - findWindow(disp, pid); - return true; -} - -bool findWindow(Display *disp, int idepid) -{ - unsigned long clientListSize; - unsigned long i; - Window *clientList; - Window activate = 0; - - if ((clientList = getClientList(disp, &clientListSize)) == NULL) - { - return false; - } - - for (i = 0; i < clientListSize / sizeof(Window); i++) - { - int pid = 0; - pid = findProcessID(disp, clientList[i]); - - if (pid == 0) - { - continue; - } - - if(pid == idepid) - { - activate = clientList[i]; - break; - } - } - - free(clientList); - - if (activate) - { - activateWindow(disp, activate); - return true; - } - else - { - return false; - } -} - -Window* getClientList(Display *disp, unsigned long *size) -{ - Window *clientList; - - if ((clientList = (Window *)getProperty(disp, DefaultRootWindow(disp), XA_WINDOW, (char*)"_NET_CLIENT_LIST", size)) == NULL) - { - if ((clientList = (Window *)getProperty(disp, DefaultRootWindow(disp), XA_CARDINAL, (char*)"_WIN_CLIENT_LIST", size)) == NULL) - { - PERROR("Can not get a client list"); - return NULL; - } - } - return clientList; -} - -char* getProperty(Display *disp, Window win, Atom xaPropType, const char *propName, unsigned long *size) -{ - Atom xaPropName; - Atom xaRetType; - int retFormat; - unsigned long retItems; - unsigned long retBytesAfter; - unsigned long tmpSize; - unsigned char *retProp; - char *ret; - - xaPropName = XInternAtom(disp, propName, False); - - int returnValue = XGetWindowProperty(disp, win, xaPropName, 0, 1024, False, xaPropType, &xaRetType, &retFormat, &retItems, &retBytesAfter, &retProp); - PERROR("XGetWindowProperty %d ", returnValue); - - if (returnValue != Success) - { - PERROR("Can not get a %s property", propName); - return NULL; - } - - if (xaRetType != xaPropType) - { - PERROR("Invalid type of %s property.", propName); - XFree(retProp); - return NULL; - } - - // null terminate the result to make string handling easier / - tmpSize = (retFormat / 8) * retItems; - // Correct 64 Architecture implementation of 32 bit data / - if(retFormat==32) tmpSize *= sizeof(long)/4; - ret = (char*)malloc(tmpSize + 1); - memcpy(ret, retProp, tmpSize); - ret[tmpSize] = '\0'; - - if (size) { - *size = tmpSize; - } - - XFree(retProp); - return ret; -} - -int findProcessID(Display *disp, Window win) -{ - int pid = 0; - unsigned long *netWmPid; - - netWmPid = (unsigned long*)getProperty(disp, win, XA_CARDINAL, (const char*)"_NET_WM_PID", NULL); - - if(netWmPid) - { - pid = (int)*netWmPid; - free(netWmPid); - } - - PERROR("findProcessID %d ", pid); - return pid; -} - -bool sendEvent(Display *disp, Window win, char *msg, - unsigned long data0, unsigned long data1, - unsigned long data2, unsigned long data3, - unsigned long data4) -{ - XEvent event; - long mask = SubstructureRedirectMask | SubstructureNotifyMask; - - event.xclient.type = ClientMessage; - event.xclient.serial = 0; - event.xclient.send_event = True; - event.xclient.message_type = XInternAtom(disp, msg, False); - event.xclient.window = win; - event.xclient.format = 32; - event.xclient.data.l[0] = data0; - event.xclient.data.l[1] = data1; - event.xclient.data.l[2] = data2; - event.xclient.data.l[3] = data3; - event.xclient.data.l[4] = data4; - - if (XSendEvent(disp, DefaultRootWindow(disp), False, mask, &event)) - { - return true; - } - else - { - PERROR("Can not send %s event", msg); - return false; - } -} - - -void activateWindow (Display *disp, Window win) -{ - unsigned long *desktop = NULL; - - // desktop ID / - if ((desktop = (unsigned long *)getProperty(disp, win, XA_CARDINAL, (const char*)"_NET_WM_DESKTOP", NULL)) == NULL) - { - if ((desktop = (unsigned long *)getProperty(disp, win, XA_CARDINAL, (const char*)"_WIN_WORKSPACE", NULL)) == NULL) - { - PERROR("Can not find desktop ID"); - } - } - - if (desktop) - { - if (sendEvent(disp, DefaultRootWindow(disp), (char*)"_NET_CURRENT_DESKTOP", *desktop, 0, 0, 0, 0) != EXIT_SUCCESS) - { - PERROR("Can not switch desktop."); - } - free(desktop); - } - - sendEvent(disp, win, (char*)"_NET_ACTIVE_WINDOW", 0, 0, 0, 0, 0); - XMapRaised(disp, win); - - XFlush(disp); - XCloseDisplay (disp); -} -#elif __APPLE__ - -#include <getopt.h> -#include <IOKit/graphics/IOGraphicsLib.h> -#include <ApplicationServices/ApplicationServices.h> - -bool WindowActivator::ActivateWindow(int pid) -{ - - ProcessSerialNumber psn; - if(noErr == GetProcessForPID(pid, &psn)) - { - SetFrontProcess(&psn); - exit(0); - } - return 0; -} - -#endif // end Linux diff --git a/activator/WindowActivator.exe b/activator/WindowActivator.exe Binary files differdeleted file mode 100644 index 7f873c1..0000000 --- a/activator/WindowActivator.exe +++ /dev/null diff --git a/activator/WindowActivator.h b/activator/WindowActivator.h deleted file mode 100644 index 100b791..0000000 --- a/activator/WindowActivator.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Window Activator - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * - * Jaewon Lim <jaewon91.lim@samsung.com> - * Juyoung Kim <j0.kim@samsung.com> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - - -/** - * @summary : - * @create date : 2011. 8. 16. - * @author(create) : Lee JaeYeol / jaeyeol148.lee@samsung.com / S-Core - * @revision date : 2011. 8. 16. - * @author(revision) : Lee JaeYeol / jaeyeol148.lee@samsung.com / S-Core - */ - - -#ifndef WINDOWACTIVATOR_H_ -#define WINDOWACTIVATOR_H_ - -#include <string> - -class WindowActivator -{ -private: - WindowActivator(); - virtual ~WindowActivator(); - -public: - static bool ActivateWindow(const std::string pid); - static bool ActivateWindow(int pid); -}; - -#endif /* WINDOWACTIVATOR_H_ */ diff --git a/activator/macoswindowactivator.sh b/activator/macoswindowactivator.sh deleted file mode 100644 index 9ef0fa0..0000000 --- a/activator/macoswindowactivator.sh +++ /dev/null @@ -1,15 +0,0 @@ -#! /bin/bash - -abspath="$(cd "${0%/*}" 2>/dev/null; echo $PWD/${0##*/})" -absdir=`dirname "$abspath"` - -PWD=`pwd` - -ACTIVATOR=MacOSWindowActivator -ACTIVATOR_PATH=${absdir} - -# for coredump file -ulimit -c unlimited - -${ACTIVATOR_PATH}/${ACTIVATOR} "$@" - diff --git a/activator/main.cpp b/activator/main.cpp deleted file mode 100644 index d2b6a67..0000000 --- a/activator/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Window Activator - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * - * Changhun Lim <changhun.lim@samsung.com> - * Gyeongmin Ju <gyeongmin.ju@samsung.com> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#include <iostream> -#include <string> -#include "WindowActivator.h" - -using namespace std; - -static void printUsage(const string appname) -{ - cout << "* error : missing required paramaters" << endl; - cout << "* usage : " << endl; - cout << "\t to activate a window :" << endl; - cout << "\t\t" << appname << " pid" << endl; -} - -int main(int argc, char **argv) -{ - if (argc < 2) - { - printUsage(argv[0]); - } - else - { - WindowActivator::ActivateWindow(argv[1]); - } - - return 0; -} - diff --git a/activator/windowactivator.bat b/activator/windowactivator.bat deleted file mode 100644 index 0655f2e..0000000 --- a/activator/windowactivator.bat +++ /dev/null @@ -1,10 +0,0 @@ -rem # find & move absolute path -set ABS_PATH=%~dp0 -cd %ABS_PATH% - -set PWD=%CD% -set ACTIVATOR_PATH=%PWD% -set ACTIVATOR_BIN=WindowActivator.exe -set PATH=%ACTIVATOR_PATH%;%PATH% - -%ACTIVATOR_PATH%\%ACTIVATOR_BIN% %* diff --git a/activator/windowactivator.sh b/activator/windowactivator.sh deleted file mode 100644 index 2adf516..0000000 --- a/activator/windowactivator.sh +++ /dev/null @@ -1,15 +0,0 @@ -#! /bin/bash - -abspath="$(cd "${0%/*}" 2>/dev/null; echo $PWD/${0##*/})" -absdir=`dirname "$abspath"` - -PWD=`pwd` - -ACTIVATOR=WindowActivator -ACTIVATOR_PATH=${absdir} - -# for coredump file -ulimit -c unlimited - -${ACTIVATOR_PATH}/${ACTIVATOR} "$@" - diff --git a/activator/windowactivator.vbs b/activator/windowactivator.vbs deleted file mode 100644 index 3e63501..0000000 --- a/activator/windowactivator.vbs +++ /dev/null @@ -1,11 +0,0 @@ -Set fso = CreateObject("Scripting.FileSystemObject") -activatorPath = fso.GetParentFolderName(Wscript.scriptFullName) -activatorScript=activatorPath & "\windowactivator.bat" - -For i = 0 To WScript.Arguments.Count - 1 - args = args & Chr(34) & WScript.Arguments(i) & Chr(34) & " " -Next - -set WshShell=WScript.CreateObject("WScript.Shell") -WshShell.run activatorScript & " " & args,0,False -Set WshShell=Nothing |