summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldmicro/CMakeLists.txt81
-rw-r--r--ldmicro/draw_outputdev.cpp2
-rw-r--r--ldmicro/ldmicro.cpp4
-rw-r--r--ldmicro/lib/freezeLD/CMakeLists.txt4
-rw-r--r--ldmicro/lib/freezeLD/freezeLD.cpp (renamed from common/linux/freeze.cpp)46
-rw-r--r--ldmicro/lib/freezeLD/freezeLD.h (renamed from common/linux/freeze.h)12
-rw-r--r--ldmicro/lib/linuxUI/CMakeLists.txt3
-rw-r--r--ldmicro/lib/linuxUI/linuxLD.h (renamed from ldmicro/includes/linuxUI/linuxLD.h)3
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.cpp (renamed from ldmicro/linuxUI.cpp)6
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.h (renamed from ldmicro/includes/linuxUI/linuxUI.h)4
10 files changed, 93 insertions, 72 deletions
diff --git a/ldmicro/CMakeLists.txt b/ldmicro/CMakeLists.txt
index 1becba8..239cb87 100644
--- a/ldmicro/CMakeLists.txt
+++ b/ldmicro/CMakeLists.txt
@@ -7,9 +7,13 @@ IF(WIN32)
add_definitions(-D__WIN32__)
ENDIF(WIN32)
+IF (MSVC)
+ MESSAGE( FATAL_ERROR "Cannot build for MacOS, exiting" )
+ add_definitions(-D__MSVC__)
+ENDIF (MSVC)
+
IF(UNIX)
add_definitions(-D__UNIX__)
- include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../common/linux")
MESSAGE( STATUS "Performing system check.." )
MESSAGE( STATUS "Identifing bitness of the platform.." )
@@ -21,45 +25,46 @@ IF(UNIX)
MESSAGE( STATUS "Bitness of the platform: " 36)
endif()
MESSAGE( STATUS "Performing system check - done" )
-ENDIF(UNIX)
-
-IF (MSVC)
- MESSAGE( FATAL_ERROR "Cannot build for MacOS, exiting" )
- add_definitions(-D__MSVC__)
-ENDIF (MSVC)
-
-MESSAGE ( STATUS "Searching for GTK+3.0..." )
-find_package (PkgConfig REQUIRED)
-pkg_check_modules (GTK3 REQUIRED gtk+-3.0)
-# Version control
-set (LDMicro_VERSION_MAJOR 1)
-set (LDMicro_VERSION_MINOR 0)
+ MESSAGE ( STATUS "Searching for GTK+3.0..." )
+ find_package (PkgConfig REQUIRED)
+ pkg_check_modules (GTK3 REQUIRED gtk+-3.0)
-# configure a header file to pass some of the CMake settings
-# to the source code
-include_directories("${CMAKE_CURRENT_SOURCE_DIR}/includes")
-set(PROJECT_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/includes")
-CONFIGURE_FILE (
- "${PROJECT_INCLUDE_DIR}/ldmicroVC.h.in"
- "${PROJECT_INCLUDE_DIR}/ldmicroVC.h"
-)
-MESSAGE ( STATUS " PROJECT_INCLUDE_DIR: " ${PROJECT_INCLUDE_DIR} )
+ # Version control
+ set (LDMicro_VERSION_MAJOR 1)
+ set (LDMicro_VERSION_MINOR 0)
+ # configure a header file to pass some of the CMake settings
+ # to the source code
+ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib/linuxUI")
+ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib/freezeLD")
+ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/includes")
+ set(PROJECT_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/includes")
+ CONFIGURE_FILE (
+ "${PROJECT_INCLUDE_DIR}/ldmicroVC.h.in"
+ "${PROJECT_INCLUDE_DIR}/ldmicroVC.h"
+ )
+ MESSAGE ( STATUS " PROJECT_INCLUDE_DIR: " ${PROJECT_INCLUDE_DIR} )
-# Add GTK3 include files if GTK3 is found
-IF ( GTK3_FOUND )
- include_directories (${GTK3_INCLUDE_DIRS})
- link_directories (${GTK3_LIBRARY_DIRS})
- add_definitions (${GTK3_CFLAGS_OTHER})
- link_libraries (${GTK3_LIBRARIES})
- MESSAGE ( STATUS " GTK3_INCLUDE_DIR: " ${GTK3_INCLUDE_DIRS} )
- MESSAGE ( STATUS " GTK3_LIBRARIES: " ${GTK3_LIBRARIES} )
-ENDIF ( GTK3_FOUND)
-## Dummy compile and install to test linuxUI
-## to compile LDmicro uncomment the below 2 line2
-#add_executable (LDMicro ldmicro.cpp)# miscutil.cpp draw_outputdev.cpp)
-# install (TARGETS LDMicro DESTINATION bin)
-add_executable (linuxUI testMain.cpp)
-install (TARGETS linuxUI DESTINATION bin)
+ # Add GTK3 include files if GTK3 is found
+ IF ( GTK3_FOUND )
+ include_directories (${GTK3_INCLUDE_DIRS})
+ link_directories (${GTK3_LIBRARY_DIRS})
+ add_definitions (${GTK3_CFLAGS_OTHER})
+ link_libraries (${GTK3_LIBRARIES})
+ MESSAGE ( STATUS " GTK3_INCLUDE_DIR: " ${GTK3_INCLUDE_DIRS} )
+ MESSAGE ( STATUS " GTK3_LIBRARIES: " ${GTK3_LIBRARIES} )
+ ENDIF ( GTK3_FOUND )
+ add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/lib/linuxUI")
+ add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/lib/freezeLD")
+
+ ## Dummy compile and install to test linuxUI
+ ## to compile LDmicro uncomment the below 2 line2
+ #add_executable (LDMicro ldmicro.cpp)# miscutil.cpp draw_outputdev.cpp)
+ # install (TARGETS LDMicro DESTINATION bin)
+ add_executable (testMain testMain.cpp)
+ target_link_libraries (testMain LinuxUI)
+ target_link_libraries (testMain FreezeLD)
+ install (TARGETS testMain DESTINATION bin)
+ENDIF(UNIX) \ No newline at end of file
diff --git a/ldmicro/draw_outputdev.cpp b/ldmicro/draw_outputdev.cpp
index bc4a7ef..0d6f3cd 100644
--- a/ldmicro/draw_outputdev.cpp
+++ b/ldmicro/draw_outputdev.cpp
@@ -25,7 +25,7 @@
// Ported to linus by: R Ramana, 2018
//-----------------------------------------------------------------------------
-#include "linuxUI/linuxUI.h"
+#include "linuxUI.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp
index e7e3f17..cc0a525 100644
--- a/ldmicro/ldmicro.cpp
+++ b/ldmicro/ldmicro.cpp
@@ -24,7 +24,7 @@
// most of the UI logic relating to the main window.
// Jonathan Westhues, Oct 2004
//-----------------------------------------------------------------------------
-#include "linuxUI/linuxUI.h"
+#include "linuxUI.h"
#include <stdio.h>
#include <stdlib.h>
@@ -36,7 +36,7 @@
HINSTANCE Instance;
-HWND MainWindow;
+HWID MainWindow;
HDC Hdc;
// parameters used to capture the mouse when implementing our totally non-
diff --git a/ldmicro/lib/freezeLD/CMakeLists.txt b/ldmicro/lib/freezeLD/CMakeLists.txt
new file mode 100644
index 0000000..761f348
--- /dev/null
+++ b/ldmicro/lib/freezeLD/CMakeLists.txt
@@ -0,0 +1,4 @@
+project( FreezeLD )
+
+add_library(FreezeLD freezeLD.cpp)
+target_link_libraries(FreezeLD LinuxUI)
diff --git a/common/linux/freeze.cpp b/ldmicro/lib/freezeLD/freezeLD.cpp
index 453ae82..5241af1 100644
--- a/common/linux/freeze.cpp
+++ b/ldmicro/lib/freezeLD/freezeLD.cpp
@@ -6,8 +6,8 @@
*
* R Ramana, 2018
*/
-#include "freeze.h"
-#include <linuxUI/linuxUI.h>
+#include "linuxUI.h"
+#include "freezeLD.h"
#include <cstdlib>
#include <fstream>
#include <stdlib.h>
@@ -16,8 +16,9 @@
/*
* store a window's position in the registry, or fail silently if the registry calls don't work
*/
-void FreezeWindowPosF(HWND hwnd, char *subKey, char *name)
+void FreezeWindowPosF(HWID hwid, char *subKey, char *name)
{
+ g_print("freezing");
char* moveToKeyLocatin = (char *)malloc(strlen(subKey) + 35);
if(!moveToKeyLocatin)
return;
@@ -32,60 +33,65 @@ void FreezeWindowPosF(HWND hwnd, char *subKey, char *name)
if(!keyName)
return;
- Key newkey;
+ Key newKey;
int val;
-
+ g_print("get width");
sprintf(keyName, "%s_width", name);
std::ofstream Register(keyName, std::ios::binary | std::ios::trunc);
if (!Register.is_open())
return;
- gtk_window_get_size(GTK_WINDOW(gtk_widget_get_parent_window(GTK_WIDGET(hwnd))), &val, NULL);
+ gtk_window_get_size(GTK_WINDOW(hwid), &val, NULL);
newKey.type = 'i';
newKey.val.i = val;
Register.write((char*) &newKey, sizeof(newKey));
Register.close();
+ g_print("get height");
sprintf(keyName, "%s_height", name);
Register.open(keyName, std::ios::binary | std::ios::trunc);
if (!Register.is_open())
return;
- gtk_window_get_size(GTK_WINDOW(gtk_widget_get_parent_window(GTK_WIDGET(hwnd))), NULL, &val);
+ gtk_window_get_size(GTK_WINDOW(hwid), NULL, &val);
newKey.type = 'i';
newKey.val.i = val;
Register.write((char*) &newKey, sizeof(newKey));
Register.close();
+ g_print("get posX");
sprintf(keyName, "%s_posX", name);
Register.open(keyName, std::ios::binary | std::ios::trunc);
if (!Register.is_open())
return;
- gtk_window_get_position(GTK_WINDOW(gtk_widget_get_parent_window(GTK_WIDGET(hwnd))), &val, NULL);
+ gtk_window_get_position(GTK_WINDOW(hwid), &val, NULL);
newKey.type = 'i';
newKey.val.i = val;
Register.write((char*) &newKey, sizeof(newKey));
Register.close();
+ g_print("get posY");
sprintf(keyName, "%s_posY", name);
Register.open(keyName, std::ios::binary | std::ios::trunc);
if (!Register.is_open())
return;
- gtk_window_get_position(GTK_WINDOW(gtk_widget_get_parent_window(GTK_WIDGET(hwnd))), NULL, &val);
+ gtk_window_get_position(GTK_WINDOW(hwid), NULL, &val);
newKey.type = 'i';
newKey.val.i = val;
Register.write((char*) &newKey, sizeof(newKey));
Register.close();
+ g_print("get max");
sprintf(keyName, "%s_maximized", name);
Register.open(keyName, std::ios::binary | std::ios::trunc);
if (!Register.is_open())
return;
newKey.type = 'b';
- newKey.val.b = gtk_window_is_maximized(GTK_WINDOW(gtk_widget_get_parent_window(GTK_WIDGET(hwnd))));
+ newKey.val.b = gtk_window_is_maximized(GTK_WINDOW(hwid));
Register.write((char*) &newKey, sizeof(newKey));
Register.close();
free(keyName);
+ g_print("freezed");
}
static void Clamp(LONG *v, LONG min, LONG max)
@@ -97,7 +103,7 @@ static void Clamp(LONG *v, LONG min, LONG max)
/*
* retrieve a window's position from the registry, or do nothing if there is no info saved
*/
-void ThawWindowPosF(HWND hwnd, char *subKey, char *name)
+void ThawWindowPosF(HWID hwid, char *subKey, char *name)
{
char* moveToKeyLocatin = (char *)malloc(strlen(name) + 30);
if(!moveToKeyLocatin)
@@ -111,7 +117,7 @@ void ThawWindowPosF(HWND hwnd, char *subKey, char *name)
if(!keyName)
return;
- Key newkey1, newkey2;
+ Key newKey1, newKey2;
/// set size
sprintf(keyName, "%s_width", name);
@@ -128,7 +134,7 @@ void ThawWindowPosF(HWND hwnd, char *subKey, char *name)
Register.read((char*) &newKey2, sizeof(newKey2));
Register.close();
if (newKey1.type == 'i' && newKey2.type == 'i')
- gtk_window_resize(GTK_WINDOW(gtk_widget_get_parent_window(GTK_WIDGET(hwnd))), &newKey1.val.i, &newKey2.val.i);
+ gtk_window_resize(GTK_WINDOW(hwid), newKey1.val.i, newKey2.val.i);
/// set position
@@ -146,18 +152,18 @@ void ThawWindowPosF(HWND hwnd, char *subKey, char *name)
Register.read((char*) &newKey2, sizeof(newKey2));
Register.close();
if (newKey1.type == 'i' && newKey2.type == 'i')
- gtk_window_move(GTK_WINDOW(gtk_widget_get_parent_window(GTK_WIDGET(hwnd))), &newKey1.val.i, &newKey2.val.i);
+ gtk_window_move(GTK_WINDOW(hwid), newKey1.val.i, newKey2.val.i);
sprintf(keyName, "%s_maximized", name);
Register.open(keyName, std::ios::binary);
if (!Register.is_open())
return;
- Register.read((char*) &newKey, sizeof(newKey));
+ Register.read((char*) &newKey1, sizeof(newKey1));
Register.close();
- if (newKey.type == 'b')
- if (newKey.val.b)
- gtk_window_maximize(GTK_WINDOW(gtk_widget_get_parent_window(GTK_WIDGET(hwnd))));
+ if (newKey1.type == 'b')
+ if (newKey1.val.b)
+ gtk_window_maximize(GTK_WINDOW(hwid));
/// gtk_window_move handles off-screen window placement
@@ -222,12 +228,12 @@ void FreezeStringF(char *val, char *subKey, char *name)
{
char* moveToKeyLocatin = (char *)malloc(strlen(name) + 30);
if(!moveToKeyLocatin)
- return val;
+ return;
sprintf(moveToKeyLocatin, "mkdir -p %s/%s", LDMICRO_REGISTER, subKey);
system(moveToKeyLocatin);
sprintf(moveToKeyLocatin, "cd %s/%s", LDMICRO_REGISTER, subKey);
if (-1 == system(moveToKeyLocatin))
- return val;
+ return;
free(moveToKeyLocatin);
std::ofstream Register(name, std::ios::trunc);
diff --git a/common/linux/freeze.h b/ldmicro/lib/freezeLD/freezeLD.h
index 7aabec7..f14ef07 100644
--- a/common/linux/freeze.h
+++ b/ldmicro/lib/freezeLD/freezeLD.h
@@ -12,15 +12,17 @@
#define LDMICRO_REGISTER "/usr/share/ldmicro"
-#ifndef FREEZE_SUBKEY
-#error must define FREEZE_SUBKEY to a string uniquely identifying the app
-#endif
+#define FREEZE_SUBKEY "LDMicro"
+
+// #ifndef FREEZE_SUBKEY
+// #error must define FREEZE_SUBKEY to a string uniquely identifying the app
+// #endif
#define FreezeWindowPos(hwnd) FreezeWindowPosF(hwnd, FREEZE_SUBKEY, #hwnd)
-void FreezeWindowPosF(HWND hWnd, char *subKey, char *name);
+void FreezeWindowPosF(HWID hWid, char *subKey, char *name);
#define ThawWindowPos(hwnd) ThawWindowPosF(hwnd, FREEZE_SUBKEY, #hwnd)
-void ThawWindowPosF(HWND hWnd, char *subKey, char *name);
+void ThawWindowPosF(HWID hWid, char *subKey, char *name);
#define FreezeDWORD(val) FreezeDWORDF(val, FREEZE_SUBKEY, #val)
void FreezeDWORDF(DWORD val, char *subKey, char *name);
diff --git a/ldmicro/lib/linuxUI/CMakeLists.txt b/ldmicro/lib/linuxUI/CMakeLists.txt
new file mode 100644
index 0000000..16226dc
--- /dev/null
+++ b/ldmicro/lib/linuxUI/CMakeLists.txt
@@ -0,0 +1,3 @@
+project(LinuxUI)
+
+add_library(LinuxUI linuxUI.cpp)
diff --git a/ldmicro/includes/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h
index 53194e1..9aba23d 100644
--- a/ldmicro/includes/linuxUI/linuxLD.h
+++ b/ldmicro/lib/linuxUI/linuxLD.h
@@ -1,7 +1,7 @@
#ifndef __LINUX_LD__
#define __LINUX_LD__
-#include "linuxUI/linuxUI.h"
+#include "linuxUI.h"
/// common windows referances for linux
@@ -15,6 +15,7 @@
typedef bool BOOL;
typedef unsigned char BYTE;
typedef unsigned int DWORD;
+typedef long LONG;
/// all handles will hold a GtkWindow* type
typedef void* PVOID;
diff --git a/ldmicro/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp
index 854ed09..8237d7d 100644
--- a/ldmicro/linuxUI.cpp
+++ b/ldmicro/lib/linuxUI/linuxUI.cpp
@@ -1,9 +1,9 @@
-#include "linuxUI/linuxUI.h"
+#include "linuxUI.h"
/// Wraper function for gtk_window_has_toplevel_focus
-BOOL isFocus(HWND window)
+BOOL isFocus(HWID window)
{
- return (BOOL) gtk_window_has_toplevel_focus(GTK_WINDOW(window)));
+ return (BOOL) gtk_window_has_toplevel_focus(GTK_WINDOW(gtk_widget_get_parent_window(GTK_WIDGET(window))));
}
COLORREF RGB(int red, int green, int blue)
diff --git a/ldmicro/includes/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h
index 01b7af2..3e49de0 100644
--- a/ldmicro/includes/linuxUI/linuxUI.h
+++ b/ldmicro/lib/linuxUI/linuxUI.h
@@ -6,14 +6,14 @@
#include <linux/limits.h>
#include <stdio.h>
#include <inttypes.h>
-#include "linuxUI/linuxLD.h"
+#include "linuxLD.h"
/// version control
#define LDMicro_VERSION_MAJOR 1
#define LDMicro_VERSION_MINOR 0
/// functions
-BOOL isFocus(HWND);
+BOOL isFocus(HWID);
COLORREF RGB(int, int, int);
#endif \ No newline at end of file