From c612a1d58623680929f4e7cecd57c40711db77a6 Mon Sep 17 00:00:00 2001 From: aacalfa Date: Thu, 31 Jul 2014 11:55:52 -0300 Subject: [PATCH 1/4] Workaround to work for MacOS X. --- konsole-qml-plugin/src/TerminalDisplay.cpp | 4 + konsole-qml-plugin/src/kpty.cpp | 182 +++++++++++++++++++++ 2 files changed, 186 insertions(+) diff --git a/konsole-qml-plugin/src/TerminalDisplay.cpp b/konsole-qml-plugin/src/TerminalDisplay.cpp index 3c674b4..7470b78 100644 --- a/konsole-qml-plugin/src/TerminalDisplay.cpp +++ b/konsole-qml-plugin/src/TerminalDisplay.cpp @@ -675,6 +675,10 @@ static void drawLineChar(QPainter* paint, qreal x, qreal y, qreal w, qreal h, uc } +void KTerminalDisplay::banana(int x, int y, int z, int w) +{ +} + void KTerminalDisplay::setKeyboardCursorShape(KeyboardCursorShape shape) { _cursorShape = shape; diff --git a/konsole-qml-plugin/src/kpty.cpp b/konsole-qml-plugin/src/kpty.cpp index 4498a97..3b45be3 100644 --- a/konsole-qml-plugin/src/kpty.cpp +++ b/konsole-qml-plugin/src/kpty.cpp @@ -135,6 +135,188 @@ extern "C" { # endif #endif +// http://markmail.org/download.xqy?id=atu7scqmvlsku4n5&number=2 +typedef enum { F=0, T=1 } boolean; + +static int utmpfd = -1; +static char utmpath[PATH_MAX+1] = _PATH_UTMP; +static boolean readonly = F; +static struct utmp utmp; + + +struct utmp *getutent(); +struct utmp *getutid( struct utmp * ); +struct utmp *getutline( struct utmp * ); +void pututline( struct utmp * ); +void setutent(); +void endutent(); +void utmpname( char * ); + + + static + struct utmp * +_getutent( struct utmp *utmp ) +{ + if ( utmpfd == -1 ) + { + if ( (utmpfd = open(utmpath,O_RDWR)) == -1 ) + { + if ( (utmpfd = open(utmpath,O_RDONLY)) == -1 ) + return NULL; + else + readonly = T; + } + else + readonly = F; + } + + if ( read(utmpfd,utmp,sizeof(struct utmp)) == sizeof(struct utmp) ) + return utmp; + + return NULL; +} + + + struct utmp * +getutent() +{ + return _getutent( &utmp ); +} + + + struct utmp * +getutid( struct utmp *id ) +{ + struct utmp *up; + + if ( strncmp(id->ut_name,utmp.ut_name,UT_NAMESIZE) == 0 ) + return &utmp; + + while( (up = getutent()) != NULL ) + { + if ( strncmp(id->ut_name,up->ut_name,UT_NAMESIZE) == 0 ) + return up; + } + + return NULL; +} + + + struct utmp * +getutline( struct utmp *line ) +{ + struct utmp *up; + + if ( strncmp(line->ut_line,utmp.ut_line,UT_LINESIZE) == 0 ) + return &utmp; + + while( (up = getutent()) != NULL ) + { + if ( strncmp(line->ut_line,up->ut_line,UT_LINESIZE) == 0 ) + return up; + } + + return NULL; +} + + + void +pututline( struct utmp *up ) +{ + struct utmp temp; + struct stat buf; + + /* Note that UP might be equal to &UTMP */ + + if ( strncmp(up->ut_name,utmp.ut_name,UT_NAMESIZE) == 0 ) + /* File already at correct position */ + { + if ( ! readonly ) + { + lseek( utmpfd, -(off_t)sizeof(struct utmp), SEEK_CUR ); + write( utmpfd, up, sizeof(struct utmp) ); + } + + utmp = *up; + } + else + /* File is not at the correct postion; read forward, but do not destroy +UTMP */ + { + while( _getutent(&temp) != NULL ) + { + if ( strncmp(up->ut_name,temp.ut_name,UT_NAMESIZE) == 0 ) + /* File is now at the correct position */ + { + if ( ! readonly ) + { + lseek( utmpfd, -(off_t)sizeof(struct utmp), SEEK_CUR ); + write( utmpfd, up, sizeof(struct utmp) ); + } + + utmp = *up; + return; + } + } + + /* File is now at EOF */ + if ( ! readonly ) + { + if ( fstat(utmpfd,&buf) == 0 && lseek(utmpfd,0,SEEK_END) != -1 ) + { + if ( write(utmpfd,up,sizeof(struct utmp)) != sizeof(struct utmp) +) + ftruncate( utmpfd, buf.st_size ); + } + } + + utmp = *up; + } +} + + + void +setutent() +{ + if ( utmpfd != -1 ) + lseek( utmpfd, 0, SEEK_SET ); +} + + + void +endutent() +{ + if ( utmpfd != -1 ) + { + close( utmpfd ); + utmpfd = -1; + + memset( &utmp, 0, sizeof(struct utmp) ); + } +} + + + void +utmpname( char *file ) +{ + endutent(); + + strncpy( utmpath, file, PATH_MAX ); +} +// https://dev.mobileread.com/svn/iliados/upstream/tinylogin-1.4/libbb/libc5.c +void updwtmp(const char *wtmp_file, const struct utmp *lutmp) +{ + int fd; + + fd = open(wtmp_file, O_APPEND | O_WRONLY, 0); + if (fd >= 0) { + if (lockf(fd, F_LOCK, 0)==0) { + write(fd, (const char *) lutmp, sizeof(struct utmp)); + lockf(fd, F_ULOCK, 0); + close(fd); + } + } +} //#include //#include // findExe From d063e888a3edf30e9ed074511f221b3786ddae11 Mon Sep 17 00:00:00 2001 From: aacalfa Date: Thu, 31 Jul 2014 12:16:43 -0300 Subject: [PATCH 2/4] Another workaround to solve blur problem. --- app/PreprocessedTerminal.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/PreprocessedTerminal.qml b/app/PreprocessedTerminal.qml index 773d00a..7e743e1 100644 --- a/app/PreprocessedTerminal.qml +++ b/app/PreprocessedTerminal.qml @@ -218,7 +218,7 @@ Item{ id: finalSource sourceItem: blurredterminal sourceRect: frame.sourceRect - format: ShaderEffectSource.Alpha + //format: ShaderEffectSource.Alpha hideSource: true } ShaderEffect { @@ -343,7 +343,7 @@ Item{ wrapMode: ShaderEffectSource.Repeat smooth: true hideSource: true - format: ShaderEffectSource.Alpha + //format: ShaderEffectSource.Alpha } // RASTERIZATION ////////////////////////////////////////////////////////// @@ -419,6 +419,6 @@ Item{ sourceItem: rasterizationContainer hideSource: true smooth: true - format: ShaderEffectSource.Alpha + //format: ShaderEffectSource.Alpha } } From 9d7efad7983d4acdb654c026a5614a75452bc356 Mon Sep 17 00:00:00 2001 From: aacalfa Date: Thu, 31 Jul 2014 14:25:23 -0300 Subject: [PATCH 3/4] Reverting PreprocessedTerminal.qml to be used in pull request. --- app/PreprocessedTerminal.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/PreprocessedTerminal.qml b/app/PreprocessedTerminal.qml index 7e743e1..773d00a 100644 --- a/app/PreprocessedTerminal.qml +++ b/app/PreprocessedTerminal.qml @@ -218,7 +218,7 @@ Item{ id: finalSource sourceItem: blurredterminal sourceRect: frame.sourceRect - //format: ShaderEffectSource.Alpha + format: ShaderEffectSource.Alpha hideSource: true } ShaderEffect { @@ -343,7 +343,7 @@ Item{ wrapMode: ShaderEffectSource.Repeat smooth: true hideSource: true - //format: ShaderEffectSource.Alpha + format: ShaderEffectSource.Alpha } // RASTERIZATION ////////////////////////////////////////////////////////// @@ -419,6 +419,6 @@ Item{ sourceItem: rasterizationContainer hideSource: true smooth: true - //format: ShaderEffectSource.Alpha + format: ShaderEffectSource.Alpha } } From 5978a0de709a45ac610c0bd081e3c3f2b6f57a20 Mon Sep 17 00:00:00 2001 From: aacalfa Date: Thu, 31 Jul 2014 22:28:12 -0300 Subject: [PATCH 4/4] Reorganizing last commit. Changes to kpty.cpp were moved to file utmpmac.cpp. Thus I modified .pro file to add this new file utmpmac to be compiled. I have put both .cpp and .h files inside a macro so that they are only considered when building from a mac. Same with include from kpty.cpp. --- konsole-qml-plugin/konsole-qml-plugin.pro | 3 +- konsole-qml-plugin/src/kpty.cpp | 184 +-------------------- konsole-qml-plugin/src/utmpmac.cpp | 186 ++++++++++++++++++++++ konsole-qml-plugin/src/utmpmac.h | 13 ++ 4 files changed, 204 insertions(+), 182 deletions(-) create mode 100644 konsole-qml-plugin/src/utmpmac.cpp create mode 100644 konsole-qml-plugin/src/utmpmac.h diff --git a/konsole-qml-plugin/konsole-qml-plugin.pro b/konsole-qml-plugin/konsole-qml-plugin.pro index 3008d02..dfe71d7 100644 --- a/konsole-qml-plugin/konsole-qml-plugin.pro +++ b/konsole-qml-plugin/konsole-qml-plugin.pro @@ -43,7 +43,8 @@ SOURCES += \ $$PWD/src/Filter.cpp \ $$PWD/src/ColorScheme.cpp \ $$PWD/src/TerminalDisplay.cpp \ - $$PWD/src/ksession.cpp + $$PWD/src/ksession.cpp \ + src/utmpmac.cpp HEADERS += \ $$PWD/src/plugin.h \ diff --git a/konsole-qml-plugin/src/kpty.cpp b/konsole-qml-plugin/src/kpty.cpp index 3b45be3..02d9b29 100644 --- a/konsole-qml-plugin/src/kpty.cpp +++ b/konsole-qml-plugin/src/kpty.cpp @@ -135,188 +135,10 @@ extern "C" { # endif #endif -// http://markmail.org/download.xqy?id=atu7scqmvlsku4n5&number=2 -typedef enum { F=0, T=1 } boolean; +#if defined (__APPLE__) +#include "utmpmac.h" +#endif -static int utmpfd = -1; -static char utmpath[PATH_MAX+1] = _PATH_UTMP; -static boolean readonly = F; -static struct utmp utmp; - - -struct utmp *getutent(); -struct utmp *getutid( struct utmp * ); -struct utmp *getutline( struct utmp * ); -void pututline( struct utmp * ); -void setutent(); -void endutent(); -void utmpname( char * ); - - - static - struct utmp * -_getutent( struct utmp *utmp ) -{ - if ( utmpfd == -1 ) - { - if ( (utmpfd = open(utmpath,O_RDWR)) == -1 ) - { - if ( (utmpfd = open(utmpath,O_RDONLY)) == -1 ) - return NULL; - else - readonly = T; - } - else - readonly = F; - } - - if ( read(utmpfd,utmp,sizeof(struct utmp)) == sizeof(struct utmp) ) - return utmp; - - return NULL; -} - - - struct utmp * -getutent() -{ - return _getutent( &utmp ); -} - - - struct utmp * -getutid( struct utmp *id ) -{ - struct utmp *up; - - if ( strncmp(id->ut_name,utmp.ut_name,UT_NAMESIZE) == 0 ) - return &utmp; - - while( (up = getutent()) != NULL ) - { - if ( strncmp(id->ut_name,up->ut_name,UT_NAMESIZE) == 0 ) - return up; - } - - return NULL; -} - - - struct utmp * -getutline( struct utmp *line ) -{ - struct utmp *up; - - if ( strncmp(line->ut_line,utmp.ut_line,UT_LINESIZE) == 0 ) - return &utmp; - - while( (up = getutent()) != NULL ) - { - if ( strncmp(line->ut_line,up->ut_line,UT_LINESIZE) == 0 ) - return up; - } - - return NULL; -} - - - void -pututline( struct utmp *up ) -{ - struct utmp temp; - struct stat buf; - - /* Note that UP might be equal to &UTMP */ - - if ( strncmp(up->ut_name,utmp.ut_name,UT_NAMESIZE) == 0 ) - /* File already at correct position */ - { - if ( ! readonly ) - { - lseek( utmpfd, -(off_t)sizeof(struct utmp), SEEK_CUR ); - write( utmpfd, up, sizeof(struct utmp) ); - } - - utmp = *up; - } - else - /* File is not at the correct postion; read forward, but do not destroy -UTMP */ - { - while( _getutent(&temp) != NULL ) - { - if ( strncmp(up->ut_name,temp.ut_name,UT_NAMESIZE) == 0 ) - /* File is now at the correct position */ - { - if ( ! readonly ) - { - lseek( utmpfd, -(off_t)sizeof(struct utmp), SEEK_CUR ); - write( utmpfd, up, sizeof(struct utmp) ); - } - - utmp = *up; - return; - } - } - - /* File is now at EOF */ - if ( ! readonly ) - { - if ( fstat(utmpfd,&buf) == 0 && lseek(utmpfd,0,SEEK_END) != -1 ) - { - if ( write(utmpfd,up,sizeof(struct utmp)) != sizeof(struct utmp) -) - ftruncate( utmpfd, buf.st_size ); - } - } - - utmp = *up; - } -} - - - void -setutent() -{ - if ( utmpfd != -1 ) - lseek( utmpfd, 0, SEEK_SET ); -} - - - void -endutent() -{ - if ( utmpfd != -1 ) - { - close( utmpfd ); - utmpfd = -1; - - memset( &utmp, 0, sizeof(struct utmp) ); - } -} - - - void -utmpname( char *file ) -{ - endutent(); - - strncpy( utmpath, file, PATH_MAX ); -} -// https://dev.mobileread.com/svn/iliados/upstream/tinylogin-1.4/libbb/libc5.c -void updwtmp(const char *wtmp_file, const struct utmp *lutmp) -{ - int fd; - - fd = open(wtmp_file, O_APPEND | O_WRONLY, 0); - if (fd >= 0) { - if (lockf(fd, F_LOCK, 0)==0) { - write(fd, (const char *) lutmp, sizeof(struct utmp)); - lockf(fd, F_ULOCK, 0); - close(fd); - } - } -} //#include //#include // findExe diff --git a/konsole-qml-plugin/src/utmpmac.cpp b/konsole-qml-plugin/src/utmpmac.cpp new file mode 100644 index 0000000..3824bb3 --- /dev/null +++ b/konsole-qml-plugin/src/utmpmac.cpp @@ -0,0 +1,186 @@ +#if defined (__APPLE__) +#include "utmpmac.h" + +typedef enum { F=0, T=1 } boolean; + +static int utmpfd = -1; +static char utmpath[PATH_MAX+1] = _PATH_UTMP; +static boolean readonly = F; +static struct utmp utmp; + + +struct utmp *getutent(); +struct utmp *getutid( struct utmp * ); +struct utmp *getutline( struct utmp * ); +void pututline( struct utmp * ); +void setutent(); +void endutent(); +void utmpname( char * ); + + + static + struct utmp * +_getutent( struct utmp *utmp ) +{ + if ( utmpfd == -1 ) + { + if ( (utmpfd = open(utmpath,O_RDWR)) == -1 ) + { + if ( (utmpfd = open(utmpath,O_RDONLY)) == -1 ) + return NULL; + else + readonly = T; + } + else + readonly = F; + } + + if ( read(utmpfd,utmp,sizeof(struct utmp)) == sizeof(struct utmp) ) + return utmp; + + return NULL; +} + + + struct utmp * +getutent() +{ + return _getutent( &utmp ); +} + + + struct utmp * +getutid( struct utmp *id ) +{ + struct utmp *up; + + if ( strncmp(id->ut_name,utmp.ut_name,UT_NAMESIZE) == 0 ) + return &utmp; + + while( (up = getutent()) != NULL ) + { + if ( strncmp(id->ut_name,up->ut_name,UT_NAMESIZE) == 0 ) + return up; + } + + return NULL; +} + + + struct utmp * +getutline( struct utmp *line ) +{ + struct utmp *up; + + if ( strncmp(line->ut_line,utmp.ut_line,UT_LINESIZE) == 0 ) + return &utmp; + + while( (up = getutent()) != NULL ) + { + if ( strncmp(line->ut_line,up->ut_line,UT_LINESIZE) == 0 ) + return up; + } + + return NULL; +} + + + void +pututline( struct utmp *up ) +{ + struct utmp temp; + struct stat buf; + + /* Note that UP might be equal to &UTMP */ + + if ( strncmp(up->ut_name,utmp.ut_name,UT_NAMESIZE) == 0 ) + /* File already at correct position */ + { + if ( ! readonly ) + { + lseek( utmpfd, -(off_t)sizeof(struct utmp), SEEK_CUR ); + write( utmpfd, up, sizeof(struct utmp) ); + } + + utmp = *up; + } + else + /* File is not at the correct postion; read forward, but do not destroy +UTMP */ + { + while( _getutent(&temp) != NULL ) + { + if ( strncmp(up->ut_name,temp.ut_name,UT_NAMESIZE) == 0 ) + /* File is now at the correct position */ + { + if ( ! readonly ) + { + lseek( utmpfd, -(off_t)sizeof(struct utmp), SEEK_CUR ); + write( utmpfd, up, sizeof(struct utmp) ); + } + + utmp = *up; + return; + } + } + + /* File is now at EOF */ + if ( ! readonly ) + { + if ( fstat(utmpfd,&buf) == 0 && lseek(utmpfd,0,SEEK_END) != -1 ) + { + if ( write(utmpfd,up,sizeof(struct utmp)) != sizeof(struct utmp) +) + ftruncate( utmpfd, buf.st_size ); + } + } + + utmp = *up; + } +} + + + void +setutent() +{ + if ( utmpfd != -1 ) + lseek( utmpfd, 0, SEEK_SET ); +} + + + void +endutent() +{ + if ( utmpfd != -1 ) + { + close( utmpfd ); + utmpfd = -1; + + memset( &utmp, 0, sizeof(struct utmp) ); + } +} + + + void +utmpname( char *file ) +{ + endutent(); + + strncpy( utmpath, file, PATH_MAX ); +} +// https://dev.mobileread.com/svn/iliados/upstream/tinylogin-1.4/libbb/libc5.c +void updwtmp(const char *wtmp_file, const struct utmp *lutmp) +{ + int fd; + + fd = open(wtmp_file, O_APPEND | O_WRONLY, 0); + if (fd >= 0) { + if (lockf(fd, F_LOCK, 0)==0) { + write(fd, (const char *) lutmp, sizeof(struct utmp)); + lockf(fd, F_ULOCK, 0); + close(fd); + } + } +} + +#endif diff --git a/konsole-qml-plugin/src/utmpmac.h b/konsole-qml-plugin/src/utmpmac.h new file mode 100644 index 0000000..9052174 --- /dev/null +++ b/konsole-qml-plugin/src/utmpmac.h @@ -0,0 +1,13 @@ +#if defined (__APPLE__) +# include + +struct utmp *getutent(); +struct utmp *getutid( struct utmp * ); +struct utmp *getutline( struct utmp * ); +void pututline( struct utmp * ); +void setutent(); +void endutent(); +void utmpname( char * ); +void updwtmp(const char *wtmp_file, const struct utmp *lutmp); + +#endif