How to Privent wxFrame from Move and stay it maxsized

Это русская секция форума wxWidjets. В этой секции вы можете обсуждать любые вопросы, связанные с wxWidgets на вашем родном языке.
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 396
Joined: Fri Dec 09, 2016 7:28 am
Contact:

How to Privent wxFrame from Move and stay it maxsized

Post by cutecode » Fri Sep 04, 2020 8:23 am

Создал киоск на линуксе с единственным приложением типа wxFrame.

Убрал у него заголовок и убрал стиль для изменения его размера мышкой.

Проблема теперь в том что menueBar ведет себя как заголовок, т.е. если схвачу его мышкой и начинаю тащить мышку, то окно перемещается
и отображает рабочий стол.

Рабочий стол конечно же пустой, но хотелось бы убрать такое странное поведение программно не извращаясь с настройками самого линукс.


Функци типа OnWindowMove я в хэлпах не нашел

Спасибо
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru

Kvaz1r
Super wx Problem Solver
Super wx Problem Solver
Posts: 319
Joined: Tue Jun 07, 2016 1:07 pm

Re: How to Privent wxFrame from Move and stay it maxsized

Post by Kvaz1r » Fri Sep 04, 2020 5:23 pm

Есть wxMoveEvent. Можно попробовать в обработчике возвращать окно на место.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5311
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to Privent wxFrame from Move and stay it maxsized

Post by ONEEYEMAN » Sat Sep 05, 2020 1:37 am

Dobrogo vremeni sutok,
Moget poprobovat ShowFullScreen().
Ili prosto sozdat pustoj obrabotchik wxMoveEvent.

Kakaja versija GTK+ ispolzuetsja?
Esli otkljuchit resizing i titul u minimal sample - vse to ge samoe?

Spasibo.

User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 396
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: How to Privent wxFrame from Move and stay it maxsized

Post by cutecode » Sat Sep 05, 2020 8:33 pm

Если использую

Code: Select all

ShowFullScreen(true);
то вроде то что надо, но зато не могу открыть другие дочерние wxFrame, они прячутся за главной wxFrame

если пишу так

Code: Select all

        ShowFullScreen(true, wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION);
то опять же меню ведет себя снова как заголовок

заметил что такое поведеение только для GTK3, у gtk2 такого поведения нет.

Придется пробовать перехват сообщений wxMoveEvent.


Спасибо
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5311
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to Privent wxFrame from Move and stay it maxsized

Post by ONEEYEMAN » Sat Sep 05, 2020 8:52 pm

Доброго времени суток,
Какая версия GTK+?

Thank you.

User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 396
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: How to Privent wxFrame from Move and stay it maxsized

Post by cutecode » Sat Sep 05, 2020 10:06 pm

версия gtk3 стандартная в debian 10, и обновлять ее не хочу.
Ибо хочу сделать все программно, чтоб работало везде одинаково.

С wxMoveEvent все получилось
спасибо
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru

User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 396
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: How to Privent wxFrame from Move and stay it maxsized

Post by cutecode » Wed Jan 13, 2021 9:50 pm

Обнаружил проблему с wxMoveEvent
Прога "жрет" процессор на 100%. оказалось, что при установке позиции окна в wxPoint(0, 0)
опять вызывается wxMoveEvent, и так все в цикле один вызов вызывает другой вызов рекурсивно.
Как лучше предотвращать перемещения окна?

Code: Select all

void MyFrame::OnFrameMove2()
{
    wxPoint pt(0, 0);
    SetPosition(pt);
}

void MyFrame::OnFrameMove(wxMoveEvent& event)
{
    if (GetIsKiosk() || GetIsDemo() || GetIsTerminal())
    {
        CallAfter(&MyFrame::OnFrameMove2);
        event.Skip(0);
    }
}
Спасибо
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru

User avatar
doublemax
Moderator
Moderator
Posts: 16389
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to Privent wxFrame from Move and stay it maxsized

Post by doublemax » Wed Jan 13, 2021 10:02 pm

Read the position of the window first, and if it's already at (0,0), don't call SetPosition().
Use the source, Luke!

User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 396
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: How to Privent wxFrame from Move and stay it maxsized

Post by cutecode » Wed Jan 13, 2021 10:17 pm

no,
After setting possition to (0, 0)
the real possition is set to (6, 43)

linux gtk3
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru

User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 396
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: How to Privent wxFrame from Move and stay it maxsized

Post by cutecode » Wed Jan 13, 2021 10:50 pm

As sugested here viewtopic.php?f=1&t=26794&p=114388&hili ... nt#p114388
I set timer for every wxMoveEvent

This code is working, and prcessor is taking 85% only for 5-10 seconds

Code: Select all

void MyFrame::OnFrameMove2()
{
    printf("OnFrameMove2\n");

    int x, y;
    GetPosition(&x, &y);

    if(x || y)
    {
        printf("%dx%d\n", x, y);

        wxPoint pt(0, 0);
        SetPosition(pt);

        GetPosition(&x, &y);
        printf("%dx%d\n", x, y);
    }
}

void MyFrame::OnFrameMove(wxMoveEvent& event)
{
    printf("OnFrameMove\n");
	if (GetIsKiosk() || GetIsDemo() || GetIsTerminal())
    {
        if (mvTimer)
        {
            if (mvTimer->IsRunning())
                mvTimer->Stop();

            mvTimer->Start(1000, true);
        }
    }
}

void MyFrame::onMoveWindowEnd(wxTimerEvent& event)
{
    CallAfter(&MyFrame::OnFrameMove2);
}
and log looks like

Code: Select all

OnFrameMove
0x0
OnFrameMove
OnFrameMove2
1x27
OnFrameMove
0x0
OnFrameMove
OnFrameMove2
1x27
OnFrameMove
0x0
OnFrameMove
OnFrameMove2
1x27
OnFrameMove
0x0
OnFrameMove
OnFrameMove2
1x27
OnFrameMove
0x0
OnFrameMove
OnFrameMove2
1x27
OnFrameMove
0x0
OnFrameMove
OnFrameMove2
1x27
OnFrameMove
0x0
OnFrameMove
OnFrameMove2
1x27
OnFrameMove
0x0
OnFrameMove
OnFrameMove2
1x27
OnFrameMove
0x0
OnFrameMove
OnFrameMove2
1x27
OnFrameMove
0x0
OnFrameMove
OnFrameMove2
1x27
OnFrameMove
0x0
OnFrameMove
OnFrameMove2
1x27
OnFrameMove
0x0
OnFrameMove
OnFrameMove2
1x27
OnFrameMove
0x0
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru

User avatar
doublemax
Moderator
Moderator
Posts: 16389
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to Privent wxFrame from Move and stay it maxsized

Post by doublemax » Thu Jan 14, 2021 12:10 am

I guess the problem is that each SetPosition() call also generates a Move event. Try setting a flag before calling SetPosition(), and if the flag is set inside the Move event handler, do nothing.

BTW: is it really so under Linux that you can move a window when it's maximized? Under Windows that's impossible, event if the caption bar is visible.
Use the source, Luke!

User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 396
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: How to Privent wxFrame from Move and stay it maxsized

Post by cutecode » Thu Jan 14, 2021 12:36 am

yes, you can check it on my demo virtual server.
Ther's no titlebar, but menuebar behaves like captionbar

https://dentasoft.ru/download.php

Thank you
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5311
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to Privent wxFrame from Move and stay it maxsized

Post by ONEEYEMAN » Thu Jan 14, 2021 8:43 pm

Dobrogo vremeni sutok,
Reshenie s tajmerom - looks like hack.

Try to use doublemax' suggestion.

Thank you.

User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 396
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: How to Privent wxFrame from Move and stay it maxsized

Post by cutecode » Thu Jan 14, 2021 9:46 pm

This won't help.
After calling SetPosition() - OnFrameMove() is called twice.
The first time immediately after calling SetPosition(), and second time after exiting from OnFrameMove2()

Not sure if this behaver would be all linux distributions
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru

User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 396
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: How to Privent wxFrame from Move and stay it maxsized

Post by cutecode » Thu Jan 14, 2021 10:08 pm

The only solution I see, is setting the flag twice.
Just tested on windows, move event is called twice too, after setting SetPissition()

Code: Select all

        wxPoint pt(0, 0);
        m_nIsMoving++;
        SetPosition(pt);

        m_nIsMoving++;
    }
}

void MyFrame::OnFrameMove(wxMoveEvent& event)
{
    if(m_nIsMoving > 0)
    {
        m_nIsMoving--;
        return;
    
    }
    
    ...
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru

Post Reply