Sorry one more question, I dont have any where else to go
.
I am using the following code to display external applications onto DispWin of previous application by passing its width and height.
The problem is after displaying the external app , if i maximize the window of main application , the external app does not resize to DispWin size, it stays same as when its displayed.
is there any thing i am doing wrong from below.
If you have time , please have a look ...
int create_window(int width, int height)
{
XSetWindowAttributes xswa;
static int resx, resy;
mDisplay = XOpenDisplay(NULL);
if(mDisplay == NULL){
printf("m_Display Failed");
return 0;
}
mScreen = DefaultScreen(mDisplay);
xswa.background_pixel=BlackPixel(mDisplay, mScreen);
xswa.border_pixel=WhitePixel(mDisplay, mScreen);
xswa.event_mask=ExposureMask|KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|StructureNotifyMask;
xswa.override_redirect = False;
mRootWin = DefaultRootWindow(mDisplay);
if (!(window = XCreateWindow(mDisplay, mRootWin, 0, 0, width, height, 0, 0, InputOutput, DefaultVisual(mDisplay, mScreen),
CWEventMask|CWBackPixel|CWBorderPixel|CWOverrideRedirect, &xswa)))
{
fprintf(stderr, "[x11] Failed to create window\n");
return 0;
}
XMapWindow(mDisplay, window);
while (1)
{
XEvent event;
XNextEvent(mDisplay, &event);
if (event.type==Expose)
break;
}
{
XSizeHints SizeHints;
SizeHints.flags=PMinSize|PMaxSize|USSize;
SizeHints.min_width = width;// does not have any effect
SizeHints.min_height = height ;// does not have any effect
SizeHints.max_width= width;
SizeHints.max_height= height;
XSetWMNormalHints(mDisplay, window, &SizeHints);
}
return 1;
}
int create_window(int width, int height)
{
XSetWindowAttributes xswa;
static int resx, resy;
mDisplay = XOpenDisplay(NULL);
if(mDisplay == NULL){
printf("m_Display Failed");
return 0;
}
mScreen = DefaultScreen(mDisplay);
xswa.background_pixel=BlackPixel(mDisplay, mScreen);
xswa.border_pixel=WhitePixel(mDisplay, mScreen);
xswa.event_mask=ExposureMask|KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|StructureNotifyMask;
xswa.override_redirect = False;
mRootWin = DefaultRootWindow(mDisplay);
if (!(window = XCreateWindow(mDisplay, mRootWin, 0, 0, width, height, 0, 0, InputOutput, DefaultVisual(mDisplay, mScreen),
CWEventMask|CWBackPixel|CWBorderPixel|CWOverrideRedirect, &xswa)))
{
fprintf(stderr, "[x11] Failed to create window\n");
return 0;
}
XMapWindow(mDisplay, window);
while (1)
{
XEvent event;
XNextEvent(mDisplay, &event);
if (event.type==Expose)
break;
}
{
XSizeHints SizeHints;
SizeHints.flags=PMinSize|PMaxSize|USSize;
SizeHints.min_width = width;// does not have any effect
SizeHints.min_height = height ;// does not have any effect
SizeHints.max_width= width;
SizeHints.max_height= height;
XSetWMNormalHints(mDisplay, window, &SizeHints);
}
return 1;
}
To copy to clipboard, switch view to plain text mode
#define DEFAULT_SCENE_WIDTH 1280
#define DEFAULT_SCENE_HEIGHT 720
int main(int argc, char **argv)
{
int width;
int height;
int retVal =0;
qDebug()<<"argc"<<argc;
for(int i= 0;i<argc;i++)
qDebug()<<"argv["<<i<<"]= "<<argv[i];
QRectF sceneRect
(0,
0,DEFAULT_SCENE_WIDTH,DEFAULT_SCENE_HEIGHT
);
scene.setSceneRect(sceneRect);
QWebView *wView = new QWebView();
wView
->load
(QUrl("http://127.0.0.1/setting.html"));
wView->grabKeyboard();
WId wid;
if(argc < 2)
{
printf("pass window arg\n");
return 0;
}
wid = app.arguments()[1].toInt();
embed->setLayout(vl);
vl->addWidget(wView);
embed->show();
width = app.arguments()[2].toInt();
height = app.arguments()[3].toInt();
embed->setMinimumSize(width,height);
qDebug()<<"width & height received:"<<width<<"&"<<height;
retVal = create_window(width,height);
if (0==retVal){
qDebug()<<"create_window failed";
return 0;
}
XReparentWindow(mDisplay,embed->winId(),window,0,0);
XReparentWindow(mDisplay,window,wid,0,0);
XFlush(mDisplay);
app.exec();
}
#define DEFAULT_SCENE_WIDTH 1280
#define DEFAULT_SCENE_HEIGHT 720
int main(int argc, char **argv)
{
int width;
int height;
int retVal =0;
qDebug()<<"argc"<<argc;
for(int i= 0;i<argc;i++)
qDebug()<<"argv["<<i<<"]= "<<argv[i];
QRectF sceneRect(0,0,DEFAULT_SCENE_WIDTH,DEFAULT_SCENE_HEIGHT);
QApplication app(argc, argv);
QGraphicsScene scene;
scene.setSceneRect(sceneRect);
QGraphicsView *gView = new QGraphicsView(&scene);
QWebView *wView = new QWebView();
wView->load(QUrl("http://127.0.0.1/setting.html"));
wView->grabKeyboard();
WId wid;
if(argc < 2)
{
printf("pass window arg\n");
return 0;
}
wid = app.arguments()[1].toInt();
embed = new QWidget();
QVBoxLayout* vl = new QVBoxLayout();
embed->setLayout(vl);
vl->addWidget(wView);
embed->show();
width = app.arguments()[2].toInt();
height = app.arguments()[3].toInt();
embed->setMinimumSize(width,height);
embed->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
qDebug()<<"width & height received:"<<width<<"&"<<height;
retVal = create_window(width,height);
if (0==retVal){
qDebug()<<"create_window failed";
return 0;
}
XReparentWindow(mDisplay,embed->winId(),window,0,0);
XReparentWindow(mDisplay,window,wid,0,0);
XFlush(mDisplay);
app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks