how to keep shadow in borderless window - qt

I'm trying to drop a shadow on a borderless window using Qt in windows.
I succeeded in dropping the shadow when launching the application, referring to the following article.
Borderless Window Using Areo Snap, Shadow, Minimize Animation, and Shake
Borderless Window with Drop Shadow
But I encountered the problem that the shadow will disappear if the application is deactivated and reactivated (
In other words, click the other applications, and click my application again.)
Perhaps my implementation is not good enough.
I'm glad if you have some ideas for this issue.
I'm trying to imprement Qt with Go bindings
Here is the code snippet:
package qframelesswindow
import (
"unsafe"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/widgets"
win "github.com/akiyosi/w32"
)
func (f *QFramelessWindow) SetNativeEvent(app *widgets.QApplication) {
filterObj := core.NewQAbstractNativeEventFilter()
filterObj.ConnectNativeEventFilter(func(eventType *core.QByteArray, message unsafe.Pointer, result int) bool {
msg := (*win.MSG)(message)
lparam := msg.LParam
hwnd := msg.Hwnd
var uflag uint
uflag = win.SWP_NOZORDER | win.SWP_NOOWNERZORDER | win.SWP_NOMOVE | win.SWP_NOSIZE | win.SWP_FRAMECHANGED
var nullptr win.HWND
shadow := &win.MARGINS{0, 0, 0, 1}
switch msg.Message {
case win.WM_CREATE:
style := win.WS_POPUP | win.WS_THICKFRAME | win.WS_MINIMIZEBOX | win.WS_MAXIMIZEBOX | win.WS_CAPTION
win.SetWindowLong(hwnd, win.GWL_STYLE, uint32(style))
win.DwmExtendFrameIntoClientArea(hwnd, shadow)
win.SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, uflag)
return true
case win.WM_NCCALCSIZE:
if msg.WParam == 1 {
// this kills the window frame and title bar we added with WS_THICKFRAME and WS_CAPTION
result = 0
return true
}
return false
case win.WM_GETMINMAXINFO:
mm := (*win.MINMAXINFO)((unsafe.Pointer)(lparam))
mm.PtMinTrackSize.X = int32(f.minimumWidth)
mm.PtMinTrackSize.Y = int32(f.minimumHeight)
return true
default:
}
return false
})
app.InstallNativeEventFilter(filterObj)
}
All source code is in my repository;
akiyosi/goqtframelesswindow

WM_NCCALCSIZE:
If wParam is TRUE, the application should return zero or a combination
of the following values.(In document)
And also:
When wParam is TRUE, simply returning 0 without processing the
NCCALCSIZE_PARAMS rectangles will cause the client area to resize to
the size of the window, including the window frame. This will remove
the window frame and caption items from your window, leaving only the
client area displayed.
Starting with Windows Vista, simply returning 0 does not affect extended frames, only the standard frame will be removed.
EDIT:
Set the return value with the DWL_MSGRESULT instead of result = 0.

Related

Accessing object properties between classes in kivy

This bit of Code here creates a scrollview of buttons to allow me select from a list of different "tickets"
SearchResultButton(Button(text=str(Datarray2[i]),id=str(Datarray2[i]),on_press=self.Pressbtn ))
self.ids.SearchResult.add_widget(SearchResultButton)
From there it opens this function, which should set a variable (In this case "UpdateTicketNum") which will be used in another function to set the label text in another screen.
def Pressbtn(self, SearchResultButton):
global UpdateTicket
UpdateTicket = OPENTicket
woo = SearchResultButton.text
print(SearchResultButton.text)
wow = [blank.strip() for blank in woo.split(',')]
print("\n\n\n\n")
global UpdateTicketNum
UpdateTicketNum = (wow[0])
self.manager.get_screen('UpdateTicket').UpdateOpen()
At this point it opens up the sqlite DB and double checks that the TicketNumber is valid. The issue comes in when trying to access the label inside the kv build
def UpdateOpen(self):
print("TESTSETST")
conn = sqlite3.connect('TicketData.db', timeout=10)
UD = conn.cursor()
UD.execute('SELECT TicketNumber FROM TicketData WHERE TicketNumber = ?',(UpdateTicketNum,))
tips = UD.fetchone()
print(tips[0])
tipsy = tips[0]
UpdatedLabelTexT = tipsy
sm.current=('UpdateTicket')
UpdateTicket.ids.UpdateLabels['text']=(UpdatedLabelTexT)
The UpdateTicket.ids.UpdateLabels['text']=UpdatedLabelText] field always claims to be a property of the scrollview buttons even though I am initializing it inside another class, and with different parameters. apologies if this question is poorly formatted. but 3 days of dying trying to figure this out and I snapped.
Here is the bit in KV
<UpdateTicket>
name: 'UpdateTicket'
on_enter:
root.UpdateOpen()
orientation: "vertical"
FloatLayout:
canvas.before:
Color:
rgba: .0, .6, 1, 1
Rectangle:
pos: self.pos
size: self.size
source: "lights.jpg"
Label:
id: UpdateLabels
text: "filler"
multiline: False
size_hint: (None, None)
size: (root.width/5,root.height/20)
pos_hint:{'center_x': .5,'center_y': .5 }
and how I initialize the screen
sm.add_widget(UpdateTicket(name='UpdateTicket'))
I found the solution that worked for me. when first initializing the app
class SampleApp(App)
return sm(to build the application)
I needed to replace that return SM with
global root
return sm
root = ScreenManager()
return root
And that appeared to fix my issue. thanks for reading

Angular-ui ui-scroll - how to make it work when scrolling up?

I'm using the angular-ui ui-scroll and it's great when I scroll down, keeps adding items as expected. However when I scroll up, it stops at the top of the last batch that I loaded. For example if I have 100 items and my buffer size is 10, and I've scrolled down so that items 61-70 are showing, when I scroll back up I want to see items 51-60. However I can't scroll up past item 61. I don't know what I'm doing wrong.
Here's the html:
<div row="row" ui-scroll="row in transactionSource" buffer-size="10" >{{row.data}}</sq-transaction>
Here's the script:
$scope.transactionSource = {
get: function (index, count, callback) {
if (index < 0) {
callback([])
}
else {
var buffer = 10;
var end = ctrl.nextIndex + buffer;
if (end > ctrl.transactions.length) end = ctrl.transactions.length;
var items = ctrl.transactions.slice(ctrl.nextIndex, end);
ctrl.nextIndex = end;
callback(items);
}
}
};
If it's related, when I console.log the index and count values received, after the first load of 10 I get an index of -9 (in which case I return an empty array - if I don't do this, the entire array gets loaded). When I scroll up, I don't get a console.log message at all so it's like the 'get' only gets called when scrolling down.
Thanks in advance for any and all help.
Your datasource looks wrong. Items retrieving (slicing in your case) should be based on index and count parameters that you have from the datasource.get method arguments. I'd like to post an example of datasource implementation where the result items array is limited from 0 to 100 and should be sliced from some external data array:
get: function(index, count, success) {
var result = [];
var start = Math.max(0, index);
var end = Math.min(index + count - 1, 100);
if (start <= end) {
result = externalDataArray.slice(start, end + 1);
}
success(result);
};
Hope it helps!

No restore button in maximised window

When I maximise one of my mdi client windows. I am then stuck with it maximised, I need to be able to restore it to view the other windows.
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = CWindowHandler::MsgRouter;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = childClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
hChild = CreateMDIWindow(childClassName, "Segments", WS_OVERLAPPEDWINDOW, m_winRect.left, m_winRect.top, m_winRect.right - m_winRect.left, m_winRect.bottom - m_winRect.top, CWindowHandler::GetInstance()->GetMDIClient(), m_hInstance, (LPARAM)this);
i fixed this by calling return DefMDIChildProc(m_Hwnd, msg, wParam, lParam); in the case WM_SIZE: of the wndprocs of the child window. god knows why but it worked.
I believe you're going to have to add the style MDIS_ALLCHILDSTYLES in order to get the window styles you want. From MSDN...
The style of the MDI child window. If the MDI client window is created
with the MDIS_ALLCHILDSTYLES window style, this parameter can be any
combination of the window styles listed in the Window Styles page.
Otherwise, this parameter is limited to one or more of the following
values.

Autolayout constraints in TextField of an outlineView

last night a have an autolayout issue. I was googling and try to find something similar in SO. Even the apple doc doesn't point me to the right direction. Maybe my search terms are completely wrong.
Maybe you guys can bring some light into my darkness.
I added a NSOutlineView in storyboard and added some constraints to the NSTableCellView. As you can see, i added a trailing space to Superview of 50:
My example code adds some foo's and bar's into the outlineView by identifyer:
func outlineView(outlineView: NSOutlineView, viewForTableColumn tableColumn: NSTableColumn?, item: AnyObject) -> NSView? {
if tableColumn?.identifier == "NAME_COLUMN" {
cell = outlineView.makeViewWithIdentifier("NAME_COLUMN", owner: self) as NSTableCellView
cell.textField!.stringValue = "foo"
cell.textField!.editable = true
cell.textField!.delegate = self
} else
if tableColumn?.identifier == "VALUE_COLUMN" {
cell = outlineView.makeViewWithIdentifier("VALUE_COLUMN", owner: self) as NSTableCellView
cell.textField!.stringValue = "bar"
cell.textField!.editable = true
cell.textField!.delegate = self
}
return cell
}
But the trailing space will not show up in my running application!
I even try to set the cell display:
cell.needsDisplay = true
cell.needsLayout = true
cell.needsUpdateConstraints = true
or - according to someone on the internet - add "requiresConstraintBasedLayout":
class func requiresConstraintBasedLayout() -> Bool {
return true
}
but all without luck. The trailing space do not appears and the bar's on the right side border looks awful.
How do i use a TableViewCell inside a OutlineView with a trailing space?
Thanks a lot for any kind of hint.
ps

Setting windows layout for a specific application in awesome-wm

How to config awesome so it would start new application with two windows aligned like this:
----------------
|xxxxxxxxxx####|
|xxxxxxxxxx####|
|xxxxxxxxxx####|
|xxxxxxxxxx####|
----------------
where "x" is for example conversation window in pidgin and '#' is buddy list window.
In general I would like to specify width of right window and put it on the right side (maximized vertically) and the other window should take the remaining space.
I already have some almost-working code, but it behaves strangely (it setups everything correct for pidgin, but it doesn't for gimp and v_sim, and occasionally without any known to me reason it changes geometry of the left window. Or when I start application (v_sim) it isn't placed in correct positions and it isn't maximized vertically, but when I then restart awesome, it places it correctly. So I guess that this application changes something when it starts.
Here is code which I use now:
awful.rules.rules = {
...
{ rule = { class = "Pidgin", role = "buddy_list" },
properties = {
floating = true
},
callback = function( c )
local w_area = screen[ c.screen ].workarea
local winwidth = 340
c:struts( { right = winwidth } )
c:geometry( { x = w_area.width - winwidth, width = winwidth, y = w_area.y, height = w_area.height } )
end
},
{ rule = { class = "Pidgin", role = "conversation" },
properties = {
floating = true,
x = 0,
maximized_vertical = true,
maximized_horizontal = true
},
callback = awful.client.setslave
},
...
}
I had this exact same problem, but I wanted a large Firefox window on the left with a small terminal on the right. To get it to work I dedicated a tag for this purpose with a tile-left layout and adjusted the width factor (i.e. the operation normally performed by CTRL-L).
Add the following to the end of rc.lua where yourtag is the tag in which you would like to place these windows. The 0.15 value can be adjusted to your taste.
awful.tag.viewonly(yourtag)
awful.tag.incmwfact(0.15, yourtage)
Also, using the awful.client.setslave for the window that you want on the right ensures that they don't get switched.
{
rule = { class = "URxvt" },
callback = awful.client.setslave
},
You may also direct certain applications to a tag using the tag property.
{
rule = { class = "Firefox" },
properties = { tag = browse }
},
{
rule = { class = "URxvt", instance = "browse" },
properties = { tag = browse },
},
I then created a binding to open these applications as follows.
-- Custom programs
awful.key({ modkey, "Shift" }, "b", function()
awful.tag.viewonly(browse)
awful.util.spawn_with_shell("urxvt -name browse -e newsbeuter")
awful.util.spawn("firefox")
end)
This is the final result:
Alternatively, you can use a floating contact list window with struts.
This prevents the contact list window from being maximized when no message-window is present.
Also, it allows the CL-window to be placed next to arbitrary (tiling) windows.
Check out: http://www.bramschoenmakers.nl/en/node/738
Although his implementation is a bit buggy for my version of awesome.
The problem is that it does not adjust for struts that have already been set.
My implementation:
{ rule = { class = "Pidgin", role = "buddy_list" },
properties = {floating=true,
maximized_vertical=true, maximized_horizontal=false },
callback = function (c)
local cl_width = 250 -- width of buddy list window
local scr_area = screen[c.screen].workarea
local cl_strut = c:struts()
-- scr_area is affected by this client's struts, so we have to adjust for that
if c:isvisible() and cl_strut ~= nil and cl_strut.left > 0 then
c:geometry({x=scr_area.x-cl_strut.left, y=scr_area.y, width=cl_strut.left})
-- scr_area is unaffected, so we can use the naive coordinates
else
c:struts({left=cl_width, right=0})
c:geometry({x=scr_area.x, y=scr_area.y, width=cl_width})
end
end },
This puts the CL window on the left and allocating a fixed space for it.
(You don't need any rule for the conversation-window)

Resources