aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-06-29 22:31:49 -0400
committerKen Moore <ken@ixsystems.com>2017-06-29 22:31:49 -0400
commit3cc4bb91529afd0a3454a3db86a7d8a7f51fde96 (patch)
treee6a724d3b495bfc62a1b1e677883d02c21906a7e /src-qt5
parentBack out that secondary close ID - unrelated to the actual window that was cl... (diff)
downloadlumina-3cc4bb91529afd0a3454a3db86a7d8a7f51fde96.tar.gz
lumina-3cc4bb91529afd0a3454a3db86a7d8a7f51fde96.tar.bz2
lumina-3cc4bb91529afd0a3454a3db86a7d8a7f51fde96.zip
Commit another large block of work on Lumina2.
1. Starting to get the compositing put together, but not functional yet. 2. Get the window close routines completely finished, with memory being freed properly on close. 3. Get some of the "reset" of window properties after an animation all setup. Not quite finished yet.
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/core/libLumina/NativeEventFilter.cpp6
-rw-r--r--src-qt5/core/libLumina/NativeWindow.cpp43
-rw-r--r--src-qt5/core/libLumina/NativeWindow.h17
-rw-r--r--src-qt5/core/libLumina/NativeWindowSystem.cpp135
-rw-r--r--src-qt5/core/libLumina/RootSubWindow.cpp42
-rw-r--r--src-qt5/core/libLumina/RootSubWindow.h1
-rw-r--r--src-qt5/core/libLumina/RootWindow.cpp2
7 files changed, 178 insertions, 68 deletions
diff --git a/src-qt5/core/libLumina/NativeEventFilter.cpp b/src-qt5/core/libLumina/NativeEventFilter.cpp
index 74402690..b85965ef 100644
--- a/src-qt5/core/libLumina/NativeEventFilter.cpp
+++ b/src-qt5/core/libLumina/NativeEventFilter.cpp
@@ -181,7 +181,7 @@ bool EventFilter::nativeEventFilter(const QByteArray &eventType, void *message,
obj->emit WindowPropertyChanged( ((xcb_map_notify_event_t *)ev)->window, NativeWindow::Visible, true);
break; //This is just a notification that a window was mapped - nothing needs to change here
case XCB_MAP_REQUEST:
- qDebug() << "Window Map Request Event";
+ //qDebug() << "Window Map Request Event";
obj->emit WindowCreated( ((xcb_map_request_event_t *) ev)->window );
break;
//==============================
@@ -195,7 +195,7 @@ bool EventFilter::nativeEventFilter(const QByteArray &eventType, void *message,
break;
//==============================
case XCB_DESTROY_NOTIFY:
- qDebug() << "Window Closed Event:" << ((xcb_destroy_notify_event_t *)ev)->window;
+ //qDebug() << "Window Closed Event:" << ((xcb_destroy_notify_event_t *)ev)->window;
obj->emit WindowDestroyed( ((xcb_destroy_notify_event_t *) ev)->window );
break;
//==============================
@@ -262,7 +262,7 @@ bool EventFilter::nativeEventFilter(const QByteArray &eventType, void *message,
obj->emit PossibleDamageEvent( ((xcb_damage_notify_event_t*)ev)->drawable );
//checkDamageID( ((xcb_damage_notify_event_t*)ev)->drawable );
//}else{
- qDebug() << "Default Event:" << (ev->response_type & ~0x80);
+ //qDebug() << "Default Event:" << (ev->response_type & ~0x80);
//}
//==============================
}
diff --git a/src-qt5/core/libLumina/NativeWindow.cpp b/src-qt5/core/libLumina/NativeWindow.cpp
index 8853c48e..819661d5 100644
--- a/src-qt5/core/libLumina/NativeWindow.cpp
+++ b/src-qt5/core/libLumina/NativeWindow.cpp
@@ -10,7 +10,8 @@
NativeWindow::NativeWindow(WId id) : QObject(){
winid = id;
frameid = 0;
- WIN = QWindow::fromWinId(winid);
+ dmgID = 0;
+ //WIN = QWindow::fromWinId(winid);
}
NativeWindow::~NativeWindow(){
@@ -22,6 +23,10 @@ void NativeWindow::addFrameWinID(WId fid){
frameid = fid;
}
+void NativeWindow::addDamageID(unsigned int dmg){
+ dmgID = dmg;
+}
+
bool NativeWindow::isRelatedTo(WId tmp){
return (relatedTo.contains(tmp) || winid == tmp || frameid == tmp);
}
@@ -30,47 +35,55 @@ WId NativeWindow::id(){
return winid;
}
-QWindow* NativeWindow::window(){
- return WIN;
+WId NativeWindow::frameId(){
+ return frameid;
+}
+
+unsigned int NativeWindow::damageId(){
+ return dmgID;
}
+/*QWindow* NativeWindow::window(){
+ return WIN;
+}*/
+
QVariant NativeWindow::property(NativeWindow::Property prop){
if(hash.contains(prop)){ return hash.value(prop); }
else if(prop == NativeWindow::RelatedWindows){ return QVariant::fromValue(relatedTo); }
return QVariant(); //null variant
}
-void NativeWindow::setProperty(NativeWindow::Property prop, QVariant val){
+void NativeWindow::setProperty(NativeWindow::Property prop, QVariant val, bool force){
if(prop == NativeWindow::RelatedWindows){ relatedTo = val.value< QList<WId> >(); }
- else if(prop == NativeWindow::None || hash.value(prop)==val){ return; }
- hash.insert(prop, val);
+ else if(prop == NativeWindow::None || (!force && hash.value(prop)==val)){ return; }
+ else{ hash.insert(prop, val); }
emit PropertiesChanged(QList<NativeWindow::Property>() << prop, QList<QVariant>() << val);
}
-void NativeWindow::setProperties(QList<NativeWindow::Property> props, QList<QVariant> vals){
+void NativeWindow::setProperties(QList<NativeWindow::Property> props, QList<QVariant> vals, bool force){
for(int i=0; i<props.length(); i++){
- if(i>=vals.length()){ props.removeAt(i); i--; continue; } //no corresponding value for this propertu
- if(props[i] == NativeWindow::None || (hash.value(props[i]) == vals[i]) ){ props.removeAt(i); vals.removeAt(i); i--; continue; } //Invalid property or identical value
+ if(i>=vals.length()){ props.removeAt(i); i--; continue; } //no corresponding value for this property
+ if(props[i] == NativeWindow::None || (!force && (hash.value(props[i]) == vals[i])) ){ props.removeAt(i); vals.removeAt(i); i--; continue; } //Invalid property or identical value
hash.insert(props[i], vals[i]);
}
emit PropertiesChanged(props, vals);
}
-void NativeWindow::requestProperty(NativeWindow::Property prop, QVariant val){
- if(prop == NativeWindow::None || prop == NativeWindow::RelatedWindows || hash.value(prop)==val ){ return; }
+void NativeWindow::requestProperty(NativeWindow::Property prop, QVariant val, bool force){
+ if(prop == NativeWindow::None || prop == NativeWindow::RelatedWindows || (!force && hash.value(prop)==val) ){ return; }
emit RequestPropertiesChange(winid, QList<NativeWindow::Property>() << prop, QList<QVariant>() << val);
}
-void NativeWindow::requestProperties(QList<NativeWindow::Property> props, QList<QVariant> vals){
+void NativeWindow::requestProperties(QList<NativeWindow::Property> props, QList<QVariant> vals, bool force){
//Verify/adjust inputs as needed
for(int i=0; i<props.length(); i++){
if(i>=vals.length()){ props.removeAt(i); i--; continue; } //no corresponding value for this property
- if(props[i] == NativeWindow::None || props[i] == NativeWindow::RelatedWindows || hash.value(props[i])==vals[i] ){ props.removeAt(i); vals.removeAt(i); i--; continue; } //Invalid property or identical value
- if( (props[i] == NativeWindow::Visible || props[i] == NativeWindow::Active) && frameid !=0){
+ if(props[i] == NativeWindow::None || props[i] == NativeWindow::RelatedWindows || (!force && hash.value(props[i])==vals[i]) ){ props.removeAt(i); vals.removeAt(i); i--; continue; } //Invalid property or identical value
+ /*if( (props[i] == NativeWindow::Visible || props[i] == NativeWindow::Active) && frameid !=0){
//These particular properties needs to change the frame - not the window itself
emit RequestPropertiesChange(frameid, QList<NativeWindow::Property>() << props[i], QList<QVariant>() << vals[i]);
props.removeAt(i); vals.removeAt(i); i--;
- }
+ }*/
}
emit RequestPropertiesChange(winid, props, vals);
}
diff --git a/src-qt5/core/libLumina/NativeWindow.h b/src-qt5/core/libLumina/NativeWindow.h
index c87ccb2d..62bb74b5 100644
--- a/src-qt5/core/libLumina/NativeWindow.h
+++ b/src-qt5/core/libLumina/NativeWindow.h
@@ -60,16 +60,20 @@ public:
~NativeWindow();
void addFrameWinID(WId);
+ void addDamageID(unsigned int);
bool isRelatedTo(WId);
WId id();
- QWindow* window();
+ WId frameId();
+ unsigned int damageId();
+
+ //QWindow* window();
QVariant property(NativeWindow::Property);
- void setProperty(NativeWindow::Property, QVariant);
- void setProperties(QList<NativeWindow::Property>, QList<QVariant>);
- void requestProperty(NativeWindow::Property, QVariant);
- void requestProperties(QList<NativeWindow::Property>, QList<QVariant>);
+ void setProperty(NativeWindow::Property, QVariant, bool force = false);
+ void setProperties(QList<NativeWindow::Property>, QList<QVariant>, bool force = false);
+ void requestProperty(NativeWindow::Property, QVariant, bool force = false);
+ void requestProperties(QList<NativeWindow::Property>, QList<QVariant>, bool force = false);
QRect geometry(); //this returns the "full" geometry of the window (window + frame)
@@ -80,9 +84,10 @@ public slots:
private:
QHash <NativeWindow::Property, QVariant> hash;
- QWindow *WIN;
+ //QWindow *WIN;
WId winid, frameid;
QList<WId> relatedTo;
+ unsigned int dmgID;
signals:
//General Notifications
diff --git a/src-qt5/core/libLumina/NativeWindowSystem.cpp b/src-qt5/core/libLumina/NativeWindowSystem.cpp
index 9c55062d..a8fb550e 100644
--- a/src-qt5/core/libLumina/NativeWindowSystem.cpp
+++ b/src-qt5/core/libLumina/NativeWindowSystem.cpp
@@ -14,6 +14,8 @@
#include <QDebug>
#include <QApplication>
#include <QScreen>
+#include <QFont>
+#include <QFontMetrics>
//XCB Library includes
#include <xcb/xcb.h>
@@ -48,6 +50,22 @@
XCB_EVENT_MASK_FOCUS_CHANGE | \
XCB_EVENT_MASK_ENTER_WINDOW)
+#define NORMAL_WIN_EVENT_MASK (XCB_EVENT_MASK_BUTTON_PRESS | \
+ XCB_EVENT_MASK_BUTTON_RELEASE | \
+ XCB_EVENT_MASK_POINTER_MOTION | \
+ XCB_EVENT_MASK_BUTTON_MOTION | \
+ XCB_EVENT_MASK_EXPOSURE | \
+ XCB_EVENT_MASK_STRUCTURE_NOTIFY | \
+ XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | \
+ XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | \
+ XCB_EVENT_MASK_ENTER_WINDOW| \
+ XCB_EVENT_MASK_PROPERTY_CHANGE)
+
+inline void registerClientEvents(WId id){
+ uint32_t value_list[1] = {NORMAL_WIN_EVENT_MASK};
+ xcb_change_window_attributes(QX11Info::connection(), id, XCB_CW_EVENT_MASK, value_list);
+}
+
//Internal XCB private objects class
class NativeWindowSystem::p_objects{
public:
@@ -66,7 +84,7 @@ public:
QStringList atoms;
atoms << "WM_TAKE_FOCUS" << "WM_DELETE_WINDOW" << "WM_PROTOCOLS" << "_NET_WM_WINDOW_OPACITY"
- << "WM_CHANGE_STATE" << "_NET_SYSTEM_TRAY_OPCODE" << "_NET_SYSTEM_TRAY_ORIENTATION"
+ << "WM_CHANGE_STATE" << "_NET_SYSTEM_TRAY_OPCODE" << "_NET_SYSTEM_TRAY_ORIENTATION" << "_XEMBED"
<< "_NET_SYSTEM_TRAY_VISUAL" << QString("_NET_SYSTEM_TRAY_S%1").arg(QString::number(QX11Info::appScreen()));
//Create all the requests for the atoms
QList<xcb_intern_atom_reply_t*> reply;
@@ -266,7 +284,8 @@ NativeWindowSystem::MouseButton NativeWindowSystem::MouseToQt(int keycode){
NativeWindow* NativeWindowSystem::findWindow(WId id, bool checkRelated){
//qDebug() << "Find Window:" << id;
for(int i=0; i<NWindows.length(); i++){
- if(NWindows[i]->isRelatedTo(id)){ return NWindows[i]; }
+ if(checkRelated && NWindows[i]->isRelatedTo(id)){ return NWindows[i]; }
+ else if(!checkRelated && id==NWindows[i]->id()){ return NWindows[i]; }
}
//Check to see if this is a transient for some other window
if(checkRelated){
@@ -446,7 +465,10 @@ void NativeWindowSystem::UpdateWindowProperties(NativeWindow* win, QList< Native
}*/
win->setProperty(NativeWindow::Workspace, wkspace);
}
-
+ if(props.contains(NativeWindow::FrameExtents)){
+ //Just assign default values to this - need to automate it later
+ win->setProperty(NativeWindow::FrameExtents, QVariant::fromValue<QList<int> >(QList<int>() << 5 << 5 << 5+QFontMetrics(QFont()).height() << 5) );
+ }
if(props.contains(NativeWindow::RelatedWindows)){
WId orig = win->id();
WId tid = obj->getTransientFor(orig);
@@ -481,6 +503,8 @@ void NativeWindowSystem::ChangeWindowProperties(NativeWindow* win, QList< Native
}
if(props.contains(NativeWindow::Size) ){//|| props.contains(NativeWindow::GlobalPos) ){
xcb_configure_window_value_list_t valList;
+ valList.x = 0;
+ valList.y = 0;
uint16_t mask = 0;
//if(props.contains(NativeWindow::Size)){
QSize sz = vals[ props.indexOf(NativeWindow::Size) ] .toSize();
@@ -494,9 +518,9 @@ void NativeWindowSystem::ChangeWindowProperties(NativeWindow* win, QList< Native
/*if(props.contains(NativeWindow::GlobalPos)){
QPoint pt = vals[ props.indexOf(NativeWindow::GlobalPos) ] .toPoint();
valList.x = pt.x();
- valList.y = pt.y();
+ valList.y = pt.y();*/
mask = mask | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y;
- }else{
+ /*}else{
valList.x = win->property(NativeWindow::GlobalPos).toPoint().x();
valList.y = win->property(NativeWindow::GlobalPos).toPoint().y();
}*/
@@ -525,7 +549,7 @@ void NativeWindowSystem::ChangeWindowProperties(NativeWindow* win, QList< Native
if(props.contains(NativeWindow::Active)){
//Only one window can be "Active" at a time - so only do anything if this window wants to be active
if(vals[props.indexOf(NativeWindow::Active)].toBool() ){
- xcb_ewmh_set_active_window(&obj->EWMH, QX11Info::appScreen(), win->id());
+ xcb_ewmh_set_active_window(&obj->EWMH, QX11Info::appScreen(), (win->frameId()==0 ?win->id() : win->frameId()));
//Also send the active window a message to take input focus
//Send the window a WM_TAKE_FOCUS message
xcb_client_message_event_t event;
@@ -657,7 +681,7 @@ int NativeWindowSystem::currentWorkspace(){
//NativeWindowEventFilter interactions
void NativeWindowSystem::NewWindowDetected(WId id){
//Make sure this can be managed first
- if(findWindow(id, false) != 0){ qDebug() << "Window Already Managed!!!!"; return; } //already managed
+ if(findWindow(id, false) != 0){ qDebug() << "Window Already Managed!!!!"; findWindow(id,false)->setProperty(NativeWindow::Visible, true, true); return; } //already managed
xcb_get_window_attributes_cookie_t cookie = xcb_get_window_attributes(QX11Info::connection(), id);
xcb_get_window_attributes_reply_t *attr = xcb_get_window_attributes_reply(QX11Info::connection(), cookie, NULL);
if(attr == 0){ return; } //could not get attributes of window
@@ -666,19 +690,7 @@ void NativeWindowSystem::NewWindowDetected(WId id){
//Now go ahead and create/populate the container for this window
NativeWindow *win = new NativeWindow(id);
//Register for events from this window
- #define NORMAL_WIN_EVENT_MASK (XCB_EVENT_MASK_BUTTON_PRESS | \
- XCB_EVENT_MASK_BUTTON_RELEASE | \
- XCB_EVENT_MASK_POINTER_MOTION | \
- XCB_EVENT_MASK_BUTTON_MOTION | \
- XCB_EVENT_MASK_EXPOSURE | \
- XCB_EVENT_MASK_STRUCTURE_NOTIFY | \
- XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | \
- XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | \
- XCB_EVENT_MASK_ENTER_WINDOW| \
- XCB_EVENT_MASK_PROPERTY_CHANGE)
-
- uint32_t value_list[1] = {NORMAL_WIN_EVENT_MASK};
- xcb_change_window_attributes(QX11Info::connection(), id, XCB_CW_EVENT_MASK, value_list);
+ registerClientEvents(win->id());
NWindows << win;
UpdateWindowProperties(win, NativeWindow::allProperties());
qDebug() << "New Window [& associated ID's]:" << win->id() << win->property(NativeWindow::RelatedWindows);
@@ -721,12 +733,14 @@ void NativeWindowSystem::NewTrayWindowDetected(WId id){
void NativeWindowSystem::WindowCloseDetected(WId id){
NativeWindow *win = findWindow(id, false);
- qDebug() << "Got Window Closed" << id << win;
- qDebug() << "Old Window List:" << NWindows.length();
+ //qDebug() << "Got Window Closed" << id << win;
+ //qDebug() << "Old Window List:" << NWindows.length();
if(win!=0){
NWindows.removeAll(win);
+ //RequestReparent(id, QX11Info::appRootWindow(), QPoint(0,0));
win->emit WindowClosed(id);
- win->deleteLater();
+ //qDebug() << "Visible Window Closed!!!";
+ //win->deleteLater();
}else{
win = findTrayWindow(id);
if(win!=0){
@@ -735,7 +749,7 @@ void NativeWindowSystem::WindowCloseDetected(WId id){
win->deleteLater();
}
}
- qDebug() << " - Now:" << NWindows.length();
+ //qDebug() << " - Now:" << NWindows.length();
}
void NativeWindowSystem::WindowPropertyChanged(WId id, NativeWindow::Property prop){
@@ -810,6 +824,29 @@ void NativeWindowSystem::NewMouseRelease(int buttoncode, WId win){
}
void NativeWindowSystem::CheckDamageID(WId win){
+ for(int i=0; i<NWindows.length(); i++){
+ if(NWindows[i]->damageId() == win || NWindows[i]->id() == win || NWindows[i]->frameId()==win){
+ //qDebug() << "Got DAMAGE Event";
+ /*NativeWindow *WIN = NWindows[i];
+ QSize sz = WIN->property(NativeWindow::Size).toSize();
+ //Need the graphics context of the window
+ xcb_gcontext_t gc = xcb_generate_id(QX11Info::connection());
+ xcb_screen_t *screen = xcb_setup_roots_iterator(xcb_get_setup(QX11Info::connection())).data;
+ uint32_t values[1];
+ values[0] = screen->black_pixel;
+ xcb_create_gc(QX11Info::connection(),
+ gc,
+ WIN->frameId(),
+ XCB_GC_BACKGROUND,
+ values );
+ xcb_pixmap_t pix = xcb_generate_id(QX11Info::connection());
+ xcb_composite_name_window_pixmap(QX11Info::connection(), WIN->id(), pix);
+ //Now put this pixmap onto the frame window
+ xcb_copy_area(QX11Info::connection(), pix, WIN->frameId(), gc, 0,0,0,0,sz.width(), sz.height());*/
+ /*xcb_put_image(QX11Info::connection(), XCB_IMAGE_FORMAT_Z_PIXMAP, pix, gc, sz.width(), sz.height(), 0, 0, */
+ return;
+ }
+ }
NativeWindow *WIN = findTrayWindow(win);
if(WIN!=0){
UpdateWindowProperties(WIN, QList<NativeWindow::Property>() << NativeWindow::Icon);
@@ -851,10 +888,52 @@ void NativeWindowSystem::RequestPing(WId win){
pingTimer->start();
}
-void NativeWindowSystem::RequestReparent(WId client, WId parent, QPoint relorigin){
+void NativeWindowSystem::RequestReparent(WId win, WId container, QPoint relorigin){
+ NativeWindow *WIN = findWindow(win);
+ if(WIN==0){ return; } //could not find corresponding window structure
+//Reparent the window into the container
+ xcb_reparent_window(QX11Info::connection(), win, container, relorigin.x(), relorigin.y());
+ //xcb_map_window(QX11Info::connection(), win);
+
+ //Now send the embed event to the app
+ //qDebug() << " - send _XEMBED event";
+ xcb_client_message_event_t event;
+ event.response_type = XCB_CLIENT_MESSAGE;
+ event.format = 32;
+ event.window = win;
+ event.type = obj->ATOMS["_XEMBED"]; //_XEMBED
+ event.data.data32[0] = XCB_TIME_CURRENT_TIME; //CurrentTime;
+ event.data.data32[1] = 0; //XEMBED_EMBEDDED_NOTIFY
+ event.data.data32[2] = 0;
+ event.data.data32[3] = container; //WID of the container
+ event.data.data32[4] = 0;
+
+ xcb_send_event(QX11Info::connection(), 0, win, XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *) &event);
+
+ //Now setup any redirects and return
+ //this->SelectInput(win, true); //Notify of structure changes
+ registerClientEvents(win);
+ //xcb_composite_redirect_window(QX11Info::connection(), win, XCB_COMPOSITE_REDIRECT_MANUAL); //XCB_COMPOSITE_REDIRECT_[MANUAL/AUTOMATIC]);
+
+ //Now map the window (will be a transparent child of the container)
+ xcb_map_window(QX11Info::connection(), win);
+ xcb_map_window(QX11Info::connection(), container);
+ //Now create/register the damage handler
+ // -- XCB (Note: The XCB damage registration is completely broken at the moment - 9/15/15, Ken Moore)
+ // -- Retested 6/29/17 (no change) Ken Moore
+ //xcb_damage_damage_t dmgID = xcb_generate_id(QX11Info::connection()); //This is a typedef for a 32-bit unsigned integer
+ //xcb_damage_create(QX11Info::connection(), dmgID, win, XCB_DAMAGE_REPORT_LEVEL_RAW_RECTANGLES);
+ // -- XLib (Note: This is only used because the XCB routine above does not work - needs to be fixed upstream in XCB itself).
+ Damage dmgID = XDamageCreate(QX11Info::display(), win, XDamageReportRawRectangles);
+ WIN->addDamageID( (uint) dmgID); //save this for later
+ //qDebug() << " - Done";
+ //return ( (uint) dmgID );
+}
+/*
xcb_reparent_window(QX11Info::connection(), client, parent, relorigin.x(), relorigin.y());
- //Now enable compositing between these two windows as well
- // TODO
+ //Now ensure that we still get event for these windows
+ registerClientEvents(client); //make sure we re-do this after reparenting
+ registerClientEvents(parent);
xcb_map_window(QX11Info::connection(), parent);
-}
+}*/
diff --git a/src-qt5/core/libLumina/RootSubWindow.cpp b/src-qt5/core/libLumina/RootSubWindow.cpp
index 9eb1ff58..92a85291 100644
--- a/src-qt5/core/libLumina/RootSubWindow.cpp
+++ b/src-qt5/core/libLumina/RootSubWindow.cpp
@@ -30,11 +30,11 @@ RootSubWindow::RootSubWindow(QWidget *root, NativeWindow *win) : QFrame(root){
WIN->emit RequestReparent(WIN->id(), WinWidget->winId(), QPoint(0,0));
qDebug() << "[NEW WINDOW]" << WIN->id() << WinWidget->winId() << this->winId();
LoadAllProperties();
- //QTimer::singleShot(20, this, SLOT(LoadAllProperties()) );
}
RootSubWindow::~RootSubWindow(){
-
+ //qDebug() << "Visible Window Destroyed";
+ WIN->deleteLater();
}
WId RootSubWindow::id(){
@@ -202,30 +202,30 @@ void RootSubWindow::LoadProperties( QList< NativeWindow::Property> list){
// === PUBLIC SLOTS ===
void RootSubWindow::clientClosed(){
- qDebug() << "Client Closed";
+ //qDebug() << "Client Closed";
closing = true;
+ /*animResetProp = QRect(WIN->property(NativeWindow::GlobalPos).toPoint(), WIN->property(NativeWindow::Size).toSize());
anim->setPropertyName("geometry");
anim->setStartValue(this->geometry());
anim->setEndValue( QRect(this->geometry().center(), QSize(0,0) ) );
anim->start();
- QTimer::singleShot(anim->duration(), this, SLOT(close()) );
- //this->close();
+ QTimer::singleShot(anim->duration(), this, SLOT(close()) );*/
+ if(anim->state()!=QAbstractAnimation::Running){ this->close(); }
}
void RootSubWindow::LoadAllProperties(){
QList< NativeWindow::Property> list = WIN->allProperties();
- /*list.removeAll(NativeWindow::Visible);
- list << NativeWindow::Visible;*/
LoadProperties(list);
}
//Button Actions - public so they can be tied to key shortcuts and stuff as well
void RootSubWindow::toggleMinimize(){
-
+ WIN->setProperty(NativeWindow::Visible, false);
+ QTimer::singleShot(2000, this, SLOT(toggleMaximize()) );
}
void RootSubWindow::toggleMaximize(){
-
+ WIN->setProperty(NativeWindow::Visible, true);
}
void RootSubWindow::triggerClose(){
@@ -270,12 +270,14 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList
//qDebug() << "Got Visibility Change:" << vals[i];
if(vals[i].toBool()){
WinWidget->setVisible(true);
+ animResetProp = WIN->geometry(); //show event - might not have the right geom yet
anim->setPropertyName("geometry");
anim->setStartValue( QRect(WIN->geometry().center(), QSize(0,0)) );
anim->setEndValue(WIN->geometry());
anim->start();
this->show();
}else{
+ animResetProp = this->geometry(); //hide event - should already be the right geom
anim->setPropertyName("geometry");
anim->setStartValue(this->geometry());
anim->setEndValue( QRect(this->geometry().center(), QSize(0,0) ) );
@@ -298,10 +300,10 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList
break;
case NativeWindow::Size:
if(WinWidget->size() != vals[i].toSize()){
- //qDebug() << "Got Widget Size Change:" << vals[i].toSize();
+ qDebug() << "Got Widget Size Change:" << vals[i].toSize();
WinWidget->resize(vals[i].toSize());
this->resize( WIN->geometry().size() );
- //qDebug() << " - Size after change:" << WinWidget->size() << this->size() << WIN->geometry();
+ qDebug() << " - Size after change:" << WinWidget->size() << this->size() << WIN->geometry();
}
break;
case NativeWindow::MinSize:
@@ -326,15 +328,25 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList
}
void RootSubWindow::animFinished(){
- if(anim->propertyName()=="geometry"){
- WIN->requestProperty(NativeWindow::Size, WinWidget->size());
- WIN->setProperty(NativeWindow::GlobalPos, WinWidget->mapToGlobal(QPoint(0,0)) );
+ if(closing){ this->close(); return;}
+ else if(anim->propertyName()=="geometry"){
+ if(!animResetProp.isNull()){
+ qDebug() << "Animation Finished, Reset Geometry:" << animResetProp;
+ qDebug() << " - Starting Value:" << anim->startValue();
+ qDebug() << " - Ending Value:" << anim->endValue();
+ qDebug() << " - Current Value:" << this->geometry();
+ this->setGeometry( animResetProp.toRect() );
+ WIN->requestProperty(NativeWindow::Size, WinWidget->size(), true);
+ WIN->setProperty(NativeWindow::GlobalPos, WinWidget->mapToGlobal(QPoint(0,0)),true );
+ }
}
-
+ animResetProp = QVariant(); //clear the variable
}
// === PROTECTED ===
void RootSubWindow::mousePressEvent(QMouseEvent *ev){
+ activate();
+ this->raise();
//qDebug() << "Frame Mouse Press Event";
offset.setX(0); offset.setY(0);
if(activeState != Normal){ return; } // do nothing - already in a state of grabbed mouse
diff --git a/src-qt5/core/libLumina/RootSubWindow.h b/src-qt5/core/libLumina/RootSubWindow.h
index 25c6596a..bd20291e 100644
--- a/src-qt5/core/libLumina/RootSubWindow.h
+++ b/src-qt5/core/libLumina/RootSubWindow.h
@@ -50,6 +50,7 @@ private:
QMenu *otherM; //menu of other actions
//Other random objects (animations,etc)
QPropertyAnimation *anim;
+ QVariant animResetProp;
void initWindowFrame();
void LoadProperties( QList< NativeWindow::Property> list);
diff --git a/src-qt5/core/libLumina/RootWindow.cpp b/src-qt5/core/libLumina/RootWindow.cpp
index 17a9ecd7..2fee5d96 100644
--- a/src-qt5/core/libLumina/RootWindow.cpp
+++ b/src-qt5/core/libLumina/RootWindow.cpp
@@ -184,7 +184,7 @@ void RootWindow::NewWindow(NativeWindow *win){
void RootWindow::CloseWindow(WId win){
for(int i=0; i<WINDOWS.length(); i++){
- if(WINDOWS[i]->id() == win){ WINDOWS.takeAt(i)->clientClosed(); break; }
+ if(WINDOWS[i]->id() == win){ qDebug() << "Remove Window From Root List"; WINDOWS.takeAt(i)->clientClosed(); break; }
}
}
bgstack15